Asterisk - The Open Source Telephony Project GIT-master-7988d11
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
channel.h File Reference

General Asterisk PBX channel definitions. More...

#include "asterisk/alertpipe.h"
#include "asterisk/abstract_jb.h"
#include "asterisk/astobj2.h"
#include "asterisk/poll-compat.h"
#include "asterisk/frame.h"
#include "asterisk/chanvars.h"
#include "asterisk/config.h"
#include "asterisk/lock.h"
#include "asterisk/cdr.h"
#include "asterisk/utils.h"
#include "asterisk/linkedlists.h"
#include "asterisk/stringfields.h"
#include "asterisk/datastore.h"
#include "asterisk/format_cap.h"
#include "asterisk/channelstate.h"
#include "asterisk/ccss.h"
#include "asterisk/framehook.h"
#include "asterisk/stasis.h"
#include "asterisk/endpoints.h"
Include dependency graph for channel.h:

Go to the source code of this file.

Data Structures

struct  ast_assigned_ids
 Structure to pass both assignedid values to channel drivers. More...
 
struct  ast_autochan_list
 
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_initializers
 Helper struct for initializing additional channel information on channel creation. More...
 
struct  ast_channel_tech
 Structure to describe a channel "technology", ie a channel driver See for examples: More...
 
struct  ast_datastore_list
 
struct  ast_generator
 
struct  ast_group_info
 channel group info More...
 
struct  ast_hangup_handler
 
struct  ast_hangup_handler_list
 
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_redirecting_reason
 Redirecting reason information. More...
 
struct  ast_party_subaddress
 Information needed to specify a subaddress in a call. More...
 
struct  ast_readq_list
 
struct  ast_set_party_caller
 Indicate what information in ast_party_caller should be set. More...
 
struct  ast_set_party_connected_line
 Indicate what information in ast_party_connected_line should be set. More...
 
struct  ast_set_party_id
 Indicate what information in ast_party_id should be set. More...
 
struct  ast_set_party_redirecting
 Indicate what information in ast_party_redirecting should be set. More...
 
struct  outgoing_helper
 

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.
 
#define AST_BRIDGE_DTMF_CHANNEL_1   (1 << 1)
 Report DTMF on channel 1.
 
#define AST_CHAN_WRITE_INFO_T_VERSION   1
 ast_chan_write_info_t version. Must be incremented if structure is changed
 
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag, ...)
 Create a channel structure.
 
#define ast_channel_alloc_with_endpoint(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag, endpoint, ...)
 
#define ast_channel_alloc_with_initializers(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag, endpoint, initializers, ...)
 
#define ast_channel_cleanup(c)   ({ ao2_cleanup(c); (struct ast_channel *) (NULL); })
 Cleanup a channel reference.
 
#define ast_channel_has_tech_function(chan, function)    (ast_channel_tech(chan) ? ast_channel_tech(chan)->function != NULL : 0)
 Checks if a channel's technology implements a particular callback function.
 
#define AST_CHANNEL_INITIALIZERS_VERSION   1
 struct ABI version
 
#define ast_channel_lock(chan)   ao2_lock(chan)
 
#define ast_channel_lock_both(chan1, chan2)
 Lock two channels.
 
#define AST_CHANNEL_NAME   80
 
#define ast_channel_ref(c)   ({ ao2_ref(c, +1); (c); })
 Increase channel reference count.
 
#define ast_channel_trylock(chan)   ao2_trylock(chan)
 
#define ast_channel_unlock(chan)   ao2_unlock(chan)
 
#define ast_channel_unref(c)   ({ ao2_ref(c, -1); (struct ast_channel *) (NULL); })
 Decrease channel reference count.
 
#define ast_dummy_channel_alloc()   __ast_dummy_channel_alloc(__FILE__, __LINE__, __PRETTY_FUNCTION__)
 Create a fake channel structure.
 
#define AST_EXTENDED_FDS   12
 
#define AST_FEATURE_DTMF_MASK
 
#define AST_GENERATOR_FD   (AST_MAX_FDS-4)
 
#define AST_JITTERBUFFER_FD   (AST_MAX_FDS-5)
 
#define AST_MAX_ACCOUNT_CODE   80
 
#define AST_MAX_CONTEXT   80
 
#define AST_MAX_EXTENSION   80
 
#define AST_MAX_FDS   11
 
#define AST_MAX_PUBLIC_UNIQUEID   149
 
#define AST_MAX_TENANT_ID   64
 
#define AST_MAX_UNIQUEID   (AST_MAX_PUBLIC_UNIQUEID + 2 + 1)
 
#define AST_MAX_USER_FIELD   256
 
#define AST_MUTE_DIRECTION_READ   (1 << 0)
 
#define AST_MUTE_DIRECTION_WRITE   (1 << 1)
 
#define AST_NUM_CHANNEL_BUCKETS   1567
 
#define AST_TIMING_FD   (AST_MAX_FDS-2)
 
#define CHECK_BLOCKING(c)
 Set the blocking indication on the channel.
 
#define DATASTORE_INHERIT_FOREVER   INT_MAX
 
#define DEBUGCHAN_FLAG   0x80000000
 
#define DECLARE_STRINGFIELD_SETTERS_FOR(field)
 
#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 *chan, const char *cmd, char *data, struct ast_str **str, ssize_t len)
 Typedef for a custom read2 function.
 
typedef int(* ast_acf_read_fn_t) (struct ast_channel *chan, const char *function, char *data, char *buf, size_t len)
 Typedef for a custom read function.
 
typedef int(* ast_acf_write_fn_t) (struct ast_channel *chan, const char *function, char *data, const char *value)
 Typedef for a custom write function.
 
typedef unsigned long long ast_group_t
 
typedef int(* ast_timing_func_t) (const void *data)
 

Enumerations

enum  { AST_CHAN_TP_WANTSJITTER = (1 << 0) , AST_CHAN_TP_CREATESJITTER = (1 << 1) , AST_CHAN_TP_INTERNAL = (1 << 2) , AST_CHAN_TP_SEND_TEXT_DATA = (1 << 3) }
 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_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_MASQ_NOSTREAM = (1 << 16) , AST_FLAG_BRIDGE_HANGUP_RUN = (1 << 17) , AST_FLAG_DISABLE_WORKAROUNDS = (1 << 20) , AST_FLAG_DISABLE_DEVSTATE_CACHE = (1 << 21) ,
  AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT = (1 << 22) , AST_FLAG_ORIGINATED = (1 << 23) , AST_FLAG_DEAD = (1 << 24) , AST_FLAG_SNAPSHOT_STAGE = (1 << 25) ,
  AST_FLAG_TIMINGDATA_IS_AO2_OBJ = (1 << 26) , AST_FLAG_SUBROUTINE_EXEC = (1 << 27)
}
 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_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_HANGUP_EXEC = (1 << 7) , AST_SOFTHANGUP_ALL = (0xFFFFFFFF)
}
 
enum  ama_flags { AST_AMA_NONE = 0 , AST_AMA_OMIT , AST_AMA_BILLING , AST_AMA_DOCUMENTATION }
 Channel AMA Flags. More...
 
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_channel_error { AST_CHANNEL_ERROR_UNKNOWN , AST_CHANNEL_ERROR_ID_EXISTS }
 
enum  ast_channel_requestor_relationship { AST_CHANNEL_REQUESTOR_BRIDGE_PEER , AST_CHANNEL_REQUESTOR_REPLACEMENT }
 
enum  AST_MONITORING_STATE { AST_MONITOR_RUNNING , AST_MONITOR_PAUSED }
 
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_ACL_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)
 Answer a channel, with a selectable delay before returning.
 
struct ast_channel__ast_channel_alloc (int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, enum ama_flags amaflag, struct ast_endpoint *endpoint, const char *file, int line, const char *function, const char *name_fmt,...)
 Create a channel structure.
 
struct ast_channel__ast_channel_alloc_with_initializers (int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, enum ama_flags amaflag, struct ast_endpoint *endpoint, struct ast_channel_initializers *initializers, const char *file, int line, const char *function, const char *name_fmt,...)
 Create a channel structure.
 
struct ast_channel__ast_dummy_channel_alloc (const char *file, int line, const char *function)
 
struct ast_channel__ast_request_and_dial (const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int timeout, int *reason, const char *cid_num, const char *cid_name, struct outgoing_helper *oh)
 Request a channel of a given type, with data as optional information used by the low level module and attempt to place a call on it.
 
int ast_activate_generator (struct ast_channel *chan, struct ast_generator *gen, void *params)
 
int ast_active_channels (void)
 returns number of active/allocated channels
 
static int ast_add_fd (struct pollfd *pfd, int fd)
 if fd is a valid descriptor, set *pfd with the descriptor
 
int ast_answer (struct ast_channel *chan)
 Answer a channel.
 
int ast_auto_answer (struct ast_channel *chan)
 Answer a channel, if it's not already answered.
 
void ast_autoservice_chan_hangup_peer (struct ast_channel *chan, struct ast_channel *peer)
 Put chan into autoservice while hanging up peer.
 
int ast_autoservice_ignore (struct ast_channel *chan, enum ast_frame_type ftype)
 Ignore certain frame types.
 
int ast_autoservice_start (struct ast_channel *chan)
 Automatically service a channel for us...
 
int ast_autoservice_stop (struct ast_channel *chan)
 Stop servicing a channel for us...
 
int ast_call (struct ast_channel *chan, const char *addr, int timeout)
 Make a call.
 
struct ast_channelast_call_forward (struct ast_channel *caller, struct ast_channel *orig, int *timeout, struct ast_format_cap *cap, 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.
 
const char * ast_cause2str (int cause) attribute_pure
 Gives the string form of a given cause code.
 
void ast_change_name (struct ast_channel *chan, const char *newname)
 Change channel name.
 
struct ast_channelast_channel__bridge (const struct ast_channel *chan)
 
void ast_channel__bridge_set (struct ast_channel *chan, struct ast_channel *value)
 
const char * ast_channel_accountcode (const struct ast_channel *chan)
 
enum ast_channel_adsicpe ast_channel_adsicpe (const struct ast_channel *chan)
 
void ast_channel_adsicpe_set (struct ast_channel *chan, enum ast_channel_adsicpe value)
 
int ast_channel_alert_writable (struct ast_channel *chan)
 
int ast_channel_alert_write (struct ast_channel *chan)
 
enum ama_flags ast_channel_amaflags (const struct ast_channel *chan)
 
const char * ast_channel_amaflags2string (enum ama_flags flags)
 Convert the enum representation of an AMA flag to a string representation.
 
void ast_channel_amaflags_set (struct ast_channel *chan, enum ama_flags value)
 
struct timeval ast_channel_answertime (struct ast_channel *chan)
 
void ast_channel_answertime_set (struct ast_channel *chan, struct timeval *value)
 
const char * ast_channel_appl (const struct ast_channel *chan)
 
void ast_channel_appl_set (struct ast_channel *chan, const char *value)
 
struct ast_audiohook_listast_channel_audiohooks (const struct ast_channel *chan)
 
void ast_channel_audiohooks_set (struct ast_channel *chan, struct ast_audiohook_list *value)
 
struct ast_autochan_listast_channel_autochans (struct ast_channel *chan)
 
pthread_t ast_channel_blocker (const struct ast_channel *chan)
 
void ast_channel_blocker_set (struct ast_channel *chan, pthread_t value)
 
int ast_channel_blocker_tid (const struct ast_channel *chan)
 
void ast_channel_blocker_tid_set (struct ast_channel *chan, int tid)
 
const char * ast_channel_blockproc (const struct ast_channel *chan)
 
void ast_channel_blockproc_set (struct ast_channel *chan, const char *value)
 
struct ast_channelast_channel_bridge_peer (struct ast_channel *chan)
 Get the channel's bridge peer only if the bridge is two-party.
 
const char * ast_channel_call_forward (const struct ast_channel *chan)
 
struct ast_party_callerast_channel_caller (struct ast_channel *chan)
 
void ast_channel_caller_set (struct ast_channel *chan, struct ast_party_caller *value)
 
ast_group_t ast_channel_callgroup (const struct ast_channel *chan)
 
void ast_channel_callgroup_set (struct ast_channel *chan, ast_group_t value)
 
ast_callid ast_channel_callid (const struct ast_channel *chan)
 
void ast_channel_callid_cleanup (struct ast_channel *chan)
 
void ast_channel_callid_set (struct ast_channel *chan, ast_callid value)
 
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.
 
struct ast_cdrast_channel_cdr (const struct ast_channel *chan)
 
void ast_channel_cdr_set (struct ast_channel *chan, struct ast_cdr *value)
 
void ast_channel_clear_flag (struct ast_channel *chan, unsigned int flag)
 Clear a flag on a channel.
 
void ast_channel_clear_softhangup (struct ast_channel *chan, int flag)
 Clear a set of softhangup flags from a channel.
 
int ast_channel_cmpwhentohangup_tv (struct ast_channel *chan, struct timeval offset)
 Compare a offset with the settings of when to hang a channel up.
 
struct ast_party_connected_lineast_channel_connected (struct ast_channel *chan)
 
struct ast_party_id ast_channel_connected_effective_id (struct ast_channel *chan)
 
struct ast_party_connected_lineast_channel_connected_indicated (struct ast_channel *chan)
 
int ast_channel_connected_line_sub (struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *connected_info, int frame)
 Run a connected line interception subroutine and update a channel's connected line information.
 
void ast_channel_connected_set (struct ast_channel *chan, struct ast_party_connected_line *value)
 
const char * ast_channel_context (const struct ast_channel *chan)
 
void ast_channel_context_set (struct ast_channel *chan, const char *value)
 
struct timeval ast_channel_creationtime (struct ast_channel *chan)
 
void ast_channel_creationtime_set (struct ast_channel *chan, struct timeval *value)
 
const char * ast_channel_data (const struct ast_channel *chan)
 
void ast_channel_data_set (struct ast_channel *chan, const char *value)
 
int ast_channel_datastore_add (struct ast_channel *chan, struct ast_datastore *datastore)
 Add a datastore to a channel.
 
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.
 
int ast_channel_datastore_inherit (struct ast_channel *from, struct ast_channel *to)
 Inherit datastores from a parent to a child.
 
int ast_channel_datastore_remove (struct ast_channel *chan, struct ast_datastore *datastore)
 Remove a datastore from a channel.
 
struct ast_datastore_listast_channel_datastores (struct ast_channel *chan)
 
int ast_channel_defer_dtmf (struct ast_channel *chan)
 Defers DTMF so that you only read things like hangups and audio.
 
const char * ast_channel_dialcontext (const struct ast_channel *chan)
 
struct ast_party_dialedast_channel_dialed (struct ast_channel *chan)
 
int ast_channel_dialed_causes_add (const struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen)
 Add cause code information to the channel.
 
struct ast_strast_channel_dialed_causes_channels (const struct ast_channel *chan)
 Retrieve a comma-separated list of channels for which dialed cause information is available.
 
void ast_channel_dialed_causes_clear (const struct ast_channel *chan)
 Clear all cause information from the channel.
 
struct ast_control_pvt_cause_codeast_channel_dialed_causes_find (const struct ast_channel *chan, const char *chan_name)
 Retrieve a ref-counted cause code information structure.
 
struct ao2_iterator ast_channel_dialed_causes_iterator (const struct ast_channel *chan)
 Retrieve an iterator for dialed cause information.
 
void ast_channel_dialed_set (struct ast_channel *chan, struct ast_party_dialed *value)
 
char ast_channel_dtmf_digit_to_emulate (const struct ast_channel *chan)
 
void ast_channel_dtmf_digit_to_emulate_set (struct ast_channel *chan, char value)
 
struct timeval * ast_channel_dtmf_tv (struct ast_channel *chan)
 
void ast_channel_dtmf_tv_set (struct ast_channel *chan, struct timeval *value)
 
struct ast_frameast_channel_dtmff (struct ast_channel *chan)
 
void ast_channel_dtmff_set (struct ast_channel *chan, struct ast_frame *value)
 
int ast_channel_early_bridge (struct ast_channel *c0, struct ast_channel *c1)
 Bridge two channels together (early)
 
unsigned int ast_channel_emulate_dtmf_duration (const struct ast_channel *chan)
 
void ast_channel_emulate_dtmf_duration_set (struct ast_channel *chan, unsigned int value)
 
void ast_channel_end_dtmf (struct ast_channel *chan, char digit, struct timeval start, const char *why)
 Simulate a DTMF end on a broken bridge channel.
 
struct ast_endpointast_channel_endpoint (const struct ast_channel *chan)
 
void ast_channel_endpoint_set (struct ast_channel *chan, struct ast_endpoint *endpoint)
 
int ast_channel_epfd (const struct ast_channel *chan)
 
void ast_channel_epfd_set (struct ast_channel *chan, int value)
 
enum ast_channel_error ast_channel_errno (void)
 Get error code for latest channel operation.
 
const char * ast_channel_exten (const struct ast_channel *chan)
 
void ast_channel_exten_set (struct ast_channel *chan, const char *value)
 
int ast_channel_fd (const struct ast_channel *chan, int which)
 
int ast_channel_fd_add (struct ast_channel *chan, int value)
 Add a file descriptor to the channel without a fixed position.
 
int ast_channel_fd_count (const struct ast_channel *chan)
 Retrieve the number of file decriptor positions present on the channel.
 
int ast_channel_fd_isset (const struct ast_channel *chan, int which)
 
int ast_channel_fdno (const struct ast_channel *chan)
 
void ast_channel_fdno_set (struct ast_channel *chan, int value)
 
int ast_channel_feature_hooks_append (struct ast_channel *chan, struct ast_bridge_features *features)
 Appends to the channel-attached features a channel has access to upon being bridged.
 
struct ast_bridge_featuresast_channel_feature_hooks_get (struct ast_channel *chan)
 Gets the channel-attached features a channel has access to upon being bridged.
 
int ast_channel_feature_hooks_replace (struct ast_channel *chan, struct ast_bridge_features *features)
 Sets the channel-attached features a channel has access to upon being bridged.
 
unsigned int ast_channel_fin (const struct ast_channel *chan)
 
void ast_channel_fin_set (struct ast_channel *chan, unsigned int value)
 
struct ast_flagsast_channel_flags (struct ast_channel *chan)
 
int ast_channel_forward_endpoint (struct ast_channel *chan, struct ast_endpoint *endpoint)
 Forward channel stasis messages to the given endpoint.
 
unsigned int ast_channel_fout (const struct ast_channel *chan)
 
void ast_channel_fout_set (struct ast_channel *chan, unsigned int value)
 
struct ast_framehook_listast_channel_framehooks (const struct ast_channel *chan)
 
void ast_channel_framehooks_set (struct ast_channel *chan, struct ast_framehook_list *value)
 
struct ast_generatorast_channel_generator (const struct ast_channel *chan)
 
void ast_channel_generator_set (struct ast_channel *chan, struct ast_generator *value)
 
void * ast_channel_generatordata (const struct ast_channel *chan)
 
void ast_channel_generatordata_set (struct ast_channel *chan, void *value)
 
struct varsheadast_channel_get_ari_vars (struct ast_channel *chan)
 Gets the variables for a given channel, as specified by ast_channel_set_ari_vars().
 
struct ast_bridgeast_channel_get_bridge (const struct ast_channel *chan)
 Get the bridge associated with a channel.
 
struct ast_bridge_channelast_channel_get_bridge_channel (struct ast_channel *chan)
 Get a reference to the channel's bridge pointer.
 
int ast_channel_get_cc_agent_type (struct ast_channel *chan, char *agent_type, size_t size)
 Find the appropriate CC agent type to use given a channel.
 
struct ast_cc_config_paramsast_channel_get_cc_config_params (struct ast_channel *chan)
 Get the CCSS parameters from a channel.
 
const char * ast_channel_get_current_storage_driver_name (void)
 Get the name of the current channel storage driver.
 
struct ast_streamast_channel_get_default_stream (struct ast_channel *chan, enum ast_media_type type)
 Retrieve the default stream of a specific media type on a channel.
 
int ast_channel_get_device_name (struct ast_channel *chan, char *device_name, size_t name_buffer_length)
 Get a device name given its channel structure.
 
int ast_channel_get_duration (struct ast_channel *chan)
 Obtain how long the channel since the channel was created.
 
int64_t ast_channel_get_duration_ms (struct ast_channel *chan)
 Obtain how long it's been, in milliseconds, since the channel was created.
 
int ast_channel_get_intercept_mode (void)
 Am I currently running an intercept dialplan routine.
 
struct varsheadast_channel_get_manager_vars (struct ast_channel *chan)
 Gets the variables for a given channel, as specified by ast_channel_set_manager_vars().
 
struct ast_stream_topologyast_channel_get_stream_topology (const struct ast_channel *chan)
 Retrieve the topology of streams on a channel.
 
void * ast_channel_get_stream_topology_change_source (struct ast_channel *chan)
 Retrieve the source that initiated the last stream topology change.
 
static enum ast_t38_state ast_channel_get_t38_state (struct ast_channel *chan)
 Retrieves the current T38 state of a channel.
 
int ast_channel_get_up_time (struct ast_channel *chan)
 Obtain how long it has been since the channel was answered.
 
int64_t ast_channel_get_up_time_ms (struct ast_channel *chan)
 Obtain how long it has been since the channel was answered in ms.
 
struct varsheadast_channel_get_vars (struct ast_channel *chan)
 Gets the variables for a given channel, as set using pbx_builtin_setvar_helper().
 
struct ast_hangup_handler_listast_channel_hangup_handlers (struct ast_channel *chan)
 
int ast_channel_hangupcause (const struct ast_channel *chan)
 
void ast_channel_hangupcause_hash_set (struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen)
 Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash on the given channel.
 
void ast_channel_hangupcause_set (struct ast_channel *chan, int value)
 
const char * ast_channel_hangupsource (const struct ast_channel *chan)
 
int ast_channel_has_ari_vars (void)
 Return whether or not any ARI variables have been set.
 
int ast_channel_has_audio_frame_or_monitor (struct ast_channel *chan)
 Check if the channel has active audiohooks, active framehooks, or a monitor.
 
int ast_channel_has_hook_requiring_audio (struct ast_channel *chan)
 Check if the channel has any active hooks that require audio.
 
int ast_channel_has_manager_vars (void)
 Return whether or not any manager variables have been set.
 
int ast_channel_hold_state (const struct ast_channel *chan)
 
void ast_channel_hold_state_set (struct ast_channel *chan, int value)
 
void ast_channel_inherit_variables (const struct ast_channel *parent, struct ast_channel *child)
 Inherits channel variable from parent to child channel.
 
unsigned long ast_channel_insmpl (const struct ast_channel *chan)
 
void ast_channel_insmpl_set (struct ast_channel *chan, unsigned long value)
 
ast_alert_status_t ast_channel_internal_alert_flush (struct ast_channel *chan)
 
ast_alert_status_t ast_channel_internal_alert_read (struct ast_channel *chan)
 
int ast_channel_internal_alert_readable (struct ast_channel *chan)
 
int ast_channel_internal_alert_readfd (struct ast_channel *chan)
 
void ast_channel_internal_alertpipe_clear (struct ast_channel *chan)
 
void ast_channel_internal_alertpipe_close (struct ast_channel *chan)
 
int ast_channel_internal_alertpipe_init (struct ast_channel *chan)
 
void ast_channel_internal_alertpipe_swap (struct ast_channel *chan1, struct ast_channel *chan2)
 Swap the interal alertpipe between two channels.
 
struct ast_bridgeast_channel_internal_bridge (const struct ast_channel *chan)
 
struct ast_bridge_channelast_channel_internal_bridge_channel (const struct ast_channel *chan)
 
void ast_channel_internal_bridge_channel_set (struct ast_channel *chan, struct ast_bridge_channel *value)
 
void ast_channel_internal_bridge_set (struct ast_channel *chan, struct ast_bridge *value)
 
struct ast_channelast_channel_internal_bridged_channel (const struct ast_channel *chan)
 
void ast_channel_internal_bridged_channel_set (struct ast_channel *chan, struct ast_channel *value)
 
void ast_channel_internal_copy_linkedid (struct ast_channel *dest, struct ast_channel *source)
 Copy the full linkedid channel id structure from one channel to another.
 
void ast_channel_internal_fd_clear (struct ast_channel *chan, int which)
 
void ast_channel_internal_fd_clear_all (struct ast_channel *chan)
 
void ast_channel_internal_fd_set (struct ast_channel *chan, int which, int value)
 
struct ast_channelast_channel_internal_oldest_linkedid (struct ast_channel *a, struct ast_channel *b)
 Determine which channel has an older linkedid.
 
void ast_channel_internal_set_fake_ids (struct ast_channel *chan, const char *uniqueid, const char *linkedid)
 Set uniqueid and linkedid string value only (not time)
 
void ast_channel_internal_swap_endpoint_forward (struct ast_channel *a, struct ast_channel *b)
 Swap endpoint_forward between two channels.
 
void ast_channel_internal_swap_endpoints (struct ast_channel *a, struct ast_channel *b)
 Swap endpoints between two channels.
 
void ast_channel_internal_swap_snapshots (struct ast_channel *a, struct ast_channel *b)
 Swap snapshots beteween two channels.
 
void ast_channel_internal_swap_topics (struct ast_channel *a, struct ast_channel *b)
 Swap topics beteween two channels.
 
void ast_channel_internal_swap_uniqueid_and_linkedid (struct ast_channel *a, struct ast_channel *b)
 Swap uniqueid and linkedid beteween two channels.
 
int ast_channel_is_bridged (const struct ast_channel *chan)
 Determine if a channel is in a bridge.
 
int ast_channel_is_leaving_bridge (struct ast_channel *chan)
 Determine if a channel is leaving a bridge, but not hung up.
 
int ast_channel_is_multistream (struct ast_channel *chan)
 Determine if a channel is multi-stream capable.
 
int ast_channel_is_t38_active (struct ast_channel *chan)
 This function will check if T.38 is active on the channel.
 
int ast_channel_is_t38_active_nolock (struct ast_channel *chan)
 ast_channel_is_t38_active variant. Use this if the channel is already locked prior to calling.
 
struct ast_jbast_channel_jb (struct ast_channel *chan)
 
void ast_channel_jb_set (struct ast_channel *chan, struct ast_jb *value)
 
const char * ast_channel_language (const struct ast_channel *chan)
 
const char * ast_channel_lastcontext (const struct ast_channel *chan)
 
const char * ast_channel_lastexten (const struct ast_channel *chan)
 
const char * ast_channel_latest_musicclass (const struct ast_channel *chan)
 
const char * ast_channel_linkedid (const struct ast_channel *chan)
 
int ast_channel_make_compatible (struct ast_channel *chan, struct ast_channel *peer)
 Make the frame formats of two channels compatible.
 
struct ast_channelast_channel_masq (const struct ast_channel *chan)
 
void ast_channel_masq_set (struct ast_channel *chan, struct ast_channel *value)
 
struct ast_channelast_channel_masqr (const struct ast_channel *chan)
 
void ast_channel_masqr_set (struct ast_channel *chan, struct ast_channel *value)
 
int ast_channel_move (struct ast_channel *dest, struct ast_channel *source)
 Move a channel from its current location to a new location.
 
void * ast_channel_music_state (const struct ast_channel *chan)
 
void ast_channel_music_state_set (struct ast_channel *chan, void *value)
 
const char * ast_channel_musicclass (const struct ast_channel *chan)
 
const char * ast_channel_name (const struct ast_channel *chan)
 
void ast_channel_name_to_dial_string (char *channel_name)
 Removes the trailing identifiers from a channel name string.
 
struct ast_namedgroups * ast_channel_named_callgroups (const struct ast_channel *chan)
 
void ast_channel_named_callgroups_set (struct ast_channel *chan, struct ast_namedgroups *value)
 
struct ast_namedgroups * ast_channel_named_pickupgroups (const struct ast_channel *chan)
 
void ast_channel_named_pickupgroups_set (struct ast_channel *chan, struct ast_namedgroups *value)
 
struct ast_format_capast_channel_nativeformats (const struct ast_channel *chan)
 
void ast_channel_nativeformats_set (struct ast_channel *chan, struct ast_format_cap *value)
 
const char * ast_channel_oldest_linkedid (const char *a, const char *b)
 Return the oldest linkedid between two channels.
 
struct ast_formatast_channel_oldwriteformat (struct ast_channel *chan)
 
unsigned long ast_channel_outsmpl (const struct ast_channel *chan)
 
void ast_channel_outsmpl_set (struct ast_channel *chan, unsigned long value)
 
const char * ast_channel_parkinglot (const struct ast_channel *chan)
 
struct ast_pbxast_channel_pbx (const struct ast_channel *chan)
 
void ast_channel_pbx_set (struct ast_channel *chan, struct ast_pbx *value)
 
const char * ast_channel_peeraccount (const struct ast_channel *chan)
 
ast_group_t ast_channel_pickupgroup (const struct ast_channel *chan)
 
void ast_channel_pickupgroup_set (struct ast_channel *chan, ast_group_t value)
 
int ast_channel_priority (const struct ast_channel *chan)
 
void ast_channel_priority_set (struct ast_channel *chan, int value)
 
int ast_channel_queryoption (struct ast_channel *channel, int option, void *data, int *datalen, int block)
 Checks the value of an option.
 
void ast_channel_queue_connected_line_update (struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
 Queue a connected line update frame on a channel.
 
void ast_channel_queue_redirecting_update (struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
 Queue a redirecting update frame on a channel.
 
struct ast_formatast_channel_rawreadformat (struct ast_channel *chan)
 
struct ast_formatast_channel_rawwriteformat (struct ast_channel *chan)
 
struct ast_formatast_channel_readformat (struct ast_channel *chan)
 
struct ast_readq_listast_channel_readq (struct ast_channel *chan)
 
struct ast_trans_pvtast_channel_readtrans (const struct ast_channel *chan)
 
void ast_channel_readtrans_set (struct ast_channel *chan, struct ast_trans_pvt *value)
 
const char * ast_channel_reason2str (int reason)
 return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument
 
struct ast_party_redirectingast_channel_redirecting (struct ast_channel *chan)
 
struct ast_party_id ast_channel_redirecting_effective_from (struct ast_channel *chan)
 
struct ast_party_id ast_channel_redirecting_effective_orig (struct ast_channel *chan)
 
struct ast_party_id ast_channel_redirecting_effective_to (struct ast_channel *chan)
 
void ast_channel_redirecting_set (struct ast_channel *chan, struct ast_party_redirecting *value)
 
int ast_channel_redirecting_sub (struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *redirecting_info, int is_frame)
 Run a redirecting interception subroutine and update a channel's redirecting information.
 
int ast_channel_register (const struct ast_channel_tech *tech)
 Register a channel technology (a new channel driver) Called by a channel module to register the kind of channels it supports.
 
struct ast_channelast_channel_release (struct ast_channel *chan)
 Unlink and release reference to a channel.
 
void ast_channel_req_accountcodes (struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship)
 Setup new channel accountcodes from the requestor channel after ast_request().
 
void ast_channel_req_accountcodes_precious (struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship)
 Setup new channel accountcodes from the requestor channel after ast_request().
 
int ast_channel_request_stream_topology_change (struct ast_channel *chan, struct ast_stream_topology *topology, void *change_source)
 Request that the stream topology of a channel change.
 
int ast_channel_rings (const struct ast_channel *chan)
 
void ast_channel_rings_set (struct ast_channel *chan, int value)
 
struct ast_sched_contextast_channel_sched (const struct ast_channel *chan)
 
void ast_channel_sched_set (struct ast_channel *chan, struct ast_sched_context *value)
 
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.
 
char ast_channel_sending_dtmf_digit (const struct ast_channel *chan)
 
void ast_channel_sending_dtmf_digit_set (struct ast_channel *chan, char value)
 
struct timeval ast_channel_sending_dtmf_tv (const struct ast_channel *chan)
 
void ast_channel_sending_dtmf_tv_set (struct ast_channel *chan, struct timeval value)
 
int ast_channel_sendurl (struct ast_channel *channel, const char *url)
 Sends a URL on a given link Send URL on link.
 
void ast_channel_set_ari_vars (size_t varc, char **vars)
 Sets the variables to be stored in the ari_vars field of all snapshots.
 
void ast_channel_set_caller (struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update)
 Set the caller id information in the Asterisk channel.
 
void ast_channel_set_caller_event (struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update)
 Set the caller id information in the Asterisk channel and generate an AMI event if the caller id name or number changed.
 
void ast_channel_set_connected_line (struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
 Set the connected line information in the Asterisk channel.
 
void ast_channel_set_fd (struct ast_channel *chan, int which, int fd)
 
void ast_channel_set_flag (struct ast_channel *chan, unsigned int flag)
 Set a flag on a channel.
 
void ast_channel_set_is_t38_active (struct ast_channel *chan, int is_t38_active)
 Sets the is_t38_active flag.
 
void ast_channel_set_is_t38_active_nolock (struct ast_channel *chan, int is_t38_active)
 Variant of ast_channel_set_is_t38_active. Use this if the channel is already locked prior to calling.
 
void ast_channel_set_manager_vars (size_t varc, char **vars)
 Sets the variables to be stored in the manager_vars field of all snapshots.
 
void ast_channel_set_oldwriteformat (struct ast_channel *chan, struct ast_format *format)
 
void ast_channel_set_rawreadformat (struct ast_channel *chan, struct ast_format *format)
 
void ast_channel_set_rawwriteformat (struct ast_channel *chan, struct ast_format *format)
 
void ast_channel_set_readformat (struct ast_channel *chan, struct ast_format *format)
 
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.
 
struct ast_stream_topologyast_channel_set_stream_topology (struct ast_channel *chan, struct ast_stream_topology *topology)
 Set the topology of streams on a channel.
 
void ast_channel_set_unbridged (struct ast_channel *chan, int value)
 Sets the unbridged flag and queues a NULL frame on the channel to trigger a check by bridge_channel_wait.
 
void ast_channel_set_unbridged_nolock (struct ast_channel *chan, int value)
 Variant of ast_channel_set_unbridged. Use this if the channel is already locked prior to calling.
 
void ast_channel_set_writeformat (struct ast_channel *chan, struct ast_format *format)
 
int ast_channel_setoption (struct ast_channel *channel, int option, void *data, int datalen, int block)
 Sets an option on a channel.
 
void ast_channel_setwhentohangup_tv (struct ast_channel *chan, struct timeval offset)
 Set when to hang a channel up.
 
struct ast_channel_snapshotast_channel_snapshot (const struct ast_channel *chan)
 
struct ast_flagsast_channel_snapshot_segment_flags (struct ast_channel *chan)
 
void ast_channel_snapshot_set (struct ast_channel *chan, struct ast_channel_snapshot *snapshot)
 
int ast_channel_softhangup_internal_flag (struct ast_channel *chan)
 
void ast_channel_softhangup_internal_flag_add (struct ast_channel *chan, int value)
 
void ast_channel_softhangup_internal_flag_clear (struct ast_channel *chan, int value)
 
void ast_channel_softhangup_internal_flag_set (struct ast_channel *chan, int value)
 
void ast_channel_softhangup_withcause_locked (struct ast_channel *chan, int causecode)
 Lock the given channel, then request softhangup on the channel with the given causecode.
 
struct ast_silence_generatorast_channel_start_silence_generator (struct ast_channel *chan)
 Starts a silence generator on the given channel.
 
enum ast_channel_state ast_channel_state (const struct ast_channel *chan)
 
void ast_channel_state_set (struct ast_channel *chan, enum ast_channel_state)
 
void ast_channel_stop_silence_generator (struct ast_channel *chan, struct ast_silence_generator *state)
 Stops a previously-started silence generator on the given channel.
 
struct ast_filestreamast_channel_stream (const struct ast_channel *chan)
 
void ast_channel_stream_set (struct ast_channel *chan, struct ast_filestream *value)
 
int ast_channel_stream_topology_changed (struct ast_channel *chan, struct ast_stream_topology *topology)
 Provide notice to a channel that the stream topology has changed.
 
int ast_channel_stream_topology_changed_externally (struct ast_channel *chan)
 Provide notice from a channel that the topology has changed on it as a result of the remote party renegotiating.
 
int ast_channel_streamid (const struct ast_channel *chan)
 
void ast_channel_streamid_set (struct ast_channel *chan, int value)
 
enum ama_flags ast_channel_string2amaflag (const char *flag)
 Convert a string to a detail record AMA flag.
 
int ast_channel_supports_html (struct ast_channel *channel)
 Checks for HTML support on a channel.
 
int ast_channel_suppress (struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype)
 Suppress passing of a frame type on a channel.
 
const struct ast_channel_techast_channel_tech (const struct ast_channel *chan)
 
int ast_channel_tech_hangupcause (const struct ast_channel *chan)
 
void ast_channel_tech_hangupcause_set (struct ast_channel *chan, int value)
 
void * ast_channel_tech_pvt (const struct ast_channel *chan)
 
void ast_channel_tech_pvt_set (struct ast_channel *chan, void *value)
 
void ast_channel_tech_set (struct ast_channel *chan, const struct ast_channel_tech *value)
 
const char * ast_channel_tenantid (const struct ast_channel *chan)
 
void ast_channel_tenantid_set (struct ast_channel *chan, const char *value)
 
struct ast_timerast_channel_timer (const struct ast_channel *chan)
 
void ast_channel_timer_set (struct ast_channel *chan, struct ast_timer *value)
 
void * ast_channel_timingdata (const struct ast_channel *chan)
 
void ast_channel_timingdata_set (struct ast_channel *chan, void *value)
 
int ast_channel_timingfd (const struct ast_channel *chan)
 
void ast_channel_timingfd_set (struct ast_channel *chan, int value)
 
ast_timing_func_t ast_channel_timingfunc (const struct ast_channel *chan)
 
void ast_channel_timingfunc_set (struct ast_channel *chan, ast_timing_func_t value)
 
struct stasis_topicast_channel_topic (struct ast_channel *chan)
 A topic which publishes the events for a particular channel.
 
unsigned short ast_channel_transfercapability (const struct ast_channel *chan)
 
void ast_channel_transfercapability_set (struct ast_channel *chan, unsigned short value)
 
int ast_channel_unbridged (struct ast_channel *chan)
 This function will check if the bridge needs to be re-evaluated due to external changes.
 
int ast_channel_unbridged_nolock (struct ast_channel *chan)
 ast_channel_unbridged variant. Use this if the channel is already locked prior to calling.
 
void ast_channel_undefer_dtmf (struct ast_channel *chan)
 Unset defer DTMF flag on channel.
 
const char * ast_channel_uniqueid (const struct ast_channel *chan)
 
void ast_channel_unlink (struct ast_channel *chan)
 Remove a channel from the global channels container.
 
void ast_channel_unregister (const struct ast_channel_tech *tech)
 Unregister a channel technology.
 
int ast_channel_unsuppress (struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype)
 Stop suppressing of a frame type on a channel.
 
void ast_channel_update_connected_line (struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
 Indicate that the connected line information has changed.
 
void ast_channel_update_redirecting (struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
 Indicate that the redirecting id has changed.
 
const char * ast_channel_userfield (const struct ast_channel *chan)
 
struct varsheadast_channel_varshead (struct ast_channel *chan)
 
void ast_channel_varshead_set (struct ast_channel *chan, struct varshead *value)
 
int ast_channel_visible_indication (const struct ast_channel *chan)
 
void ast_channel_visible_indication_set (struct ast_channel *chan, int value)
 
struct ast_filestreamast_channel_vstream (const struct ast_channel *chan)
 
void ast_channel_vstream_set (struct ast_channel *chan, struct ast_filestream *value)
 
int ast_channel_vstreamid (const struct ast_channel *chan)
 
void ast_channel_vstreamid_set (struct ast_channel *chan, int value)
 
struct timeval * ast_channel_whentohangup (struct ast_channel *chan)
 
void ast_channel_whentohangup_set (struct ast_channel *chan, struct timeval *value)
 
struct ast_formatast_channel_writeformat (struct ast_channel *chan)
 
struct ast_trans_pvtast_channel_writetrans (const struct ast_channel *chan)
 
void ast_channel_writetrans_set (struct ast_channel *chan, struct ast_trans_pvt *value)
 
struct ast_channelast_channel_yank (struct ast_channel *yankee)
 Gain control of a channel in the system.
 
struct ast_tone_zoneast_channel_zone (const struct ast_channel *chan)
 
void ast_channel_zone_set (struct ast_channel *chan, struct ast_tone_zone *value)
 
struct ast_variableast_channeltype_list (void)
 return an ast_variable list of channeltypes
 
int ast_check_hangup (struct ast_channel *chan)
 Check to see if a channel is needing hang up.
 
int ast_check_hangup_locked (struct ast_channel *chan)
 
int ast_connected_line_build_data (unsigned char *data, size_t datalen, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
 Build the connected line information data frame.
 
void ast_connected_line_copy_from_caller (struct ast_party_connected_line *dest, const struct ast_party_caller *src)
 Copy the caller information to the connected line information.
 
void ast_connected_line_copy_to_caller (struct ast_party_caller *dest, const struct ast_party_connected_line *src)
 Copy the connected line information to the caller information.
 
int ast_connected_line_parse_data (const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected)
 Parse connected line indication frame data.
 
void ast_deactivate_generator (struct ast_channel *chan)
 
static int ast_fdisset (struct pollfd *pfds, int fd, int maximum, int *start)
 Helper function for migrating select to poll.
 
const struct ast_channel_techast_get_channel_tech (const char *name)
 Get a channel technology structure by name.
 
ast_group_t ast_get_group (const char *s)
 
struct ast_namedgroups * ast_get_namedgroups (const char *s)
 Create an ast_namedgroups set with group names from comma separated string.
 
void ast_hangup (struct ast_channel *chan)
 Hang up a channel.
 
int ast_indicate (struct ast_channel *chan, int condition)
 Indicates condition of channel.
 
int ast_indicate_data (struct ast_channel *chan, int condition, const void *data, size_t datalen)
 Indicates condition of channel, with payload.
 
int ast_is_deferrable_frame (const struct ast_frame *frame)
 Should we keep this frame for later?
 
int ast_namedgroups_intersect (struct ast_namedgroups *a, struct ast_namedgroups *b)
 Return TRUE if group a and b contain at least one common groupname.
 
void ast_party_caller_copy (struct ast_party_caller *dest, const struct ast_party_caller *src)
 Copy the source caller information to the destination caller.
 
void ast_party_caller_free (struct ast_party_caller *doomed)
 Destroy the caller party contents.
 
void ast_party_caller_init (struct ast_party_caller *init)
 Initialize the given caller structure.
 
void ast_party_caller_set (struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update)
 Set the caller information based on another caller source.
 
void ast_party_caller_set_init (struct ast_party_caller *init, const struct ast_party_caller *guide)
 Initialize the given caller structure using the given guide for a set update operation.
 
void ast_party_connected_line_collect_caller (struct ast_party_connected_line *connected, struct ast_party_caller *caller)
 Collect the caller party information into a connected line structure.
 
void ast_party_connected_line_copy (struct ast_party_connected_line *dest, const struct ast_party_connected_line *src)
 Copy the source connected line information to the destination connected line.
 
void ast_party_connected_line_free (struct ast_party_connected_line *doomed)
 Destroy the connected line information contents.
 
void ast_party_connected_line_init (struct ast_party_connected_line *init)
 Initialize the given connected line structure.
 
void ast_party_connected_line_set (struct ast_party_connected_line *dest, const struct ast_party_connected_line *src, const struct ast_set_party_connected_line *update)
 Set the connected line information based on another connected line source.
 
void ast_party_connected_line_set_init (struct ast_party_connected_line *init, const struct ast_party_connected_line *guide)
 Initialize the given connected line structure using the given guide for a set update operation.
 
void ast_party_dialed_copy (struct ast_party_dialed *dest, const struct ast_party_dialed *src)
 Copy the source dialed party information to the destination dialed party.
 
void ast_party_dialed_free (struct ast_party_dialed *doomed)
 Destroy the dialed party contents.
 
void ast_party_dialed_init (struct ast_party_dialed *init)
 Initialize the given dialed structure.
 
void ast_party_dialed_set (struct ast_party_dialed *dest, const struct ast_party_dialed *src)
 Set the dialed information based on another dialed source.
 
void ast_party_dialed_set_init (struct ast_party_dialed *init, const struct ast_party_dialed *guide)
 Initialize the given dialed structure using the given guide for a set update operation.
 
void ast_party_id_copy (struct ast_party_id *dest, const struct ast_party_id *src)
 Copy the source party id information to the destination party id.
 
void ast_party_id_free (struct ast_party_id *doomed)
 Destroy the party id contents.
 
void ast_party_id_init (struct ast_party_id *init)
 Initialize the given party id structure.
 
void ast_party_id_invalidate (struct ast_party_id *id)
 Invalidate all components of the given party id.
 
struct ast_party_id ast_party_id_merge (struct ast_party_id *base, struct ast_party_id *overlay)
 Merge a given party id into another given party id.
 
void ast_party_id_merge_copy (struct ast_party_id *dest, struct ast_party_id *base, struct ast_party_id *overlay)
 Copy a merge of a given party id into another given party id to a given destination party id.
 
int ast_party_id_presentation (const struct ast_party_id *id)
 Determine the overall presentation value for the given party.
 
void ast_party_id_reset (struct ast_party_id *id)
 Destroy and initialize the given party id structure.
 
void ast_party_id_set (struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update)
 Set the source party id information into the destination party id.
 
void ast_party_id_set_init (struct ast_party_id *init, const struct ast_party_id *guide)
 Initialize the given party id structure using the given guide for a set update operation.
 
void ast_party_name_copy (struct ast_party_name *dest, const struct ast_party_name *src)
 Copy the source party name information to the destination party name.
 
void ast_party_name_free (struct ast_party_name *doomed)
 Destroy the party name contents.
 
void ast_party_name_init (struct ast_party_name *init)
 Initialize the given name structure.
 
void ast_party_name_set (struct ast_party_name *dest, const struct ast_party_name *src)
 Set the source party name information into the destination party name.
 
void ast_party_name_set_init (struct ast_party_name *init, const struct ast_party_name *guide)
 Initialize the given party name structure using the given guide for a set update operation.
 
void ast_party_number_copy (struct ast_party_number *dest, const struct ast_party_number *src)
 Copy the source party number information to the destination party number.
 
void ast_party_number_free (struct ast_party_number *doomed)
 Destroy the party number contents.
 
void ast_party_number_init (struct ast_party_number *init)
 Initialize the given number structure.
 
void ast_party_number_set (struct ast_party_number *dest, const struct ast_party_number *src)
 Set the source party number information into the destination party number.
 
void ast_party_number_set_init (struct ast_party_number *init, const struct ast_party_number *guide)
 Initialize the given party number structure using the given guide for a set update operation.
 
void ast_party_redirecting_copy (struct ast_party_redirecting *dest, const struct ast_party_redirecting *src)
 Copy the source redirecting information to the destination redirecting.
 
void ast_party_redirecting_free (struct ast_party_redirecting *doomed)
 Destroy the redirecting information contents.
 
void ast_party_redirecting_init (struct ast_party_redirecting *init)
 Initialize the given redirecting structure.
 
void ast_party_redirecting_reason_copy (struct ast_party_redirecting_reason *dest, const struct ast_party_redirecting_reason *src)
 Copy the source redirecting reason information to the destination redirecting reason.
 
void ast_party_redirecting_reason_free (struct ast_party_redirecting_reason *doomed)
 Destroy the redirecting reason contents.
 
void ast_party_redirecting_reason_init (struct ast_party_redirecting_reason *init)
 Initialize the given redirecting reason structure.
 
void ast_party_redirecting_reason_set (struct ast_party_redirecting_reason *dest, const struct ast_party_redirecting_reason *src)
 Set the redirecting reason information based on another redirecting reason source.
 
void ast_party_redirecting_reason_set_init (struct ast_party_redirecting_reason *init, const struct ast_party_redirecting_reason *guide)
 Initialize the given redirecting reason structure using the given guide for a set update operation.
 
void ast_party_redirecting_set (struct ast_party_redirecting *dest, const struct ast_party_redirecting *src, const struct ast_set_party_redirecting *update)
 Set the redirecting information based on another redirecting source.
 
void ast_party_redirecting_set_init (struct ast_party_redirecting *init, const struct ast_party_redirecting *guide)
 Initialize the given redirecting id structure using the given guide for a set update operation.
 
void ast_party_subaddress_copy (struct ast_party_subaddress *dest, const struct ast_party_subaddress *src)
 Copy the source party subaddress information to the destination party subaddress.
 
void ast_party_subaddress_free (struct ast_party_subaddress *doomed)
 Destroy the party subaddress contents.
 
void ast_party_subaddress_init (struct ast_party_subaddress *init)
 Initialize the given subaddress structure.
 
void ast_party_subaddress_set (struct ast_party_subaddress *dest, const struct ast_party_subaddress *src)
 Set the source party subaddress information into the destination party subaddress.
 
void ast_party_subaddress_set_init (struct ast_party_subaddress *init, const struct ast_party_subaddress *guide)
 Initialize the given party subaddress structure using the given guide for a set update operation.
 
int ast_pre_call (struct ast_channel *chan, const char *sub_args)
 Execute a Gosub call on the channel before a call is placed.
 
char * ast_print_group (char *buf, int buflen, ast_group_t group)
 Print call and pickup groups into buffer.
 
char * ast_print_namedgroups (struct ast_str **buf, struct ast_namedgroups *groups)
 Print named call groups and named pickup groups.
 
int ast_prod (struct ast_channel *chan)
 Send empty audio to prime a channel driver.
 
int ast_queue_answer (struct ast_channel *chan, const struct ast_stream_topology *topology)
 Queue an ANSWER control frame with topology.
 
int ast_queue_control (struct ast_channel *chan, enum ast_control_frame_type control)
 Queue a control frame without payload.
 
int ast_queue_control_data (struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen)
 Queue a control frame with payload.
 
int ast_queue_frame (struct ast_channel *chan, struct ast_frame *f)
 Queue one or more frames to a channel's frame queue.
 
int ast_queue_frame_head (struct ast_channel *chan, struct ast_frame *f)
 Queue one or more frames to the head of a channel's frame queue.
 
int ast_queue_hangup (struct ast_channel *chan)
 Queue a hangup frame.
 
int ast_queue_hangup_with_cause (struct ast_channel *chan, int cause)
 Queue a hangup frame with hangupcause set.
 
int ast_queue_hold (struct ast_channel *chan, const char *musicclass)
 Queue a hold frame.
 
int ast_queue_unhold (struct ast_channel *chan)
 Queue an unhold frame.
 
int ast_raw_answer (struct ast_channel *chan)
 Answer a channel.
 
int ast_raw_answer_with_stream_topology (struct ast_channel *chan, struct ast_stream_topology *topology)
 Answer a channel passing in a stream topology.
 
struct ast_frameast_read (struct ast_channel *chan)
 Reads a frame.
 
struct ast_frameast_read_noaudio (struct ast_channel *chan)
 Reads a frame, returning AST_FRAME_NULL frame if audio.
 
struct ast_frameast_read_stream (struct ast_channel *chan)
 Reads a frame, but does not filter to just the default streams.
 
struct ast_frameast_read_stream_noaudio (struct ast_channel *chan)
 Reads a frame, but does not filter to just the default streams, returning AST_FRAME_NULL frame if audio.
 
int ast_readstring (struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders)
 Reads multiple digits.
 
int ast_readstring_full (struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders, int audiofd, int ctrlfd)
 
int ast_recvchar (struct ast_channel *chan, int timeout)
 Receives a text character from a channel.
 
char * ast_recvtext (struct ast_channel *chan, int timeout)
 Receives a text string from a channel Read a string of text from a channel.
 
int ast_redirecting_build_data (unsigned char *data, size_t datalen, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
 Build the redirecting id data frame.
 
int ast_redirecting_parse_data (const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting)
 Parse redirecting indication frame data.
 
struct ast_namedgroups * ast_ref_namedgroups (struct ast_namedgroups *groups)
 
struct ast_channelast_request (const char *type, struct ast_format_cap *request_cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
 Requests a channel.
 
struct ast_channelast_request_and_dial (const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, 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.
 
struct ast_channelast_request_with_stream_topology (const char *type, struct ast_stream_topology *topology, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
 Requests a channel (specifying stream topology)
 
int ast_safe_sleep (struct ast_channel *chan, int ms)
 Wait for a specified amount of time, looking for hangups.
 
int ast_safe_sleep_conditional (struct ast_channel *chan, int ms, int(*cond)(void *), void *data)
 Wait for a specified amount of time, looking for hangups and a condition argument.
 
int ast_safe_sleep_without_silence (struct ast_channel *chan, int ms)
 Wait for a specified amount of time, looking for hangups, and do not generate silence.
 
int ast_senddigit (struct ast_channel *chan, char digit, unsigned int duration)
 Send a DTMF digit to a channel.
 
int ast_senddigit_begin (struct ast_channel *chan, char digit)
 Send a DTMF digit to a channel.
 
int ast_senddigit_end (struct ast_channel *chan, char digit, unsigned int duration)
 Send a DTMF digit to a channel.
 
int ast_senddigit_external (struct ast_channel *chan, char digit, unsigned int duration)
 Send a DTMF digit to a channel from an external thread.
 
int ast_senddigit_mf (struct ast_channel *chan, char digit, unsigned int duration, unsigned int durationkp, unsigned int durationst, int is_external)
 Send an MF digit to a channel.
 
int ast_senddigit_mf_begin (struct ast_channel *chan, char digit)
 Send an MF digit to a channel.
 
int ast_senddigit_mf_end (struct ast_channel *chan)
 End sending an MF digit to a channel.
 
int ast_sendtext (struct ast_channel *chan, const char *text)
 Sends text to a channel.
 
int ast_sendtext_data (struct ast_channel *chan, struct ast_msg_data *msg)
 Sends text to a channel in an ast_msg_data structure wrapper with ast_sendtext as fallback.
 
void ast_set_callerid (struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani)
 Set caller ID number, name and ANI and generate AMI event.
 
void ast_set_hangupsource (struct ast_channel *chan, const char *source, int force)
 Set the source of the hangup in this channel and it's bridge.
 
void ast_set_party_id_all (struct ast_set_party_id *update_id)
 Set the update marker to update all information of a corresponding party id.
 
int ast_set_read_format (struct ast_channel *chan, struct ast_format *format)
 Sets read format on channel chan.
 
int ast_set_read_format_from_cap (struct ast_channel *chan, struct ast_format_cap *formats)
 Sets read format on channel chan from capabilities Set read format for channel to whichever component of "format" is best.
 
int ast_set_read_format_path (struct ast_channel *chan, struct ast_format *raw_format, struct ast_format *core_format)
 Set specific read path on channel.
 
void ast_set_variables (struct ast_channel *chan, struct ast_variable *vars)
 adds a list of channel variables to a channel
 
int ast_set_write_format (struct ast_channel *chan, struct ast_format *format)
 Sets write format on channel chan.
 
int ast_set_write_format_from_cap (struct ast_channel *chan, struct ast_format_cap *formats)
 Sets write format on channel chan Set write format for channel to whichever component of "format" is best.
 
int ast_set_write_format_interleaved_stereo (struct ast_channel *chan, struct ast_format *format)
 Sets write format for a channel. All internal data will than be handled in an interleaved format. (needed by binaural opus)
 
int ast_set_write_format_path (struct ast_channel *chan, struct ast_format *core_format, struct ast_format *raw_format)
 Set specific write path on channel.
 
int ast_settimeout (struct ast_channel *c, unsigned int rate, int(*func)(const void *data), void *data)
 Enable or disable timer ticks for a channel.
 
int ast_settimeout_full (struct ast_channel *c, unsigned int rate, int(*func)(const void *data), void *data, unsigned int is_ao2_obj)
 
int ast_softhangup (struct ast_channel *chan, int cause)
 Softly hangup up a channel.
 
void ast_softhangup_all (void)
 Soft hangup all active channels.
 
int ast_softhangup_nolock (struct ast_channel *chan, int cause)
 Softly hangup up a channel (no channel lock)
 
const char * ast_state2str (enum ast_channel_state state)
 Gives the string form of a given channel state.
 
int ast_str2cause (const char *name) attribute_pure
 Convert the string form of a cause code to a number.
 
int ast_tonepair (struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
 
int ast_tonepair_start (struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
 
void ast_tonepair_stop (struct ast_channel *chan)
 
int ast_transfer (struct ast_channel *chan, char *dest)
 Transfer a channel (if supported).
 
int ast_transfer_protocol (struct ast_channel *chan, char *dest, int *protocol)
 Transfer a channel (if supported) receieve protocol result.
 
char * ast_transfercapability2str (int transfercapability) attribute_const
 Gives the string form of a given transfer capability.
 
int ast_undestroyed_channels (void)
 
struct ast_namedgroups * ast_unref_namedgroups (struct ast_namedgroups *groups)
 
int ast_waitfor (struct ast_channel *chan, int ms)
 Wait for input on a channel.
 
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.
 
int ast_waitfor_n_fd (int *fds, int n, int *ms, int *exception)
 Waits for input on an fd.
 
struct ast_channelast_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.
 
int ast_waitfordigit (struct ast_channel *c, int ms)
 Waits for a digit.
 
int ast_waitfordigit_full (struct ast_channel *c, int ms, const char *breakon, int audiofd, int ctrlfd)
 Wait for a digit Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to monitor for reading.
 
int ast_write (struct ast_channel *chan, struct ast_frame *frame)
 Write a frame to a channel This function writes the given frame to the indicated channel.
 
int ast_write_stream (struct ast_channel *chan, int stream_num, struct ast_frame *frame)
 Write a frame to a stream This function writes the given frame to the indicated stream on the channel.
 
int ast_write_text (struct ast_channel *chan, struct ast_frame *frame)
 Write text frame to a channel This function writes the given frame to the indicated channel.
 
int ast_write_video (struct ast_channel *chan, struct ast_frame *frame)
 Write video frame to a channel This function writes the given frame to the indicated channel.
 
 DECLARE_STRINGFIELD_SETTERS_FOR (accountcode)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (call_forward)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (dialcontext)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (hangupsource)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (language)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (latest_musicclass)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (linkedid)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (musicclass)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (name)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (parkinglot)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (peeraccount)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (uniqueid)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (userfield)
 
int internal_channel_set_current_storage_driver (const char *driver_name)
 
struct ast_channel_iteratorast_channel_iterator_all_new (void)
 Create a new channel iterator.
 
struct ast_channel_iteratorast_channel_iterator_by_exten_new (const char *exten, const char *context)
 Create a new channel iterator based on extension.
 
struct ast_channel_iteratorast_channel_iterator_by_name_new (const char *name, size_t name_len)
 Create a new channel iterator based on name.
 
struct ast_channel_iteratorast_channel_iterator_destroy (struct ast_channel_iterator *i)
 Destroy a channel iterator.
 
struct ast_channelast_channel_iterator_next (struct ast_channel_iterator *i)
 Get the next channel for a channel iterator.
 
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.
 
struct ast_channelast_channel_get_by_exten (const char *exten, const char *context)
 Find a channel by extension and context.
 
struct ast_channelast_channel_get_by_name (const char *search)
 Find a channel by name or uniqueid.
 
struct ast_channelast_channel_get_by_name_prefix (const char *name, size_t name_len)
 Find a channel by a name prefix.
 
struct ast_channelast_channel_get_by_uniqueid (const char *uniqueid)
 Find a channel by a uniqueid.
 

Variables

const struct ast_channel_tech ast_kill_tech
 Kill the channel channel driver technology descriptor.
 
static const char ast_stream_topology_changed_external [] = "external"
 Set as the change source reason when a channel stream topology has been changed externally as a result of the remote side renegotiating.
 
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

◆ AST_AGENT_FD

#define AST_AGENT_FD   (AST_MAX_FDS-3)

unused - formerly used by agents for pass through

Definition at line 204 of file channel.h.

◆ AST_ALERT_FD

#define AST_ALERT_FD   (AST_MAX_FDS-1)

used for alertpipe

Definition at line 202 of file channel.h.

◆ AST_BRIDGE_DTMF_CHANNEL_0

#define AST_BRIDGE_DTMF_CHANNEL_0   (1 << 0)

Report DTMF on channel 0.

Definition at line 2427 of file channel.h.

◆ AST_BRIDGE_DTMF_CHANNEL_1

#define AST_BRIDGE_DTMF_CHANNEL_1   (1 << 1)

Report DTMF on channel 1.

Definition at line 2429 of file channel.h.

◆ AST_CHAN_WRITE_INFO_T_VERSION

#define AST_CHAN_WRITE_INFO_T_VERSION   1

ast_chan_write_info_t version. Must be incremented if structure is changed

Definition at line 593 of file channel.h.

◆ ast_channel_alloc

#define ast_channel_alloc (   needqueue,
  state,
  cid_num,
  cid_name,
  acctcode,
  exten,
  context,
  assignedids,
  requestor,
  amaflag,
  ... 
)
Value:
__ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag, NULL, \
__FILE__, __LINE__, __FUNCTION__, __VA_ARGS__)
struct ast_channel * __ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, enum ama_flags amaflag, struct ast_endpoint *endpoint, const char *file, int line, const char *function, const char *name_fmt,...)
Create a channel structure.
Definition channel.c:967
#define NULL
Definition resample.c:96

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.
Since 12.0.0 this function returns with the newly created channel locked.

Definition at line 1299 of file channel.h.

1522 {
1523 /*! The requestor is the future bridge peer of the channel. */
1525 /*! The requestor is to be replaced by the channel. */
1527};
1528
1529/*!
1530 * \brief Setup new channel accountcodes from the requestor channel after ast_request().
1531 * \since 13.0.0
1532 *
1533 * \param chan New channel to get accountcodes setup.
1534 * \param requestor Requesting channel to get accountcodes from.
1535 * \param relationship What the new channel was created for.
1536 *
1537 * \pre The chan and requestor channels are already locked.
1538 *
1539 * \note Pre-existing accountcodes on chan will be overwritten.
1540 */
1541void ast_channel_req_accountcodes(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship);
1542
1543/*!
1544 * \brief Setup new channel accountcodes from the requestor channel after ast_request().
1545 * \since 13.0.0
1546 *
1547 * \param chan New channel to get accountcodes setup.
1548 * \param requestor Requesting channel to get accountcodes from.
1549 * \param relationship What the new channel was created for.
1550 *
1551 * \pre The chan and requestor channels are already locked.
1552 *
1553 * \note Pre-existing accountcodes on chan will not be overwritten.
1554 */
1555void ast_channel_req_accountcodes_precious(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship);
1556
1557/*!
1558 * \brief Request a channel of a given type, with data as optional information used
1559 * by the low level module and attempt to place a call on it
1560 *
1561 * \param type type of channel to request
1562 * \param cap format capabilities for requested channel
1563 * \param assignedids Unique Id to assign to channel
1564 * \param requestor channel asking for data
1565 * \param addr destination of the call
1566 * \param timeout maximum amount of time to wait for an answer
1567 * \param reason why unsuccessful (if unsuccessful)
1568 * \param cid_num Caller-ID Number
1569 * \param cid_name Caller-ID Name (ascii)
1570 *
1571 * \return Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state
1572 * to know if the call was answered or not.
1573 */
1574struct ast_channel *ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr,
1575 int timeout, int *reason, const char *cid_num, const char *cid_name);
1576
1577/*!
1578 * \brief Request a channel of a given type, with data as optional information used
1579 * by the low level module and attempt to place a call on it
1580 * \param type type of channel to request
1581 * \param cap format capabilities for requested channel
1582 * \param assignedids Unique Id to assign to channel
1583 * \param requestor channel requesting data
1584 * \param addr destination of the call
1585 * \param timeout maximum amount of time to wait for an answer
1586 * \param reason why unsuccessful (if unsuccessful)
1587 * \param cid_num Caller-ID Number
1588 * \param cid_name Caller-ID Name (ascii)
1589 * \param oh Outgoing helper
1590 * \return Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state
1591 * to know if the call was answered or not.
1592 */
1593struct ast_channel *__ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr,
1594 int timeout, int *reason, const char *cid_num, const char *cid_name, struct outgoing_helper *oh);
1595
1596/*!
1597 * \brief 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.
1598 * \param caller in channel that requested orig
1599 * \param orig channel being replaced by the call forward channel
1600 * \param timeout maximum amount of time to wait for setup of new forward channel
1601 * \param cap format capabilities for requested channel
1602 * \param oh outgoing helper used with original channel
1603 * \param outstate reason why unsuccessful (if unsuccessful)
1604 * \return Returns the forwarded call's ast_channel on success or NULL on failure
1605 */
1606struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, struct ast_format_cap *cap, struct outgoing_helper *oh, int *outstate);
1607
1608/*!
1609 * \brief Register a channel technology (a new channel driver)
1610 * Called by a channel module to register the kind of channels it supports.
1611 * \param tech Structure defining channel technology or "type"
1612 * \return Returns 0 on success, -1 on failure.
1613 */
1614int ast_channel_register(const struct ast_channel_tech *tech);
1615
1616/*!
1617 * \brief Unregister a channel technology
1618 * \param tech Structure defining channel technology or "type" that was previously registered
1619 */
1620void ast_channel_unregister(const struct ast_channel_tech *tech);
1621
1622/*!
1623 * \brief Get a channel technology structure by name
1624 * \param name name of technology to find
1625 * \return a pointer to the structure, or NULL if no matching technology found
1626 */
1627const struct ast_channel_tech *ast_get_channel_tech(const char *name);
1628
1629/*!
1630 * \brief Hang up a channel
1631 * \note Absolutely _NO_ channel locks should be held before calling this function.
1632 * \note This function performs a hard hangup on a channel. Unlike the soft-hangup, this function
1633 * performs all stream stopping, etc, on the channel that needs to end.
1634 * chan is no longer valid after this call.
1635 * \param chan channel to hang up (NULL tolerant)
1636 */
1637void ast_hangup(struct ast_channel *chan);
1638
1639/*!
1640 * \brief Soft hangup all active channels.
1641 * \since 13.3.0
1642 */
1643void ast_softhangup_all(void);
1644
1645/*!
1646 * \brief Softly hangup up a channel
1647 *
1648 * \param chan channel to be soft-hung-up
1649 * \param cause an AST_SOFTHANGUP_* reason code
1650 *
1651 * \details
1652 * Call the protocol layer, but don't destroy the channel structure
1653 * (use this if you are trying to
1654 * safely hangup a channel managed by another thread.
1655 *
1656 * \warning The channel passed to this function must NOT be locked.
1657 * ast_softhangup() calls ast_rtp_instance_set_stats_vars() to set RTP QOS variables.
1658 * If this channel is in a bridge, ast_rtp_instance_set_stats_vars() will
1659 * attempt to lock the bridge peer as well as this channel. This can cause
1660 * a lock inversion if we already have this channel locked and another
1661 * thread tries to set bridge variables on the peer because it will have
1662 * locked the peer first, then this channel. For this reason, we must
1663 * NOT have the channel locked when we call ast_softhangup().
1664 *
1665 * \return Returns 0 regardless
1666 */
1667int ast_softhangup(struct ast_channel *chan, int cause);
1668
1669/*!
1670 * \brief Softly hangup up a channel (no channel lock)
1671 * \param chan channel to be soft-hung-up
1672 * \param cause an AST_SOFTHANGUP_* reason code
1673 */
1674int ast_softhangup_nolock(struct ast_channel *chan, int cause);
1675
1676/*!
1677 * \brief Clear a set of softhangup flags from a channel
1678 *
1679 * Never clear a softhangup flag from a channel directly. Instead,
1680 * use this function. This ensures that all aspects of the softhangup
1681 * process are aborted.
1682 *
1683 * \param chan the channel to clear the flag on
1684 * \param flag the flag or flags to clear
1685 */
1686void ast_channel_clear_softhangup(struct ast_channel *chan, int flag);
1687
1688/*!
1689 * \brief Set the source of the hangup in this channel and it's bridge
1690 *
1691 * \param chan channel to set the field on
1692 * \param source a string describing the source of the hangup for this channel
1693 * \param force
1694 *
1695 * \note Absolutely _NO_ channel locks should be held before calling this function.
1696 *
1697 * \since 1.8
1698 *
1699 * Hangupsource is generally the channel name that caused the bridge to be
1700 * hung up, but it can also be other things such as "dialplan/agi"
1701 * This can then be logged in the CDR or CEL
1702 */
1703void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force);
1704
1705/*! \brief Check to see if a channel is needing hang up
1706 * \param chan channel on which to check for hang up
1707 * This function determines if the channel is being requested to be hung up.
1708 * \return Returns 0 if not, or 1 if hang up is requested (including time-out).
1709 */
1710int ast_check_hangup(struct ast_channel *chan);
1711
1712int ast_check_hangup_locked(struct ast_channel *chan);
1713
1714/*! \brief This function will check if the bridge needs to be re-evaluated due to
1715 * external changes.
1716 *
1717 * \param chan Channel on which to check the unbridge_eval flag
1718 *
1719 * \return Returns 0 if the flag is down or 1 if the flag is up.
1720 */
1721int ast_channel_unbridged(struct ast_channel *chan);
1722
1723/*! \brief ast_channel_unbridged variant. Use this if the channel
1724 * is already locked prior to calling.
1725 *
1726 * \param chan Channel on which to check the unbridge flag
1727 *
1728 * \return Returns 0 if the flag is down or 1 if the flag is up.
1729 */
1731
1732/*! \brief Sets the unbridged flag and queues a NULL frame on the channel to trigger
1733 * a check by bridge_channel_wait
1734 *
1735 * \param chan Which channel is having its unbridged value set
1736 * \param value What the unbridge value is being set to
1737 */
1738void ast_channel_set_unbridged(struct ast_channel *chan, int value);
1739
1740/*! \brief Variant of ast_channel_set_unbridged. Use this if the channel
1741 * is already locked prior to calling.
1742 *
1743 * \param chan Which channel is having its unbridged value set
1744 * \param value What the unbridge value is being set to
1745 */
1746void ast_channel_set_unbridged_nolock(struct ast_channel *chan, int value);
1747
1748/*!
1749 * \brief This function will check if T.38 is active on the channel.
1750 *
1751 * \param chan Channel on which to check the unbridge_eval flag
1752 *
1753 * \return Returns 0 if the flag is down or 1 if the flag is up.
1754 */
1755int ast_channel_is_t38_active(struct ast_channel *chan);
1756
1757/*!
1758 * \brief ast_channel_is_t38_active variant. Use this if the channel
1759 * is already locked prior to calling.
1760 *
1761 * \param chan Channel on which to check the is_t38_active flag
1762 *
1763 * \return Returns 0 if the flag is down or 1 if the flag is up.
1764 */
1766
1767/*!
1768 * \brief Sets the is_t38_active flag
1769 *
1770 * \param chan Which channel is having its is_t38_active value set
1771 * \param is_t38_active Non-zero if T.38 is active
1772 */
1773void ast_channel_set_is_t38_active(struct ast_channel *chan, int is_t38_active);
1774
1775/*!
1776 * \brief Variant of ast_channel_set_is_t38_active. Use this if the channel
1777 * is already locked prior to calling.
1778 *
1779 * \param chan Which channel is having its is_t38_active value set
1780 * \param is_t38_active Non-zero if T.38 is active
1781 */
1782void ast_channel_set_is_t38_active_nolock(struct ast_channel *chan, int is_t38_active);
1783
1784/*!
1785 * \brief Lock the given channel, then request softhangup on the channel with the given causecode
1786 * \param chan channel on which to hang up
1787 * \param causecode cause code to use (Zero if don't use cause code)
1788 */
1789void ast_channel_softhangup_withcause_locked(struct ast_channel *chan, int causecode);
1790
1791/*!
1792 * \brief Compare a offset with the settings of when to hang a channel up
1793 * \param chan channel on which to check for hangup
1794 * \param offset offset in seconds and microseconds from current time
1795 * \retval 1
1796 * \retval 0
1797 * \retval -1
1798 * This function compares a offset from current time with the absolute time
1799 * out on a channel (when to hang up). If the absolute time out on a channel
1800 * is earlier than current time plus the offset, it returns 1, if the two
1801 * time values are equal, it return 0, otherwise, it return -1.
1802 * \since 1.6.1
1803 */
1804int ast_channel_cmpwhentohangup_tv(struct ast_channel *chan, struct timeval offset);
1805
1806/*!
1807 * \brief Set when to hang a channel up
1808 *
1809 * \param chan channel on which to check for hang up
1810 * \param offset offset in seconds and useconds relative to the current time of when to hang up
1811 *
1812 * This function sets the absolute time out on a channel (when to hang up).
1813 *
1814 * \pre chan is locked
1815 *
1816 * \since 1.6.1
1817 */
1818void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset);
1819
1820/*!
1821 * \brief Answer a channel
1822 *
1823 * \param chan channel to answer
1824 *
1825 * \details
1826 * This function answers a channel and handles all necessary call
1827 * setup functions.
1828 *
1829 * \note The channel passed does not need to be locked, but is locked
1830 * by the function when needed.
1831 *
1832 * \note This function will wait up to 500 milliseconds for media to
1833 * arrive on the channel before returning to the caller, so that the
1834 * caller can properly assume the channel is 'ready' for media flow.
1835 *
1836 * \retval 0 on success
1837 * \retval non-zero on failure
1838 */
1839int ast_answer(struct ast_channel *chan);
1840
1841/*!
1842 * \brief Answer a channel, if it's not already answered.
1843 *
1844 * \param chan channel to answer
1845 *
1846 * \details See ast_answer()
1847 *
1848 * \retval 0 on success
1849 * \retval non-zero on failure
1850 */
1851int ast_auto_answer(struct ast_channel *chan);
1852
1853/*!
1854 * \brief Answer a channel
1855 *
1856 * \param chan channel to answer
1857 *
1858 * This function answers a channel and handles all necessary call
1859 * setup functions.
1860 *
1861 * \note The channel passed does not need to be locked, but is locked
1862 * by the function when needed.
1863 *
1864 * \note Unlike ast_answer(), this function will not wait for media
1865 * flow to begin. The caller should be careful before sending media
1866 * to the channel before incoming media arrives, as the outgoing
1867 * media may be lost.
1868 *
1869 * \retval 0 on success
1870 * \retval non-zero on failure
1871 */
1872int ast_raw_answer(struct ast_channel *chan);
1873
1874/*!
1875 * \brief Answer a channel passing in a stream topology
1876 * \since 18.0.0
1877 *
1878 * \param chan channel to answer
1879 * \param topology the peer's stream topology
1880 *
1881 * This function answers a channel and handles all necessary call
1882 * setup functions.
1883 *
1884 * \note The channel passed does not need to be locked, but is locked
1885 * by the function when needed.
1886 *
1887 * \note Unlike ast_answer(), this function will not wait for media
1888 * flow to begin. The caller should be careful before sending media
1889 * to the channel before incoming media arrives, as the outgoing
1890 * media may be lost.
1891 *
1892 * \note The topology is usually that of the peer channel and may be NULL.
1893 *
1894 * \retval 0 on success
1895 * \retval non-zero on failure
1896 */
1897int ast_raw_answer_with_stream_topology(struct ast_channel *chan, struct ast_stream_topology *topology);
1898
1899/*!
1900 * \brief Answer a channel, with a selectable delay before returning
1901 *
1902 * \param chan channel to answer
1903 * \param delay maximum amount of time to wait for incoming media
1904 *
1905 * This function answers a channel and handles all necessary call
1906 * setup functions.
1907 *
1908 * \note The channel passed does not need to be locked, but is locked
1909 * by the function when needed.
1910 *
1911 * \note This function will wait up to 'delay' milliseconds for media to
1912 * arrive on the channel before returning to the caller, so that the
1913 * caller can properly assume the channel is 'ready' for media flow. If
1914 * 'delay' is less than 500, the function will wait up to 500 milliseconds.
1915 *
1916 * \retval 0 on success
1917 * \retval non-zero on failure
1918 */
1919int __ast_answer(struct ast_channel *chan, unsigned int delay);
1920
1921/*!
1922 * \brief Execute a Gosub call on the channel before a call is placed.
1923 * \since 11.0
1924 *
1925 * \details
1926 * This is called between ast_request() and ast_call() to
1927 * execute a predial routine on the newly created channel.
1928 *
1929 * \param chan Channel to execute Gosub.
1930 * \param sub_args Gosub application parameter string.
1931 *
1932 * \note Absolutely _NO_ channel locks should be held before calling this function.
1933 *
1934 * \retval 0 on success.
1935 * \retval -1 on error.
1936 */
1937int ast_pre_call(struct ast_channel *chan, const char *sub_args);
1938
1939/*!
1940 * \brief Make a call
1941 * \note Absolutely _NO_ channel locks should be held before calling this function.
1942 * \param chan which channel to make the call on
1943 * \param addr destination of the call
1944 * \param timeout time to wait on for connect (Doesn't seem to be used.)
1945 * \details
1946 * Place a call, take no longer than timeout ms.
1947 * \retval 0 on success
1948 * \retval -1 on failure
1949 */
1950int ast_call(struct ast_channel *chan, const char *addr, int timeout);
1951
1952/*!
1953 * \brief Indicates condition of channel
1954 * \note Absolutely _NO_ channel locks should be held before calling this function.
1955 * \note Indicate a condition such as AST_CONTROL_BUSY, AST_CONTROL_RINGING, or AST_CONTROL_CONGESTION on a channel
1956 * \param chan channel to change the indication
1957 * \param condition which condition to indicate on the channel
1958 * \return Returns 0 on success, -1 on failure
1959 */
1960int ast_indicate(struct ast_channel *chan, int condition);
1961
1962/*!
1963 * \brief Indicates condition of channel, with payload
1964 * \note Absolutely _NO_ channel locks should be held before calling this function.
1965 * \note Indicate a condition such as AST_CONTROL_HOLD with payload being music on hold class
1966 * \param chan channel to change the indication
1967 * \param condition which condition to indicate on the channel
1968 * \param data pointer to payload data
1969 * \param datalen size of payload data
1970 * \return Returns 0 on success, -1 on failure
1971 */
1972int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen);
1973
1974/* Misc stuff ------------------------------------------------ */
1975
1976/*!
1977 * \brief Wait for input on a channel
1978 * \param chan channel to wait on
1979 * \param ms length of time to wait on the channel
1980 * \details
1981 * Wait for input on a channel for a given # of milliseconds (<0 for indefinite).
1982 * \retval < 0 on failure
1983 * \retval 0 if nothing ever arrived
1984 * \retval the # of ms remaining otherwise
1985 */
1986int ast_waitfor(struct ast_channel *chan, int ms);
1987
1988/*!
1989 * \brief Should we keep this frame for later?
1990 *
1991 * There are functions such as ast_safe_sleep which will
1992 * service a channel to ensure that it does not have a
1993 * large backlog of queued frames. When this happens,
1994 * we want to hold on to specific frame types and just drop
1995 * others. This function will tell if the frame we just
1996 * read should be held onto.
1997 *
1998 * \param frame The frame we just read
1999 * \retval 1 frame should be kept
2000 * \retval 0 frame should be dropped
2001 */
2002int ast_is_deferrable_frame(const struct ast_frame *frame);
2003
2004/*!
2005 * \brief Wait for a specified amount of time, looking for hangups
2006 * \param chan channel to wait for
2007 * \param ms length of time in milliseconds to sleep. This should never be less than zero.
2008 * \details
2009 * Waits for a specified amount of time, servicing the channel as required.
2010 * \return returns -1 on hangup, otherwise 0.
2011 */
2012int ast_safe_sleep(struct ast_channel *chan, int ms);
2013
2014/*!
2015 * \brief Wait for a specified amount of time, looking for hangups, and do not generate silence
2016 * \param chan channel to wait for
2017 * \param ms length of time in milliseconds to sleep. This should never be less than zero.
2018 * \details
2019 * Waits for a specified amount of time, servicing the channel as required.
2020 * \return returns -1 on hangup, otherwise 0.
2021 * \note Unlike ast_safe_sleep this will not generate silence if Asterisk is configured to do so.
2022 */
2023int ast_safe_sleep_without_silence(struct ast_channel *chan, int ms);
2024
2025/*!
2026 * \brief Wait for a specified amount of time, looking for hangups and a condition argument
2027 * \param chan channel to wait for
2028 * \param ms length of time in milliseconds to sleep.
2029 * \param cond a function pointer for testing continue condition
2030 * \param data argument to be passed to the condition test function
2031 * \return returns -1 on hangup, otherwise 0.
2032 * \details
2033 * Waits for a specified amount of time, servicing the channel as required. If cond
2034 * returns 0, this function returns.
2035 */
2036int ast_safe_sleep_conditional(struct ast_channel *chan, int ms, int (*cond)(void*), void *data );
2037
2038/*!
2039 * \brief Waits for activity on a group of channels
2040 * \param c an array of pointers to channels
2041 * \param n number of channels that are to be waited upon
2042 * \param fds an array of fds to wait upon
2043 * \param nfds the number of fds to wait upon
2044 * \param exception exception flag
2045 * \param outfd fd that had activity on it
2046 * \param ms On invocation, max wait time. Upon returning, how long the wait
2047 * actually was (in/out parameter).
2048 * \details
2049 * Big momma function here. Wait for activity on any of the n channels, or any of the nfds
2050 * file descriptors. -1 can be passed as the ms timeout to wait forever, 0 to
2051 * return instantly if theres no activity immediantely available.
2052 * \return Returns the channel with activity, or NULL on error or if an FD
2053 * came first. If the FD came first, it will be returned in outfd, otherwise, outfd
2054 * will be -1
2055 */
2056struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n,
2057 int *fds, int nfds, int *exception, int *outfd, int *ms);
2058
2059/*!
2060 * \brief Waits for input on a group of channels
2061 * Wait for input on an array of channels for a given # of milliseconds.
2062 * \return Return channel with activity, or NULL if none has activity.
2063 * \param chan an array of pointers to channels
2064 * \param n number of channels that are to be waited upon
2065 * \param ms time "ms" is modified in-place, if applicable
2066 */
2067struct ast_channel *ast_waitfor_n(struct ast_channel **chan, int n, int *ms);
2068
2069/*!
2070 * \brief Waits for input on an fd
2071 * \note This version works on fd's only. Be careful with it.
2072 */
2073int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception);
2074
2075
2076/*!
2077 * \brief Reads a frame
2078 *
2079 * \param chan channel to read a frame from
2080 *
2081 * \return Returns a frame, or NULL on error. If it returns NULL, you
2082 * best just stop reading frames and assume the channel has been
2083 * disconnected.
2084 *
2085 * \note This function will filter frames received from the channel so
2086 * that only frames from the default stream for each media type
2087 * are returned. All other media frames from other streams will
2088 * be absorbed internally and a NULL frame returned instead.
2089 */
2090struct ast_frame *ast_read(struct ast_channel *chan);
2091
2092/*!
2093 * \brief Reads a frame, but does not filter to just the default streams
2094 *
2095 * \param chan channel to read a frame from
2096 *
2097 * \return Returns a frame, or NULL on error. If it returns NULL, you
2098 * best just stop reading frames and assume the channel has been
2099 * disconnected.
2100 *
2101 * \note This function will not perform any filtering and will return
2102 * media frames from all streams on the channel. To determine which
2103 * stream a frame originated from the stream_num on it can be
2104 * examined.
2105 */
2106struct ast_frame *ast_read_stream(struct ast_channel *chan);
2107
2108/*!
2109 * \brief Reads a frame, returning AST_FRAME_NULL frame if audio.
2110 * \param chan channel to read a frame from
2111 * \return Returns a frame, or NULL on error. If it returns NULL, you
2112 * best just stop reading frames and assume the channel has been
2113 * disconnected.
2114 * \note Audio is replaced with AST_FRAME_NULL to avoid
2115 * transcode when the resulting audio is not necessary.
2116 */
2117struct ast_frame *ast_read_noaudio(struct ast_channel *chan);
2118
2119/*!
2120 * \brief Reads a frame, but does not filter to just the default streams,
2121 * returning AST_FRAME_NULL frame if audio.
2122 *
2123 * \param chan channel to read a frame from
2124 *
2125 * \return Returns a frame, or NULL on error. If it returns NULL, you
2126 * best just stop reading frames and assume the channel has been
2127 * disconnected.
2128 *
2129 * \note This function will not perform any filtering and will return
2130 * media frames from all streams on the channel. To determine which
2131 * stream a frame originated from the stream_num on it can be
2132 * examined.
2133 *
2134 * \note Audio is replaced with AST_FRAME_NULL to avoid
2135 * transcode when the resulting audio is not necessary.
2136 */
2137struct ast_frame *ast_read_stream_noaudio(struct ast_channel *chan);
2138
2139/*!
2140 * \brief Write a frame to a channel
2141 * This function writes the given frame to the indicated channel.
2142 * \param chan destination channel of the frame
2143 * \param frame frame that will be written
2144 * \return It returns 0 on success, -1 on failure.
2145 */
2146int ast_write(struct ast_channel *chan, struct ast_frame *frame);
2147
2148/*!
2149 * \brief Write video frame to a channel
2150 * This function writes the given frame to the indicated channel.
2151 * \param chan destination channel of the frame
2152 * \param frame frame that will be written
2153 * \return It returns 1 on success, 0 if not implemented, and -1 on failure.
2154 */
2155int ast_write_video(struct ast_channel *chan, struct ast_frame *frame);
2156
2157/*!
2158 * \brief Write text frame to a channel
2159 * This function writes the given frame to the indicated channel.
2160 * \param chan destination channel of the frame
2161 * \param frame frame that will be written
2162 * \return It returns 1 on success, 0 if not implemented, and -1 on failure.
2163 */
2164int ast_write_text(struct ast_channel *chan, struct ast_frame *frame);
2165
2166/*!
2167 * \brief Write a frame to a stream
2168 * This function writes the given frame to the indicated stream on the channel.
2169 * \param chan destination channel of the frame
2170 * \param stream_num destination stream on the channel
2171 * \param frame frame that will be written
2172 * \return It returns 0 on success, -1 on failure.
2173 * \note If -1 is provided as the stream number and a media frame is provided the
2174 * function will write to the default stream of the type of media.
2175 */
2176int ast_write_stream(struct ast_channel *chan, int stream_num, struct ast_frame *frame);
2177
2178/*! \brief Send empty audio to prime a channel driver */
2179int ast_prod(struct ast_channel *chan);
2180
2181/*!
2182 * \brief Set specific read path on channel.
2183 * \since 13.4.0
2184 *
2185 * \param chan Channel to setup read path.
2186 * \param raw_format Format to expect from the channel driver.
2187 * \param core_format What the core wants to read.
2188 *
2189 * \pre chan is locked
2190 *
2191 * \retval 0 on success.
2192 * \retval -1 on error.
2193 */
2194int ast_set_read_format_path(struct ast_channel *chan, struct ast_format *raw_format, struct ast_format *core_format);
2195
2196/*!
2197 * \brief Set specific write path on channel.
2198 * \since 13.13.0
2199 *
2200 * \param chan Channel to setup write path.
2201 * \param core_format What the core wants to write.
2202 * \param raw_format Raw write format.
2203 *
2204 * \pre chan is locked
2205 *
2206 * \retval 0 on success.
2207 * \retval -1 on error.
2208 */
2209int ast_set_write_format_path(struct ast_channel *chan, struct ast_format *core_format, struct ast_format *raw_format);
2210
2211/*!
2212 * \brief Sets read format on channel chan from capabilities
2213 * Set read format for channel to whichever component of "format" is best.
2214 * \param chan channel to change
2215 * \param formats new formats to pick from for reading
2216 * \return Returns 0 on success, -1 on failure
2217 */
2219
2220/*!
2221 * \brief Sets read format on channel chan
2222 * \param chan channel to change
2223 * \param format format to set for reading
2224 * \return Returns 0 on success, -1 on failure
2225 */
2226int ast_set_read_format(struct ast_channel *chan, struct ast_format *format);
2227
2228/*!
2229 * \brief Sets write format on channel chan
2230 * Set write format for channel to whichever component of "format" is best.
2231 * \param chan channel to change
2232 * \param formats new formats to pick from for writing
2233 * \return Returns 0 on success, -1 on failure
2234 */
2236
2237/*!
2238 * \brief Sets write format on channel chan
2239 * \param chan channel to change
2240 * \param format format to set for writing
2241 * \return Returns 0 on success, -1 on failure
2242 */
2243int ast_set_write_format(struct ast_channel *chan, struct ast_format *format);
2244
2245/*!
2246 * \brief Sets write format for a channel.
2247 * All internal data will than be handled in an interleaved format. (needed by binaural opus)
2248 *
2249 * \param chan channel to change
2250 * \param format format to set for writing
2251 * \return Returns 0 on success, -1 on failure
2252 */
2253int ast_set_write_format_interleaved_stereo(struct ast_channel *chan, struct ast_format *format);
2254
2255/*!
2256 * \brief Sends text to a channel
2257 *
2258 * \param chan channel to act upon
2259 * \param text string of text to send on the channel
2260 *
2261 * \details
2262 * Write text to a display on a channel
2263 *
2264 * \note The channel does not need to be locked before calling this function.
2265 *
2266 * \retval 0 on success
2267 * \retval -1 on failure
2268 */
2269int ast_sendtext(struct ast_channel *chan, const char *text);
2270
2271/*!
2272 * \brief Sends text to a channel in an ast_msg_data structure wrapper with ast_sendtext as fallback
2273 * \since 13.22.0
2274 * \since 15.5.0
2275 *
2276 * \param chan channel to act upon
2277 * \param msg ast_msg_data structure
2278 *
2279 * \details
2280 * Write text to a display on a channel. If the channel driver doesn't support the
2281 * send_text_data callback. then the original send_text callback will be used if
2282 * available.
2283 *
2284 * \note The channel does not need to be locked before calling this function.
2285 *
2286 * \retval 0 on success
2287 * \retval -1 on failure
2288 */
2289int ast_sendtext_data(struct ast_channel *chan, struct ast_msg_data *msg);
2290
2291/*!
2292 * \brief Receives a text character from a channel
2293 * \param chan channel to act upon
2294 * \param timeout timeout in milliseconds (0 for infinite wait)
2295 * \details
2296 * Read a char of text from a channel
2297 * \return 0 on success, -1 on failure
2298 */
2299int ast_recvchar(struct ast_channel *chan, int timeout);
2300
2301/*!
2302 * \brief End sending an MF digit to a channel.
2303 * \param chan channel to act upon
2304 * \return Returns 0 on success, -1 on failure
2305 */
2306int ast_senddigit_mf_end(struct ast_channel *chan);
2307
2308/*!
2309 * \brief Send an MF digit to a channel.
2310 *
2311 * \param chan channel to act upon
2312 * \param digit the MF digit to send, encoded in ASCII
2313 * \param duration the duration of a numeric digit ending in ms
2314 * \param durationkp the duration of a KP digit ending in ms
2315 * \param durationst the duration of a ST, STP, ST2P, or ST3P digit ending in ms
2316 * \param is_external 1 if called by a thread that is not the channel's media
2317 * handler thread, 0 if called by the channel's media handler
2318 * thread.
2319 *
2320 * \return 0 on success, -1 on failure
2321 */
2322int ast_senddigit_mf(struct ast_channel *chan, char digit, unsigned int duration,
2323 unsigned int durationkp, unsigned int durationst, int is_external);
2324
2325/*!
2326 * \brief Send a DTMF digit to a channel.
2327 *
2328 * \param chan channel to act upon
2329 * \param digit the DTMF digit to send, encoded in ASCII
2330 * \param duration the duration of the digit ending in ms
2331 *
2332 * \pre This must only be called by the channel's media handler thread.
2333 *
2334 * \return 0 on success, -1 on failure
2335 */
2336int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration);
2337
2338/*!
2339 * \brief Send a DTMF digit to a channel from an external thread.
2340 *
2341 * \param chan channel to act upon
2342 * \param digit the DTMF digit to send, encoded in ASCII
2343 * \param duration the duration of the digit ending in ms
2344 *
2345 * \pre This must only be called by threads that are not the channel's
2346 * media handler thread.
2347 *
2348 * \return 0 on success, -1 on failure
2349 */
2350int ast_senddigit_external(struct ast_channel *chan, char digit, unsigned int duration);
2351
2352/*!
2353 * \brief Send an MF digit to a channel.
2354 * \param chan channel to act upon
2355 * \param digit the MF digit to send, encoded in ASCII
2356 * \return 0 on success, -1 on failure
2357 */
2358int ast_senddigit_mf_begin(struct ast_channel *chan, char digit);
2359
2360/*!
2361 * \brief Send a DTMF digit to a channel.
2362 * \param chan channel to act upon
2363 * \param digit the DTMF digit to send, encoded in ASCII
2364 * \return 0 on success, -1 on failure
2365 */
2366int ast_senddigit_begin(struct ast_channel *chan, char digit);
2367
2368/*!
2369 * \brief Send a DTMF digit to a channel.
2370 * \param chan channel to act upon
2371 * \param digit the DTMF digit to send, encoded in ASCII
2372 * \param duration the duration of the digit ending in ms
2373 * \return Returns 0 on success, -1 on failure
2374 */
2375int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration);
2376
2377/*!
2378 * \brief Receives a text string from a channel
2379 * Read a string of text from a channel
2380 * \param chan channel to act upon
2381 * \param timeout timeout in milliseconds (0 for infinite wait)
2382 * \return the received text, or NULL to signify failure.
2383 */
2384char *ast_recvtext(struct ast_channel *chan, int timeout);
2385
2386/*!
2387 * \brief Waits for a digit
2388 * \param c channel to wait for a digit on
2389 * \param ms how many milliseconds to wait (<0 for indefinite).
2390 * \return Returns <0 on error, 0 on no entry, and the digit on success.
2391 */
2392int ast_waitfordigit(struct ast_channel *c, int ms);
2393
2394/*!
2395 * \brief Wait for a digit
2396 * Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to monitor for reading.
2397 * \param c channel to wait for a digit on
2398 * \param ms how many milliseconds to wait (<0 for indefinite).
2399 * \param breakon string of DTMF digits to break upon or NULL for any.
2400 * \param audiofd audio file descriptor to write to if audio frames are received
2401 * \param ctrlfd control file descriptor to monitor for reading
2402 * \return Returns 1 if ctrlfd becomes available
2403 */
2404int ast_waitfordigit_full(struct ast_channel *c, int ms, const char *breakon, int audiofd, int ctrlfd);
2405
2406/*!
2407 * \brief Reads multiple digits
2408 * \param c channel to read from
2409 * \param s string to read in to. Must be at least the size of your length
2410 * \param len how many digits to read (maximum)
2411 * \param timeout how long to timeout between digits
2412 * \param rtimeout timeout to wait on the first digit
2413 * \param enders digits to end the string
2414 * \details
2415 * Read in a digit string "s", max length "len", maximum timeout between
2416 * digits "timeout" (-1 for none), terminated by anything in "enders". Give them rtimeout
2417 * for the first digit.
2418 * \return Returns 0 on normal return, or 1 on a timeout. In the case of
2419 * a timeout, any digits that were read before the timeout will still be available in s.
2420 * RETURNS 2 in full version when ctrlfd is available, NOT 1
2421 */
2422int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders);
2423int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders, int audiofd, int ctrlfd);
2424
2425/*! \brief Report DTMF on channel 0 */
2426#define AST_BRIDGE_DTMF_CHANNEL_0 (1 << 0)
2427/*! \brief Report DTMF on channel 1 */
2428#define AST_BRIDGE_DTMF_CHANNEL_1 (1 << 1)
2429
2430
2431/*!
2432 * \brief Make the frame formats of two channels compatible.
2433 *
2434 * \param chan First channel to make compatible. Should be the calling party.
2435 * \param peer Other channel to make compatible. Should be the called party.
2436 *
2437 * \note Absolutely _NO_ channel locks should be held before calling this function.
2438 *
2439 * \details
2440 * Set two channels to compatible frame formats in both
2441 * directions. The path from peer to chan is made compatible
2442 * first to allow for in-band audio in case the other direction
2443 * cannot be made compatible.
2444 *
2445 * \retval 0 on success.
2446 * \retval -1 on error.
2447 */
2448int ast_channel_make_compatible(struct ast_channel *chan, struct ast_channel *peer);
2449
2450/*!
2451 * \brief Bridge two channels together (early)
2452 * \param c0 first channel to bridge
2453 * \param c1 second channel to bridge
2454 * \details
2455 * Bridge two channels (c0 and c1) together early. This implies either side may not be answered yet.
2456 * \return Returns 0 on success and -1 if it could not be done
2457 */
2458int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1);
2459
2460/*!
2461 * \brief Gives the string form of a given cause code.
2462 *
2463 * \param cause cause to get the description of
2464 * \return the text form of the binary cause code given
2465 */
2466const char *ast_cause2str(int cause) attribute_pure;
2467
2468/*!
2469 * \brief Convert the string form of a cause code to a number
2470 *
2471 * \param name string form of the cause
2472 * \return the cause code
2473 */
2474int ast_str2cause(const char *name) attribute_pure;
2475
2476/*!
2477 * \brief Gives the string form of a given channel state
2478 *
2479 * \param state state to get the name of
2480 * \return the text form of the binary state given
2481 *
2482 * \note This function is not reentrant.
2483 */
2484const char *ast_state2str(enum ast_channel_state state);
2485
2486/*!
2487 * \brief Gives the string form of a given transfer capability
2488 *
2489 * \param transfercapability transfer capability to get the name of
2490 * \return the text form of the binary transfer capability
2491 */
2492char *ast_transfercapability2str(int transfercapability) attribute_const;
2493
2494/*
2495 * Options: Some low-level drivers may implement "options" allowing fine tuning of the
2496 * low level channel. See frame.h for options. Note that many channel drivers may support
2497 * none or a subset of those features, and you should not count on this if you want your
2498 * asterisk application to be portable. They're mainly useful for tweaking performance
2499 */
2500
2501/*!
2502 * \brief Sets an option on a channel
2503 *
2504 * \param channel channel to set options on
2505 * \param option option to change
2506 * \param data data specific to option
2507 * \param datalen length of the data
2508 * \param block blocking or not
2509 * \details
2510 * Set an option on a channel (see frame.h), optionally blocking awaiting the reply
2511 * \return 0 on success and -1 on failure
2512 */
2513int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block);
2514
2515/*!
2516 * \brief Checks the value of an option
2517 *
2518 * Query the value of an option
2519 * Works similarly to setoption except only reads the options.
2520 */
2521int ast_channel_queryoption(struct ast_channel *channel, int option, void *data, int *datalen, int block);
2522
2523/*!
2524 * \brief Checks for HTML support on a channel
2525 * \return 0 if channel does not support HTML or non-zero if it does
2526 */
2527int ast_channel_supports_html(struct ast_channel *channel);
2528
2529/*!
2530 * \brief Sends HTML on given channel
2531 * Send HTML or URL on link.
2532 * \return 0 on success or -1 on failure
2533 */
2534int ast_channel_sendhtml(struct ast_channel *channel, int subclass, const char *data, int datalen);
2535
2536/*!
2537 * \brief Sends a URL on a given link
2538 * Send URL on link.
2539 * \return 0 on success or -1 on failure
2540 */
2541int ast_channel_sendurl(struct ast_channel *channel, const char *url);
2542
2543/*!
2544 * \brief Defers DTMF so that you only read things like hangups and audio.
2545 * \return non-zero if channel was already DTMF-deferred or
2546 * 0 if channel is just now being DTMF-deferred
2547 */
2548int ast_channel_defer_dtmf(struct ast_channel *chan);
2549
2550/*! Undo defer. ast_read will return any DTMF characters that were queued */
2551void ast_channel_undefer_dtmf(struct ast_channel *chan);
2552
2553/*! \return number of channels available for lookup */
2554int ast_active_channels(void);
2555
2556/*! \return the number of channels not yet destroyed */
2557int ast_undestroyed_channels(void);
2558
2559/*! Activate a given generator */
2560int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params);
2561
2562/*! Deactivate an active generator */
2563void ast_deactivate_generator(struct ast_channel *chan);
2564
2565/*!
2566 * \since 13.27.0
2567 * \since 16.4.0
2568 * \brief Obtain how long it's been, in milliseconds, since the channel was created
2569 *
2570 * \param chan The channel object
2571 *
2572 * \retval 0 if the time value cannot be computed (or you called this really fast)
2573 * \retval The number of milliseconds since channel creation
2574 */
2575int64_t ast_channel_get_duration_ms(struct ast_channel *chan);
2576
2577/*!
2578 * \since 12
2579 * \brief Obtain how long the channel since the channel was created
2580 *
2581 * \param chan The channel object
2582 *
2583 * \retval 0 if the time value cannot be computed (or you called this really fast)
2584 * \retval The number of seconds the channel has been up
2585 */
2586int ast_channel_get_duration(struct ast_channel *chan);
2587
2588/*!
2589 * \since 13.27.0
2590 * \since 16.4.0
2591 * \brief Obtain how long it has been since the channel was answered in ms
2592 *
2593 * \param chan The channel object
2594 *
2595 * \retval 0 if the channel isn't answered (or you called this really fast)
2596 * \retval The number of milliseconds the channel has been up
2597 */
2598int64_t ast_channel_get_up_time_ms(struct ast_channel *chan);
2599
2600/*!
2601 * \since 12
2602 * \brief Obtain how long it has been since the channel was answered
2603 *
2604 * \param chan The channel object
2605 *
2606 * \retval 0 if the channel isn't answered (or you called this really fast)
2607 * \retval The number of seconds the channel has been up
2608 */
2609int ast_channel_get_up_time(struct ast_channel *chan);
2610
2611/*!
2612 * \brief Set caller ID number, name and ANI and generate AMI event.
2613 *
2614 * \note Use ast_channel_set_caller() and ast_channel_set_caller_event() instead.
2615 * \note The channel does not need to be locked before calling this function.
2616 */
2617void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani);
2618
2619/*!
2620 * \brief Set the caller id information in the Asterisk channel
2621 * \since 1.8
2622 *
2623 * \param chan Asterisk channel to set caller id information
2624 * \param caller Caller id information
2625 * \param update What caller information to update. NULL if all.
2626 *
2627 * \note The channel does not need to be locked before calling this function.
2628 */
2629void ast_channel_set_caller(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update);
2630
2631/*!
2632 * \brief Set the caller id information in the Asterisk channel and generate an AMI event
2633 * if the caller id name or number changed.
2634 * \since 1.8
2635 *
2636 * \param chan Asterisk channel to set caller id information
2637 * \param caller Caller id information
2638 * \param update What caller information to update. NULL if all.
2639 *
2640 * \note The channel does not need to be locked before calling this function.
2641 */
2642void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update);
2643
2644/*! Set the file descriptor on the channel */
2645void ast_channel_set_fd(struct ast_channel *chan, int which, int fd);
2646
2647/*! Start a tone going */
2648int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);
2649/*! Stop a tone from playing */
2650void ast_tonepair_stop(struct ast_channel *chan);
2651/*! Play a tone pair for a given amount of time */
2652int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);
2653
2654/*!
2655 * \brief Automatically service a channel for us...
2656 *
2657 * \retval 0 success
2658 * \retval -1 failure, or the channel is already being autoserviced
2659 */
2660int ast_autoservice_start(struct ast_channel *chan);
2661
2662/*!
2663 * \brief Stop servicing a channel for us...
2664 *
2665 * \note if chan is locked prior to calling ast_autoservice_stop, it
2666 * is likely that there will be a deadlock between the thread that calls
2667 * ast_autoservice_stop and the autoservice thread. It is important
2668 * that chan is not locked prior to this call
2669 *
2670 * \param chan
2671 * \retval 0 success
2672 * \retval -1 error, or the channel has been hungup
2673 */
2674int ast_autoservice_stop(struct ast_channel *chan);
2675
2676/*!
2677 * \brief Put chan into autoservice while hanging up peer.
2678 * \since 11.0
2679 *
2680 * \param chan Chan to put into autoservice.
2681 * \param peer Chan to run hangup handlers and hangup.
2682 */
2683void ast_autoservice_chan_hangup_peer(struct ast_channel *chan, struct ast_channel *peer);
2684
2685/*!
2686 * \brief Ignore certain frame types
2687 * \note Normally, we cache DTMF, IMAGE, HTML, TEXT, and CONTROL frames
2688 * while a channel is in autoservice and queue them up when taken out of
2689 * autoservice. When this is not desireable, this API may be used to
2690 * cause the channel to ignore those frametypes after the channel is put
2691 * into autoservice, but before autoservice is stopped.
2692 * \retval 0 success
2693 * \retval -1 channel is not in autoservice
2694 */
2695int ast_autoservice_ignore(struct ast_channel *chan, enum ast_frame_type ftype);
2696
2697/*!
2698 * \brief Enable or disable timer ticks for a channel
2699 *
2700 * \param c channel
2701 * \param rate number of timer ticks per second
2702 * \param func callback function
2703 * \param data
2704 *
2705 * \details
2706 * If timers are supported, force a scheduled expiration on the
2707 * timer fd, at which point we call the callback function / data
2708 *
2709 * \note Call this function with a rate of 0 to turn off the timer ticks
2710 *
2711 * \version 1.6.1 changed samples parameter to rate, accommodates new timing methods
2712 */
2713int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const void *data), void *data);
2714int ast_settimeout_full(struct ast_channel *c, unsigned int rate, int (*func)(const void *data), void *data, unsigned int is_ao2_obj);
2715
2716/*!
2717 * \brief Transfer a channel (if supported).
2718 * \retval -1 on error
2719 * \retval 0 if not supported
2720 * \retval 1 if supported and requested
2721 * \param chan current channel
2722 * \param dest destination extension for transfer
2723 */
2724int ast_transfer(struct ast_channel *chan, char *dest);
2725
2726/*!
2727 * \brief Transfer a channel (if supported) receieve protocol result.
2728 * \retval -1 on error
2729 * \retval 0 if not supported
2730 * \retval 1 if supported and requested
2731 * \param chan channel to transfer
2732 * \param dest destination extension to transfer to
2733 * \param protocol protocol is the protocol result
2734 * SIP example, 0=success, 3xx-6xx is SIP error code
2735 */
2736int ast_transfer_protocol(struct ast_channel *chan, char *dest, int *protocol);
2737
2738/*!
2739 * \brief Inherits channel variable from parent to child channel
2740 * \param parent Parent channel
2741 * \param child Child channel
2742 *
2743 * \details
2744 * Scans all channel variables in the parent channel, looking for those
2745 * that should be copied into the child channel.
2746 * Variables whose names begin with a single '_' are copied into the
2747 * child channel with the prefix removed.
2748 * Variables whose names begin with '__' are copied into the child
2749 * channel with their names unchanged.
2750 */
2751void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child);
2752
2753/*!
2754 * \brief adds a list of channel variables to a channel
2755 * \param chan the channel
2756 * \param vars a linked list of variables
2757 *
2758 * \pre chan is locked
2759 *
2760 * \details
2761 * Variable names can be for a regular channel variable or a dialplan function
2762 * that has the ability to be written to.
2763 */
2764void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars);
2765
2766/*!
2767 * \brief An opaque 'object' structure use by silence generators on channels.
2768 */
2770
2771/*!
2772 * \brief Starts a silence generator on the given channel.
2773 * \param chan The channel to generate silence on
2774 * \return An ast_silence_generator pointer, or NULL if an error occurs
2775 *
2776 * \details
2777 * This function will cause SLINEAR silence to be generated on the supplied
2778 * channel until it is disabled; if the channel cannot be put into SLINEAR
2779 * mode then the function will fail.
2780 *
2781 * \note
2782 * The pointer returned by this function must be preserved and passed to
2783 * ast_channel_stop_silence_generator when you wish to stop the silence
2784 * generation.
2785 */
2787
2788/*!
2789 * \brief Stops a previously-started silence generator on the given channel.
2790 * \param chan The channel to operate on
2791 * \param state The ast_silence_generator pointer return by a previous call to
2792 * ast_channel_start_silence_generator.
2793 *
2794 * \details
2795 * This function will stop the operating silence generator and return the channel
2796 * to its previous write format.
2797 */
2799
2800/*!
2801 * \brief Determine which channel has an older linkedid
2802 * \param a First channel
2803 * \param b Second channel
2804 * \return Returns an ast_channel structure that has oldest linkedid
2805 */
2807
2808/*!
2809 * \brief Copy the full linkedid channel id structure from one channel to another
2810 * \param dest Destination to copy linkedid to
2811 * \param source Source channel to copy linkedid from
2812 */
2813void ast_channel_internal_copy_linkedid(struct ast_channel *dest, struct ast_channel *source);
2814
2815/*!
2816 * \brief Swap uniqueid and linkedid beteween two channels
2817 * \param a First channel
2818 * \param b Second channel
2819 *
2820 * \note
2821 * This is used in masquerade to exchange identities
2822 */
2824
2825/*!
2826 * \brief Swap topics beteween two channels
2827 * \param a First channel
2828 * \param b Second channel
2829 *
2830 * \note
2831 * This is used in masquerade to exchange topics for message routing
2832 */
2834
2835/*!
2836 * \brief Swap endpoint_forward between two channels
2837 * \param a First channel
2838 * \param b Second channel
2839 *
2840 * \note
2841 * This is used in masquerade to exchange endpoint details if one of the two or both
2842 * the channels were created with endpoint
2843 */
2845
2846/*!
2847 * \brief Swap snapshots beteween two channels
2848 * \param a First channel
2849 * \param b Second channel
2850 *
2851 * \note
2852 * This is used in masquerade to exchange snapshots
2853 */
2855
2856/*!
2857 * \brief Swap endpoints between two channels
2858 * \param a First channel
2859 * \param b Second channel
2860 *
2861 * \note
2862 * This is used in masquerade to exchange endpoints
2863 */
2865
2866/*!
2867 * \brief Set uniqueid and linkedid string value only (not time)
2868 * \param chan The channel to set the uniqueid to
2869 * \param uniqueid The uniqueid to set
2870 * \param linkedid The linkedid to set
2871 *
2872 * \note
2873 * This is used only by ast_cel_fabricate_channel_from_event()
2874 * to create a temporary fake channel - time values are invalid
2875 */
2876void ast_channel_internal_set_fake_ids(struct ast_channel *chan, const char *uniqueid, const char *linkedid);
2877
2878/* Misc. functions below */
2879
2880/*!
2881 * \brief if fd is a valid descriptor, set *pfd with the descriptor
2882 * \return Return 1 (not -1!) if added, 0 otherwise (so we can add the
2883 * return value to the index into the array)
2884 */
2885static inline int ast_add_fd(struct pollfd *pfd, int fd)
2886{
2887 pfd->fd = fd;
2888 pfd->events = POLLIN | POLLPRI;
2889 return fd >= 0;
2890}
2891
2892/*! \brief Helper function for migrating select to poll */
2893static inline int ast_fdisset(struct pollfd *pfds, int fd, int maximum, int *start)
2894{
2895 int x;
2896 int dummy = 0;
2897
2898 if (fd < 0)
2899 return 0;
2900 if (!start)
2901 start = &dummy;
2902 for (x = *start; x < maximum; x++)
2903 if (pfds[x].fd == fd) {
2904 if (x == *start)
2905 (*start)++;
2906 return pfds[x].revents;
2907 }
2908 return 0;
2909}
2910
2911/*!
2912 * \brief Retrieves the current T38 state of a channel
2913 *
2914 * \note Absolutely _NO_ channel locks should be held before calling this function.
2915 */
2916static inline enum ast_t38_state ast_channel_get_t38_state(struct ast_channel *chan)
2917{
2919 int datalen = sizeof(state);
2920
2922
2923 return state;
2924}
2925
2926/*!
2927 * \brief Set the blocking indication on the channel.
2928 *
2929 * \details
2930 * Indicate that the thread handling the channel is about to do a blocking
2931 * operation to wait for media on the channel. (poll, read, or write)
2932 *
2933 * Masquerading and ast_queue_frame() use this indication to wake up the thread.
2934 *
2935 * \pre The channel needs to be locked
2936 */
2937#define CHECK_BLOCKING(c) \
2938 do { \
2939 if (ast_test_flag(ast_channel_flags(c), AST_FLAG_BLOCKING)) { \
2940 /* This should not happen as there should only be one thread handling a channel's media at a time. */ \
2941 ast_log(LOG_DEBUG, "Thread LWP %d is blocking '%s', already blocked by thread LWP %d in procedure %s\n", \
2942 ast_get_tid(), ast_channel_name(c), \
2943 ast_channel_blocker_tid(c), ast_channel_blockproc(c)); \
2944 ast_assert(0); \
2945 } \
2946 ast_channel_blocker_tid_set((c), ast_get_tid()); \
2947 ast_channel_blocker_set((c), pthread_self()); \
2948 ast_channel_blockproc_set((c), __PRETTY_FUNCTION__); \
2949 ast_set_flag(ast_channel_flags(c), AST_FLAG_BLOCKING); \
2950 } while (0)
2951
2952ast_group_t ast_get_group(const char *s);
2953
2954/*! \brief Print call and pickup groups into buffer */
2955char *ast_print_group(char *buf, int buflen, ast_group_t group);
2956
2957/*! \brief Opaque struct holding a namedgroups set, i.e. a set of group names */
2958struct ast_namedgroups;
2959
2960/*! \brief Create an ast_namedgroups set with group names from comma separated string */
2961struct ast_namedgroups *ast_get_namedgroups(const char *s);
2962struct ast_namedgroups *ast_unref_namedgroups(struct ast_namedgroups *groups);
2963struct ast_namedgroups *ast_ref_namedgroups(struct ast_namedgroups *groups);
2964/*! \brief Return TRUE if group a and b contain at least one common groupname */
2965int ast_namedgroups_intersect(struct ast_namedgroups *a, struct ast_namedgroups *b);
2966
2967/*! \brief Print named call groups and named pickup groups */
2968char *ast_print_namedgroups(struct ast_str **buf, struct ast_namedgroups *groups);
2969
2970/*! \brief return an ast_variable list of channeltypes */
2972
2973/*!
2974 * \brief return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument
2975 * \param reason The integer argument, usually taken from AST_CONTROL_ macros
2976 * \return char pointer explaining the code
2977 */
2978const char *ast_channel_reason2str(int reason);
2979
2980/*! \brief channel group info */
2981struct ast_group_info {
2982 struct ast_channel *chan;
2983 char *category;
2984 char *group;
2986};
2987
2988#define ast_channel_lock(chan) ao2_lock(chan)
2989#define ast_channel_unlock(chan) ao2_unlock(chan)
2990#define ast_channel_trylock(chan) ao2_trylock(chan)
2991
2992/*!
2993 * \brief Lock two channels.
2994 */
2995#define ast_channel_lock_both(chan1, chan2) do { \
2996 ast_channel_lock(chan1); \
2997 while (ast_channel_trylock(chan2)) { \
2998 ast_channel_unlock(chan1); \
2999 sched_yield(); \
3000 ast_channel_lock(chan1); \
3001 } \
3002 } while (0)
3003
3004/*!
3005 * \brief Increase channel reference count
3006 *
3007 * \param c the channel
3008 *
3009 * \retval c always
3010 *
3011 * \since 1.8
3012 */
3013#define ast_channel_ref(c) ({ ao2_ref(c, +1); (c); })
3014
3015/*!
3016 * \brief Decrease channel reference count
3017 *
3018 * \param c the channel
3019 *
3020 * \retval NULL always
3021 *
3022 * \since 1.8
3023 */
3024#define ast_channel_unref(c) ({ ao2_ref(c, -1); (struct ast_channel *) (NULL); })
3025
3026/*!
3027 * \brief Cleanup a channel reference
3028 *
3029 * \param c the channel (NULL tolerant)
3030 *
3031 * \retval NULL always
3032 *
3033 * \since 12.0.0
3034 */
3035#define ast_channel_cleanup(c) ({ ao2_cleanup(c); (struct ast_channel *) (NULL); })
3036
3037/*! Channel Iterating @{ */
3038
3039/*!
3040 * \brief A channel iterator
3041 *
3042 * This is an opaque type.
3043 */
3045
3046/*!
3047 * \brief Destroy a channel iterator
3048 *
3049 * \param i the itereator to destroy
3050 *
3051 * \details
3052 * This function is used to destroy a channel iterator that was retrieved by
3053 * using one of the channel_iterator_xxx_new() functions.
3054 *
3055 * \retval NULL for convenience to clear out the pointer to the iterator that
3056 * was just destroyed.
3057 *
3058 * \since 1.8
3059 */
3061
3062/*!
3063 * \brief Create a new channel iterator based on extension
3064 *
3065 * \param exten The extension that channels must be in
3066 * \param context The context that channels must be in
3067 *
3068 * \details
3069 * After creating an iterator using this function, the ast_channel_iterator_next()
3070 * function can be used to iterate through all channels that are currently
3071 * in the specified context and extension.
3072 *
3073 * \note You must call ast_channel_iterator_destroy() when done.
3074 *
3075 * \retval NULL on failure
3076 * \retval a new channel iterator based on the specified parameters
3077 *
3078 * \since 1.8
3079 */
3080struct ast_channel_iterator *ast_channel_iterator_by_exten_new(const char *exten, const char *context);
3081
3082/*!
3083 * \brief Create a new channel iterator based on name
3084 *
3085 * \param name channel name or channel uniqueid to match
3086 * \param name_len number of characters in the channel name to match on. This
3087 * would be used to match based on name prefix. If matching on the full
3088 * channel name is desired, then this parameter should be 0.
3089 *
3090 * \details
3091 * After creating an iterator using this function, the ast_channel_iterator_next()
3092 * function can be used to iterate through all channels that exist that have
3093 * the specified name or name prefix.
3094 *
3095 * \note You must call ast_channel_iterator_destroy() when done.
3096 *
3097 * \retval NULL on failure
3098 * \retval a new channel iterator based on the specified parameters
3099 *
3100 * \since 1.8
3101 */
3102struct ast_channel_iterator *ast_channel_iterator_by_name_new(const char *name, size_t name_len);
3103
3104/*!
3105 * \brief Create a new channel iterator
3106 *
3107 * \details
3108 * After creating an iterator using this function, the ast_channel_iterator_next()
3109 * function can be used to iterate through all channels that exist.
3110 *
3111 * \note You must call ast_channel_iterator_destroy() when done.
3112 *
3113 * \retval NULL on failure
3114 * \retval a new channel iterator
3115 *
3116 * \since 1.8
3117 */
3119
3120/*!
3121 * \brief Get the next channel for a channel iterator
3122 *
3123 * \param i the channel iterator that was created using one of the
3124 * channel_iterator_xxx_new() functions.
3125 *
3126 * \details
3127 * This function should be used to iterate through all channels that match a
3128 * specified set of parameters that were provided when the iterator was created.
3129 *
3130 * \retval the next channel that matches the parameters used when the iterator
3131 * was created.
3132 * \retval NULL if no more channels match the iterator parameters.
3133 *
3134 * \since 1.8
3135 */
3137
3138/*! @} End channel iterator definitions. */
3139
3140/*! @{ Channel search functions */
3141
3142/*!
3143* \warning Absolutely _NO_ channel locks should be held while calling any of
3144* these functions.
3145*/
3146
3147/*!
3148 * \brief Call a function with every active channel
3149 *
3150 * \details
3151 * This function executes a callback one time for each active channel on the
3152 * system. The channel is provided as an argument to the function.
3153 *
3154 * \since 1.8
3155 */
3156struct ast_channel *ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg,
3157 void *data, int ao2_flags);
3158
3159/*!
3160 * \brief Find a channel by name or uniqueid
3161 *
3162 * \param search the name or uniqueid of the channel to search for
3163 *
3164 * \details
3165 * First searches for a channel with a matching name. If not found
3166 * a search for a channel with a matching uniqueid is done.
3167 *
3168 * \retval a channel with a matching name or uniqueid
3169 * \retval NULL if no channel was found
3170 *
3171 *\note The fallback search by uniqueid is a historical thing. If you
3172 * know the search term is a uniqueid, use \ref ast_channel_get_by_uniqueid
3173 * instead.
3174 *
3175 * \since 1.8
3176 */
3177struct ast_channel *ast_channel_get_by_name(const char *search);
3178
3179/*!
3180 * \brief Find a channel by a name prefix
3181 *
3182 * \param search The channel name or uniqueid prefix to search for
3183 * \param len Only search for up to this many characters from the search term
3184 *
3185 * \details
3186 * Search for a channel that has the same name prefix as specified by the
3187 * search term. If not found, search for an exact match on the uniqueid.
3188 * Searching by partial uniqueid doesn't make any sense as it's usually
3189 * a system-name plus a timestamp and is not supported.
3190 *
3191 * \retval a channel with a matching name or uniqueid
3192 * \retval NULL if no channel was found
3193 *
3194 *\note The fallback search by uniqueid is a historical thing. If you
3195 * know the search term is a uniqueid, use \ref ast_channel_get_by_uniqueid
3196 * instead.
3197 *
3198 * \since 1.8
3199 */
3200struct ast_channel *ast_channel_get_by_name_prefix(const char *name, size_t name_len);
3201
3202/*!
3203 * \brief Find a channel by extension and context
3204 *
3205 * \param exten the extension to search for
3206 * \param context the context to search for
3207 *
3208 * \details
3209 * Return a channel that is currently at the specified extension and context.
3210 *
3211 * \retval a channel that is at the specified extension and context
3212 * \retval NULL if no channel was found
3213 *
3214 * \since 1.8
3215 */
3216struct ast_channel *ast_channel_get_by_exten(const char *exten, const char *context);
3217
3218/*!
3219 * \brief Find a channel by a uniqueid
3220 *
3221 * \param uniqueid The uniqueid to search for
3222 *
3223 * \retval a channel with the uniqueid specified by the arguments
3224 * \retval NULL if no channel was found
3225 */
3227
3228/*! @} End channel search functions. */
3229
3230/*!
3231 * \brief Initialize the given name structure.
3232 * \since 1.8
3233 *
3234 * \param init Name structure to initialize.
3235 */
3236void ast_party_name_init(struct ast_party_name *init);
3237
3238/*!
3239 * \brief Copy the source party name information to the destination party name.
3240 * \since 1.8
3241 *
3242 * \param dest Destination party name
3243 * \param src Source party name
3244 */
3245void ast_party_name_copy(struct ast_party_name *dest, const struct ast_party_name *src);
3246
3247/*!
3248 * \brief Initialize the given party name structure using the given guide
3249 * for a set update operation.
3250 * \since 1.8
3251 *
3252 * \details
3253 * The initialization is needed to allow a set operation to know if a
3254 * value needs to be updated. Simple integers need the guide's original
3255 * value in case the set operation is not trying to set a new value.
3256 * String values are simply set to NULL pointers if they are not going
3257 * to be updated.
3258 *
3259 * \param init Party name structure to initialize.
3260 * \param guide Source party name to use as a guide in initializing.
3261 */
3262void ast_party_name_set_init(struct ast_party_name *init, const struct ast_party_name *guide);
3263
3264/*!
3265 * \brief Set the source party name information into the destination party name.
3266 * \since 1.8
3267 *
3268 * \param dest The name one wishes to update
3269 * \param src The new name values to update the dest
3270 */
3271void ast_party_name_set(struct ast_party_name *dest, const struct ast_party_name *src);
3272
3273/*!
3274 * \brief Destroy the party name contents
3275 * \since 1.8
3276 *
3277 * \param doomed The party name to destroy.
3278 */
3279void ast_party_name_free(struct ast_party_name *doomed);
3280
3281/*!
3282 * \brief Initialize the given number structure.
3283 * \since 1.8
3284 *
3285 * \param init Number structure to initialize.
3286 */
3287void ast_party_number_init(struct ast_party_number *init);
3288
3289/*!
3290 * \brief Copy the source party number information to the destination party number.
3291 * \since 1.8
3292 *
3293 * \param dest Destination party number
3294 * \param src Source party number
3295 */
3296void ast_party_number_copy(struct ast_party_number *dest, const struct ast_party_number *src);
3297
3298/*!
3299 * \brief Initialize the given party number structure using the given guide
3300 * for a set update operation.
3301 * \since 1.8
3302 *
3303 * \details
3304 * The initialization is needed to allow a set operation to know if a
3305 * value needs to be updated. Simple integers need the guide's original
3306 * value in case the set operation is not trying to set a new value.
3307 * String values are simply set to NULL pointers if they are not going
3308 * to be updated.
3309 *
3310 * \param init Party number structure to initialize.
3311 * \param guide Source party number to use as a guide in initializing.
3312 */
3313void ast_party_number_set_init(struct ast_party_number *init, const struct ast_party_number *guide);
3314
3315/*!
3316 * \brief Set the source party number information into the destination party number.
3317 * \since 1.8
3318 *
3319 * \param dest The number one wishes to update
3320 * \param src The new number values to update the dest
3321 */
3322void ast_party_number_set(struct ast_party_number *dest, const struct ast_party_number *src);
3323
3324/*!
3325 * \brief Destroy the party number contents
3326 * \since 1.8
3327 *
3328 * \param doomed The party number to destroy.
3329 */
3330void ast_party_number_free(struct ast_party_number *doomed);
3331
3332/*!
3333 * \since 1.8
3334 * \brief Initialize the given subaddress structure.
3335 *
3336 * \param init Subaddress structure to initialize.
3337 */
3339
3340/*!
3341 * \since 1.8
3342 * \brief Copy the source party subaddress information to the destination party subaddress.
3343 *
3344 * \param dest Destination party subaddress
3345 * \param src Source party subaddress
3346 */
3347void ast_party_subaddress_copy(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src);
3348
3349/*!
3350 * \since 1.8
3351 * \brief Initialize the given party subaddress structure using the given guide
3352 * for a set update operation.
3353 *
3354 * \details
3355 * The initialization is needed to allow a set operation to know if a
3356 * value needs to be updated. Simple integers need the guide's original
3357 * value in case the set operation is not trying to set a new value.
3358 * String values are simply set to NULL pointers if they are not going
3359 * to be updated.
3360 *
3361 * \param init Party subaddress structure to initialize.
3362 * \param guide Source party subaddress to use as a guide in initializing.
3363 */
3364void ast_party_subaddress_set_init(struct ast_party_subaddress *init, const struct ast_party_subaddress *guide);
3365
3366/*!
3367 * \since 1.8
3368 * \brief Set the source party subaddress information into the destination party subaddress.
3369 *
3370 * \param dest The subaddress one wishes to update
3371 * \param src The new subaddress values to update the dest
3372 */
3373void ast_party_subaddress_set(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src);
3374
3375/*!
3376 * \since 1.8
3377 * \brief Destroy the party subaddress contents
3378 *
3379 * \param doomed The party subaddress to destroy.
3380 */
3382
3383/*!
3384 * \brief Set the update marker to update all information of a corresponding party id.
3385 * \since 11.0
3386 *
3387 * \param update_id The update marker for a corresponding party id.
3388 */
3389void ast_set_party_id_all(struct ast_set_party_id *update_id);
3390
3391/*!
3392 * \brief Initialize the given party id structure.
3393 * \since 1.8
3394 *
3395 * \param init Party id structure to initialize.
3396 */
3397void ast_party_id_init(struct ast_party_id *init);
3398
3399/*!
3400 * \brief Copy the source party id information to the destination party id.
3401 * \since 1.8
3402 *
3403 * \param dest Destination party id
3404 * \param src Source party id
3405 */
3406void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src);
3407
3408/*!
3409 * \brief Initialize the given party id structure using the given guide
3410 * for a set update operation.
3411 * \since 1.8
3412 *
3413 * \details
3414 * The initialization is needed to allow a set operation to know if a
3415 * value needs to be updated. Simple integers need the guide's original
3416 * value in case the set operation is not trying to set a new value.
3417 * String values are simply set to NULL pointers if they are not going
3418 * to be updated.
3419 *
3420 * \param init Party id structure to initialize.
3421 * \param guide Source party id to use as a guide in initializing.
3422 */
3423void ast_party_id_set_init(struct ast_party_id *init, const struct ast_party_id *guide);
3424
3425/*!
3426 * \brief Set the source party id information into the destination party id.
3427 * \since 1.8
3428 *
3429 * \param dest The id one wishes to update
3430 * \param src The new id values to update the dest
3431 * \param update What id information to update. NULL if all.
3432 */
3433void ast_party_id_set(struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update);
3434
3435/*!
3436 * \brief Destroy the party id contents
3437 * \since 1.8
3438 *
3439 * \param doomed The party id to destroy.
3440 */
3441void ast_party_id_free(struct ast_party_id *doomed);
3442
3443/*!
3444 * \brief Determine the overall presentation value for the given party.
3445 * \since 1.8
3446 *
3447 * \param id Party to determine the overall presentation value.
3448 *
3449 * \return Overall presentation value for the given party.
3450 */
3451int ast_party_id_presentation(const struct ast_party_id *id);
3452
3453/*!
3454 * \brief Invalidate all components of the given party id.
3455 * \since 11.0
3456 *
3457 * \param id The party id to invalidate.
3458 */
3459void ast_party_id_invalidate(struct ast_party_id *id);
3460
3461/*!
3462 * \brief Destroy and initialize the given party id structure.
3463 * \since 11.0
3464 *
3465 * \param id The party id to reset.
3466 */
3467void ast_party_id_reset(struct ast_party_id *id);
3468
3469/*!
3470 * \brief Merge a given party id into another given party id.
3471 * \since 11.0
3472 *
3473 * \details
3474 * This function will generate an effective party id.
3475 *
3476 * Each party id component of the party id 'base' is overwritten
3477 * by components of the party id 'overlay' if the overlay
3478 * component is marked as valid. However the component 'tag' of
3479 * the base party id remains untouched.
3480 *
3481 * \param base The party id which is merged.
3482 * \param overlay The party id which is used to merge into.
3483 *
3484 * \return The merged party id as a struct, not as a pointer.
3485 * \note The merged party id returned is a shallow copy and must not be freed.
3486 */
3487struct ast_party_id ast_party_id_merge(struct ast_party_id *base, struct ast_party_id *overlay);
3488
3489/*!
3490 * \brief Copy a merge of a given party id into another given party id to a given destination party id.
3491 * \since 11.0
3492 *
3493 * \details
3494 * Each party id component of the party id 'base' is overwritten by components
3495 * of the party id 'overlay' if the 'overlay' component is marked as valid.
3496 * However the component 'tag' of the 'base' party id remains untouched.
3497 * The result is copied into the given party id 'dest'.
3498 *
3499 * \note The resulting merged party id is a real copy and has to be freed.
3500 *
3501 * \param dest The resulting merged party id.
3502 * \param base The party id which is merged.
3503 * \param overlay The party id which is used to merge into.
3504 */
3505void ast_party_id_merge_copy(struct ast_party_id *dest, struct ast_party_id *base, struct ast_party_id *overlay);
3506
3507/*!
3508 * \brief Initialize the given dialed structure.
3509 * \since 1.8
3510 *
3511 * \param init Dialed structure to initialize.
3512 */
3513void ast_party_dialed_init(struct ast_party_dialed *init);
3514
3515/*!
3516 * \brief Copy the source dialed party information to the destination dialed party.
3517 * \since 1.8
3518 *
3519 * \param dest Destination dialed party
3520 * \param src Source dialed party
3521 */
3522void ast_party_dialed_copy(struct ast_party_dialed *dest, const struct ast_party_dialed *src);
3523
3524/*!
3525 * \brief Initialize the given dialed structure using the given
3526 * guide for a set update operation.
3527 * \since 1.8
3528 *
3529 * \details
3530 * The initialization is needed to allow a set operation to know if a
3531 * value needs to be updated. Simple integers need the guide's original
3532 * value in case the set operation is not trying to set a new value.
3533 * String values are simply set to NULL pointers if they are not going
3534 * to be updated.
3535 *
3536 * \param init Caller structure to initialize.
3537 * \param guide Source dialed to use as a guide in initializing.
3538 */
3539void ast_party_dialed_set_init(struct ast_party_dialed *init, const struct ast_party_dialed *guide);
3540
3541/*!
3542 * \brief Set the dialed information based on another dialed source
3543 * \since 1.8
3544 *
3545 * This is similar to ast_party_dialed_copy, except that NULL values for
3546 * strings in the src parameter indicate not to update the corresponding dest values.
3547 *
3548 * \param dest The dialed one wishes to update
3549 * \param src The new dialed values to update the dest
3550 */
3551void ast_party_dialed_set(struct ast_party_dialed *dest, const struct ast_party_dialed *src);
3552
3553/*!
3554 * \brief Destroy the dialed party contents
3555 * \since 1.8
3556 *
3557 * \param doomed The dialed party to destroy.
3558 */
3559void ast_party_dialed_free(struct ast_party_dialed *doomed);
3560
3561/*!
3562 * \since 1.8
3563 * \brief Initialize the given caller structure.
3564 *
3565 * \param init Caller structure to initialize.
3566 */
3567void ast_party_caller_init(struct ast_party_caller *init);
3568
3569/*!
3570 * \since 1.8
3571 * \brief Copy the source caller information to the destination caller.
3572 *
3573 * \param dest Destination caller
3574 * \param src Source caller
3575 */
3576void ast_party_caller_copy(struct ast_party_caller *dest, const struct ast_party_caller *src);
3577
3578/*!
3579 * \brief Initialize the given caller structure using the given
3580 * guide for a set update operation.
3581 * \since 1.8
3582 *
3583 * \details
3584 * The initialization is needed to allow a set operation to know if a
3585 * value needs to be updated. Simple integers need the guide's original
3586 * value in case the set operation is not trying to set a new value.
3587 * String values are simply set to NULL pointers if they are not going
3588 * to be updated.
3589 *
3590 * \param init Caller structure to initialize.
3591 * \param guide Source caller to use as a guide in initializing.
3592 */
3593void ast_party_caller_set_init(struct ast_party_caller *init, const struct ast_party_caller *guide);
3594
3595/*!
3596 * \brief Set the caller information based on another caller source
3597 * \since 1.8
3598 *
3599 * This is similar to ast_party_caller_copy, except that NULL values for
3600 * strings in the src parameter indicate not to update the corresponding dest values.
3601 *
3602 * \param dest The caller one wishes to update
3603 * \param src The new caller values to update the dest
3604 * \param update What caller information to update. NULL if all.
3605 */
3606void ast_party_caller_set(struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update);
3607
3608/*!
3609 * \brief Destroy the caller party contents
3610 * \since 1.8
3611 *
3612 * \param doomed The caller party to destroy.
3613 */
3614void ast_party_caller_free(struct ast_party_caller *doomed);
3615
3616/*!
3617 * \since 1.8
3618 * \brief Initialize the given connected line structure.
3619 *
3620 * \param init Connected line structure to initialize.
3621 */
3623
3624/*!
3625 * \since 1.8
3626 * \brief Copy the source connected line information to the destination connected line.
3627 *
3628 * \param dest Destination connected line
3629 * \param src Source connected line
3630 */
3632
3633/*!
3634 * \since 1.8
3635 * \brief Initialize the given connected line structure using the given
3636 * guide for a set update operation.
3637 *
3638 * \details
3639 * The initialization is needed to allow a set operation to know if a
3640 * value needs to be updated. Simple integers need the guide's original
3641 * value in case the set operation is not trying to set a new value.
3642 * String values are simply set to NULL pointers if they are not going
3643 * to be updated.
3644 *
3645 * \param init Connected line structure to initialize.
3646 * \param guide Source connected line to use as a guide in initializing.
3647 */
3649
3650/*!
3651 * \since 1.8
3652 * \brief Set the connected line information based on another connected line source
3653 *
3654 * This is similar to ast_party_connected_line_copy, except that NULL values for
3655 * strings in the src parameter indicate not to update the corresponding dest values.
3656 *
3657 * \param dest The connected line one wishes to update
3658 * \param src The new connected line values to update the dest
3659 * \param update What connected line information to update. NULL if all.
3660 */
3662
3663/*!
3664 * \since 1.8
3665 * \brief Collect the caller party information into a connected line structure.
3666 *
3667 * \param connected Collected caller information for the connected line
3668 * \param caller Caller information.
3669 *
3670 * \warning This is a shallow copy.
3671 * \warning DO NOT call ast_party_connected_line_free() on the filled in
3672 * connected line structure!
3673 */
3675
3676/*!
3677 * \since 1.8
3678 * \brief Destroy the connected line information contents
3679 *
3680 * \param doomed The connected line information to destroy.
3681 */
3683
3684/*!
3685 * \brief Initialize the given redirecting reason structure
3686 *
3687 * \param init Redirecting reason structure to initialize
3688 */
3690
3691/*!
3692 * \brief Copy the source redirecting reason information to the destination redirecting reason.
3693 *
3694 * \param dest Destination redirecting reason
3695 * \param src Source redirecting reason
3696 */
3698 const struct ast_party_redirecting_reason *src);
3699
3700/*!
3701 * \brief Initialize the given redirecting reason structure using the given guide
3702 * for a set update operation.
3703 *
3704 * \details
3705 * The initialization is needed to allow a set operation to know if a
3706 * value needs to be updated. Simple integers need the guide's original
3707 * value in case the set operation is not trying to set a new value.
3708 * String values are simply set to NULL pointers if they are not going
3709 * to be updated.
3710 *
3711 * \param init Redirecting reason structure to initialize.
3712 * \param guide Source redirecting reason to use as a guide in initializing.
3713 */
3715 const struct ast_party_redirecting_reason *guide);
3716
3717/*!
3718 * \brief Set the redirecting reason information based on another redirecting reason source
3719 *
3720 * This is similar to ast_party_redirecting_reason_copy, except that NULL values for
3721 * strings in the src parameter indicate not to update the corresponding dest values.
3722 *
3723 * \param dest The redirecting reason one wishes to update
3724 * \param src The new redirecting reason values to update the dest
3725 */
3727 const struct ast_party_redirecting_reason *src);
3728
3729/*!
3730 * \brief Destroy the redirecting reason contents
3731 *
3732 * \param doomed The redirecting reason to destroy.
3733 */
3735
3736/*!
3737 * \brief Initialize the given redirecting structure.
3738 * \since 1.8
3739 *
3740 * \param init Redirecting structure to initialize.
3741 */
3743
3744/*!
3745 * \since 1.8
3746 * \brief Copy the source redirecting information to the destination redirecting.
3747 *
3748 * \param dest Destination redirecting
3749 * \param src Source redirecting
3750 */
3751void ast_party_redirecting_copy(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src);
3752
3753/*!
3754 * \since 1.8
3755 * \brief Initialize the given redirecting id structure using the given guide
3756 * for a set update operation.
3757 *
3758 * \details
3759 * The initialization is needed to allow a set operation to know if a
3760 * value needs to be updated. Simple integers need the guide's original
3761 * value in case the set operation is not trying to set a new value.
3762 * String values are simply set to NULL pointers if they are not going
3763 * to be updated.
3764 *
3765 * \param init Redirecting id structure to initialize.
3766 * \param guide Source redirecting id to use as a guide in initializing.
3767 */
3768void ast_party_redirecting_set_init(struct ast_party_redirecting *init, const struct ast_party_redirecting *guide);
3769
3770/*!
3771 * \brief Set the redirecting information based on another redirecting source
3772 * \since 1.8
3773 *
3774 * This is similar to ast_party_redirecting_copy, except that NULL values for
3775 * strings in the src parameter indicate not to update the corresponding dest values.
3776 *
3777 * \param dest The redirecting one wishes to update
3778 * \param src The new redirecting values to update the dest
3779 * \param update What redirecting information to update. NULL if all.
3780 */
3782
3783/*!
3784 * \since 1.8
3785 * \brief Destroy the redirecting information contents
3786 *
3787 * \param doomed The redirecting information to destroy.
3788 */
3790
3791/*!
3792 * \since 1.8
3793 * \brief Copy the caller information to the connected line information.
3794 *
3795 * \param dest Destination connected line information
3796 * \param src Source caller information
3797 *
3798 * \note Assumes locks are already acquired
3799 */
3801
3802/*!
3803 * \since 1.8
3804 * \brief Copy the connected line information to the caller information.
3805 *
3806 * \param dest Destination caller information
3807 * \param src Source connected line information
3808 *
3809 * \note Assumes locks are already acquired
3810 */
3812
3813/*!
3814 * \since 1.8
3815 * \brief Set the connected line information in the Asterisk channel
3816 *
3817 * \param chan Asterisk channel to set connected line information
3818 * \param connected Connected line information
3819 * \param update What connected line information to update. NULL if all.
3820 *
3821 * \note The channel does not need to be locked before calling this function.
3822 */
3824
3825/*!
3826 * \since 1.8
3827 * \brief Build the connected line information data frame.
3828 *
3829 * \param data Buffer to fill with the frame data
3830 * \param datalen Size of the buffer to fill
3831 * \param connected Connected line information
3832 * \param update What connected line information to build. NULL if all.
3833 *
3834 * \retval -1 if error
3835 * \retval Amount of data buffer used
3836 */
3837int 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);
3838
3839/*!
3840 * \since 1.8
3841 * \brief Parse connected line indication frame data
3842 *
3843 * \param data Buffer with the frame data to parse
3844 * \param datalen Size of the buffer
3845 * \param connected Extracted connected line information
3846 *
3847 * \retval 0 on success.
3848 * \retval -1 on error.
3849 *
3850 * \note The filled in connected line structure needs to be initialized by
3851 * ast_party_connected_line_set_init() before calling. If defaults are not
3852 * required use ast_party_connected_line_init().
3853 * \note The filled in connected line structure needs to be destroyed by
3854 * ast_party_connected_line_free() when it is no longer needed.
3855 */
3856int ast_connected_line_parse_data(const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected);
3857
3858/*!
3859 * \since 1.8
3860 * \brief Indicate that the connected line information has changed
3861 *
3862 * \param chan Asterisk channel to indicate connected line information
3863 * \param connected Connected line information
3864 * \param update What connected line information to update. NULL if all.
3865 */
3867
3868/*!
3869 * \since 1.8
3870 * \brief Queue a connected line update frame on a channel
3871 *
3872 * \param chan Asterisk channel to indicate connected line information
3873 * \param connected Connected line information
3874 * \param update What connected line information to update. NULL if all.
3875 */
3877
3878/*!
3879 * \since 1.8
3880 * \brief Set the redirecting id information in the Asterisk channel
3881 *
3882 * \param chan Asterisk channel to set redirecting id information
3883 * \param redirecting Redirecting id information
3884 * \param update What redirecting information to update. NULL if all.
3885 *
3886 * \note The channel does not need to be locked before calling this function.
3887 */
3888void ast_channel_set_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3889
3890/*!
3891 * \since 1.8
3892 * \brief Build the redirecting id data frame.
3893 *
3894 * \param data Buffer to fill with the frame data
3895 * \param datalen Size of the buffer to fill
3896 * \param redirecting Redirecting id information
3897 * \param update What redirecting information to build. NULL if all.
3898 *
3899 * \retval -1 if error
3900 * \retval Amount of data buffer used
3901 */
3902int ast_redirecting_build_data(unsigned char *data, size_t datalen, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3903
3904/*!
3905 * \since 1.8
3906 * \brief Parse redirecting indication frame data
3907 *
3908 * \param data Buffer with the frame data to parse
3909 * \param datalen Size of the buffer
3910 * \param redirecting Extracted redirecting id information
3911 *
3912 * \retval 0 on success.
3913 * \retval -1 on error.
3914 *
3915 * \note The filled in id structure needs to be initialized by
3916 * ast_party_redirecting_set_init() before calling.
3917 * \note The filled in id structure needs to be destroyed by
3918 * ast_party_redirecting_free() when it is no longer needed.
3919 */
3920int ast_redirecting_parse_data(const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting);
3921
3922/*!
3923 * \since 1.8
3924 * \brief Indicate that the redirecting id has changed
3925 *
3926 * \param chan Asterisk channel to indicate redirecting id information
3927 * \param redirecting Redirecting id information
3928 * \param update What redirecting information to update. NULL if all.
3929 */
3930void ast_channel_update_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3931
3932/*!
3933 * \since 1.8
3934 * \brief Queue a redirecting update frame on a channel
3935 *
3936 * \param chan Asterisk channel to indicate redirecting id information
3937 * \param redirecting Redirecting id information
3938 * \param update What redirecting information to update. NULL if all.
3939 */
3940void ast_channel_queue_redirecting_update(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3941
3942/*!
3943 * \since 11
3944 * \brief Run a connected line interception subroutine and update a channel's connected line
3945 * information
3946 *
3947 * Whenever we want to update a channel's connected line information, we may need to run
3948 * a subroutine so that an administrator can manipulate the information before sending it
3949 * out. This function both runs the subroutine specified by CONNECTED_LINE_SEND_SUB and
3950 * sends the update to the channel.
3951 *
3952 * \param autoservice_chan Channel to place into autoservice while the sub is running.
3953 * It is perfectly safe for this to be NULL
3954 * \param sub_chan The channel to run the subroutine on. Also the channel from which we
3955 * determine which subroutine we need to run.
3956 * \param connected_info Either an ast_party_connected_line or ast_frame pointer of type
3957 * AST_CONTROL_CONNECTED_LINE
3958 * \param frame If true, then connected_info is an ast_frame pointer, otherwise it is an
3959 * ast_party_connected_line pointer.
3960 * \retval 0 Success
3961 * \retval -1 Either the subroutine does not exist, or there was an error while attempting to
3962 * run the subroutine
3963 */
3964int ast_channel_connected_line_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *connected_info, int frame);
3965
3966/*!
3967 * \since 11
3968 * \brief Run a redirecting interception subroutine and update a channel's redirecting information
3969 *
3970 * \details
3971 * Whenever we want to update a channel's redirecting information, we may need to run
3972 * a subroutine so that an administrator can manipulate the information before sending it
3973 * out. This function both runs the subroutine specified by REDIRECTING_SEND_SUB and
3974 * sends the update to the channel.
3975 *
3976 * \param autoservice_chan Channel to place into autoservice while the subroutine is running.
3977 * It is perfectly safe for this to be NULL
3978 * \param sub_chan The channel to run the subroutine on. Also the channel from which we
3979 * determine which subroutine we need to run.
3980 * \param redirecting_info Either an ast_party_redirecting or ast_frame pointer of type
3981 * AST_CONTROL_REDIRECTING
3982 * \param is_frame If true, then redirecting_info is an ast_frame pointer, otherwise it is an
3983 * ast_party_redirecting pointer.
3984 *
3985 * \retval 0 Success
3986 * \retval -1 Either the subroutine does not exist, or there was an error while attempting to
3987 * run the subroutine
3988 */
3989int ast_channel_redirecting_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *redirecting_info, int is_frame);
3990
3991#include "asterisk/ccss.h"
3992
3993/*!
3994 * \since 1.8
3995 * \brief Set up datastore with CCSS parameters for a channel
3996 *
3997 * \note
3998 * If base_params is NULL, the channel will get the default
3999 * values for all CCSS parameters.
4000 *
4001 * \details
4002 * This function makes use of datastore operations on the channel, so
4003 * it is important to lock the channel before calling this function.
4004 *
4005 * \warning You should call this function only if \ref ast_cc_is_enabled()
4006 * returns true.
4007 *
4008 * \param chan The channel to create the datastore on
4009 * \param base_params CCSS parameters we wish to copy into the channel
4010 * \retval 0 Success
4011 * \retval -1 Failure or CCSS is globally disabled.
4012 */
4014 const struct ast_cc_config_params *base_params);
4015
4016/*!
4017 * \since 1.8
4018 * \brief Get the CCSS parameters from a channel
4019 *
4020 * \details
4021 * This function makes use of datastore operations on the channel, so
4022 * it is important to lock the channel before calling this function.
4023 *
4024 * \warning You should call this function only if \ref ast_cc_is_enabled()
4025 * returns true.
4026 *
4027 * \param chan Channel to retrieve parameters from
4028 * \retval NULL Failure or CCSS is globally disabled.
4029 * \retval non-NULL The parameters desired
4030 */
4032
4033
4034/*!
4035 * \since 1.8
4036 * \brief Get a device name given its channel structure
4037 *
4038 * \details
4039 * A common practice in Asterisk is to determine the device being talked
4040 * to by dissecting the channel name. For certain channel types, this is not
4041 * accurate. For instance, an ISDN channel is named based on what B channel is
4042 * used, not the device being communicated with.
4043 *
4044 * This function interfaces with a channel tech's queryoption callback to
4045 * retrieve the name of the device being communicated with. If the channel does not
4046 * implement this specific option, then the traditional method of using the channel
4047 * name is used instead.
4048 *
4049 * \param chan The channel to retrieve the information from
4050 * \param[out] device_name The buffer to place the device's name into
4051 * \param name_buffer_length The allocated space for the device_name
4052 * \return 0 always
4053 */
4054int ast_channel_get_device_name(struct ast_channel *chan, char *device_name, size_t name_buffer_length);
4055
4056/*!
4057 * \since 1.8
4058 * \brief Find the appropriate CC agent type to use given a channel
4059 *
4060 * \details
4061 * During call completion, we will need to create a call completion agent structure. To
4062 * figure out the type of agent to construct, we need to ask the channel driver for the
4063 * appropriate type.
4064 *
4065 * Prior to adding this function, the call completion core attempted to figure this
4066 * out for itself by stripping the technology off the channel's name. However, in the
4067 * case of chan_dahdi, there are multiple agent types registered, and so simply searching
4068 * for an agent type called "DAHDI" is not possible. In a case where multiple agent types
4069 * are defined, the channel driver must have a queryoption callback defined in its
4070 * channel_tech, and the queryoption callback must handle AST_OPTION_CC_AGENT_TYPE
4071 *
4072 * If a channel driver does not have a queryoption callback or if the queryoption callback
4073 * does not handle AST_OPTION_CC_AGENT_TYPE, then the old behavior of using the technology
4074 * portion of the channel name is used instead. This is perfectly suitable for channel drivers
4075 * whose channel technologies are a one-to-one match with the agent types defined within.
4076 *
4077 * Note that this function is only called when the agent policy on a given channel is set
4078 * to "native." Generic agents' type can be determined automatically by the core.
4079 *
4080 * \param chan The channel for which we wish to retrieve the agent type
4081 * \param[out] agent_type The type of agent the channel driver wants us to use
4082 * \param size The size of the buffer to write to
4083 */
4084int ast_channel_get_cc_agent_type(struct ast_channel *chan, char *agent_type, size_t size);
4085#if defined(__cplusplus) || defined(c_plusplus)
4086}
4087#endif
4088
4089/*!
4090 * \brief Remove a channel from the global channels container
4091 *
4092 * \param chan channel to remove
4093 *
4094 * In a case where it is desired that a channel not be available in any lookups
4095 * in the global channels conatiner, use this function.
4096 */
4097void ast_channel_unlink(struct ast_channel *chan);
4098
4099/*!
4100 * \brief Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash
4101 * on the given channel
4102 *
4103 * \param chan channel on which to set the cause information
4104 * \param cause_code ast_control_pvt_cause_code structure containing cause information
4105 * \param datalen total length of the structure since it may vary
4106 */
4107void ast_channel_hangupcause_hash_set(struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen);
4108
4109/*!
4110 * \since 12
4111 * \brief Convert a string to a detail record AMA flag
4112 *
4113 * \param flag string form of flag
4114 *
4115 * \retval the enum (integer) form of the flag
4116 */
4117enum ama_flags ast_channel_string2amaflag(const char *flag);
4118
4119/*!
4120 * \since 12
4121 * \brief Convert the enum representation of an AMA flag to a string representation
4122 *
4123 * \param flags integer flag
4124 *
4125 * \retval A string representation of the flag
4126 */
4127const char *ast_channel_amaflags2string(enum ama_flags flags);
4128
4132};
4133
4134/* ACCESSOR FUNCTIONS */
4135
4136#define DECLARE_STRINGFIELD_SETTERS_FOR(field) \
4137 void ast_channel_##field##_set(struct ast_channel *chan, const char *field); \
4138 void ast_channel_##field##_build_va(struct ast_channel *chan, const char *fmt, va_list ap) __attribute__((format(printf, 2, 0))); \
4139 void ast_channel_##field##_build(struct ast_channel *chan, const char *fmt, ...) __attribute__((format(printf, 2, 3)))
4140
4141/*!
4142 * The following string fields result in channel snapshot creation and
4143 * should have the channel locked when called:
4144 *
4145 * \li language
4146 * \li accountcode
4147 * \li peeraccount
4148 * \li linkedid
4149 */
4153DECLARE_STRINGFIELD_SETTERS_FOR(latest_musicclass);
4163
4164const char *ast_channel_name(const struct ast_channel *chan);
4165const char *ast_channel_language(const struct ast_channel *chan);
4166const char *ast_channel_musicclass(const struct ast_channel *chan);
4167const char *ast_channel_latest_musicclass(const struct ast_channel *chan);
4168const char *ast_channel_accountcode(const struct ast_channel *chan);
4169const char *ast_channel_peeraccount(const struct ast_channel *chan);
4170const char *ast_channel_userfield(const struct ast_channel *chan);
4171const char *ast_channel_call_forward(const struct ast_channel *chan);
4172const char *ast_channel_uniqueid(const struct ast_channel *chan);
4173const char *ast_channel_linkedid(const struct ast_channel *chan);
4174const char *ast_channel_tenantid(const struct ast_channel *chan);
4175void ast_channel_tenantid_set(struct ast_channel *chan, const char *value);
4176const char *ast_channel_parkinglot(const struct ast_channel *chan);
4177const char *ast_channel_hangupsource(const struct ast_channel *chan);
4178const char *ast_channel_dialcontext(const struct ast_channel *chan);
4179
4180const char *ast_channel_appl(const struct ast_channel *chan);
4181void ast_channel_appl_set(struct ast_channel *chan, const char *value);
4182const char *ast_channel_blockproc(const struct ast_channel *chan);
4183void ast_channel_blockproc_set(struct ast_channel *chan, const char *value);
4184const char *ast_channel_data(const struct ast_channel *chan);
4185void ast_channel_data_set(struct ast_channel *chan, const char *value);
4186
4187const char *ast_channel_lastcontext(const struct ast_channel *chan);
4188const char *ast_channel_context(const struct ast_channel *chan);
4189void ast_channel_context_set(struct ast_channel *chan, const char *value);
4190const char *ast_channel_lastexten(const struct ast_channel *chan);
4191const char *ast_channel_exten(const struct ast_channel *chan);
4192void ast_channel_exten_set(struct ast_channel *chan, const char *value);
4193
4194char ast_channel_dtmf_digit_to_emulate(const struct ast_channel *chan);
4196char ast_channel_sending_dtmf_digit(const struct ast_channel *chan);
4198struct timeval ast_channel_sending_dtmf_tv(const struct ast_channel *chan);
4199void ast_channel_sending_dtmf_tv_set(struct ast_channel *chan, struct timeval value);
4200enum ama_flags ast_channel_amaflags(const struct ast_channel *chan);
4201
4202/*!
4203 * \pre chan is locked
4204 */
4205void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value);
4206int ast_channel_epfd(const struct ast_channel *chan);
4207void ast_channel_epfd_set(struct ast_channel *chan, int value);
4208int ast_channel_fdno(const struct ast_channel *chan);
4209void ast_channel_fdno_set(struct ast_channel *chan, int value);
4210int ast_channel_hangupcause(const struct ast_channel *chan);
4211void ast_channel_hangupcause_set(struct ast_channel *chan, int value);
4212int ast_channel_tech_hangupcause(const struct ast_channel *chan);
4213void ast_channel_tech_hangupcause_set(struct ast_channel *chan, int value);
4214int ast_channel_priority(const struct ast_channel *chan);
4215void ast_channel_priority_set(struct ast_channel *chan, int value);
4216int ast_channel_rings(const struct ast_channel *chan);
4217void ast_channel_rings_set(struct ast_channel *chan, int value);
4218int ast_channel_streamid(const struct ast_channel *chan);
4219void ast_channel_streamid_set(struct ast_channel *chan, int value);
4220int ast_channel_timingfd(const struct ast_channel *chan);
4221void ast_channel_timingfd_set(struct ast_channel *chan, int value);
4222int ast_channel_visible_indication(const struct ast_channel *chan);
4224int ast_channel_hold_state(const struct ast_channel *chan);
4225void ast_channel_hold_state_set(struct ast_channel *chan, int value);
4226int ast_channel_vstreamid(const struct ast_channel *chan);
4227void ast_channel_vstreamid_set(struct ast_channel *chan, int value);
4228unsigned short ast_channel_transfercapability(const struct ast_channel *chan);
4229void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value);
4230unsigned int ast_channel_emulate_dtmf_duration(const struct ast_channel *chan);
4231void ast_channel_emulate_dtmf_duration_set(struct ast_channel *chan, unsigned int value);
4232unsigned int ast_channel_fin(const struct ast_channel *chan);
4233void ast_channel_fin_set(struct ast_channel *chan, unsigned int value);
4234unsigned int ast_channel_fout(const struct ast_channel *chan);
4235void ast_channel_fout_set(struct ast_channel *chan, unsigned int value);
4236unsigned long ast_channel_insmpl(const struct ast_channel *chan);
4237void ast_channel_insmpl_set(struct ast_channel *chan, unsigned long value);
4238unsigned long ast_channel_outsmpl(const struct ast_channel *chan);
4239void ast_channel_outsmpl_set(struct ast_channel *chan, unsigned long value);
4240void *ast_channel_generatordata(const struct ast_channel *chan);
4241void ast_channel_generatordata_set(struct ast_channel *chan, void *value);
4242void *ast_channel_music_state(const struct ast_channel *chan);
4243void ast_channel_music_state_set(struct ast_channel *chan, void *value);
4244void *ast_channel_tech_pvt(const struct ast_channel *chan);
4245void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value);
4246void *ast_channel_timingdata(const struct ast_channel *chan);
4247void ast_channel_timingdata_set(struct ast_channel *chan, void *value);
4248struct ast_audiohook_list *ast_channel_audiohooks(const struct ast_channel *chan);
4250struct ast_cdr *ast_channel_cdr(const struct ast_channel *chan);
4251void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr *value);
4252struct ast_channel *ast_channel__bridge(const struct ast_channel *chan);
4253void ast_channel__bridge_set(struct ast_channel *chan, struct ast_channel *value);
4254struct ast_channel *ast_channel_masq(const struct ast_channel *chan);
4255void ast_channel_masq_set(struct ast_channel *chan, struct ast_channel *value);
4256struct ast_channel *ast_channel_masqr(const struct ast_channel *chan);
4257void ast_channel_masqr_set(struct ast_channel *chan, struct ast_channel *value);
4258struct ast_filestream *ast_channel_stream(const struct ast_channel *chan);
4259void ast_channel_stream_set(struct ast_channel *chan, struct ast_filestream *value);
4260struct ast_filestream *ast_channel_vstream(const struct ast_channel *chan);
4261void ast_channel_vstream_set(struct ast_channel *chan, struct ast_filestream *value);
4262struct ast_format_cap *ast_channel_nativeformats(const struct ast_channel *chan);
4264struct ast_framehook_list *ast_channel_framehooks(const struct ast_channel *chan);
4266struct ast_generator *ast_channel_generator(const struct ast_channel *chan);
4267void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator *value);
4268struct ast_pbx *ast_channel_pbx(const struct ast_channel *chan);
4269void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx *value);
4270struct ast_sched_context *ast_channel_sched(const struct ast_channel *chan);
4271void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context *value);
4272struct ast_timer *ast_channel_timer(const struct ast_channel *chan);
4273void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer *value);
4274struct ast_tone_zone *ast_channel_zone(const struct ast_channel *chan);
4275void ast_channel_zone_set(struct ast_channel *chan, struct ast_tone_zone *value);
4276struct ast_trans_pvt *ast_channel_readtrans(const struct ast_channel *chan);
4277void ast_channel_readtrans_set(struct ast_channel *chan, struct ast_trans_pvt *value);
4278struct ast_trans_pvt *ast_channel_writetrans(const struct ast_channel *chan);
4279void ast_channel_writetrans_set(struct ast_channel *chan, struct ast_trans_pvt *value);
4280const struct ast_channel_tech *ast_channel_tech(const struct ast_channel *chan);
4281void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value);
4282enum ast_channel_adsicpe ast_channel_adsicpe(const struct ast_channel *chan);
4284enum ast_channel_state ast_channel_state(const struct ast_channel *chan);
4285ast_callid ast_channel_callid(const struct ast_channel *chan);
4286struct ast_channel_snapshot *ast_channel_snapshot(const struct ast_channel *chan);
4287void ast_channel_snapshot_set(struct ast_channel *chan, struct ast_channel_snapshot *snapshot);
4289struct ast_endpoint *ast_channel_endpoint(const struct ast_channel *chan);
4290void ast_channel_endpoint_set(struct ast_channel *chan, struct ast_endpoint *endpoint);
4291
4292/*!
4293 * \pre chan is locked
4294 */
4296
4297/* XXX Internal use only, make sure to move later */
4298void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state);
4302void ast_channel_callid_cleanup(struct ast_channel *chan);
4304
4305/* Format getters */
4309struct ast_format *ast_channel_readformat(struct ast_channel *chan);
4310struct ast_format *ast_channel_writeformat(struct ast_channel *chan);
4311
4312/* Format setters - all of these functions will increment the reference count of the format passed in */
4313void ast_channel_set_oldwriteformat(struct ast_channel *chan, struct ast_format *format);
4314void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format);
4315void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format);
4316void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format);
4317void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format);
4318
4319/* Other struct getters */
4320struct ast_frame *ast_channel_dtmff(struct ast_channel *chan);
4321struct ast_jb *ast_channel_jb(struct ast_channel *chan);
4322struct ast_party_caller *ast_channel_caller(struct ast_channel *chan);
4326struct ast_party_dialed *ast_channel_dialed(struct ast_channel *chan);
4331struct timeval *ast_channel_dtmf_tv(struct ast_channel *chan);
4332struct timeval *ast_channel_whentohangup(struct ast_channel *chan);
4333struct varshead *ast_channel_varshead(struct ast_channel *chan);
4334
4335void ast_channel_dtmff_set(struct ast_channel *chan, struct ast_frame *value);
4336void ast_channel_jb_set(struct ast_channel *chan, struct ast_jb *value);
4337void ast_channel_caller_set(struct ast_channel *chan, struct ast_party_caller *value);
4339void ast_channel_dialed_set(struct ast_channel *chan, struct ast_party_dialed *value);
4341void ast_channel_dtmf_tv_set(struct ast_channel *chan, struct timeval *value);
4342
4343/*!
4344 * \pre chan is locked
4345 */
4346void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value);
4347void ast_channel_varshead_set(struct ast_channel *chan, struct varshead *value);
4348struct timeval ast_channel_creationtime(struct ast_channel *chan);
4349void ast_channel_creationtime_set(struct ast_channel *chan, struct timeval *value);
4350struct timeval ast_channel_answertime(struct ast_channel *chan);
4351void ast_channel_answertime_set(struct ast_channel *chan, struct timeval *value);
4352
4353/* List getters */
4357struct ast_readq_list *ast_channel_readq(struct ast_channel *chan);
4358
4359/* Typedef accessors */
4361/*!
4362 * \pre chan is locked
4363 */
4366/*!
4367 * \pre chan is locked
4368 */
4370struct ast_namedgroups *ast_channel_named_callgroups(const struct ast_channel *chan);
4371void ast_channel_named_callgroups_set(struct ast_channel *chan, struct ast_namedgroups *value);
4372struct ast_namedgroups *ast_channel_named_pickupgroups(const struct ast_channel *chan);
4373void ast_channel_named_pickupgroups_set(struct ast_channel *chan, struct ast_namedgroups *value);
4374
4375/* Alertpipe accessors--the "internal" functions for channel.c use only */
4376int ast_channel_alert_write(struct ast_channel *chan);
4377int ast_channel_alert_writable(struct ast_channel *chan);
4385/*! \brief Swap the interal alertpipe between two channels
4386 * \note Handle all of the necessary locking before calling this
4387 */
4388void ast_channel_internal_alertpipe_swap(struct ast_channel *chan1, struct ast_channel *chan2);
4389
4390/* file descriptor array accessors */
4391void ast_channel_internal_fd_clear(struct ast_channel *chan, int which);
4393void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value);
4394int ast_channel_fd(const struct ast_channel *chan, int which);
4395int ast_channel_fd_isset(const struct ast_channel *chan, int which);
4396
4397/*!
4398 * \since 15
4399 * \brief Retrieve the number of file decriptor positions present on the channel
4400 *
4401 * \param chan The channel to get the count of
4402 *
4403 * \pre chan is locked
4404 *
4405 * \return The number of file descriptor positions
4406 */
4407int ast_channel_fd_count(const struct ast_channel *chan);
4408
4409/*!
4410 * \since 15
4411 * \brief Add a file descriptor to the channel without a fixed position
4412 *
4413 * \param chan The channel to add the file descriptor to
4414 * \param value The file descriptor
4415 *
4416 * \pre chan is locked
4417 *
4418 * \return The position of the file descriptor
4419 */
4420int ast_channel_fd_add(struct ast_channel *chan, int value);
4421
4422pthread_t ast_channel_blocker(const struct ast_channel *chan);
4423void ast_channel_blocker_set(struct ast_channel *chan, pthread_t value);
4424
4425int ast_channel_blocker_tid(const struct ast_channel *chan);
4426void ast_channel_blocker_tid_set(struct ast_channel *chan, int tid);
4427
4430
4431struct ast_bridge *ast_channel_internal_bridge(const struct ast_channel *chan);
4432/*!
4433 * \pre chan is locked
4434 */
4436
4439
4442
4443/*!
4444 * \since 11
4445 * \brief Retrieve a comma-separated list of channels for which dialed cause information is available
4446 *
4447 * \details
4448 * This function makes use of datastore operations on the channel, so
4449 * it is important to lock the channel before calling this function.
4450 *
4451 * \param chan The channel from which to retrieve information
4452 * \retval NULL on allocation failure
4453 * \retval Pointer to an ast_str object containing the desired information which must be freed
4454 */
4455struct ast_str *ast_channel_dialed_causes_channels(const struct ast_channel *chan);
4456
4457/*!
4458 * \since 20.19.0
4459 * \since 22.9.0
4460 * \since 23.3.0
4461 * \brief Retrieve an iterator for dialed cause information
4462 *
4463 * \details
4464 * Each call to ao2_iterator_next() will return a pointer to an ast_control_pvt_cause_code
4465 * structure containing the dialed cause information for one channel. One of the entries
4466 * may be for the channel itself if the channel was hung up because of a non-2XX SIP
4467 * response code. The rest of the entries will be for channels bridged to the channel for
4468 * which dialed cause information is being retrieved. The caller is responsible for
4469 * cleaning up the reference count of each entry returned and destroying the returned
4470 * iterator with ao2_iterator_destroy() when it is finished with it.
4471 *
4472 * \param chan The channel from which to retrieve cause information
4473 * \retval ao2_iterator
4474 */
4476
4477/*!
4478 * \since 11
4479 * \brief Retrieve a ref-counted cause code information structure
4480 *
4481 * \details
4482 * This function makes use of datastore operations on the channel, so
4483 * it is important to lock the channel before calling this function.
4484 * This function increases the ref count of the returned object, so the
4485 * calling function must decrease the reference count when it is finished
4486 * with the object.
4487 *
4488 * \param chan The channel from which to retrieve information
4489 * \param chan_name The name of the channel about which to retrieve information
4490 * \retval NULL on search failure
4491 * \retval Pointer to a ref-counted ast_control_pvt_cause_code object containing the desired information
4492 */
4494
4495/*!
4496 * \since 11
4497 * \brief Add cause code information to the channel
4498 *
4499 * \details
4500 * This function makes use of datastore operations on the channel, so
4501 * it is important to lock the channel before calling this function.
4502 * The passed in data is copied and so is still owned by the caller.
4503 *
4504 * \param chan The channel on which to add information
4505 * \param cause_code The cause information to be added to the channel
4506 * \param datalen The total length of the structure since its length is variable
4507 * \retval 0 on success
4508 * \retval -1 on error
4509 */
4510int ast_channel_dialed_causes_add(const struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen);
4511
4512/*!
4513 * \since 11
4514 * \brief Clear all cause information from the channel
4515 *
4516 * \details
4517 * This function makes use of datastore operations on the channel, so
4518 * it is important to lock the channel before calling this function.
4519 *
4520 * \param chan The channel from which to clear information
4521 */
4522void ast_channel_dialed_causes_clear(const struct ast_channel *chan);
4523
4524struct ast_flags *ast_channel_flags(struct ast_channel *chan);
4525
4526/*!
4527 * \since 13.17.0
4528 * \brief Set a flag on a channel
4529 *
4530 * \param chan The channel to set the flag on
4531 * \param flag The flag to set
4532 *
4533 * \note This will lock the channel internally. If the channel is already
4534 * locked it is still safe to call.
4535 */
4536
4537void ast_channel_set_flag(struct ast_channel *chan, unsigned int flag);
4538
4539/*!
4540 * \since 13.17.0
4541 * \brief Clear a flag on a channel
4542 *
4543 * \param chan The channel to clear the flag from
4544 * \param flag The flag to clear
4545 *
4546 * \note This will lock the channel internally. If the channel is already
4547 * locked it is still safe to call.
4548 */
4549void ast_channel_clear_flag(struct ast_channel *chan, unsigned int flag);
4550
4551/*!
4552 * \since 12.4.0
4553 * \brief Return whether or not any manager variables have been set
4554 *
4555 * \retval 0 if no manager variables are expected
4556 * \retval 1 if manager variables are expected
4557 */
4559
4560/*!
4561 * \since 12
4562 * \brief Sets the variables to be stored in the \a manager_vars field of all
4563 * snapshots.
4564 * \param varc Number of variable names.
4565 * \param vars Array of variable names.
4566 */
4567void ast_channel_set_manager_vars(size_t varc, char **vars);
4568
4569/*!
4570 * \since 12
4571 * \brief Gets the variables for a given channel, as specified by ast_channel_set_manager_vars().
4572 *
4573 * The returned variable list is an AO2 object, so ao2_cleanup() to free it.
4574 *
4575 * \param chan Channel to get variables for.
4576 * \return List of channel variables.
4577 * \retval NULL on error
4578 */
4580
4581/*!
4582 * \since 14.2.0
4583 * \brief Return whether or not any ARI variables have been set
4584 *
4585 * \retval 0 if no ARI variables are expected
4586 * \retval 1 if ARI variables are expected
4587 */
4588int ast_channel_has_ari_vars(void);
4589
4590/*!
4591 * \since 14.2.0
4592 * \brief Sets the variables to be stored in the \a ari_vars field of all
4593 * snapshots.
4594 * \param varc Number of variable names.
4595 * \param vars Array of variable names.
4596 */
4597void ast_channel_set_ari_vars(size_t varc, char **vars);
4598
4599/*!
4600 * \since 14.2.0
4601 * \brief Gets the variables for a given channel, as specified by ast_channel_set_ari_vars().
4602 *
4603 * The returned variable list is an AO2 object, so ao2_cleanup() to free it.
4604 *
4605 * \param chan Channel to get variables for.
4606 * \return List of channel variables.
4607 * \retval NULL on error
4608 */
4609struct varshead *ast_channel_get_ari_vars(struct ast_channel *chan);
4610
4611/*!
4612 * \since 12
4613 * \brief Gets the variables for a given channel, as set using pbx_builtin_setvar_helper().
4614 *
4615 * The returned variable list is an AO2 object, so ao2_cleanup() to free it.
4616 *
4617 * \param chan Channel to get variables for
4618 * \return List of channel variables.
4619 * \retval NULL on error
4620 */
4621struct varshead *ast_channel_get_vars(struct ast_channel *chan);
4622
4623/*!
4624 * \since 12
4625 * \brief A topic which publishes the events for a particular channel.
4626 *
4627 * If the given \a chan is \c NULL, ast_channel_topic_all() is returned.
4628 *
4629 * \param chan Channel, or \c NULL.
4630 *
4631 * \retval Topic for channel's events.
4632 * \retval ast_channel_topic_all() if \a chan is \c NULL.
4633 */
4634struct stasis_topic *ast_channel_topic(struct ast_channel *chan);
4635
4636/*!
4637 * \brief Get the bridge associated with a channel
4638 * \since 12.0.0
4639 *
4640 * \param chan The channel whose bridge we want
4641 *
4642 * \details
4643 * The bridge returned has its reference count incremented. Use
4644 * ao2_cleanup() or ao2_ref() in order to decrement the
4645 * reference count when you are finished with the bridge.
4646 *
4647 * \note This function expects the channel to be locked prior to
4648 * being called and will not grab the channel lock.
4649 *
4650 * \retval NULL No bridge present on the channel
4651 * \retval non-NULL The bridge the channel is in
4652 */
4653struct ast_bridge *ast_channel_get_bridge(const struct ast_channel *chan);
4654
4655/*!
4656 * \brief Determine if a channel is in a bridge
4657 * \since 12.0.0
4658 *
4659 * \param chan The channel to test
4660 *
4661 * \note This function expects the channel to be locked prior to
4662 * being called and will not grab the channel lock.
4663 *
4664 * \retval 0 The channel is not bridged
4665 * \retval non-zero The channel is bridged
4666 */
4667int ast_channel_is_bridged(const struct ast_channel *chan);
4668
4669/*!
4670 * \brief Determine if a channel is leaving a bridge, but \em not hung up
4671 * \since 12.4.0
4672 *
4673 * \param chan The channel to test
4674 *
4675 * \note If a channel is hung up, it is implicitly leaving any bridge it
4676 * may be in. This function is used to test if a channel is leaving a bridge
4677 * but may survive the experience, if it has a place to go to (dialplan or
4678 * otherwise)
4679 *
4680 * \retval 0 The channel is not leaving the bridge or is hung up
4681 * \retval non-zero The channel is leaving the bridge
4682 */
4684
4685/*!
4686 * \brief Get the channel's bridge peer only if the bridge is two-party.
4687 * \since 12.0.0
4688 *
4689 * \param chan Channel desiring the bridge peer channel.
4690 *
4691 * \note The returned peer channel is the current peer in the
4692 * bridge when called.
4693 *
4694 * \note Absolutely _NO_ channel locks should be held when calling this function.
4695 *
4696 * \retval NULL Channel not in a bridge or the bridge is not two-party.
4697 * \retval non-NULL Reffed peer channel at time of calling.
4698 */
4699struct ast_channel *ast_channel_bridge_peer(struct ast_channel *chan);
4700
4701/*!
4702 * \brief Get a reference to the channel's bridge pointer.
4703 * \since 12.0.0
4704 *
4705 * \param chan The channel whose bridge channel is desired
4706 *
4707 * \note This increases the reference count of the bridge_channel.
4708 * Use ao2_ref() or ao2_cleanup() to decrement the refcount when
4709 * you are finished with it.
4710 *
4711 * \note It is expected that the channel is locked prior to
4712 * placing this call.
4713 *
4714 * \retval NULL The channel has no bridge_channel
4715 * \retval non-NULL A reference to the bridge_channel
4716 */
4718
4719/*!
4720 * \since 12
4721 * \brief Gain control of a channel in the system
4722 *
4723 * The intention of this function is to take a channel that currently
4724 * is running in one thread and gain control of it in the current thread.
4725 * This can be used to redirect a channel to a different place in the dialplan,
4726 * for instance.
4727 *
4728 * \note This function is NOT intended to be used on bridged channels. If you
4729 * need to control a bridged channel, you can set a callback to be called
4730 * once the channel exits the bridge, and run your controlling logic in that
4731 * callback
4732 *
4733 * XXX Put name of callback-setting function in above paragraph once it is written
4734 *
4735 * \note When this function returns successfully, the yankee channel is in a state where
4736 * it cannot be used any further. Always use the returned channel instead.
4737 *
4738 * \note absolutely _NO_ channel locks should be held before calling this function.
4739 *
4740 * \note The dialplan location on the returned channel is where the channel
4741 * should be started in the dialplan if it is returned to it.
4742 *
4743 * \param yankee The channel to gain control of
4744 * \retval NULL Could not gain control of the channel
4745 * \retval non-NULL The channel
4746 */
4747struct ast_channel *ast_channel_yank(struct ast_channel *yankee);
4748
4749/*!
4750 * \since 12
4751 * \brief Move a channel from its current location to a new location
4752 *
4753 * The intention of this function is to have the destination channel
4754 * take on the identity of the source channel.
4755 *
4756 * \note This function is NOT intended to be used on bridged channels. If you
4757 * wish to move an unbridged channel into the place of a bridged channel, then
4758 * use ast_bridge_join() or ast_bridge_impart(). If you wish to move a bridged
4759 * channel into the place of another bridged channel, then use ast_bridge_move().
4760 *
4761 * \note When this function returns succesfully, the source channel is in a
4762 * state where its continued use is unreliable.
4763 *
4764 * \note absolutely _NO_ channel locks should be held before calling this function.
4765 *
4766 * \param dest The place to move the source channel
4767 * \param source The channel to move
4768 * \retval 0 Success
4769 * \retval non-zero Failure
4770 */
4771int ast_channel_move(struct ast_channel *dest, struct ast_channel *source);
4772
4773/*!
4774 * \since 12
4775 * \brief Forward channel stasis messages to the given endpoint
4776 *
4777 * \param chan The channel to forward from
4778 * \param endpoint The endpoint to forward to
4779 *
4780 * \retval 0 Success
4781 * \retval non-zero Failure
4782 */
4784
4785/*!
4786 * \brief Return the oldest linkedid between two channels.
4787 *
4788 * A channel linkedid is derived from the channel uniqueid which is formed like this:
4789 * [systemname-]ctime.seq
4790 *
4791 * The systemname, and the dash are optional, followed by the epoch time followed by an
4792 * integer sequence. Note that this is not a decimal number, since 1.2 is less than 1.11
4793 * in uniqueid land.
4794 *
4795 * To compare two uniqueids, we parse out the integer values of the time and the sequence
4796 * numbers and compare them, with time trumping sequence.
4797 *
4798 * \param a The linkedid value of the first channel to compare
4799 * \param b The linkedid value of the second channel to compare
4800 *
4801 * \retval NULL on failure
4802 * \retval The oldest linkedid value
4803 * \since 12.0.0
4804*/
4805const char *ast_channel_oldest_linkedid(const char *a, const char *b);
4806
4807/*!
4808 * \brief Check if the channel has active audiohooks, active framehooks, or a monitor.
4809 * \since 12.0.0
4810 *
4811 * \param chan The channel to check.
4812 *
4813 * \retval non-zero if channel has active audiohooks, framehooks, or monitor.
4814 */
4816
4817/*!
4818 * \brief Check if the channel has any active hooks that require audio.
4819 * \since 12.3.0
4820 *
4821 * \param chan The channel to check.
4822 *
4823 * \retval non-zero if channel has active audiohooks, audio framehooks, or monitor.
4824 */
4826
4827/*!
4828 * \brief Removes the trailing identifiers from a channel name string
4829 * \since 12.0.0
4830 *
4831 * \param channel_name string that you wish to turn into a dial string.
4832 * This string will be edited in place.
4833 */
4834void ast_channel_name_to_dial_string(char *channel_name);
4835
4836#define AST_MUTE_DIRECTION_READ (1 << 0)
4837#define AST_MUTE_DIRECTION_WRITE (1 << 1)
4838
4839/*!
4840 * \brief Suppress passing of a frame type on a channel
4841 *
4842 * \note The channel should be locked before calling this function.
4843 *
4844 * \param chan The channel to suppress
4845 * \param direction The direction in which to suppress
4846 * \param frametype The type of frame (AST_FRAME_VOICE, etc) to suppress
4847 *
4848 * \retval 0 Success
4849 * \retval -1 Failure
4850 */
4851int ast_channel_suppress(struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype);
4852
4853/*!
4854 * \brief Stop suppressing of a frame type on a channel
4855 *
4856 * \note The channel should be locked before calling this function.
4857 *
4858 * \param chan The channel to stop suppressing
4859 * \param direction The direction in which to stop suppressing
4860 * \param frametype The type of frame (AST_FRAME_VOICE, etc) to stop suppressing
4861 *
4862 * \retval 0 Success
4863 * \retval -1 Failure
4864 */
4865int ast_channel_unsuppress(struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype);
4866
4867/*!
4868 * \brief Simulate a DTMF end on a broken bridge channel.
4869 *
4870 * \param chan Channel sending DTMF that has not ended.
4871 * \param digit DTMF digit to stop.
4872 * \param start DTMF digit start time.
4873 * \param why Reason bridge broken.
4874 */
4875void ast_channel_end_dtmf(struct ast_channel *chan, char digit, struct timeval start, const char *why);
4876
4877struct ast_bridge_features;
4878
4879/*!
4880 * \brief Gets the channel-attached features a channel has access to upon being bridged.
4881 *
4882 * \note The channel must be locked when calling this function.
4883 *
4884 * \param chan Which channel to get features for
4885 *
4886 * \retval non-NULL The features currently set for this channel
4887 * \retval NULL if the features have not been set
4888 */
4890
4891/*!
4892 * \brief Appends to the channel-attached features a channel has access to upon being bridged.
4893 *
4894 * \note The channel must be locked when calling this function.
4895 *
4896 * \param chan Which channel to set features for
4897 * \param features The feature set to append to the channel's features
4898 *
4899 * \retval 0 on success
4900 * \retval -1 on failure
4901 */
4902int ast_channel_feature_hooks_append(struct ast_channel *chan, struct ast_bridge_features *features);
4903
4904/*!
4905 * \brief Sets the channel-attached features a channel has access to upon being bridged.
4906 *
4907 * \note The channel must be locked when calling this function.
4908 *
4909 * \param chan Which channel to set features for
4910 * \param features The feature set with which to replace the channel's features
4911 *
4912 * \retval 0 on success
4913 * \retval -1 on failure
4914 */
4915int ast_channel_feature_hooks_replace(struct ast_channel *chan, struct ast_bridge_features *features);
4916
4917enum ast_channel_error {
4918 /* Unable to determine what error occurred. */
4920 /* Channel with this ID already exists */
4922};
4923
4924/*!
4925 * \brief Get error code for latest channel operation.
4926 */
4928
4929/*!
4930 * \brief Am I currently running an intercept dialplan routine.
4931 * \since 13.14.0
4932 *
4933 * \details
4934 * A dialplan intercept routine is equivalent to an interrupt
4935 * routine. As such, the routine must be done quickly and you
4936 * do not have access to the media stream. These restrictions
4937 * are necessary because the media stream is the responsibility
4938 * of some other code and interfering with or delaying that
4939 * processing is bad.
4940 *
4941 * \retval 0 Not in an intercept routine.
4942 * \retval 1 In an intercept routine.
4943 */
4945
4946/*!
4947 * \brief Retrieve the topology of streams on a channel
4948 *
4949 * \param chan The channel to get the stream topology of
4950 *
4951 * \pre chan is locked
4952 *
4953 * \retval non-NULL success
4954 * \retval NULL failure
4955 */
4957 const struct ast_channel *chan);
4958
4959/*!
4960 * \brief Set the topology of streams on a channel
4961 *
4962 * \param chan The channel to set the stream topology on
4963 * \param topology The stream topology to set
4964 *
4965 * \pre chan is locked
4966 *
4967 * \note If topology is NULL a new empty topology will be created
4968 * and returned.
4969 *
4970 * \retval non-NULL Success
4971 * \retval NULL failure
4972 */
4974 struct ast_channel *chan, struct ast_stream_topology *topology);
4975
4976/*!
4977 * \brief Retrieve the default stream of a specific media type on a channel
4978 *
4979 * \param chan The channel to get the stream from
4980 * \param type The media type of the default stream
4981 *
4982 * \pre chan is locked
4983 *
4984 * \retval non-NULL success
4985 * \retval NULL failure
4986 */
4988
4989/*!
4990 * \brief Determine if a channel is multi-stream capable
4991 *
4992 * \param chan The channel to test
4993 *
4994 * \pre chan is locked
4995 *
4996 * \retval true if the channel is multi-stream capable.
4997 */
4998int ast_channel_is_multistream(struct ast_channel *chan);
4999
5000/*!
5001 * \brief Request that the stream topology of a channel change
5002 *
5003 * \param chan The channel to change
5004 * \param topology The new stream topology
5005 * \param change_source The source that initiated the change
5006 *
5007 * \note Absolutely _NO_ channel locks should be held before calling this function.
5008 *
5009 * \retval 0 request has been accepted to be attempted
5010 * \retval -1 request could not be attempted
5011 *
5012 * \note This function initiates an asynchronous request to change the stream topology. It is not
5013 * guaranteed that the topology will change and until an AST_CONTROL_STREAM_TOPOLOGY_CHANGED
5014 * frame is received from the channel the current handler of the channel must tolerate the
5015 * stream topology as it currently exists.
5016 *
5017 * \note This interface is provided for applications and resources to request that the topology change.
5018 * It is not for use by the channel driver itself.
5019 */
5021 struct ast_stream_topology *topology, void *change_source);
5022
5023/*!
5024 * \brief Provide notice to a channel that the stream topology has changed
5025 *
5026 * \param chan The channel to provide notice to
5027 * \param topology The new stream topology
5028 *
5029 * \pre chan is locked Absolutely _NO_ other channels can be locked.
5030 *
5031 * \retval 0 success
5032 * \retval -1 failure
5033 *
5034 * \note This interface is provided for applications and resources to accept a topology change.
5035 * It is not for use by the channel driver itself.
5036 */
5037int ast_channel_stream_topology_changed(struct ast_channel *chan, struct ast_stream_topology *topology);
5038
5039/*!
5040 * \brief Provide notice from a channel that the topology has changed on it as a result
5041 * of the remote party renegotiating.
5042 *
5043 * \param chan The channel to provide notice from
5044 *
5045 * \retval 0 success
5046 * \retval -1 failure
5047 *
5048 * \note This interface is provided for channels to provide notice that a topology change
5049 * has occurred as a result of a remote party renegotiating the stream topology.
5050 */
5052
5053/*!
5054 * \brief Retrieve the source that initiated the last stream topology change
5055 *
5056 * \param chan The channel
5057 *
5058 * \retval The channel's stream topology change source
5059 */
5061
5062/*!
5063 * \brief Checks if a channel's technology implements a particular callback function
5064 * \since 18.0.0
5065 *
5066 * \param chan The channel
5067 * \param function The function to look for
5068 *
5069 * \retval 1 if the channel has a technology set and it implements the function
5070 * \retval 0 if the channel doesn't have a technology set or it doesn't implement the function
5071 */
5072#define ast_channel_has_tech_function(chan, function) \
5073 (ast_channel_tech(chan) ? ast_channel_tech(chan)->function != NULL : 0)
5074
5075/*!
5076 * \brief Get the name of the current channel storage driver
5077 *
5078 * \return The name of the current channel storage driver
5079 */
5081
5082/*!
5083 * \internal
5084 * \brief Set the current channel storage driver
5085 *
5086 * \param driver_name The name of the driver to set as the current driver
5087 *
5088 * \return 0 on success, -1 on failure
5089 *
5090 * \warning Changing the channel storage driver while Asterisk is running is
5091 * not supported. This function will return an error if called while
5092 * the ast_fully_booted flag is set. The function is exposed only
5093 * because options.c needs it to set the driver when reading
5094 * asterisk.conf.
5095 */
5096int internal_channel_set_current_storage_driver(const char *driver_name);
5097
5098#endif /* _ASTERISK_CHANNEL_H */
ast_alert_status_t
Definition alertpipe.h:24
static struct aco_type agent_type
char digit
static struct ast_generator gen
ast_cond_t cond
Definition app_sla.c:336
static char dialcontext[AST_MAX_CONTEXT]
int() ao2_callback_data_fn(void *obj, void *arg, void *data, int flags)
Type of a generic callback function.
Definition astobj2.h:1244
Call Completion Supplementary Services API.
static int connected
Definition cdr_pgsql.c:73
static char language[MAX_LANGUAGE]
Definition chan_iax2.c:361
static char accountcode[AST_MAX_ACCOUNT_CODE]
Definition chan_iax2.c:510
static const char type[]
static void dummy(char *unused,...)
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:1692
void ast_channel_internal_alertpipe_swap(struct ast_channel *chan1, struct ast_channel *chan2)
Swap the interal alertpipe between two channels.
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
struct ao2_iterator ast_channel_dialed_causes_iterator(const struct ast_channel *chan)
Retrieve an iterator for dialed cause information.
struct varshead * ast_channel_get_manager_vars(struct ast_channel *chan)
Gets the variables for a given channel, as specified by ast_channel_set_manager_vars().
Definition channel.c:8030
int ast_senddigit_mf_begin(struct ast_channel *chan, char digit)
Send an MF digit to a channel.
Definition channel.c:4892
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
Definition channel.c:3213
int ast_str2cause(const char *name) attribute_pure
Convert the string form of a cause code to a number.
Definition channel.c:626
const char * ast_channel_linkedid(const struct ast_channel *chan)
const char * ast_channel_name(const struct ast_channel *chan)
static int ast_fdisset(struct pollfd *pfds, int fd, int maximum, int *start)
Helper function for migrating select to poll.
Definition channel.h:2894
int ast_channel_tech_hangupcause(const struct ast_channel *chan)
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
char * ast_print_namedgroups(struct ast_str **buf, struct ast_namedgroups *groups)
Print named call groups and named pickup groups.
Definition channel.c:8162
struct ast_bridge * ast_channel_internal_bridge(const struct ast_channel *chan)
void * ast_channel_get_stream_topology_change_source(struct ast_channel *chan)
Retrieve the source that initiated the last stream topology change.
struct timeval ast_channel_answertime(struct ast_channel *chan)
void ast_softhangup_all(void)
Soft hangup all active channels.
Definition channel.c:494
int ast_channel_request_stream_topology_change(struct ast_channel *chan, struct ast_stream_topology *topology, void *change_source)
Request that the stream topology of a channel change.
Definition channel.c:11076
void ast_channel_end_dtmf(struct ast_channel *chan, char digit, struct timeval start, const char *why)
Simulate a DTMF end on a broken bridge channel.
Definition channel.c:10979
void ast_party_redirecting_reason_copy(struct ast_party_redirecting_reason *dest, const struct ast_party_redirecting_reason *src)
Copy the source redirecting reason information to the destination redirecting reason.
Definition channel.c:2072
void ast_channel_rings_set(struct ast_channel *chan, int value)
void ast_channel_internal_copy_linkedid(struct ast_channel *dest, struct ast_channel *source)
Copy the full linkedid channel id structure from one channel to another.
void ast_channel_named_pickupgroups_set(struct ast_channel *chan, struct ast_namedgroups *value)
struct ast_channel * ast_channel_get_by_exten(const char *exten, const char *context)
Find a channel by extension and context.
Definition channel.c:1430
int(* ast_timing_func_t)(const void *data)
Definition channel.h:919
struct ast_channel * ast_channel_masq(const struct ast_channel *chan)
void ast_party_name_init(struct ast_party_name *init)
Initialize the given name structure.
Definition channel.c:1578
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:4774
enum ast_channel_error ast_channel_errno(void)
Get error code for latest channel operation.
Definition channel.c:11071
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
Definition channel.c:2989
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.
Definition channel.c:1336
int ast_channel_blocker_tid(const struct ast_channel *chan)
void ast_channel_stream_set(struct ast_channel *chan, struct ast_filestream *value)
void ast_channel_appl_set(struct ast_channel *chan, const char *value)
void ast_channel_dtmff_set(struct ast_channel *chan, struct ast_frame *value)
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.
Definition channel.c:1937
void ast_channel_internal_bridged_channel_set(struct ast_channel *chan, struct ast_channel *value)
void ast_channel_visible_indication_set(struct ast_channel *chan, int value)
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.
Definition channel.c:10606
const char * ast_channel_blockproc(const struct ast_channel *chan)
void ast_channel_caller_set(struct ast_channel *chan, struct ast_party_caller *value)
struct ast_stream_topology * ast_channel_set_stream_topology(struct ast_channel *chan, struct ast_stream_topology *topology)
Set the topology of streams on a channel.
char * ast_transfercapability2str(int transfercapability) attribute_const
Gives the string form of a given transfer capability.
Definition channel.c:673
void ast_channel_set_unbridged_nolock(struct ast_channel *chan, int value)
Variant of ast_channel_set_unbridged. Use this if the channel is already locked prior to calling.
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.
Definition channel.c:3026
int ast_auto_answer(struct ast_channel *chan)
Answer a channel, if it's not already answered.
Definition channel.c:2845
struct ast_namedgroups * ast_channel_named_pickupgroups(const struct ast_channel *chan)
void ast_party_redirecting_init(struct ast_party_redirecting *init)
Initialize the given redirecting structure.
Definition channel.c:2109
void * ast_channel_tech_pvt(const struct ast_channel *chan)
void ast_channel_internal_set_fake_ids(struct ast_channel *chan, const char *uniqueid, const char *linkedid)
Set uniqueid and linkedid string value only (not time)
static enum ast_t38_state ast_channel_get_t38_state(struct ast_channel *chan)
Retrieves the current T38 state of a channel.
Definition channel.h:2917
int ast_call(struct ast_channel *chan, const char *addr, int timeout)
Make a call.
Definition channel.c:6518
const char * ast_channel_data(const struct ast_channel *chan)
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:9225
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:6620
void ast_channel_dialed_set(struct ast_channel *chan, struct ast_party_dialed *value)
void ast_channel_clear_flag(struct ast_channel *chan, unsigned int flag)
Clear a flag on a channel.
Definition channel.c:11144
struct ast_party_id ast_channel_redirecting_effective_to(struct ast_channel *chan)
struct ast_control_pvt_cause_code * ast_channel_dialed_causes_find(const struct ast_channel *chan, const char *chan_name)
Retrieve a ref-counted cause code information structure.
struct ast_channel * ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, struct ast_format_cap *cap, struct outgoing_helper *oh, int *outstate)
Forwards a call to a new channel specified by the original channel's call_forward str....
Definition channel.c:5955
struct ast_format * ast_channel_rawreadformat(struct ast_channel *chan)
struct ast_party_id ast_channel_redirecting_effective_from(struct ast_channel *chan)
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition channel.c:1744
int ast_set_read_format_path(struct ast_channel *chan, struct ast_format *raw_format, struct ast_format *core_format)
Set specific read path on channel.
Definition channel.c:5545
void ast_channel_clear_softhangup(struct ast_channel *chan, int flag)
Clear a set of softhangup flags from a channel.
Definition channel.c:2423
void * ast_channel_music_state(const struct ast_channel *chan)
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.
Definition channel.c:1368
struct varshead * ast_channel_get_vars(struct ast_channel *chan)
Gets the variables for a given channel, as set using pbx_builtin_setvar_helper().
Definition channel.c:7958
void ast_channel_blockproc_set(struct ast_channel *chan, const char *value)
int ast_prod(struct ast_channel *chan)
Send empty audio to prime a channel driver.
Definition channel.c:5057
unsigned int ast_channel_fin(const struct ast_channel *chan)
void ast_channel_tech_hangupcause_set(struct ast_channel *chan, int value)
int __ast_answer(struct ast_channel *chan, unsigned int delay)
Answer a channel, with a selectable delay before returning.
Definition channel.c:2729
int ast_channel_connected_line_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *connected_info, int frame)
Run a connected line interception subroutine and update a channel's connected line information.
Definition channel.c:10444
const char * ast_channel_latest_musicclass(const struct ast_channel *chan)
void ast_channel_callid_cleanup(struct ast_channel *chan)
void ast_channel_insmpl_set(struct ast_channel *chan, unsigned long value)
void ast_party_number_init(struct ast_party_number *init)
Initialize the given number structure.
Definition channel.c:1631
void ast_channel_set_oldwriteformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_softhangup_internal_flag_clear(struct ast_channel *chan, int value)
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition channel.c:2574
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.
Definition channel.c:7433
struct varshead * ast_channel_varshead(struct ast_channel *chan)
int ast_channel_rings(const struct ast_channel *chan)
#define DECLARE_STRINGFIELD_SETTERS_FOR(field)
Definition channel.h:4137
void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator *value)
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.
Definition channel.c:5074
int ast_raw_answer_with_stream_topology(struct ast_channel *chan, struct ast_stream_topology *topology)
Answer a channel passing in a stream topology.
Definition channel.c:2672
void ast_channel_blocker_set(struct ast_channel *chan, pthread_t value)
void ast_channel_tenantid_set(struct ast_channel *chan, const char *value)
void ast_channel_sending_dtmf_digit_set(struct ast_channel *chan, char value)
void * ast_channel_timingdata(const struct ast_channel *chan)
struct ast_channel_iterator * ast_channel_iterator_destroy(struct ast_channel_iterator *i)
Destroy a channel iterator.
Definition channel.c:1349
int ast_channel_internal_alert_readfd(struct ast_channel *chan)
ast_channel_requestor_relationship
Definition channel.h:1523
@ AST_CHANNEL_REQUESTOR_BRIDGE_PEER
Definition channel.h:1525
@ AST_CHANNEL_REQUESTOR_REPLACEMENT
Definition channel.h:1527
struct ast_channel * ast_channel_bridge_peer(struct ast_channel *chan)
Get the channel's bridge peer only if the bridge is two-party.
Definition channel.c:10674
int ast_transfer_protocol(struct ast_channel *chan, char *dest, int *protocol)
Transfer a channel (if supported) receieve protocol result.
Definition channel.c:6555
const char * ast_channel_tenantid(const struct ast_channel *chan)
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:1706
void ast_channel_dtmf_tv_set(struct ast_channel *chan, struct timeval *value)
struct ast_flags * ast_channel_snapshot_segment_flags(struct ast_channel *chan)
void ast_channel_set_connected_line(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Set the connected line information in the Asterisk channel.
Definition channel.c:8414
int ast_senddigit_begin(struct ast_channel *chan, char digit)
Send a DTMF digit to a channel.
Definition channel.c:4931
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
Definition channel.c:1808
struct ast_channel * ast_channel_get_by_uniqueid(const char *uniqueid)
Find a channel by a uniqueid.
Definition channel.c:1442
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:1639
void ast_channel_internal_swap_endpoint_forward(struct ast_channel *a, struct ast_channel *b)
Swap endpoint_forward between two channels.
void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
const char * ast_channel_musicclass(const struct ast_channel *chan)
void ast_channel_unlink(struct ast_channel *chan)
Remove a channel from the global channels container.
Definition channel.c:10639
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:6685
int ast_channel_fdno(const struct ast_channel *chan)
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:1661
void ast_channel_internal_fd_clear_all(struct ast_channel *chan)
void ast_party_subaddress_init(struct ast_party_subaddress *init)
Initialize the given subaddress structure.
Definition channel.c:1684
int ast_channel_has_hook_requiring_audio(struct ast_channel *chan)
Check if the channel has any active hooks that require audio.
Definition channel.c:2557
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition channel.c:2059
void ast_channel_internal_bridge_channel_set(struct ast_channel *chan, struct ast_bridge_channel *value)
void ast_channel_internal_alertpipe_close(struct ast_channel *chan)
int64_t ast_channel_get_up_time_ms(struct ast_channel *chan)
Obtain how long it has been since the channel was answered in ms.
Definition channel.c:2869
void ast_channel_set_manager_vars(size_t varc, char **vars)
Sets the variables to be stored in the manager_vars field of all snapshots.
Definition channel.c:7934
struct stasis_topic * ast_channel_topic(struct ast_channel *chan)
A topic which publishes the events for a particular channel.
int ast_sendtext_data(struct ast_channel *chan, struct ast_msg_data *msg)
Sends text to a channel in an ast_msg_data structure wrapper with ast_sendtext as fallback.
Definition channel.c:4808
void ast_channel_answertime_set(struct ast_channel *chan, struct timeval *value)
int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
Definition channel.c:7656
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...
Definition channel.c:7446
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 millis...
Definition channel.c:3195
void ast_channel_hold_state_set(struct ast_channel *chan, int value)
int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition channel.c:5031
struct ast_trans_pvt * ast_channel_readtrans(const struct ast_channel *chan)
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:2153
const char * ast_channel_lastexten(const struct ast_channel *chan)
int ast_channel_make_compatible(struct ast_channel *chan, struct ast_channel *peer)
Make the frame formats of two channels compatible.
Definition channel.c:6777
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
ast_t38_state
Possible T38 states on channels.
Definition channel.h:898
@ T38_STATE_UNAVAILABLE
Definition channel.h:899
void ast_channel_data_set(struct ast_channel *chan, const char *value)
struct timeval ast_channel_sending_dtmf_tv(const struct ast_channel *chan)
struct varshead * ast_channel_get_ari_vars(struct ast_channel *chan)
Gets the variables for a given channel, as specified by ast_channel_set_ari_vars().
Definition channel.c:8035
void ast_channel_jb_set(struct ast_channel *chan, struct ast_jb *value)
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
void ast_channel_snapshot_set(struct ast_channel *chan, struct ast_channel_snapshot *snapshot)
void ast_party_id_free(struct ast_party_id *doomed)
Destroy the party id contents.
Definition channel.c:1798
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
Definition channel.c:571
struct ast_trans_pvt * ast_channel_writetrans(const struct ast_channel *chan)
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:1714
int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception)
Waits for input on an fd.
Definition channel.c:3018
unsigned short ast_channel_transfercapability(const struct ast_channel *chan)
int ast_channel_stream_topology_changed(struct ast_channel *chan, struct ast_stream_topology *topology)
Provide notice to a channel that the stream topology has changed.
Definition channel.c:11106
struct ast_namedgroups * ast_channel_named_callgroups(const struct ast_channel *chan)
ast_group_t ast_channel_pickupgroup(const struct ast_channel *chan)
void ast_channel_blocker_tid_set(struct ast_channel *chan, int tid)
void ast_channel_vstreamid_set(struct ast_channel *chan, int value)
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:1775
struct ast_channel * ast_channel_iterator_next(struct ast_channel_iterator *i)
Get the next channel for a channel iterator.
Definition channel.c:1388
void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars)
adds a list of channel variables to a channel
Definition channel.c:8221
struct ast_namedgroups * ast_ref_namedgroups(struct ast_namedgroups *groups)
Definition channel.c:7812
int ast_channel_feature_hooks_replace(struct ast_channel *chan, struct ast_bridge_features *features)
Sets the channel-attached features a channel has access to upon being bridged.
Definition channel.c:11066
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
Definition channel.c:8270
int internal_channel_set_current_storage_driver(const char *driver_name)
Definition channel.c:8085
void ast_channel_timingdata_set(struct ast_channel *chan, void *value)
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:2018
int ast_recvchar(struct ast_channel *chan, int timeout)
Receives a text character from a channel.
Definition channel.c:4763
struct ast_format * ast_channel_oldwriteformat(struct ast_channel *chan)
int ast_channel_internal_alert_readable(struct ast_channel *chan)
struct ast_cdr * ast_channel_cdr(const struct ast_channel *chan)
struct ast_channel * ast_channel_yank(struct ast_channel *yankee)
Gain control of a channel in the system.
Definition channel.c:10703
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:7516
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition channel.c:3200
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:10557
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
struct ast_channel * __ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, 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:6033
void ast_channel_redirecting_set(struct ast_channel *chan, struct ast_party_redirecting *value)
unsigned long long ast_group_t
Definition channel.h:215
ast_channel_error
Definition channel.h:4918
@ AST_CHANNEL_ERROR_ID_EXISTS
Definition channel.h:4922
@ AST_CHANNEL_ERROR_UNKNOWN
Definition channel.h:4920
int ast_channel_get_intercept_mode(void)
Am I currently running an intercept dialplan routine.
Definition channel.c:10439
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:2041
int ast_channel_priority(const struct ast_channel *chan)
void ast_channel_writetrans_set(struct ast_channel *chan, struct ast_trans_pvt *value)
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:8316
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:3223
void ast_channel_streamid_set(struct ast_channel *chan, int value)
void ast_channel_generatordata_set(struct ast_channel *chan, void *value)
void ast_party_dialed_init(struct ast_party_dialed *init)
Initialize the given dialed structure.
Definition channel.c:1915
const char * ast_channel_get_current_storage_driver_name(void)
Get the name of the current channel storage driver.
Definition channel.c:8079
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
void ast_party_caller_copy(struct ast_party_caller *dest, const struct ast_party_caller *src)
Copy the source caller information to the destination caller.
Definition channel.c:1973
struct ast_str * ast_channel_dialed_causes_channels(const struct ast_channel *chan)
Retrieve a comma-separated list of channels for which dialed cause information is available.
void ast_channel_softhangup_internal_flag_set(struct ast_channel *chan, int value)
ast_callid ast_channel_callid(const struct ast_channel *chan)
void ast_party_redirecting_reason_set(struct ast_party_redirecting_reason *dest, const struct ast_party_redirecting_reason *src)
Set the redirecting reason information based on another redirecting reason source.
Definition channel.c:2089
int ast_namedgroups_intersect(struct ast_namedgroups *a, struct ast_namedgroups *b)
Return TRUE if group a and b contain at least one common groupname.
Definition channel.c:8196
const char * ast_channel_uniqueid(const struct ast_channel *chan)
const char * ast_channel_accountcode(const struct ast_channel *chan)
void ast_channel_internal_swap_endpoints(struct ast_channel *a, struct ast_channel *b)
Swap endpoints between two channels.
struct ast_channel * ast_channel__bridge(const struct ast_channel *chan)
void ast_channel_undefer_dtmf(struct ast_channel *chan)
Unset defer DTMF flag on channel.
Definition channel.c:1329
void ast_channel_req_accountcodes(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship)
Setup new channel accountcodes from the requestor channel after ast_request().
Definition channel.c:6491
const char * ast_channel_context(const struct ast_channel *chan)
const char * ast_channel_userfield(const struct ast_channel *chan)
char ast_channel_dtmf_digit_to_emulate(const struct ast_channel *chan)
unsigned long ast_channel_insmpl(const struct ast_channel *chan)
int ast_channel_fd_add(struct ast_channel *chan, int value)
Add a file descriptor to the channel without a fixed position.
void ast_deactivate_generator(struct ast_channel *chan)
Definition channel.c:2926
ast_alert_status_t ast_channel_internal_alert_flush(struct ast_channel *chan)
void ast_party_id_merge_copy(struct ast_party_id *dest, struct ast_party_id *base, struct ast_party_id *overlay)
Copy a merge of a given party id into another given party id to a given destination party id.
Definition channel.c:1907
struct ast_channel_iterator * ast_channel_iterator_by_exten_new(const char *exten, const char *context)
Create a new channel iterator based on extension.
Definition channel.c:1357
int ast_check_hangup_locked(struct ast_channel *chan)
Definition channel.c:460
void ast_channel_timingfd_set(struct ast_channel *chan, int value)
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:524
void ast_channel_endpoint_set(struct ast_channel *chan, struct ast_endpoint *endpoint)
char * ast_print_group(char *buf, int buflen, ast_group_t group)
Print call and pickup groups into buffer.
Definition channel.c:8137
struct ast_channel * ast_channel_get_by_name_prefix(const char *name, size_t name_len)
Find a channel by a name prefix.
Definition channel.c:1400
pthread_t ast_channel_blocker(const struct ast_channel *chan)
void ast_party_redirecting_reason_set_init(struct ast_party_redirecting_reason *init, const struct ast_party_redirecting_reason *guide)
Initialize the given redirecting reason structure using the given guide for a set update operation.
Definition channel.c:2083
ama_flags
Channel AMA Flags.
Definition channel.h:1197
int ast_set_write_format_interleaved_stereo(struct ast_channel *chan, struct ast_format *format)
Sets write format for a channel. All internal data will than be handled in an interleaved format....
Definition channel.c:5842
void ast_channel_sending_dtmf_tv_set(struct ast_channel *chan, struct timeval value)
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:5201
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:1994
int ast_channel_suppress(struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype)
Suppress passing of a frame type on a channel.
Definition channel.c:10887
int ast_channel_feature_hooks_append(struct ast_channel *chan, struct ast_bridge_features *features)
Appends to the channel-attached features a channel has access to upon being bridged.
Definition channel.c:11061
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
void ast_channel_softhangup_withcause_locked(struct ast_channel *chan, int causecode)
Lock the given channel, then request softhangup on the channel with the given causecode.
Definition channel.c:469
int ast_channel_epfd(const struct ast_channel *chan)
int ast_undestroyed_channels(void)
Definition channel.c:505
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition channel.c:4312
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.
Definition channel.c:2050
struct ast_bridge_features * ast_channel_feature_hooks_get(struct ast_channel *chan)
Gets the channel-attached features a channel has access to upon being bridged.
Definition channel.c:11013
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:9199
int ast_channel_is_t38_active_nolock(struct ast_channel *chan)
ast_channel_is_t38_active variant. Use this if the channel is already locked prior to calling.
int ast_senddigit_mf_end(struct ast_channel *chan)
End sending an MF digit to a channel.
Definition channel.c:5000
int ast_channel_move(struct ast_channel *dest, struct ast_channel *source)
Move a channel from its current location to a new location.
Definition channel.c:10776
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.
Definition channel.c:10403
void ast_party_redirecting_reason_init(struct ast_party_redirecting_reason *init)
Initialize the given redirecting reason structure.
Definition channel.c:2066
const char * ast_channel_parkinglot(const struct ast_channel *chan)
ast_channel_adsicpe
Definition channel.h:888
int ast_senddigit_external(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel from an external thread.
Definition channel.c:5044
void ast_channel_internal_swap_topics(struct ast_channel *a, struct ast_channel *b)
Swap topics beteween two channels.
int ast_sendtext(struct ast_channel *chan, const char *text)
Sends text to a channel.
Definition channel.c:4866
const char * ast_channel_appl(const struct ast_channel *chan)
struct ast_frame * ast_read_stream(struct ast_channel *chan)
Reads a frame, but does not filter to just the default streams.
Definition channel.c:4317
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.
Definition channel.c:1986
int ast_channel_unbridged_nolock(struct ast_channel *chan)
ast_channel_unbridged variant. Use this if the channel is already locked prior to calling.
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:1767
void ast_party_name_free(struct ast_party_name *doomed)
Destroy the party name contents.
Definition channel.c:1625
void ast_channel_set_ari_vars(size_t varc, char **vars)
Sets the variables to be stored in the ari_vars field of all snapshots.
Definition channel.c:7939
const char * ast_channel_peeraccount(const struct ast_channel *chan)
void ast_party_dialed_free(struct ast_party_dialed *doomed)
Destroy the dialed party contents.
Definition channel.c:1958
void ast_channel_framehooks_set(struct ast_channel *chan, struct ast_framehook_list *value)
struct timeval ast_channel_creationtime(struct ast_channel *chan)
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:7408
int ast_channel_redirecting_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *redirecting_info, int is_frame)
Run a redirecting interception subroutine and update a channel's redirecting information.
Definition channel.c:10489
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:6833
struct ast_channel * ast_channel_get_by_name(const char *search)
Find a channel by name or uniqueid.
Definition channel.c:1417
struct ast_bridge_channel * ast_channel_internal_bridge_channel(const struct ast_channel *chan)
struct ast_framehook_list * ast_channel_framehooks(const struct ast_channel *chan)
struct ast_frame * ast_read_stream_noaudio(struct ast_channel *chan)
Reads a frame, but does not filter to just the default streams, returning AST_FRAME_NULL frame if aud...
Definition channel.c:4327
void ast_channel_audiohooks_set(struct ast_channel *chan, struct ast_audiohook_list *value)
int ast_channel_fd(const struct ast_channel *chan, int which)
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:2140
void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer *value)
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
Definition channel.c:5819
void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value)
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:1600
void ast_channel_fin_set(struct ast_channel *chan, unsigned int value)
void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format)
struct ast_audiohook_list * ast_channel_audiohooks(const struct ast_channel *chan)
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
enum ama_flags ast_channel_amaflags(const struct ast_channel *chan)
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:8891
void ast_party_caller_free(struct ast_party_caller *doomed)
Destroy the caller party contents.
Definition channel.c:2002
void ast_channel_readtrans_set(struct ast_channel *chan, struct ast_trans_pvt *value)
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.
Definition channel.c:1923
int ast_active_channels(void)
returns number of active/allocated channels
Definition channel.c:500
struct ast_namedgroups * ast_get_namedgroups(const char *s)
Create an ast_namedgroups set with group names from comma separated string.
Definition channel.c:7749
int ast_channel_supports_html(struct ast_channel *channel)
Checks for HTML support on a channel.
Definition channel.c:6680
void ast_channel_callgroup_set(struct ast_channel *chan, ast_group_t value)
void ast_channel_internal_bridge_set(struct ast_channel *chan, struct ast_bridge *value)
void * ast_channel_generatordata(const struct ast_channel *chan)
struct ast_format * ast_channel_rawwriteformat(struct ast_channel *chan)
void ast_channel_set_is_t38_active_nolock(struct ast_channel *chan, int is_t38_active)
Variant of ast_channel_set_is_t38_active. Use this if the channel is already locked prior to calling.
const char * ast_channel_hangupsource(const struct ast_channel *chan)
AST_MONITORING_STATE
Definition channel.h:4130
@ AST_MONITOR_PAUSED
Definition channel.h:4132
@ AST_MONITOR_RUNNING
Definition channel.h:4131
unsigned int ast_channel_fout(const struct ast_channel *chan)
const char * ast_channel_dialcontext(const struct ast_channel *chan)
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition channel.c:446
struct ast_stream_topology * ast_channel_get_stream_topology(const struct ast_channel *chan)
Retrieve the topology of streams on a channel.
void ast_channel_set_unbridged(struct ast_channel *chan, int value)
Sets the unbridged flag and queues a NULL frame on the channel to trigger a check by bridge_channel_w...
void ast_channel_outsmpl_set(struct ast_channel *chan, unsigned long value)
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:1608
int ast_channel_hangupcause(const struct ast_channel *chan)
void ast_set_party_id_all(struct ast_set_party_id *update_id)
Set the update marker to update all information of a corresponding party id.
Definition channel.c:1737
int ast_channel_is_bridged(const struct ast_channel *chan)
Determine if a channel is in a bridge.
Definition channel.c:10655
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.
Definition channel.c:1945
const char * ast_channel_reason2str(int reason)
return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument
Definition channel.c:5883
int ast_channel_timingfd(const struct ast_channel *chan)
void ast_channel_fdno_set(struct ast_channel *chan, int value)
struct ast_frame * ast_read_noaudio(struct ast_channel *chan)
Reads a frame, returning AST_FRAME_NULL frame if audio.
Definition channel.c:4322
int64_t ast_channel_get_duration_ms(struct ast_channel *chan)
Obtain how long it's been, in milliseconds, since the channel was created.
Definition channel.c:2854
struct ast_bridge * ast_channel_get_bridge(const struct ast_channel *chan)
Get the bridge associated with a channel.
Definition channel.c:10644
void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format)
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
struct ast_channel * ast_channel_internal_bridged_channel(const struct ast_channel *chan)
void ast_channel_creationtime_set(struct ast_channel *chan, struct timeval *value)
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:4710
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:9374
struct ast_tone_zone * ast_channel_zone(const struct ast_channel *chan)
void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force)
Set the source of the hangup in this channel and it's bridge.
Definition channel.c:2532
void ast_channel_set_flag(struct ast_channel *chan, unsigned int flag)
Set a flag on a channel.
Definition channel.c:11137
int ast_softhangup(struct ast_channel *chan, int cause)
Softly hangup up a channel.
Definition channel.c:2462
struct ast_party_id ast_channel_redirecting_effective_orig(struct ast_channel *chan)
void ast_channel_name_to_dial_string(char *channel_name)
Removes the trailing identifiers from a channel name string.
Definition channel.c:6901
int ast_channel_dialed_causes_add(const struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen)
Add cause code information to the channel.
void ast_channel_named_callgroups_set(struct ast_channel *chan, struct ast_namedgroups *value)
int ast_channel_alert_write(struct ast_channel *chan)
void ast_channel_hangupcause_hash_set(struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen)
Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash on the given channel.
Definition channel.c:4402
const char * ast_channel_lastcontext(const struct ast_channel *chan)
int ast_channel_vstreamid(const struct ast_channel *chan)
struct ast_readq_list * ast_channel_readq(struct ast_channel *chan)
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:10390
int ast_channel_has_manager_vars(void)
Return whether or not any manager variables have been set.
Definition channel.c:7902
void ast_channel_set_is_t38_active(struct ast_channel *chan, int is_t38_active)
Sets the is_t38_active flag.
struct ast_jb * ast_channel_jb(struct ast_channel *chan)
void ast_party_id_reset(struct ast_party_id *id)
Destroy and initialize the given party id structure.
Definition channel.c:1883
const char * ast_channel_amaflags2string(enum ama_flags flags)
Convert the enum representation of an AMA flag to a string representation.
Definition channel.c:4429
void ast_channel__bridge_set(struct ast_channel *chan, struct ast_channel *value)
void ast_party_id_invalidate(struct ast_party_id *id)
Invalidate all components of the given party id.
Definition channel.c:1876
ast_timing_func_t ast_channel_timingfunc(const struct ast_channel *chan)
void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
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:8803
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition channel.c:4981
int ast_channel_has_ari_vars(void)
Return whether or not any ARI variables have been set.
Definition channel.c:7907
void ast_channel_dtmf_digit_to_emulate_set(struct ast_channel *chan, char value)
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 ...
Definition channel.c:540
void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
struct timeval * ast_channel_whentohangup(struct ast_channel *chan)
struct ast_party_id ast_party_id_merge(struct ast_party_id *base, struct ast_party_id *overlay)
Merge a given party id into another given party id.
Definition channel.c:1889
struct ast_stream * ast_channel_get_default_stream(struct ast_channel *chan, enum ast_media_type type)
Retrieve the default stream of a specific media type on a channel.
struct ast_channel * ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, 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...
Definition channel.c:6231
struct ast_filestream * ast_channel_vstream(const struct ast_channel *chan)
int ast_channel_stream_topology_changed_externally(struct ast_channel *chan)
Provide notice from a channel that the topology has changed on it as a result of the remote party ren...
Definition channel.c:11118
ast_alert_status_t ast_channel_internal_alert_read(struct ast_channel *chan)
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
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:1653
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:3218
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
Definition channel.c:5860
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:1752
void ast_party_number_free(struct ast_party_number *doomed)
Destroy the party number contents.
Definition channel.c:1678
void ast_channel_internal_swap_uniqueid_and_linkedid(struct ast_channel *a, struct ast_channel *b)
Swap uniqueid and linkedid beteween two channels.
struct ast_generator * ast_channel_generator(const struct ast_channel *chan)
ast_group_t ast_channel_callgroup(const struct ast_channel *chan)
struct ast_party_id ast_channel_connected_effective_id(struct ast_channel *chan)
int ast_channel_unbridged(struct ast_channel *chan)
This function will check if the bridge needs to be re-evaluated due to external changes.
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
Definition channel.c:2009
int ast_channel_get_up_time(struct ast_channel *chan)
Obtain how long it has been since the channel was answered.
Definition channel.c:2879
int ast_channel_is_leaving_bridge(struct ast_channel *chan)
Determine if a channel is leaving a bridge, but not hung up.
Definition channel.c:10660
void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset)
Set when to hang a channel up.
Definition channel.c:511
int ast_channel_hold_state(const struct ast_channel *chan)
int ast_channel_sendurl(struct ast_channel *channel, const char *url)
Sends a URL on a given link Send URL on link.
Definition channel.c:6692
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:9585
void ast_channel_emulate_dtmf_duration_set(struct ast_channel *chan, unsigned int value)
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:1555
void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value)
struct ast_variable * ast_channeltype_list(void)
return an ast_variable list of channeltypes
Definition channel.c:189
const char * ast_channel_oldest_linkedid(const char *a, const char *b)
Return the oldest linkedid between two channels.
const char * ast_channel_language(const struct ast_channel *chan)
struct ast_bridge_channel * ast_channel_get_bridge_channel(struct ast_channel *chan)
Get a reference to the channel's bridge pointer.
Definition channel.c:10692
const char * ast_cause2str(int cause) attribute_pure
Gives the string form of a given cause code.
Definition channel.c:613
int ast_senddigit_mf(struct ast_channel *chan, char digit, unsigned int duration, unsigned int durationkp, unsigned int durationst, int is_external)
Send an MF digit to a channel.
Definition channel.c:5009
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.
struct ast_party_connected_line * ast_channel_connected_indicated(struct ast_channel *chan)
struct ast_endpoint * ast_channel_endpoint(const struct ast_channel *chan)
int ast_transfer(struct ast_channel *chan, char *dest)
Transfer a channel (if supported).
Definition channel.c:6542
void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr *value)
int ast_channel_unsuppress(struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype)
Stop suppressing of a frame type on a channel.
Definition channel.c:10949
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition channel.c:2166
void ast_channel_context_set(struct ast_channel *chan, const char *value)
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
Definition channel.c:2417
int ast_channel_streamid(const struct ast_channel *chan)
void ast_channel_connected_set(struct ast_channel *chan, struct ast_party_connected_line *value)
const char * ast_state2str(enum ast_channel_state state)
Gives the string form of a given channel state.
Definition channel.c:637
void ast_channel_timingfunc_set(struct ast_channel *chan, ast_timing_func_t value)
struct ast_sched_context * ast_channel_sched(const struct ast_channel *chan)
void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state)
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.
Definition channel.c:8399
int ast_softhangup_nolock(struct ast_channel *chan, int cause)
Softly hangup up a channel (no channel lock)
Definition channel.c:2449
int ast_channel_forward_endpoint(struct ast_channel *chan, struct ast_endpoint *endpoint)
Forward channel stasis messages to the given endpoint.
int ast_channel_fd_count(const struct ast_channel *chan)
Retrieve the number of file decriptor positions present on the channel.
enum ama_flags ast_channel_string2amaflag(const char *flag)
Convert a string to a detail record AMA flag.
Definition channel.c:4416
struct ast_frame * ast_channel_dtmff(struct ast_channel *chan)
void ast_channel_internal_swap_snapshots(struct ast_channel *a, struct ast_channel *b)
Swap snapshots beteween two channels.
void ast_channel_music_state_set(struct ast_channel *chan, void *value)
void ast_channel_req_accountcodes_precious(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship)
Setup new channel accountcodes from the requestor channel after ast_request().
Definition channel.c:6496
unsigned int ast_channel_emulate_dtmf_duration(const struct ast_channel *chan)
static int ast_add_fd(struct pollfd *pfd, int fd)
if fd is a valid descriptor, set *pfd with the descriptor
Definition channel.h:2886
const char * ast_channel_call_forward(const struct ast_channel *chan)
int ast_set_write_format_path(struct ast_channel *chan, struct ast_format *core_format, struct ast_format *raw_format)
Set specific write path on channel.
Definition channel.c:5581
struct ast_filestream * ast_channel_stream(const struct ast_channel *chan)
void ast_channel_internal_fd_clear(struct ast_channel *chan, int which)
struct ast_pbx * ast_channel_pbx(const struct ast_channel *chan)
void ast_channel_fout_set(struct ast_channel *chan, unsigned int value)
struct ast_autochan_list * ast_channel_autochans(struct ast_channel *chan)
int ast_pre_call(struct ast_channel *chan, const char *sub_args)
Execute a Gosub call on the channel before a call is placed.
Definition channel.c:6501
void ast_channel_zone_set(struct ast_channel *chan, struct ast_tone_zone *value)
struct ast_channel * ast_channel_masqr(const struct ast_channel *chan)
struct ast_namedgroups * ast_unref_namedgroups(struct ast_namedgroups *groups)
Definition channel.c:7806
void ast_party_subaddress_free(struct ast_party_subaddress *doomed)
Destroy the party subaddress contents.
Definition channel.c:1731
int ast_channel_softhangup_internal_flag(struct ast_channel *chan)
int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block)
Sets an option on a channel.
Definition channel.c:7496
int ast_set_read_format_from_cap(struct ast_channel *chan, struct ast_format_cap *formats)
Sets read format on channel chan from capabilities Set read format for channel to whichever component...
Definition channel.c:5837
struct timeval * ast_channel_dtmf_tv(struct ast_channel *chan)
int ast_channel_get_duration(struct ast_channel *chan)
Obtain how long the channel since the channel was created.
Definition channel.c:2864
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
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.
Definition channel.c:9212
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:2032
char ast_channel_sending_dtmf_digit(const struct ast_channel *chan)
int ast_channel_visible_indication(const struct ast_channel *chan)
struct ast_timer * ast_channel_timer(const struct ast_channel *chan)
struct ast_hangup_handler_list * ast_channel_hangup_handlers(struct ast_channel *chan)
void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value)
unsigned long ast_channel_outsmpl(const struct ast_channel *chan)
void ast_channel_masqr_set(struct ast_channel *chan, struct ast_channel *value)
void ast_channel_callid_set(struct ast_channel *chan, ast_callid value)
int ast_write_stream(struct ast_channel *chan, int stream_num, struct ast_frame *frame)
Write a frame to a stream This function writes the given frame to the indicated stream on the channel...
Definition channel.c:5206
void ast_channel_internal_alertpipe_clear(struct ast_channel *chan)
void ast_channel_priority_set(struct ast_channel *chan, int value)
int ast_safe_sleep_without_silence(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups, and do not generate silence.
Definition channel.c:1566
int ast_autoservice_ignore(struct ast_channel *chan, enum ast_frame_type ftype)
Ignore certain frame types.
int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders)
Reads multiple digits.
Definition channel.c:6615
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.
Definition channel.c:8406
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
void ast_autoservice_chan_hangup_peer(struct ast_channel *chan, struct ast_channel *peer)
Put chan into autoservice while hanging up peer.
void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value)
void ast_channel_pickupgroup_set(struct ast_channel *chan, ast_group_t value)
const struct ast_channel_tech * ast_get_channel_tech(const char *name)
Get a channel technology structure by name.
Definition channel.c:593
int ast_channel_fd_isset(const struct ast_channel *chan, int which)
int ast_channel_defer_dtmf(struct ast_channel *chan)
Defers DTMF so that you only read things like hangups and audio.
Definition channel.c:1315
int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
Definition channel.c:7674
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition channel.c:2839
void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value)
void ast_channel_dialed_causes_clear(const struct ast_channel *chan)
Clear all cause information from the channel.
void ast_channel_epfd_set(struct ast_channel *chan, int value)
ast_group_t ast_get_group(const char *s)
Definition channel.c:7692
int ast_channel_is_multistream(struct ast_channel *chan)
Determine if a channel is multi-stream capable.
int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1)
Bridge two channels together (early)
Definition channel.c:7486
int ast_channel_internal_alertpipe_init(struct ast_channel *chan)
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition channel.c:4332
void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context *value)
int ast_is_deferrable_frame(const struct ast_frame *frame)
Should we keep this frame for later?
Definition channel.c:1454
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
struct ast_channel_iterator * ast_channel_iterator_all_new(void)
Create a new channel iterator.
Definition channel.c:1380
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
Definition channel.c:1561
const char * ast_channel_exten(const struct ast_channel *chan)
int ast_channel_is_t38_active(struct ast_channel *chan)
This function will check if T.38 is active on the channel.
struct ast_datastore_list * ast_channel_datastores(struct ast_channel *chan)
struct ast_cc_config_params * ast_channel_get_cc_config_params(struct ast_channel *chan)
Get the CCSS parameters from a channel.
Definition channel.c:10580
void ast_channel_masq_set(struct ast_channel *chan, struct ast_channel *value)
int ast_raw_answer(struct ast_channel *chan)
Answer a channel.
Definition channel.c:2724
int ast_waitfordigit_full(struct ast_channel *c, int ms, const char *breakon, 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:3278
void ast_channel_varshead_set(struct ast_channel *chan, struct varshead *value)
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:2122
void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx *value)
struct ast_channel * ast_channel_internal_oldest_linkedid(struct ast_channel *a, struct ast_channel *b)
Determine which channel has an older linkedid.
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:1586
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_vstream_set(struct ast_channel *chan, struct ast_filestream *value)
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.
Definition channel.c:10623
void ast_party_redirecting_reason_free(struct ast_party_redirecting_reason *doomed)
Destroy the redirecting reason contents.
Definition channel.c:2103
void ast_party_caller_init(struct ast_party_caller *init)
Initialize the given caller structure.
Definition channel.c:1965
int ast_set_write_format_from_cap(struct ast_channel *chan, struct ast_format_cap *formats)
Sets write format on channel chan Set write format for channel to whichever component of "format" is ...
Definition channel.c:5878
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
int ast_channel_alert_writable(struct ast_channel *chan)
void ast_tonepair_stop(struct ast_channel *chan)
Definition channel.c:7669
int ast_channel_has_audio_frame_or_monitor(struct ast_channel *chan)
Check if the channel has active audiohooks, active framehooks, or a monitor.
Definition channel.c:2551
ast_channel_state
ast_channel states
ast_media_type
Types of media.
Definition codec.h:30
static void update(int code_size, int y, int wi, int fi, int dq, int sr, int dqsez, struct g726_state *state_ptr)
Definition codec_g726.c:367
#define attribute_pure
Definition compiler.h:35
#define attribute_const
Definition compiler.h:41
char buf[BUFSIZE]
Definition eagi_proxy.c:66
long int flag
Definition f2c.h:83
static const char name[]
Definition format_mp3.c:68
direction
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define AST_OPTION_T38_STATE
ast_frame_type
Frame types.
unsigned int ast_callid
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
static char url[512]
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition astobj2.h:1821
Structure to pass both assignedid values to channel drivers.
Definition channel.h:606
Structure that contains information regarding a channel in a bridge.
struct ast_channel * chan
Structure that contains features information.
Structure that contains information about a bridge.
Definition bridge.h:353
Responsible for call detail data.
Definition cdr.h:281
Structure representing a snapshot of channel state.
Structure to describe a channel "technology", ie a channel driver See for examples:
Definition channel.h:648
Main Channel structure associated with a channel.
struct ast_channel_id uniqueid
char exten[AST_MAX_EXTENSION]
const char * data
const struct ast_channel_tech * tech
struct ast_endpoint * endpoint
struct ast_channel_id linkedid
enum ast_channel_state state
char context[AST_MAX_CONTEXT]
struct ast_party_caller caller
Channel Caller ID information.
This structure is allocated by file.c in one chunk, together with buf_size and desc_size bytes of mem...
Definition mod_format.h:101
Structure used to handle boolean flags.
Definition utils.h:220
Format capabilities structure, holds formats + preference order + etc.
Definition format_cap.c:54
Definition of a media format.
Definition format.c:43
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
union ast_frame::@235 data
channel group info
Definition channel.h:2982
struct ast_group_info::@219 group_list
char * category
Definition channel.h:2984
struct ast_channel * chan
Definition channel.h:2983
General jitterbuffer state.
Structure used to transport a message through the frame core.
Caller Party information.
Definition channel.h:420
Connected Line/Party information.
Definition channel.h:458
Dialed/Called Party information.
Definition channel.h:380
Information needed to identify an endpoint in a call.
Definition channel.h:340
Information needed to specify a name in a call.
Definition channel.h:264
Information needed to specify a number in a call.
Definition channel.h:291
Redirecting reason information.
Definition channel.h:503
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
Definition channel.h:524
Information needed to specify a subaddress in a call.
Definition channel.h:309
Definition pbx.h:216
Indicate what information in ast_party_caller should be set.
Definition channel.h:442
Indicate what information in ast_party_connected_line should be set.
Definition channel.h:491
Indicate what information in ast_party_id should be set.
Definition channel.h:363
Indicate what information in ast_party_redirecting should be set.
Definition channel.h:557
Support for dynamic strings.
Definition strings.h:623
A set of tones for a given locale.
Definition indications.h:74
Default structure for translators, with the basic fields and buffers, all allocated as part of the sa...
Definition translate.h:213
Structure for variables, used for configurations and for channel variables.
Definition file.c:70
int value
Definition syslog.c:37
static struct test_val b
static struct test_val a
static struct test_val c

◆ ast_channel_alloc_with_endpoint

#define ast_channel_alloc_with_endpoint (   needqueue,
  state,
  cid_num,
  cid_name,
  acctcode,
  exten,
  context,
  assignedids,
  requestor,
  amaflag,
  endpoint,
  ... 
)
Value:
__ast_channel_alloc((needqueue), (state), (cid_num), (cid_name), (acctcode), (exten), (context), (assignedids), (requestor), (amaflag), (endpoint), \
__FILE__, __LINE__, __FUNCTION__, __VA_ARGS__)

Definition at line 1303 of file channel.h.

◆ ast_channel_alloc_with_initializers

#define ast_channel_alloc_with_initializers (   needqueue,
  state,
  cid_num,
  cid_name,
  acctcode,
  exten,
  context,
  assignedids,
  requestor,
  amaflag,
  endpoint,
  initializers,
  ... 
)
Value:
__ast_channel_alloc_with_initializers((needqueue), (state), (cid_num), (cid_name), (acctcode), (exten), (context), (assignedids), (requestor), (amaflag), (endpoint), \
(initializers), __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__)
struct ast_channel * __ast_channel_alloc_with_initializers(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, enum ama_flags amaflag, struct ast_endpoint *endpoint, struct ast_channel_initializers *initializers, const char *file, int line, const char *function, const char *name_fmt,...)
Create a channel structure.
Definition channel.c:986

Definition at line 1307 of file channel.h.

◆ ast_channel_cleanup

#define ast_channel_cleanup (   c)    ({ ao2_cleanup(c); (struct ast_channel *) (NULL); })

Cleanup a channel reference.

Parameters
cthe channel (NULL tolerant)
Return values
NULLalways
Since
12.0.0

Definition at line 3036 of file channel.h.

◆ ast_channel_has_tech_function

#define ast_channel_has_tech_function (   chan,
  function 
)     (ast_channel_tech(chan) ? ast_channel_tech(chan)->function != NULL : 0)

Checks if a channel's technology implements a particular callback function.

Since
18.0.0
Parameters
chanThe channel
functionThe function to look for
Return values
1if the channel has a technology set and it implements the function
0if the channel doesn't have a technology set or it doesn't implement the function

Definition at line 5073 of file channel.h.

5074 : 0)

◆ AST_CHANNEL_INITIALIZERS_VERSION

#define AST_CHANNEL_INITIALIZERS_VERSION   1

struct ABI version

Note
This must be incremented when the struct changes.

Definition at line 620 of file channel.h.

◆ ast_channel_lock

#define ast_channel_lock (   chan)    ao2_lock(chan)

Definition at line 2989 of file channel.h.

◆ ast_channel_lock_both

#define ast_channel_lock_both (   chan1,
  chan2 
)

Lock two channels.

Definition at line 2996 of file channel.h.

2996 { \
2997 ast_channel_lock(chan1); \
2998 while (ast_channel_trylock(chan2)) { \
2999 ast_channel_unlock(chan1); \
3000 sched_yield(); \
3001 ast_channel_lock(chan1); \
3002 } \
3003 } while (0)
#define ast_channel_trylock(chan)
Definition channel.h:2991

◆ AST_CHANNEL_NAME

#define AST_CHANNEL_NAME   80

Max length of an ast_channel name

Definition at line 173 of file channel.h.

◆ ast_channel_ref

#define ast_channel_ref (   c)    ({ ao2_ref(c, +1); (c); })

Increase channel reference count.

Parameters
cthe channel
Return values
calways
Since
1.8

Definition at line 3014 of file channel.h.

◆ ast_channel_trylock

#define ast_channel_trylock (   chan)    ao2_trylock(chan)

Definition at line 2991 of file channel.h.

◆ ast_channel_unlock

#define ast_channel_unlock (   chan)    ao2_unlock(chan)

Definition at line 2990 of file channel.h.

◆ ast_channel_unref

#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 3025 of file channel.h.

◆ ast_dummy_channel_alloc

#define ast_dummy_channel_alloc ( )    __ast_dummy_channel_alloc(__FILE__, __LINE__, __PRETTY_FUNCTION__)

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 1328 of file channel.h.

◆ AST_EXTENDED_FDS

#define AST_EXTENDED_FDS   12

the start of extended file descriptor positions

Definition at line 197 of file channel.h.

◆ AST_FEATURE_DTMF_MASK

#define AST_FEATURE_DTMF_MASK
Value:
@ AST_FEATURE_AUTOMIXMON
Definition channel.h:1089
@ AST_FEATURE_REDIRECT
Definition channel.h:1084
@ AST_FEATURE_ATXFER
Definition channel.h:1086
@ AST_FEATURE_PARKCALL
Definition channel.h:1088
@ AST_FEATURE_AUTOMON
Definition channel.h:1087
@ AST_FEATURE_DISCONNECT
Definition channel.h:1085

Definition at line 1092 of file channel.h.

◆ AST_GENERATOR_FD

#define AST_GENERATOR_FD   (AST_MAX_FDS-4)

unused - formerly used by generator

Definition at line 205 of file channel.h.

◆ AST_JITTERBUFFER_FD

#define AST_JITTERBUFFER_FD   (AST_MAX_FDS-5)

used by generator

Definition at line 206 of file channel.h.

◆ AST_MAX_ACCOUNT_CODE

#define AST_MAX_ACCOUNT_CODE   80

Max length of an account code

Definition at line 172 of file channel.h.

◆ AST_MAX_CONTEXT

#define AST_MAX_CONTEXT   80

Max length of a context

Definition at line 135 of file channel.h.

◆ AST_MAX_EXTENSION

#define AST_MAX_EXTENSION   80

Max length of an extension

Definition at line 134 of file channel.h.

◆ AST_MAX_FDS

#define AST_MAX_FDS   11

original maximum number of file descriptors

Definition at line 196 of file channel.h.

◆ AST_MAX_PUBLIC_UNIQUEID

#define AST_MAX_PUBLIC_UNIQUEID   149

Max length of a channel uniqueid reported to the outside world.

149 = 127 (max systemname) + "-" + 10 (epoch timestamp)

  • "." + 10 (monotonically incrementing integer).
Note
If this value is ever changed, MAX_CHANNEL_ID should be updated in rtp_engine.h.

Definition at line 147 of file channel.h.

◆ AST_MAX_TENANT_ID

#define AST_MAX_TENANT_ID   64

Max length of a channel tenant_id

Definition at line 149 of file channel.h.

◆ AST_MAX_UNIQUEID

#define AST_MAX_UNIQUEID   (AST_MAX_PUBLIC_UNIQUEID + 2 + 1)

Maximum size of an internal Asterisk channel unique ID.

Add two for the Local;2 channel to append a ';2' if needed plus nul terminator.

Note
If this value is ever changed, MAX_CHANNEL_ID should be updated in rtp_engine.h.

Definition at line 170 of file channel.h.

◆ AST_MAX_USER_FIELD

#define AST_MAX_USER_FIELD   256

Max length of the channel user field

Definition at line 176 of file channel.h.

◆ AST_MUTE_DIRECTION_READ

#define AST_MUTE_DIRECTION_READ   (1 << 0)

Definition at line 4837 of file channel.h.

◆ AST_MUTE_DIRECTION_WRITE

#define AST_MUTE_DIRECTION_WRITE   (1 << 1)

Definition at line 4838 of file channel.h.

◆ AST_NUM_CHANNEL_BUCKETS

#define AST_NUM_CHANNEL_BUCKETS   1567

The number of buckets to store channels or channel information

Definition at line 157 of file channel.h.

◆ AST_TIMING_FD

#define AST_TIMING_FD   (AST_MAX_FDS-2)

used for timingfd

Definition at line 203 of file channel.h.

◆ CHECK_BLOCKING

#define CHECK_BLOCKING (   c)

Set the blocking indication on the channel.

Indicate that the thread handling the channel is about to do a blocking operation to wait for media on the channel. (poll, read, or write)

Masquerading and ast_queue_frame() use this indication to wake up the thread.

Precondition
The channel needs to be locked

Definition at line 2938 of file channel.h.

2939 { \
2941 /* This should not happen as there should only be one thread handling a channel's media at a time. */ \
2942 ast_log(LOG_DEBUG, "Thread LWP %d is blocking '%s', already blocked by thread LWP %d in procedure %s\n", \
2945 ast_assert(0); \
2946 } \
2947 ast_channel_blocker_tid_set((c), ast_get_tid()); \
2948 ast_channel_blocker_set((c), pthread_self()); \
2949 ast_channel_blockproc_set((c), __PRETTY_FUNCTION__); \
2950 ast_set_flag(ast_channel_flags(c), AST_FLAG_BLOCKING); \
2951 } while (0)
@ AST_FLAG_BLOCKING
Definition channel.h:1005
#define LOG_DEBUG
#define ast_test_flag(p, flag)
Definition utils.h:64
int ast_get_tid(void)
Get current thread ID.
Definition utils.c:2786

◆ DATASTORE_INHERIT_FOREVER

#define DATASTORE_INHERIT_FOREVER   INT_MAX

Definition at line 194 of file channel.h.

◆ DEBUGCHAN_FLAG

#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 877 of file channel.h.

◆ DECLARE_STRINGFIELD_SETTERS_FOR

#define DECLARE_STRINGFIELD_SETTERS_FOR (   field)
Value:
void ast_channel_##field##_set(struct ast_channel *chan, const char *field); \
void ast_channel_##field##_build_va(struct ast_channel *chan, const char *fmt, va_list ap) __attribute__((format(printf, 2, 0))); \
void ast_channel_##field##_build(struct ast_channel *chan, const char *fmt, ...) __attribute__((format(printf, 2, 3)))

Definition at line 4137 of file channel.h.

◆ FRAMECOUNT_INC

#define FRAMECOUNT_INC (   x)    ( ((x) & DEBUGCHAN_FLAG) | (((x)+1) & ~DEBUGCHAN_FLAG) )

Definition at line 880 of file channel.h.

◆ MAX_LANGUAGE

#define MAX_LANGUAGE   40

Max length of the language setting

Definition at line 174 of file channel.h.

◆ MAX_MUSICCLASS

#define MAX_MUSICCLASS   80

Max length of the music class setting

Definition at line 175 of file channel.h.

Typedef Documentation

◆ ast_acf_read2_fn_t

typedef int(* ast_acf_read2_fn_t) (struct ast_channel *chan, const char *cmd, char *data, struct ast_str **str, ssize_t len)

Typedef for a custom read2 function.

Note
data should be treated as const char *.

Definition at line 582 of file channel.h.

◆ ast_acf_read_fn_t

typedef int(* ast_acf_read_fn_t) (struct ast_channel *chan, const char *function, char *data, char *buf, size_t len)

Typedef for a custom read function.

Note
data should be treated as const char *.

Definition at line 576 of file channel.h.

◆ ast_acf_write_fn_t

typedef int(* ast_acf_write_fn_t) (struct ast_channel *chan, const char *function, char *data, const char *value)

Typedef for a custom write function.

Note
data should be treated as const char *.

Definition at line 588 of file channel.h.

◆ ast_group_t

typedef unsigned long long ast_group_t

Definition at line 215 of file channel.h.

◆ ast_timing_func_t

typedef int(* ast_timing_func_t) (const void *data)

Definition at line 919 of file channel.h.

Enumeration Type Documentation

◆ anonymous enum

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.

AST_CHAN_TP_INTERNAL 

Channels with this particular technology are an implementation detail of Asterisk and should generally not be exposed or manipulated by the outside world.

AST_CHAN_TP_SEND_TEXT_DATA 

Channels have this property if they implement send_text_data.

Definition at line 975 of file channel.h.

975 {
976 /*!
977 * \brief Channels have this property if they can accept input with jitter;
978 * i.e. most VoIP channels
979 */
980 AST_CHAN_TP_WANTSJITTER = (1 << 0),
981 /*!
982 * \brief Channels have this property if they can create jitter;
983 * i.e. most VoIP channels
984 */
985 AST_CHAN_TP_CREATESJITTER = (1 << 1),
986 /*!
987 * \brief Channels with this particular technology are an implementation detail of
988 * Asterisk and should generally not be exposed or manipulated by the outside
989 * world
990 */
991 AST_CHAN_TP_INTERNAL = (1 << 2),
992 /*!
993 * \brief Channels have this property if they implement send_text_data
994 */
996};
@ AST_CHAN_TP_INTERNAL
Channels with this particular technology are an implementation detail of Asterisk and should generall...
Definition channel.h:991
@ AST_CHAN_TP_SEND_TEXT_DATA
Channels have this property if they implement send_text_data.
Definition channel.h:995
@ AST_CHAN_TP_WANTSJITTER
Channels have this property if they can accept input with jitter; i.e. most VoIP channels.
Definition channel.h:980
@ AST_CHAN_TP_CREATESJITTER
Channels have this property if they can create jitter; i.e. most VoIP channels.
Definition channel.h:985

◆ anonymous enum

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_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_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_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_ORIGINATED 

This flag indicates that the channel was originated.

AST_FLAG_DEAD 

The channel is well and truly dead. Once this is set and published, no further actions should be taken upon the channel, and no further publications should occur.

AST_FLAG_SNAPSHOT_STAGE 

Channel snapshot should not be published, it is being staged for an explicit publish.

AST_FLAG_TIMINGDATA_IS_AO2_OBJ 

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

AST_FLAG_SUBROUTINE_EXEC 

The channel is executing a subroutine or macro

Definition at line 999 of file channel.h.

999 {
1000 /*! Queue incoming DTMF, to be released when this flag is turned off */
1001 AST_FLAG_DEFER_DTMF = (1 << 1),
1002 /*! write should be interrupt generator */
1003 AST_FLAG_WRITE_INT = (1 << 2),
1004 /*! a thread is blocking on this channel */
1005 AST_FLAG_BLOCKING = (1 << 3),
1006 /*! This is a zombie channel */
1007 AST_FLAG_ZOMBIE = (1 << 4),
1008 /*! There is an exception pending */
1009 AST_FLAG_EXCEPTION = (1 << 5),
1010 /*! Listening to moh XXX anthm promises me this will disappear XXX */
1011 AST_FLAG_MOH = (1 << 6),
1012 /*! This channel is spying on another channel */
1013 AST_FLAG_SPYING = (1 << 7),
1014 /*! the channel is in an auto-incrementing dialplan processor,
1015 * so when ->priority is set, it will get incremented before
1016 * finding the next priority to run */
1017 AST_FLAG_IN_AUTOLOOP = (1 << 9),
1018 /*! This is an outgoing call */
1019 AST_FLAG_OUTGOING = (1 << 10),
1020 /*! A DTMF_BEGIN frame has been read from this channel, but not yet an END */
1021 AST_FLAG_IN_DTMF = (1 << 12),
1022 /*! A DTMF_END was received when not IN_DTMF, so the length of the digit is
1023 * currently being emulated */
1024 AST_FLAG_EMULATE_DTMF = (1 << 13),
1025 /*! This is set to tell the channel not to generate DTMF begin frames, and
1026 * to instead only generate END frames. */
1027 AST_FLAG_END_DTMF_ONLY = (1 << 14),
1028 /* OBSOLETED in favor of AST_CAUSE_ANSWERED_ELSEWHERE
1029 * Flag to show channels that this call is hangup due to the fact that the call
1030 * was indeed answered, but in another channel */
1031 /* AST_FLAG_ANSWERED_ELSEWHERE = (1 << 15), */
1032 /*! This flag indicates that on a masquerade, an active stream should not
1033 * be carried over */
1034 AST_FLAG_MASQ_NOSTREAM = (1 << 16),
1035 /*! This flag indicates that the hangup exten was run when the bridge terminated,
1036 * a message aimed at preventing a subsequent hangup exten being run at the pbx_run
1037 * level */
1038 AST_FLAG_BRIDGE_HANGUP_RUN = (1 << 17),
1039 /*! Disable certain workarounds. This reintroduces certain bugs, but allows
1040 * some non-traditional dialplans (like AGI) to continue to function.
1041 */
1042 AST_FLAG_DISABLE_WORKAROUNDS = (1 << 20),
1043 /*!
1044 * Disable device state event caching. This allows channel
1045 * drivers to selectively prevent device state events from being
1046 * cached by certain channels such as anonymous calls which have
1047 * no persistent represenatation that can be tracked.
1048 */
1050 /*!
1051 * This flag indicates that a dual channel redirect is in
1052 * progress. The bridge needs to wait until the flag is cleared
1053 * to continue.
1054 */
1056 /*!
1057 * This flag indicates that the channel was originated.
1058 */
1059 AST_FLAG_ORIGINATED = (1 << 23),
1060 /*!
1061 * The channel is well and truly dead. Once this is set and published, no further
1062 * actions should be taken upon the channel, and no further publications should
1063 * occur.
1064 */
1065 AST_FLAG_DEAD = (1 << 24),
1066 /*!
1067 * Channel snapshot should not be published, it is being staged for an explicit
1068 * publish.
1069 */
1070 AST_FLAG_SNAPSHOT_STAGE = (1 << 25),
1071 /*!
1072 * The data on chan->timingdata is an astobj2 object.
1073 */
1075 /*!
1076 * The channel is executing a subroutine or macro
1077 */
1078 AST_FLAG_SUBROUTINE_EXEC = (1 << 27),
1079};
@ AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT
Definition channel.h:1055
@ AST_FLAG_ZOMBIE
Definition channel.h:1007
@ AST_FLAG_DISABLE_DEVSTATE_CACHE
Definition channel.h:1049
@ AST_FLAG_SNAPSHOT_STAGE
Definition channel.h:1070
@ AST_FLAG_OUTGOING
Definition channel.h:1019
@ AST_FLAG_BRIDGE_HANGUP_RUN
Definition channel.h:1038
@ AST_FLAG_MASQ_NOSTREAM
Definition channel.h:1034
@ AST_FLAG_IN_AUTOLOOP
Definition channel.h:1017
@ AST_FLAG_END_DTMF_ONLY
Definition channel.h:1027
@ AST_FLAG_DEAD
Definition channel.h:1065
@ AST_FLAG_EXCEPTION
Definition channel.h:1009
@ AST_FLAG_EMULATE_DTMF
Definition channel.h:1024
@ AST_FLAG_IN_DTMF
Definition channel.h:1021
@ AST_FLAG_WRITE_INT
Definition channel.h:1003
@ AST_FLAG_DEFER_DTMF
Definition channel.h:1001
@ AST_FLAG_SPYING
Definition channel.h:1013
@ AST_FLAG_DISABLE_WORKAROUNDS
Definition channel.h:1042
@ AST_FLAG_SUBROUTINE_EXEC
Definition channel.h:1078
@ AST_FLAG_ORIGINATED
Definition channel.h:1059
@ AST_FLAG_TIMINGDATA_IS_AO2_OBJ
Definition channel.h:1074
@ AST_FLAG_MOH
Definition channel.h:1011

◆ anonymous enum

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 

Definition at line 1082 of file channel.h.

1082 {
1083 AST_FEATURE_PLAY_WARNING = (1 << 0),
1084 AST_FEATURE_REDIRECT = (1 << 1),
1085 AST_FEATURE_DISCONNECT = (1 << 2),
1086 AST_FEATURE_ATXFER = (1 << 3),
1087 AST_FEATURE_AUTOMON = (1 << 4),
1088 AST_FEATURE_PARKCALL = (1 << 5),
1089 AST_FEATURE_AUTOMIXMON = (1 << 6),
1090};
@ AST_FEATURE_PLAY_WARNING
Definition channel.h:1083

◆ anonymous enum

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_HANGUP_EXEC 

Used to indicate that the channel is currently executing hangup logic in the dialplan. The channel has been hungup when this is set.

AST_SOFTHANGUP_ALL 

All softhangup flags.

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

Definition at line 1136 of file channel.h.

1136 {
1137 /*!
1138 * Soft hangup requested by device or other internal reason.
1139 * Actual hangup needed.
1140 */
1141 AST_SOFTHANGUP_DEV = (1 << 0),
1142 /*!
1143 * Used to break the normal frame flow so an async goto can be
1144 * done instead of actually hanging up.
1145 */
1146 AST_SOFTHANGUP_ASYNCGOTO = (1 << 1),
1147 /*!
1148 * Soft hangup requested by system shutdown. Actual hangup
1149 * needed.
1150 */
1151 AST_SOFTHANGUP_SHUTDOWN = (1 << 2),
1152 /*!
1153 * Used to break the normal frame flow after a timeout so an
1154 * implicit async goto can be done to the 'T' exten if it exists
1155 * instead of actually hanging up. If the exten does not exist
1156 * then actually hangup.
1157 */
1158 AST_SOFTHANGUP_TIMEOUT = (1 << 3),
1159 /*!
1160 * Soft hangup requested by application/channel-driver being
1161 * unloaded. Actual hangup needed.
1162 */
1163 AST_SOFTHANGUP_APPUNLOAD = (1 << 4),
1164 /*!
1165 * Soft hangup requested by non-associated party. Actual hangup
1166 * needed.
1167 */
1168 AST_SOFTHANGUP_EXPLICIT = (1 << 5),
1169 /*!
1170 * Used to indicate that the channel is currently executing hangup
1171 * logic in the dialplan. The channel has been hungup when this is
1172 * set.
1173 */
1174 AST_SOFTHANGUP_HANGUP_EXEC = (1 << 7),
1175 /*!
1176 * \brief All softhangup flags.
1177 *
1178 * This can be used as an argument to ast_channel_clear_softhangup()
1179 * to clear all softhangup flags from a channel.
1180 */
1181 AST_SOFTHANGUP_ALL = (0xFFFFFFFF)
1182};
@ AST_SOFTHANGUP_ASYNCGOTO
Definition channel.h:1146
@ AST_SOFTHANGUP_EXPLICIT
Definition channel.h:1168
@ AST_SOFTHANGUP_DEV
Definition channel.h:1141
@ AST_SOFTHANGUP_HANGUP_EXEC
Definition channel.h:1174
@ AST_SOFTHANGUP_ALL
All softhangup flags.
Definition channel.h:1181
@ AST_SOFTHANGUP_TIMEOUT
Definition channel.h:1158
@ AST_SOFTHANGUP_SHUTDOWN
Definition channel.h:1151
@ AST_SOFTHANGUP_APPUNLOAD
Definition channel.h:1163

◆ ama_flags

enum ama_flags

Channel AMA Flags.

Enumerator
AST_AMA_NONE 
AST_AMA_OMIT 
AST_AMA_BILLING 
AST_AMA_DOCUMENTATION 

Definition at line 1197 of file channel.h.

1197 {
1198 AST_AMA_NONE = 0,
1202};
@ AST_AMA_DOCUMENTATION
Definition channel.h:1201
@ AST_AMA_OMIT
Definition channel.h:1199
@ AST_AMA_NONE
Definition channel.h:1198
@ AST_AMA_BILLING
Definition channel.h:1200

◆ ast_bridge_result

Enumerator
AST_BRIDGE_COMPLETE 
AST_BRIDGE_FAILED 
AST_BRIDGE_FAILED_NOWARN 
AST_BRIDGE_RETRY 

Definition at line 208 of file channel.h.

208 {
212 AST_BRIDGE_RETRY = -3,
213};
@ AST_BRIDGE_FAILED_NOWARN
Definition channel.h:211
@ AST_BRIDGE_RETRY
Definition channel.h:212
@ AST_BRIDGE_COMPLETE
Definition channel.h:209
@ AST_BRIDGE_FAILED
Definition channel.h:210

◆ ast_channel_adsicpe

Enumerator
AST_ADSI_UNKNOWN 
AST_ADSI_AVAILABLE 
AST_ADSI_UNAVAILABLE 
AST_ADSI_OFFHOOKONLY 

Definition at line 888 of file channel.h.

888 {
893};
@ AST_ADSI_UNKNOWN
Definition channel.h:889
@ AST_ADSI_UNAVAILABLE
Definition channel.h:891
@ AST_ADSI_AVAILABLE
Definition channel.h:890
@ AST_ADSI_OFFHOOKONLY
Definition channel.h:892

◆ ast_channel_error

Enumerator
AST_CHANNEL_ERROR_UNKNOWN 
AST_CHANNEL_ERROR_ID_EXISTS 

Definition at line 4918 of file channel.h.

4918 {
4919 /* Unable to determine what error occurred. */
4921 /* Channel with this ID already exists */
4923};

◆ ast_channel_requestor_relationship

Enumerator
AST_CHANNEL_REQUESTOR_BRIDGE_PEER 

The requestor is the future bridge peer of the channel.

AST_CHANNEL_REQUESTOR_REPLACEMENT 

The requestor is to be replaced by the channel.

Definition at line 1523 of file channel.h.

1523 {
1524 /*! The requestor is the future bridge peer of the channel. */
1526 /*! The requestor is to be replaced by the channel. */
1528};

◆ AST_MONITORING_STATE

Enumerator
AST_MONITOR_RUNNING 
AST_MONITOR_PAUSED 

Definition at line 4130 of file channel.h.

4130 {
4133};

◆ AST_PARTY_CHAR_SET

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 244 of file channel.h.

244 {
247 AST_PARTY_CHAR_SET_WITHDRAWN = 2,/* ITU withdrew this enum value. */
255};
@ AST_PARTY_CHAR_SET_UNKNOWN
Definition channel.h:245
@ AST_PARTY_CHAR_SET_ISO8859_4
Definition channel.h:250
@ AST_PARTY_CHAR_SET_WITHDRAWN
Definition channel.h:247
@ AST_PARTY_CHAR_SET_ISO8859_5
Definition channel.h:251
@ AST_PARTY_CHAR_SET_ISO8859_7
Definition channel.h:252
@ AST_PARTY_CHAR_SET_ISO8859_2
Definition channel.h:248
@ AST_PARTY_CHAR_SET_ISO8859_1
Definition channel.h:246
@ AST_PARTY_CHAR_SET_ISO10646_UTF_8STRING
Definition channel.h:254
@ AST_PARTY_CHAR_SET_ISO10646_BMPSTRING
Definition channel.h:253
@ AST_PARTY_CHAR_SET_ISO8859_3
Definition channel.h:249

◆ ast_t38_state

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 898 of file channel.h.

898 {
899 T38_STATE_UNAVAILABLE, /*!< T38 is unavailable on this channel or disabled by configuration */
900 T38_STATE_UNKNOWN, /*!< The channel supports T38 but the current status is unknown */
901 T38_STATE_NEGOTIATING, /*!< T38 is being negotiated */
902 T38_STATE_REJECTED, /*!< Remote side has rejected our offer */
903 T38_STATE_NEGOTIATED, /*!< T38 established */
904};
@ T38_STATE_UNKNOWN
Definition channel.h:900
@ T38_STATE_REJECTED
Definition channel.h:902
@ T38_STATE_NEGOTIATED
Definition channel.h:903
@ T38_STATE_NEGOTIATING
Definition channel.h:901

◆ channelreloadreason

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 
CHANNEL_ACL_RELOAD 

Definition at line 1186 of file channel.h.

1186 {
1192};
@ CHANNEL_CLI_RELOAD
Definition channel.h:1189
@ CHANNEL_MODULE_RELOAD
Definition channel.h:1188
@ CHANNEL_MODULE_LOAD
Definition channel.h:1187
@ CHANNEL_ACL_RELOAD
Definition channel.h:1191
@ CHANNEL_MANAGER_RELOAD
Definition channel.h:1190

Function Documentation

◆ __ast_answer()

int __ast_answer ( struct ast_channel chan,
unsigned int  delay 
)

Answer a channel, with a selectable delay before returning.

Parameters
chanchannel to answer
delaymaximum amount of time to wait for incoming media

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

2730{
2731 int res = 0;
2732 enum ast_channel_state old_state;
2733 SCOPE_TRACE(1, "%s\n", ast_channel_name(chan));
2734
2735 old_state = ast_channel_state(chan);
2736 if ((res = ast_raw_answer(chan))) {
2737 return res;
2738 }
2739
2740 switch (old_state) {
2741 case AST_STATE_RINGING:
2742 case AST_STATE_RING:
2743 /* wait for media to start flowing, but don't wait any longer
2744 * than 'delay' or 500 milliseconds, whichever is longer
2745 */
2746 do {
2748 struct ast_frame *cur;
2749 struct ast_frame *new_frame;
2750 int timeout_ms = MAX(delay, 500);
2751 unsigned int done = 0;
2752 struct timeval start;
2753
2755
2756 start = ast_tvnow();
2757 for (;;) {
2758 int ms = ast_remaining_ms(start, timeout_ms);
2759 ms = ast_waitfor(chan, ms);
2760 if (ms < 0) {
2761 ast_log(LOG_WARNING, "Error condition occurred when polling channel %s for a voice frame: %s\n", ast_channel_name(chan), strerror(errno));
2762 res = -1;
2763 break;
2764 }
2765 if (ms == 0) {
2766 ast_debug(2, "Didn't receive a media frame from %s within %u ms of answering. Continuing anyway\n", ast_channel_name(chan), MAX(delay, 500));
2767 break;
2768 }
2769 cur = ast_read(chan);
2770 if (!cur || ((cur->frametype == AST_FRAME_CONTROL) &&
2771 (cur->subclass.integer == AST_CONTROL_HANGUP))) {
2772 if (cur) {
2773 ast_frfree(cur);
2774 }
2775 res = -1;
2776 ast_debug(2, "Hangup of channel %s detected in answer routine\n", ast_channel_name(chan));
2777 break;
2778 }
2779
2780 if ((new_frame = ast_frisolate(cur)) != cur) {
2781 ast_frfree(cur);
2782 }
2783
2785
2786 /* if a specific delay period was requested, continue
2787 * until that delay has passed. don't stop just because
2788 * incoming media has arrived.
2789 */
2790 if (delay) {
2791 continue;
2792 }
2793
2794 switch (new_frame->frametype) {
2795 /* all of these frametypes qualify as 'media' */
2796 case AST_FRAME_VOICE:
2797 case AST_FRAME_VIDEO:
2798 case AST_FRAME_TEXT:
2801 case AST_FRAME_DTMF_END:
2802 case AST_FRAME_IMAGE:
2803 case AST_FRAME_HTML:
2804 case AST_FRAME_MODEM:
2805 case AST_FRAME_RTCP:
2806 done = 1;
2807 break;
2808 case AST_FRAME_CONTROL:
2809 case AST_FRAME_IAX:
2812 case AST_FRAME_NULL:
2813 case AST_FRAME_CNG:
2814 break;
2815 }
2816
2817 if (done) {
2818 break;
2819 }
2820 }
2821
2822 ast_channel_lock(chan);
2823 while ((cur = AST_LIST_REMOVE_HEAD(&frames, frame_list))) {
2824 if (res == 0) {
2825 ast_queue_frame_head(chan, cur);
2826 }
2827 ast_frfree(cur);
2828 }
2829 ast_channel_unlock(chan);
2830 } while (0);
2831 break;
2832 default:
2833 break;
2834 }
2835
2836 return res;
2837}
#define ast_log
Definition astobj2.c:42
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition channel.c:4312
int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to the head of a channel's frame queue.
Definition channel.c:1176
int ast_waitfor(struct ast_channel *c, int ms)
Wait for input on a channel.
Definition channel.c:3200
int ast_raw_answer(struct ast_channel *chan)
Answer a channel.
Definition channel.c:2724
#define ast_channel_lock(chan)
Definition channel.h:2989
#define ast_channel_unlock(chan)
Definition channel.h:2990
@ AST_STATE_RING
@ AST_STATE_RINGING
#define SCOPE_TRACE(__level,...)
#define ast_frisolate(fr)
Makes a frame independent of any static storage.
#define ast_frfree(fr)
@ AST_FRAME_DTMF_END
@ AST_FRAME_DTMF_BEGIN
@ AST_FRAME_BRIDGE_ACTION_SYNC
@ AST_FRAME_TEXT_DATA
@ AST_FRAME_CONTROL
@ AST_FRAME_BRIDGE_ACTION
@ AST_CONTROL_HANGUP
#define ast_debug(level,...)
Log a DEBUG message.
#define LOG_WARNING
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
int errno
static int frames
Definition parser.c:51
enum ast_frame_type frametype
int done
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
Definition utils.c:2315
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition time.h:159
#define MAX(a, b)
Definition utils.h:254

References ast_channel_lock, ast_channel_name(), ast_channel_unlock, AST_CONTROL_HANGUP, ast_debug, AST_FRAME_BRIDGE_ACTION, AST_FRAME_BRIDGE_ACTION_SYNC, 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_RTCP, AST_FRAME_TEXT, AST_FRAME_TEXT_DATA, 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(), done, errno, frames, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, MAX, SCOPE_TRACE, and ast_frame::subclass.

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

◆ __ast_channel_alloc()

struct ast_channel * __ast_channel_alloc ( int  needqueue,
int  state,
const char *  cid_num,
const char *  cid_name,
const char *  acctcode,
const char *  exten,
const char *  context,
const struct ast_assigned_ids assignedids,
const struct ast_channel requestor,
enum ama_flags  amaflag,
struct ast_endpoint endpoint,
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.
Since 12.0.0 this function returns with the newly created channel locked.

Definition at line 967 of file channel.c.

974{
975 va_list ap;
976 struct ast_channel *result;
977
978 va_start(ap, name_fmt);
979 result = __ast_channel_alloc_ap(needqueue, state, cid_num, cid_name, acctcode, exten, context,
980 assignedids, requestor, amaflag, endpoint, NULL, file, line, function, name_fmt, ap);
981 va_end(ap);
982
983 return result;
984}
static PGresult * result
Definition cel_pgsql.c:84
static struct ast_channel * __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 struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, enum ama_flags amaflag, struct ast_endpoint *endpoint, struct ast_channel_initializers *initializers, const char *file, int line, const char *function, const char *name_fmt, va_list ap)
Create a new channel structure.
Definition channel.c:746

References __ast_channel_alloc_ap(), ast_channel::context, ast_channel::endpoint, ast_channel::exten, NULL, and result.

◆ __ast_channel_alloc_with_initializers()

struct ast_channel * __ast_channel_alloc_with_initializers ( int  needqueue,
int  state,
const char *  cid_num,
const char *  cid_name,
const char *  acctcode,
const char *  exten,
const char *  context,
const struct ast_assigned_ids assignedids,
const struct ast_channel requestor,
enum ama_flags  amaflag,
struct ast_endpoint endpoint,
struct ast_channel_initializers initializers,
const char *  file,
int  line,
const char *  function,
const char *  name_fmt,
  ... 
)

Create a channel structure.

Since
18.25.0
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.
Same as __ast_channel_alloc but with ast_channel_initializers struct.

Definition at line 986 of file channel.c.

993{
994 va_list ap;
995 struct ast_channel *result;
996
997 va_start(ap, name_fmt);
998 result = __ast_channel_alloc_ap(needqueue, state, cid_num, cid_name, acctcode, exten, context,
999 assignedids, requestor, amaflag, endpoint, initializers, file, line, function, name_fmt, ap);
1000 va_end(ap);
1001
1002 return result;
1003}

References __ast_channel_alloc_ap(), ast_channel::context, ast_channel::endpoint, ast_channel::exten, and result.

◆ __ast_dummy_channel_alloc()

struct ast_channel * __ast_dummy_channel_alloc ( const char *  file,
int  line,
const char *  function 
)

Definition at line 1007 of file channel.c.

1008{
1009 struct ast_channel *tmp;
1010 struct varshead *headp;
1011
1013 file, line, function);
1014 if (!tmp) {
1015 /* Dummy channel structure allocation failure. */
1016 return NULL;
1017 }
1018
1021
1022 /*
1023 * Init file descriptors to unopened state just in case
1024 * autoservice is called on the channel or something tries to
1025 * read a frame from it.
1026 */
1027 ast_channel_timingfd_set(tmp, -1);
1030
1032
1034
1035 headp = ast_channel_varshead(tmp);
1037
1038 return tmp;
1039}
static void ast_dummy_channel_destructor(void *obj)
Free a dummy channel structure.
Definition channel.c:2324
struct ast_channel * __ast_channel_internal_alloc(void(*destructor)(void *obj), const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *file, int line, const char *function)
int ast_channel_internal_setup_topics(struct ast_channel *chan)
@ AST_CONTROL_UNHOLD
void ast_pbx_hangup_handler_init(struct ast_channel *chan)
Init the hangup handler container on a channel.

References __ast_channel_internal_alloc(), ast_channel_datastores(), ast_channel_hold_state_set(), ast_channel_internal_alertpipe_clear(), ast_channel_internal_fd_clear_all(), ast_channel_internal_setup_topics(), ast_channel_timingfd_set(), ast_channel_varshead(), AST_CONTROL_UNHOLD, ast_dummy_channel_destructor(), AST_LIST_HEAD_INIT_NOLOCK, ast_pbx_hangup_handler_init(), and NULL.

◆ __ast_request_and_dial()

struct ast_channel * __ast_request_and_dial ( const char *  type,
struct ast_format_cap cap,
const struct ast_assigned_ids assignedids,
const struct ast_channel requestor,
const char *  addr,
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
capformat capabilities for requested channel
assignedidsUnique Id to assign to channel
requestorchannel requesting data
addrdestination of the call
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 6033 of file channel.c.

6034{
6035 int dummy_outstate;
6036 int cause = 0;
6037 struct ast_channel *chan;
6038 int res = 0;
6039 int last_subclass = 0;
6041
6042 if (outstate)
6043 *outstate = 0;
6044 else
6045 outstate = &dummy_outstate; /* make outstate always a valid pointer */
6046
6047 chan = ast_request(type, cap, assignedids, requestor, addr, &cause);
6048 if (!chan) {
6049 ast_log(LOG_NOTICE, "Unable to request channel %s/%s\n", type, addr);
6050 handle_cause(cause, outstate);
6051 return NULL;
6052 }
6053
6054 if (oh) {
6055 if (oh->vars) {
6056 ast_channel_lock(chan);
6057 ast_set_variables(chan, oh->vars);
6058 ast_channel_unlock(chan);
6059 }
6060 if (!ast_strlen_zero(oh->cid_num) && !ast_strlen_zero(oh->cid_name)) {
6061 /*
6062 * Use the oh values instead of the function parameters for the
6063 * outgoing CallerID.
6064 */
6065 cid_num = oh->cid_num;
6066 cid_name = oh->cid_name;
6067 }
6068 if (oh->parent_channel) {
6069 /* Safely inherit variables and datastores from the parent channel. */
6075 ast_channel_unlock(chan);
6076 }
6077 if (!ast_strlen_zero(oh->account)) {
6078 ast_channel_lock(chan);
6080 ast_channel_accountcode_set(chan, oh->account);
6081 ast_channel_peeraccount_set(chan, oh->account);
6083 ast_channel_unlock(chan);
6084 }
6085 }
6086
6087 /*
6088 * It seems strange to set the CallerID on an outgoing call leg
6089 * to whom we are calling, but this function's callers are doing
6090 * various Originate methods. This call leg goes to the local
6091 * user. Once the local user answers, the dialplan needs to be
6092 * able to access the CallerID from the CALLERID function as if
6093 * the local user had placed this call.
6094 */
6095 ast_set_callerid(chan, cid_num, cid_name, cid_num);
6096
6097 ast_channel_lock(chan);
6099 ast_channel_unlock(chan);
6101 if (cid_num) {
6102 connected.id.number.valid = 1;
6103 connected.id.number.str = (char *) cid_num;
6105 }
6106 if (cid_name) {
6107 connected.id.name.valid = 1;
6108 connected.id.name.str = (char *) cid_name;
6110 }
6112 if (requestor) {
6113 ast_channel_lock_both(chan, (struct ast_channel *) requestor);
6115 ast_channel_unlock(chan);
6116 ast_channel_unlock((struct ast_channel *) requestor);
6117 }
6118
6119 if (ast_call(chan, addr, 0)) { /* ast_call failed... */
6120 ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, addr);
6121 } else {
6122 struct timeval start = ast_tvnow();
6123 res = 1; /* mark success in case chan->_state is already AST_STATE_UP */
6124 while (timeout && ast_channel_state(chan) != AST_STATE_UP) {
6125 struct ast_frame *f;
6126 int ms = ast_remaining_ms(start, timeout);
6127
6128 res = ast_waitfor(chan, ms);
6129 if (res == 0) { /* timeout, treat it like ringing */
6130 *outstate = AST_CONTROL_RINGING;
6131 break;
6132 }
6133 if (res < 0) /* error or done */
6134 break;
6136 if (!(chan = ast_call_forward(NULL, chan, NULL, cap, oh, outstate))) {
6137 return NULL;
6138 }
6139 continue;
6140 }
6141
6142 f = ast_read(chan);
6143 if (!f) {
6144 *outstate = AST_CONTROL_HANGUP;
6145 res = 0;
6146 break;
6147 }
6148 if (f->frametype == AST_FRAME_CONTROL) {
6149 switch (f->subclass.integer) {
6150 case AST_CONTROL_RINGING: /* record but keep going */
6151 *outstate = f->subclass.integer;
6152 break;
6153
6154 case AST_CONTROL_BUSY:
6155 *outstate = f->subclass.integer;
6156 timeout = 0;
6157 break;
6158
6160 *outstate = AST_CONTROL_CONGESTION;
6161 timeout = 0;
6162 break;
6163
6165 *outstate = f->subclass.integer;
6166 timeout = 0;
6167 break;
6168
6169 case AST_CONTROL_ANSWER:
6170 *outstate = f->subclass.integer;
6171 timeout = 0; /* trick to force exit from the while() */
6172 break;
6173
6176 break;
6177
6179 if (oh && oh->connect_on_early_media) {
6180 *outstate = f->subclass.integer;
6181 timeout = 0; /* trick to force exit from the while() */
6182 break;
6183 }
6184 /* Fallthrough */
6185 /* Ignore these */
6187 case AST_CONTROL_HOLD:
6188 case AST_CONTROL_UNHOLD:
6194 case AST_CONTROL_CC:
6195 case -1: /* Ignore -- just stopping indications */
6196 break;
6197
6198 default:
6199 ast_log(LOG_NOTICE, "Don't know what to do with control frame %d\n", f->subclass.integer);
6200 }
6201 last_subclass = f->subclass.integer;
6202 }
6203 ast_frfree(f);
6204 }
6205 }
6206
6207 /* Final fixups */
6208 if (oh) {
6209 if (!ast_strlen_zero(oh->context))
6211 if (!ast_strlen_zero(oh->exten))
6212 ast_channel_exten_set(chan, oh->exten);
6213 if (oh->priority)
6215 }
6216 if (ast_channel_state(chan) == AST_STATE_UP)
6217 *outstate = AST_CONTROL_ANSWER;
6218
6219 if (res <= 0) {
6220 ast_channel_lock(chan);
6221 if (AST_CONTROL_RINGING == last_subclass) {
6223 }
6224 ast_channel_unlock(chan);
6225 ast_hangup(chan);
6226 chan = NULL;
6227 }
6228 return chan;
6229}
#define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED
Definition callerid.h:437
#define AST_CAUSE_NO_ANSWER
Definition causes.h:109
int ast_call(struct ast_channel *chan, const char *addr, int timeout)
Make a call.
Definition channel.c:6518
static void handle_cause(int cause, int *outstate)
Definition channel.c:5906
struct ast_channel * ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, struct ast_format_cap *cap, struct outgoing_helper *oh, int *outstate)
Forwards a call to a new channel specified by the original channel's call_forward str....
Definition channel.c:5955
void ast_hangup(struct ast_channel *chan)
Hangup a channel.
Definition channel.c:2574
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:8414
void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars)
adds a list of channel variables to a channel
Definition channel.c:8221
int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to)
Inherit datastores from a parent to a child.
Definition channel.c:2359
void ast_channel_req_accountcodes(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship)
Setup new channel accountcodes from the requestor channel after ast_request().
Definition channel.c:6491
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:7408
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:6833
void ast_channel_hangupcause_hash_set(struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen)
Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash on the given channel.
Definition channel.c:4402
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:2032
struct ast_channel * ast_request(const char *type, struct ast_format_cap *request_cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
Requests a channel.
Definition channel.c:6411
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition channel.h:2996
@ AST_STATE_UP
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
@ AST_CONTROL_SRCUPDATE
@ AST_CONTROL_PROGRESS
@ AST_CONTROL_VIDUPDATE
@ AST_CONTROL_PROCEEDING
@ AST_CONTROL_REDIRECTING
@ AST_CONTROL_CONGESTION
@ AST_CONTROL_ANSWER
@ AST_CONTROL_RINGING
@ AST_CONTROL_CONNECTED_LINE
@ AST_CONTROL_SRCCHANGE
@ AST_CONTROL_INCOMPLETE
@ AST_CONTROL_PVT_CAUSE_CODE
#define LOG_NOTICE
int ast_max_forwards_decrement(struct ast_channel *chan)
Decrement the max forwards count for a particular channel.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition strings.h:65
const char * cid_num
Definition channel.h:1129
struct ast_variable * vars
Definition channel.h:1132
int connect_on_early_media
Definition channel.h:1128
const char * account
Definition channel.h:1131
const char * cid_name
Definition channel.h:1130
const char * exten
Definition channel.h:1126
const char * context
Definition channel.h:1125
struct ast_channel * parent_channel
Definition channel.h:1133
#define ast_set_flag(p, flag)
Definition utils.h:71

References outgoing_helper::account, ast_call(), ast_call_forward(), AST_CAUSE_NO_ANSWER, ast_channel_call_forward(), ast_channel_connected(), ast_channel_context_set(), ast_channel_datastore_inherit(), ast_channel_exten_set(), ast_channel_flags(), ast_channel_hangupcause_hash_set(), ast_channel_hangupcause_set(), ast_channel_inherit_variables(), ast_channel_lock, ast_channel_lock_both, ast_channel_priority_set(), ast_channel_req_accountcodes(), AST_CHANNEL_REQUESTOR_BRIDGE_PEER, ast_channel_set_connected_line(), ast_channel_stage_snapshot(), ast_channel_stage_snapshot_done(), 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_PVT_CAUSE_CODE, AST_CONTROL_REDIRECTING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_CONTROL_UNHOLD, AST_CONTROL_VIDUPDATE, AST_FLAG_ORIGINATED, AST_FRAME_CONTROL, ast_frfree, ast_hangup(), ast_log, ast_max_forwards_decrement(), 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(), outgoing_helper::cid_name, outgoing_helper::cid_num, outgoing_helper::connect_on_early_media, connected, outgoing_helper::context, ast_frame::data, ast_frame::datalen, outgoing_helper::exten, ast_frame::frametype, handle_cause(), ast_frame_subclass::integer, LOG_NOTICE, NULL, outgoing_helper::parent_channel, outgoing_helper::priority, ast_frame::ptr, ast_frame::subclass, type, and outgoing_helper::vars.

Referenced by announce_to_dial(), and ast_request_and_dial().

◆ ast_activate_generator()

int ast_activate_generator ( struct ast_channel chan,
struct ast_generator gen,
void *  params 
)

Activate a given generator

Definition at line 2989 of file channel.c.

2990{
2991 int res = 0;
2992 void *generatordata = NULL;
2993
2994 ast_channel_lock(chan);
2995 if (ast_channel_generatordata(chan)) {
2996 struct ast_generator *generator_old = ast_channel_generator(chan);
2997
2998 if (generator_old && generator_old->release) {
2999 generator_old->release(chan, ast_channel_generatordata(chan));
3000 }
3001 }
3002 if (gen->alloc && !(generatordata = gen->alloc(chan, params))) {
3003 res = -1;
3004 }
3005 ast_channel_generatordata_set(chan, generatordata);
3006 if (!res) {
3007 ast_settimeout(chan, 50, generator_force, chan);
3009 }
3010 ast_channel_unlock(chan);
3011
3012 ast_prod(chan);
3013
3014 return res;
3015}
int ast_prod(struct ast_channel *chan)
Send empty audio to prime a channel driver.
Definition channel.c:5057
static int generator_force(const void *data)
Definition channel.c:2954
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:3218
void *(* alloc)(struct ast_channel *chan, void *params)
Definition channel.h:228
void(* release)(struct ast_channel *chan, void *data)
Definition channel.h:230

References ast_generator::alloc, ast_channel_generator(), ast_channel_generator_set(), ast_channel_generatordata(), ast_channel_generatordata_set(), ast_channel_lock, ast_channel_unlock, ast_prod(), ast_settimeout(), gen, generator_force(), ast_channel::generatordata, NULL, and ast_generator::release.

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

◆ ast_active_channels()

int ast_active_channels ( void  )

returns number of active/allocated channels

Returns
number of channels available for lookup

Definition at line 500 of file channel.c.

501{
503}
struct ast_channelstorage_instance * current_channel_storage_instance
The current channel storage instance.
#define CHANNELSTORAGE_API(_instance, _func,...)
static int active_channels(struct ast_channelstorage_instance *driver, int rdlock)
returns number of active/allocated channels

References active_channels(), CHANNELSTORAGE_API, and current_channel_storage_instance.

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

◆ ast_add_fd()

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 2886 of file channel.h.

2887{
2888 pfd->fd = fd;
2889 pfd->events = POLLIN | POLLPRI;
2890 return fd >= 0;
2891}

Referenced by ast_waitfor_nandfds().

◆ ast_answer()

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

2840{
2841 SCOPE_TRACE(1, "%s\n", ast_channel_name(chan));
2842 return __ast_answer(chan, 0);
2843}
int __ast_answer(struct ast_channel *chan, unsigned int delay)
Answer a channel, with a selectable delay before returning.
Definition channel.c:2729

References __ast_answer(), ast_channel_name(), and SCOPE_TRACE.

Referenced by agent_login_exec(), agi_exec_full(), alarmreceiver_exec(), announce_request(), app_exec(), app_exec(), ast_auto_answer(), ast_bridge_add_channel(), ast_do_pickup(), ast_pickup_call(), auth_exec(), background_detect_exec(), bridge_channel_handle_control(), bridge_parking_push(), bridgeadd_exec(), bridgewait_exec(), common_exec(), conf_exec(), conf_start_record(), confbridge_exec(), count_exec(), dial_exec_full(), dictate_exec(), directory_exec(), disa_exec(), eivr_comm(), handle_answer(), leave_voicemail(), local_call(), media_request_helper(), minivm_accmess_exec(), minivm_greet_exec(), minivm_record_exec(), old_milliwatt_exec(), park_app_exec(), parked_call_app_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(), vm_exec(), vm_execmain(), vm_playmsgexec(), waitfor_exec(), and zapateller_exec().

◆ ast_auto_answer()

int ast_auto_answer ( struct ast_channel chan)
inline

Answer a channel, if it's not already answered.

Parameters
chanchannel to answer

See ast_answer()

Return values
0on success
non-zeroon failure

Definition at line 2845 of file channel.c.

2846{
2847 if (ast_channel_state(chan) == AST_STATE_UP) {
2848 /* Already answered */
2849 return 0;
2850 }
2851 return ast_answer(chan);
2852}
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition channel.c:2839

References ast_answer(), and AST_STATE_UP.

Referenced by record_file(), and senddtmf_exec().

◆ ast_autoservice_chan_hangup_peer()

void ast_autoservice_chan_hangup_peer ( struct ast_channel chan,
struct ast_channel peer 
)

Put chan into autoservice while hanging up peer.

Since
11.0
Parameters
chanChan to put into autoservice.
peerChan to run hangup handlers and hangup.

Definition at line 349 of file autoservice.c.

350{
351 if (chan && !ast_autoservice_start(chan)) {
352 ast_hangup(peer);
354 } else {
355 ast_hangup(peer);
356 }
357}
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...

References ast_autoservice_start(), ast_autoservice_stop(), and ast_hangup().

Referenced by app_exec(), bridge_failed_peer_goto(), dial_exec_full(), and try_calling().

◆ ast_autoservice_ignore()

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 359 of file autoservice.c.

360{
361 struct asent *as;
362 int res = -1;
363
366 if (as->chan == chan) {
367 res = 0;
368 as->ignore_frame_types |= (1 << ftype);
369 break;
370 }
371 }
373 return res;
374}
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_LOCK(head)
Locks a list.
Definition linkedlists.h:40
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
unsigned int ignore_frame_types
Definition autoservice.c:62
struct asent::@324 list
struct ast_channel * chan
Definition autoservice.c:55

References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, asent::chan, asent::ignore_frame_types, and asent::list.

◆ ast_autoservice_start()

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 200 of file autoservice.c.

201{
202 int res = 0;
203 struct asent *as;
204
206 /* User interface threads do not handle channel media. */
207 ast_debug(1, "Thread is a user interface, not putting channel %s into autoservice\n",
209 return 0;
210 }
211
214 if (as->chan == chan) {
215 as->use_count++;
216 break;
217 }
218 }
220
221 if (as) {
222 /* Entry exists, autoservice is already handling this channel */
223 return 0;
224 }
225
226 if (!(as = ast_calloc(1, sizeof(*as))))
227 return -1;
228
229 /* New entry created */
230 as->chan = chan;
231 as->use_count = 1;
232
235 if (!as->orig_end_dtmf_flag)
238
240
243 }
244
246
247 if (asthread == AST_PTHREADT_NULL) { /* need start the thread */
249 ast_log(LOG_WARNING, "Unable to create autoservice thread :(\n");
250 /* There will only be a single member in the list at this point,
251 the one we just added. */
253 ast_free(as);
255 res = -1;
256 } else {
257 pthread_kill(asthread, SIGURG);
258 }
259 }
260
262
263 return res;
264}
#define ast_free(a)
Definition astmm.h:180
#define ast_calloc(num, len)
A wrapper for calloc()
Definition astmm.h:202
static void * autoservice_run(void *ign)
Definition autoservice.c:78
static ast_cond_t as_cond
Definition autoservice.c:71
static pthread_t asthread
Definition autoservice.c:73
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
#define AST_PTHREADT_NULL
Definition lock.h:73
#define ast_cond_signal(cond)
Definition lock.h:210
unsigned int use_count
Definition autoservice.c:59
unsigned int orig_end_dtmf_flag
Definition autoservice.c:60
int ast_thread_is_user_interface(void)
Indicates whether the current thread is a user interface.
Definition utils.c:3282
#define ast_pthread_create_background(a, b, c, d)
Definition utils.h:632

References as_cond, ast_calloc, ast_channel_flags(), ast_channel_lock, ast_channel_name(), ast_channel_unlock, ast_cond_signal, ast_debug, AST_FLAG_END_DTMF_ONLY, ast_free, 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, ast_thread_is_user_interface(), asthread, autoservice_run(), asent::chan, asent::list, LOG_WARNING, NULL, asent::orig_end_dtmf_flag, and asent::use_count.

Referenced by acf_curl_helper(), acf_jabberreceive_read(), acf_odbc_read(), acf_odbc_write(), action_toggle_mute_participants(), app_exec(), ast_app_exec_sub(), ast_audiosocket_connect(), ast_autoservice_chan_hangup_peer(), ast_dtmf_stream(), ast_get_enum(), ast_get_srv(), ast_get_txt(), ast_mf_stream(), ast_sf_stream(), begin_dial_prerun(), conf_play(), confbridge_exec(), dial_exec_full(), exec(), findmeexec(), function_realtime_read(), function_realtime_readdestroy(), function_realtime_store(), function_realtime_write(), join_conference_bridge(), lock_read(), lua_autoservice_start(), lua_get_variable_value(), lua_pbx_exec(), lua_set_variable(), lua_set_variable_value(), mf_stream(), originate_exec(), pbx_find_extension(), playback_common(), post_join_play_begin(), push_announcer(), realtimefield_read(), reload_exec(), ring_one(), sf_stream(), shell_helper(), smdi_msg_retrieve_read(), srv_datastore_setup(), system_exec_helper(), try_calling(), and trylock_read().

◆ ast_autoservice_stop()

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 266 of file autoservice.c.

267{
268 int res = -1;
269 struct asent *as, *removed = NULL;
270 struct ast_frame *f;
271 int chan_list_state;
272
274 /* User interface threads do not handle channel media. */
275 ast_debug(1, "Thread is a user interface, not removing channel %s from autoservice\n",
276 ast_channel_name(chan));
277 return 0;
278 }
279
281
282 /* Save the autoservice channel list state. We _must_ verify that the channel
283 * list has been rebuilt before we return. Because, after we return, the channel
284 * could get destroyed and we don't want our poor autoservice thread to step on
285 * it after its gone! */
286 chan_list_state = as_chan_list_state;
287
288 /* Find the entry, but do not free it because it still can be in the
289 autoservice thread array */
291 if (as->chan == chan) {
292 as->use_count--;
293 if (as->use_count < 1) {
295 removed = as;
296 }
297 break;
298 }
299 }
301
302 if (removed && asthread != AST_PTHREADT_NULL) {
303 pthread_kill(asthread, SIGURG);
304 }
305
307
308 if (!removed) {
309 return 0;
310 }
311
312 if (asthread != AST_PTHREADT_NULL && pthread_equal(pthread_self(), asthread)) {
313 /* Do not sleep if ast_autoservice_stop is called within the autoservice thread,
314 otherwise the thread will be stuck in an endless sleep. */
315 ast_debug(1, "ast_autoservice_stop is called within the autoservice thread, channel %s\n",
316 ast_channel_name(chan));
317 } else {
318 /* Wait while autoservice thread rebuilds its list. */
319 while (chan_list_state == as_chan_list_state) {
320 usleep(1000);
321 }
322 }
323
324 /* Now autoservice thread should have no references to our entry
325 and we can safely destroy it */
326
328 res = 0;
329 }
330
331 ast_channel_lock(chan);
332 if (!as->orig_end_dtmf_flag) {
334 }
335
336 while ((f = AST_LIST_REMOVE_HEAD(&as->deferred_frames, frame_list))) {
337 if (!((1 << f->frametype) & as->ignore_frame_types)) {
338 ast_queue_frame_head(chan, f);
339 }
340 ast_frfree(f);
341 }
342 ast_channel_unlock(chan);
343
344 ast_free(as);
345
346 return res;
347}
static int as_chan_list_state
Definition autoservice.c:76
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.
Definition channel.c:1176
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
struct asent::@323 deferred_frames
#define ast_clear_flag(p, flag)
Definition utils.h:78

References as_chan_list_state, ast_channel_flags(), ast_channel_lock, ast_channel_name(), ast_channel_softhangup_internal_flag(), ast_channel_unlock, ast_clear_flag, ast_debug, AST_FLAG_END_DTMF_ONLY, ast_free, 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(), ast_thread_is_user_interface(), asthread, asent::chan, asent::deferred_frames, ast_frame::frametype, asent::ignore_frame_types, NULL, asent::orig_end_dtmf_flag, and asent::use_count.

Referenced by acf_curl_helper(), acf_jabberreceive_read(), acf_odbc_read(), acf_odbc_write(), action_toggle_mute_participants(), app_exec(), array(), ast_app_exec_sub(), ast_audiosocket_connect(), ast_autoservice_chan_hangup_peer(), ast_dtmf_stream(), ast_get_enum(), ast_get_srv(), ast_get_txt(), ast_hangup(), ast_mf_stream(), ast_sf_stream(), begin_dial_prerun(), conf_play(), confbridge_exec(), dial_exec_full(), exec(), findmeexec(), function_realtime_read(), function_realtime_readdestroy(), function_realtime_store(), function_realtime_write(), hangup_playback(), join_conference_bridge(), lock_read(), lua_autoservice_stop(), lua_get_variable_value(), lua_pbx_exec(), lua_set_variable(), lua_set_variable_value(), mf_stream(), originate_exec(), pbx_find_extension(), playback_common(), post_join_play_begin(), realtimefield_read(), reload_exec(), ring_one(), sf_stream(), shell_helper(), smdi_msg_retrieve_read(), srv_datastore_setup(), system_exec_helper(), try_calling(), and trylock_read().

◆ ast_call()

int ast_call ( struct ast_channel chan,
const 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
timeouttime to wait on for connect (Doesn't seem to be used.)

Place a call, take no longer than timeout ms.

Return values
0on success
-1on failure

Definition at line 6518 of file channel.c.

6519{
6520 /* Place an outgoing call, but don't wait any longer than timeout ms before returning.
6521 If the remote end does not answer within the timeout, then do NOT hang up, but
6522 return anyway. */
6523 int res = -1;
6524 /* Stop if we're a zombie or need a soft hangup */
6525 ast_channel_lock(chan);
6527 if (ast_channel_tech(chan)->call)
6528 res = ast_channel_tech(chan)->call(chan, addr, timeout);
6530 }
6531 ast_channel_unlock(chan);
6532 return res;
6533}
static int call(void *data)
int ast_check_hangup(struct ast_channel *chan)
Checks to see if a channel is needing hang up.
Definition channel.c:446
int(*const call)(struct ast_channel *chan, const char *addr, int timeout)
Make a call.
Definition channel.h:721

References ast_channel_flags(), ast_channel_lock, ast_channel_unlock, ast_check_hangup(), AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, ast_set_flag, ast_test_flag, call(), and ast_channel_tech::call.

Referenced by __ast_request_and_dial(), app_control_dial(), ast_call_forward(), attended_transfer_bridge(), begin_dial_channel(), blind_transfer_bridge(), dial_exec_full(), do_forward(), feature_attended_transfer(), findmeexec(), park_local_transfer(), retransfer_enter(), ring_entry(), and wait_for_answer().

◆ ast_call_forward()

struct ast_channel * ast_call_forward ( struct ast_channel caller,
struct ast_channel orig,
int *  timeout,
struct ast_format_cap cap,
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
capformat capabilities for requested channel
ohoutgoing helper used with original channel
outstatereason why unsuccessful (if unsuccessful)
Returns
Returns the forwarded call's ast_channel on success or NULL on failure

Definition at line 5955 of file channel.c.

5956{
5957 char tmpchan[256];
5958 char forwarder[AST_CHANNEL_NAME];
5959 struct ast_channel *new_chan = NULL;
5960 char *data, *type;
5961 int cause = 0;
5962 int res;
5963
5964 /* gather data and request the new forward channel */
5965 ast_copy_string(tmpchan, ast_channel_call_forward(orig), sizeof(tmpchan));
5966 ast_copy_string(forwarder, ast_channel_name(orig), sizeof(forwarder));
5967 if ((data = strchr(tmpchan, '/'))) {
5968 *data++ = '\0';
5969 type = tmpchan;
5970 } else {
5971 const char *forward_context;
5972 ast_channel_lock(orig);
5973 forward_context = pbx_builtin_getvar_helper(orig, "FORWARD_CONTEXT");
5974 snprintf(tmpchan, sizeof(tmpchan), "%s@%s", ast_channel_call_forward(orig), S_OR(forward_context, ast_channel_context(orig)));
5975 ast_channel_unlock(orig);
5976 data = tmpchan;
5977 type = "Local";
5978 }
5979 if (!(new_chan = ast_request(type, cap, NULL, orig, data, &cause))) {
5980 ast_log(LOG_NOTICE, "Unable to create channel for call forward to '%s/%s' (cause = %d)\n", type, data, cause);
5981 handle_cause(cause, outstate);
5982 ast_hangup(orig);
5983 return NULL;
5984 }
5985
5986 /* Copy/inherit important information into new channel */
5987 if (oh) {
5988 if (oh->vars) {
5989 ast_channel_lock(new_chan);
5990 ast_set_variables(new_chan, oh->vars);
5991 ast_channel_unlock(new_chan);
5992 }
5993 if (oh->parent_channel) {
5994 call_forward_inherit(new_chan, oh->parent_channel, orig);
5995 }
5996 if (!ast_strlen_zero(oh->account)) {
5997 ast_channel_lock(new_chan);
5999 ast_channel_accountcode_set(new_chan, oh->account);
6000 ast_channel_peeraccount_set(new_chan, oh->account);
6002 ast_channel_unlock(new_chan);
6003 }
6004 } else if (caller) { /* no outgoing helper so use caller if available */
6005 call_forward_inherit(new_chan, caller, orig);
6006 }
6007
6008 ast_channel_lock_both(orig, new_chan);
6010 pbx_builtin_setvar_helper(new_chan, "FORWARDERNAME", forwarder);
6014 ast_channel_unlock(new_chan);
6015 ast_channel_unlock(orig);
6016
6017 /* call new channel */
6018 res = ast_call(new_chan, data, 0);
6019 if (timeout) {
6020 *timeout = res;
6021 }
6022 if (res) {
6023 ast_log(LOG_NOTICE, "Unable to call forward to channel %s/%s\n", type, (char *)data);
6024 ast_hangup(orig);
6025 ast_hangup(new_chan);
6026 return NULL;
6027 }
6028 ast_hangup(orig);
6029
6030 return new_chan;
6031}
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:2018
static void call_forward_inherit(struct ast_channel *new_chan, struct ast_channel *parent, struct ast_channel *orig)
Definition channel.c:5927
void ast_channel_set_flag(struct ast_channel *chan, unsigned int flag)
Set a flag on a channel.
Definition channel.c:11137
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:2122
#define AST_CHANNEL_NAME
Definition channel.h:173
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
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.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
Definition strings.h:80
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition strings.h:425

References outgoing_helper::account, ast_call(), ast_channel_call_forward(), ast_channel_connected(), ast_channel_context(), ast_channel_lock, ast_channel_lock_both, AST_CHANNEL_NAME, ast_channel_name(), ast_channel_redirecting(), ast_channel_req_accountcodes(), AST_CHANNEL_REQUESTOR_REPLACEMENT, ast_channel_set_flag(), ast_channel_stage_snapshot(), ast_channel_stage_snapshot_done(), ast_channel_unlock, ast_copy_string(), AST_FLAG_ORIGINATED, ast_hangup(), ast_log, ast_party_connected_line_copy(), ast_party_redirecting_copy(), ast_request(), ast_set_variables(), ast_strlen_zero(), call_forward_inherit(), ast_channel::caller, ast_channel::data, handle_cause(), LOG_NOTICE, NULL, outgoing_helper::parent_channel, pbx_builtin_getvar_helper(), pbx_builtin_setvar_helper(), S_OR, type, and outgoing_helper::vars.

Referenced by __ast_request_and_dial().

◆ ast_cause2str()

const char * ast_cause2str ( int  cause)

Gives the string form of a given cause code.

Parameters
causecause 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 613 of file channel.c.

614{
615 int x;
616
617 for (x = 0; x < ARRAY_LEN(causes); x++) {
618 if (causes[x].cause == cause)
619 return causes[x].desc;
620 }
621
622 return "Unknown";
623}
static const struct causes_map causes[]
Definition channel.c:137
const char * desc
Definition channel.c:134
#define ARRAY_LEN(a)
Definition utils.h:706

References ARRAY_LEN, causes, and causes_map::desc.

Referenced by _websocket_request_hangup(), bridge_dissolve(), channel_destroyed_event(), channel_state_change(), dial_exec_full(), findmeexec(), hangupcause_read(), and rfc3326_add_reason_header().

◆ ast_change_name()

void ast_change_name ( struct ast_channel chan,
const char *  newname 
)

Change channel name.

Precondition
Absolutely all channels and the channel storage backend MUST be unlocked before calling this function.
Parameters
chanthe channel to change the name of
newnamethe name to change to
Note
this function must NEVER be used when any channels or the channel storage backend 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 6821 of file channel.c.

6822{
6823 /* We must re-link, as the hash value will change here. */
6825 ast_channel_lock(chan);
6827 __ast_change_name_nolink(chan, newname);
6829 ast_channel_unlock(chan);
6831}
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:6799
#define remove

References __ast_change_name_nolink(), ast_channel_lock, ast_channel_unlock, CHANNELSTORAGE_API, current_channel_storage_instance, and remove.

◆ ast_channel__bridge()

struct ast_channel * ast_channel__bridge ( const struct ast_channel chan)

◆ ast_channel__bridge_set()

void ast_channel__bridge_set ( struct ast_channel chan,
struct ast_channel value 
)

◆ ast_channel_accountcode()

const char * ast_channel_accountcode ( const struct ast_channel chan)

◆ ast_channel_adsicpe()

enum ast_channel_adsicpe ast_channel_adsicpe ( const struct ast_channel chan)

Definition at line 648 of file channel_internal_api.c.

649{
650 return chan->adsicpe;
651}
enum ast_channel_adsicpe adsicpe

References ast_channel::adsicpe.

◆ ast_channel_adsicpe_set()

void ast_channel_adsicpe_set ( struct ast_channel chan,
enum ast_channel_adsicpe  value 
)

◆ ast_channel_alert_writable()

int ast_channel_alert_writable ( struct ast_channel chan)

Definition at line 992 of file channel_internal_api.c.

993{
994 return ast_alertpipe_writable(chan->alertpipe);
995}
int attribute_pure ast_alertpipe_writable(int alert_pipe[2])
Determine if the alert pipe is writable.
Definition alertpipe.h:130

References ast_channel::alertpipe, and ast_alertpipe_writable().

Referenced by __ast_queue_frame().

◆ ast_channel_alert_write()

int ast_channel_alert_write ( struct ast_channel chan)

Definition at line 977 of file channel_internal_api.c.

978{
979 return ast_alertpipe_write(chan->alertpipe);
980}
ssize_t ast_alertpipe_write(int alert_pipe[2])
Write an event to an alert pipe.
Definition alertpipe.c:120

References ast_channel::alertpipe, and ast_alertpipe_write().

Referenced by __ast_queue_frame(), __ast_read(), and channel_do_masquerade().

◆ ast_channel_amaflags()

enum ama_flags ast_channel_amaflags ( const struct ast_channel chan)

◆ ast_channel_amaflags2string()

const char * ast_channel_amaflags2string ( enum ama_flags  flags)

Convert the enum representation of an AMA flag to a string representation.

Since
12
Parameters
flagsinteger flag
Return values
Astring representation of the flag

Definition at line 4429 of file channel.c.

4430{
4431 switch (flag) {
4432 case AST_AMA_OMIT:
4433 return "OMIT";
4434 case AST_AMA_BILLING:
4435 return "BILLING";
4437 return "DOCUMENTATION";
4438 default:
4439 return "Unknown";
4440 }
4441}

References AST_AMA_BILLING, AST_AMA_DOCUMENTATION, and AST_AMA_OMIT.

Referenced by ast_cdr_format_var(), beanstalk_put(), build_csv_record(), build_radius_record(), build_radius_record(), cdr_read_callback(), cel_bs_put(), format_amaflags(), handle_cli_ooh323_show_config(), handle_cli_ooh323_show_peer(), handle_cli_ooh323_show_user(), manager_log(), manager_log(), tds_log(), and tds_log().

◆ ast_channel_amaflags_set()

void ast_channel_amaflags_set ( struct ast_channel chan,
enum ama_flags  value 
)
Precondition
chan is locked

Definition at line 282 of file channel_internal_api.c.

283{
284 if (chan->amaflags == value) {
285 return;
286 }
287 chan->amaflags = value;
289}
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.

References ast_channel::amaflags, ast_channel_publish_snapshot(), and value.

Referenced by __ast_channel_alloc_ap(), ast_cel_fabricate_channel_from_event(), ast_iax2_new(), AST_TEST_DEFINE(), cdr_write(), dahdi_new(), func_channel_write_real(), and ooh323_new().

◆ ast_channel_answertime()

struct timeval ast_channel_answertime ( struct ast_channel chan)

Definition at line 853 of file channel_internal_api.c.

854{
855 return chan->answertime;
856}
struct timeval answertime

Referenced by ast_channel_get_up_time_ms(), and set_channel_answer_time().

◆ ast_channel_answertime_set()

void ast_channel_answertime_set ( struct ast_channel chan,
struct timeval *  value 
)

Definition at line 858 of file channel_internal_api.c.

859{
860 chan->answertime = *value;
861}

References ast_channel::answertime, and value.

Referenced by set_channel_answer_time().

◆ ast_channel_appl()

const char * ast_channel_appl ( const struct ast_channel chan)

◆ ast_channel_appl_set()

void ast_channel_appl_set ( struct ast_channel chan,
const char *  value 
)

Definition at line 192 of file channel_internal_api.c.

193{
194 chan->appl = value;
196}
void ast_channel_snapshot_invalidate_segment(struct ast_channel *chan, enum ast_channel_snapshot_segment_invalidation segment)
Invalidate a channel snapshot segment from being reused.
@ AST_CHANNEL_SNAPSHOT_INVALIDATE_DIALPLAN

References ast_channel::appl, AST_CHANNEL_SNAPSHOT_INVALIDATE_DIALPLAN, ast_channel_snapshot_invalidate_segment(), and value.

Referenced by ast_cel_fabricate_channel_from_event(), AST_TEST_DEFINE(), begin_dial_prerun(), dial_exec_full(), do_forward(), pbx_exec(), realtime_exec(), and ring_entry().

◆ ast_channel_audiohooks()

struct ast_audiohook_list * ast_channel_audiohooks ( const struct ast_channel chan)

◆ ast_channel_audiohooks_set()

void ast_channel_audiohooks_set ( struct ast_channel chan,
struct ast_audiohook_list value 
)

Definition at line 460 of file channel_internal_api.c.

461{
462 chan->audiohooks = value;
463}

References ast_channel::audiohooks, and value.

Referenced by __ast_read(), ast_audiohook_attach(), ast_write_stream(), and destroy_hooks().

◆ ast_channel_autochans()

struct ast_autochan_list * ast_channel_autochans ( struct ast_channel chan)

Definition at line 739 of file channel_internal_api.c.

740{
741 return &chan->autochans;
742}
struct ast_autochan_list autochans

References ast_channel::autochans.

Referenced by __ast_channel_alloc_ap(), ast_autochan_destroy(), ast_autochan_new_channel(), and ast_autochan_setup().

◆ ast_channel_blocker()

pthread_t ast_channel_blocker ( const struct ast_channel chan)

Definition at line 1080 of file channel_internal_api.c.

1081{
1082 return chan->blocker;
1083}
pthread_t blocker

References ast_channel::blocker.

Referenced by __ast_queue_frame(), ast_softhangup_nolock(), and channel_do_masquerade().

◆ ast_channel_blocker_set()

void ast_channel_blocker_set ( struct ast_channel chan,
pthread_t  value 
)

Definition at line 1084 of file channel_internal_api.c.

1085{
1086 chan->blocker = value;
1087}

References ast_channel::blocker, and value.

◆ ast_channel_blocker_tid()

int ast_channel_blocker_tid ( const struct ast_channel chan)

Definition at line 1089 of file channel_internal_api.c.

1090{
1091 return chan->blocker_tid;
1092}

References ast_channel::blocker_tid.

Referenced by ast_hangup().

◆ ast_channel_blocker_tid_set()

void ast_channel_blocker_tid_set ( struct ast_channel chan,
int  tid 
)

Definition at line 1093 of file channel_internal_api.c.

1094{
1095 chan->blocker_tid = value;
1096}

References ast_channel::blocker_tid, and value.

◆ ast_channel_blockproc()

const char * ast_channel_blockproc ( const struct ast_channel chan)

Definition at line 197 of file channel_internal_api.c.

198{
199 return chan->blockproc;
200}
const char * blockproc

References ast_channel::blockproc.

Referenced by ast_hangup(), and serialize_showchan().

◆ ast_channel_blockproc_set()

void ast_channel_blockproc_set ( struct ast_channel chan,
const char *  value 
)

Definition at line 201 of file channel_internal_api.c.

202{
203 chan->blockproc = value;
204}

References ast_channel::blockproc, and value.

◆ ast_channel_bridge_peer()

struct ast_channel * ast_channel_bridge_peer ( struct ast_channel chan)

Get the channel's bridge peer only if the bridge is two-party.

Since
12.0.0
Parameters
chanChannel desiring the bridge peer channel.
Note
The returned peer channel is the current peer in the bridge when called.
Absolutely NO channel locks should be held when calling this function.
Return values
NULLChannel not in a bridge or the bridge is not two-party.
non-NULLReffed peer channel at time of calling.

Definition at line 10674 of file channel.c.

10675{
10676 struct ast_channel *peer;
10677 struct ast_bridge *bridge;
10678
10679 /* Get the bridge the channel is in. */
10680 ast_channel_lock(chan);
10681 bridge = ast_channel_get_bridge(chan);
10682 ast_channel_unlock(chan);
10683 if (!bridge) {
10684 return NULL;
10685 }
10686
10687 peer = ast_bridge_peer(bridge, chan);
10688 ao2_ref(bridge, -1);
10689 return peer;
10690}
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition astobj2.h:459
struct ast_channel * ast_bridge_peer(struct ast_bridge *bridge, struct ast_channel *chan)
Get the channel's bridge peer only if the bridge is two-party.
Definition bridge.c:4154
struct ast_bridge * ast_channel_get_bridge(const struct ast_channel *chan)
Get the bridge associated with a channel.
Definition channel.c:10644

References ao2_ref, ast_bridge_peer(), ast_channel_get_bridge(), ast_channel_lock, ast_channel_unlock, and NULL.

Referenced by analog_ss_thread(), ast_rtp_instance_set_stats_vars(), ast_set_hangupsource(), ast_unreal_queryoption(), ast_var_channels_table(), attach_barge(), attach_barge(), channel_do_masquerade(), create_jb(), fax_detect_framehook(), fax_gateway_framehook(), func_channel_read(), handle_incoming_request(), manager_park(), my_get_sigpvt_bridged_channel(), and spandsp_fax_gateway_start().

◆ ast_channel_call_forward()

const char * ast_channel_call_forward ( const struct ast_channel chan)

◆ ast_channel_callback()

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.

Channel search functions

Warning
Absolutely NO channel locks should be held while calling any of these functions.

This function executes a callback one time for each active channel on the system. The channel is provided as an argument to the function.

Since
1.8

Definition at line 1336 of file channel.c.

1338{
1340 return NULL;
1341 }
1342 if (!cb_fn) {
1343 ast_log(LOG_ERROR, "callback function must be provided\n");
1344 return NULL;
1345 }
1346 return CHANNELSTORAGE_API(current_channel_storage_instance, callback, cb_fn, arg, data, ao2_flags, 1);
1347}
static struct ast_channel * callback(struct ast_channelstorage_instance *driver, ao2_callback_data_fn *cb_fn, void *arg, void *data, int ao2_flags, int rdlock)
#define LOG_ERROR

References ast_log, callback(), CHANNELSTORAGE_API, current_channel_storage_instance, ast_channel::data, LOG_ERROR, and NULL.

Referenced by ast_pickup_find_by_group(), ast_softhangup_all(), find_by_channel(), find_by_part(), handle_core_set_debug_channel(), and pickup_by_mark().

◆ ast_channel_caller()

struct ast_party_caller * ast_channel_caller ( struct ast_channel chan)

Definition at line 755 of file channel_internal_api.c.

756{
757 return &chan->caller;
758}

References ast_channel::caller.

Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_channel_alloc_ap(), __ast_goto_if_exists(), __ast_pbx_run(), action_meetmelist(), after_bridge_move_channel(), agent_request_exec(), analog_ss_thread(), app_exec(), ast_app_dtget(), ast_ari_channels_dial(), ast_bridge_setup_after_goto(), ast_cel_fabricate_channel_from_event(), ast_channel_destructor(), ast_channel_set_caller(), ast_channel_set_caller_event(), ast_do_pickup(), ast_dummy_channel_destructor(), ast_iax2_new(), ast_pbx_h_exten_run(), ast_set_callerid(), ast_str_retrieve_variable(), AST_TEST_DEFINE(), ast_unreal_call_setup(), ast_var_channels_table(), background_detect_exec(), begin_dial_prerun(), blacklist_read(), bridge_reconfigured_connected_line_update(), callerid_read(), callerid_write(), cc_generic_agent_init(), chan_pjsip_cng_tone_detected(), chan_pjsip_new(), channel_do_masquerade(), channel_snapshot_caller_create(), collect_digits(), console_call(), copy_caller_data(), copy_message(), dahdi_handle_dtmf(), dahdi_handle_event(), dahdi_new(), dial_exec_full(), dial_trunk(), dialog_info_generate_body_content(), disa_exec(), do_forward(), fax_detect_framehook(), find_matching_endif(), find_matching_endwhile(), findmeexec(), forward_message(), gosub_exec(), gosub_run(), grab_transfer(), handle_cli_confbridge_list_item(), handle_gosub(), handle_setpriority(), handle_showchan(), incoming_in_dialog_request(), isAnsweringMachine(), isexten_function_read(), launch_monitor_thread(), leave_voicemail(), leave_voicemail(), local_call(), manager_queues_status(), meetme_show_cmd(), minivm_greet_exec(), minivm_notify_exec(), my_get_callerid(), my_handle_dtmf(), onModeChanged(), ooh323_rtp_read(), originate_exec(), park_local_transfer(), pbx_builtin_background(), pbx_builtin_waitexten(), pbx_outgoing_attempt(), pbx_parse_location(), privacy_exec(), queue_connected_line_update(), queue_exec(), readexten_exec(), recalling_enter(), ring_entry(), run_externnotify(), send_broadcast_event(), serialize_showchan(), setup_env(), setup_privacy_args(), sla_ring_station(), sms_exec(), socket_process_helper(), start_automixmonitor(), try_calling(), unistim_new(), unreal_colp_redirect_indicate(), update_connected_line_from_peer(), update_connected_line_from_peer(), update_initial_connected_line(), valid_exit(), vm_authenticate(), wait_for_answer(), waitstream_core(), write_metadata(), and zapateller_exec().

◆ ast_channel_caller_set()

void ast_channel_caller_set ( struct ast_channel chan,
struct ast_party_caller value 
)

◆ ast_channel_callgroup()

ast_group_t ast_channel_callgroup ( const struct ast_channel chan)

◆ ast_channel_callgroup_set()

void ast_channel_callgroup_set ( struct ast_channel chan,
ast_group_t  value 
)
Precondition
chan is locked

Definition at line 945 of file channel_internal_api.c.

946{
947 chan->callgroup = value;
948}

References ast_channel::callgroup, and value.

Referenced by chan_pjsip_new(), dahdi_new(), func_channel_write_real(), jingle_new(), and unistim_new().

◆ ast_channel_callid()

ast_callid ast_channel_callid ( const struct ast_channel chan)

◆ ast_channel_callid_cleanup()

void ast_channel_callid_cleanup ( struct ast_channel chan)

Definition at line 935 of file channel_internal_api.c.

936{
937 chan->callid = 0;
938}

References ast_channel::callid.

Referenced by ast_channel_destructor().

◆ ast_channel_callid_set()

void ast_channel_callid_set ( struct ast_channel chan,
ast_callid  value 
)
Precondition
chan is locked

Definition at line 664 of file channel_internal_api.c.

665{
666 char call_identifier_from[AST_CALLID_BUFFER_LENGTH];
667 char call_identifier_to[AST_CALLID_BUFFER_LENGTH];
668 call_identifier_from[0] = '\0';
669 ast_callid_strnprint(call_identifier_to, sizeof(call_identifier_to), callid);
670 if (chan->callid) {
671 ast_callid_strnprint(call_identifier_from, sizeof(call_identifier_from), chan->callid);
672 ast_debug(3, "Channel Call ID changing from %s to %s\n", call_identifier_from, call_identifier_to);
673 }
674
675 chan->callid = callid;
676
677 ast_test_suite_event_notify("CallIDChange",
678 "State: CallIDChange\r\n"
679 "Channel: %s\r\n"
680 "CallID: %s\r\n"
681 "PriorCallID: %s",
682 ast_channel_name(chan),
683 call_identifier_to,
684 call_identifier_from);
685}
void ast_callid_strnprint(char *buffer, size_t buffer_size, ast_callid callid)
copy a string representation of the callid into a target string
Definition logger.c:2258
#define AST_CALLID_BUFFER_LENGTH
#define ast_test_suite_event_notify(s, f,...)
Definition test.h:189

References AST_CALLID_BUFFER_LENGTH, ast_callid_strnprint(), ast_channel_name(), ast_debug, ast_test_suite_event_notify, and ast_channel::callid.

Referenced by __ast_pbx_run(), ast_iax2_new(), ast_unreal_channel_push_to_bridge(), ast_unreal_new_channels(), common_recall_channel_setup(), dahdi_new(), iax2_request(), jingle_new(), and request_channel().

◆ ast_channel_cc_params_init()

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.

Warning
You should call this function only if ast_cc_is_enabled() returns true.
Parameters
chanThe channel to create the datastore on
base_paramsCCSS parameters we wish to copy into the channel
Return values
0Success
-1Failure or CCSS is globally disabled.

Definition at line 10557 of file channel.c.

10559{
10560 struct ast_cc_config_params *cc_params;
10561 struct ast_datastore *cc_datastore;
10562
10563 if (!(cc_params = ast_cc_config_params_init())) {
10564 return -1;
10565 }
10566
10567 if (!(cc_datastore = ast_datastore_alloc(&cc_channel_datastore_info, NULL))) {
10569 return -1;
10570 }
10571
10572 if (base_params) {
10573 ast_cc_copy_config_params(cc_params, base_params);
10574 }
10575 cc_datastore->data = cc_params;
10576 ast_channel_datastore_add(chan, cc_datastore);
10577 return 0;
10578}
#define ast_cc_config_params_init()
Allocate and initialize an ast_cc_config_params structure.
Definition ccss.h:135
void ast_cc_config_params_destroy(struct ast_cc_config_params *params)
Free memory from CCSS configuration params.
Definition ccss.c:714
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:876
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition channel.c:2376
static const struct ast_datastore_info cc_channel_datastore_info
Definition channel.c:10551
#define ast_datastore_alloc(info, uid)
Definition datastore.h:85
Structure for a data store object.
Definition datastore.h:64
void * data
Definition datastore.h:66

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

Referenced by ast_channel_get_cc_config_params(), ast_unreal_call_setup(), ast_unreal_new_channels(), and dahdi_new().

◆ ast_channel_cdr()

struct ast_cdr * ast_channel_cdr ( const struct ast_channel chan)

Definition at line 464 of file channel_internal_api.c.

465{
466 return chan->cdr;
467}
struct ast_cdr * cdr

References ast_channel::cdr.

Referenced by ast_channel_destructor(), ast_channel_log(), ast_dummy_channel_destructor(), cdr_read_callback(), and cdr_retrieve_time().

◆ ast_channel_cdr_set()

void ast_channel_cdr_set ( struct ast_channel chan,
struct ast_cdr value 
)

Definition at line 468 of file channel_internal_api.c.

469{
470 chan->cdr = value;
471}

References ast_channel::cdr, and value.

Referenced by ast_channel_destructor(), ast_dummy_channel_destructor(), dummy_chan_alloc_cdr(), and manager_log().

◆ ast_channel_clear_flag()

void ast_channel_clear_flag ( struct ast_channel chan,
unsigned int  flag 
)

Clear a flag on a channel.

Since
13.17.0
Parameters
chanThe channel to clear the flag from
flagThe flag to clear
Note
This will lock the channel internally. If the channel is already locked it is still safe to call.

Definition at line 11144 of file channel.c.

11145{
11146 ast_channel_lock(chan);
11148 ast_channel_unlock(chan);
11149}

References ast_channel_flags(), ast_channel_lock, ast_channel_unlock, and ast_clear_flag.

Referenced by action_redirect(), ast_bridge_setup_after_goto(), ast_channel_undefer_dtmf(), ast_waitfordigit_full(), bridge_channel_internal_pull(), channel_spy(), common_exec(), dial_exec_full(), disa_exec(), do_broadcast(), handle_exec(), and waitstream_core().

◆ ast_channel_clear_softhangup()

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

Definition at line 2423 of file channel.c.

2424{
2425 ast_channel_lock(chan);
2426
2428
2430 struct ast_frame *fr;
2431
2432 /* If we have completely cleared the softhangup flag,
2433 * then we need to fully abort the hangup process. This requires
2434 * pulling the END_OF_Q frame out of the channel frame queue if it
2435 * still happens to be there. */
2436
2437 fr = AST_LIST_LAST(ast_channel_readq(chan));
2438 if (fr && fr->frametype == AST_FRAME_CONTROL &&
2441 ast_frfree(fr);
2442 }
2443 }
2444
2445 ast_channel_unlock(chan);
2446}
@ AST_CONTROL_END_OF_Q
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.

References ast_channel_lock, ast_channel_readq(), ast_channel_softhangup_internal_flag(), ast_channel_softhangup_internal_flag_clear(), 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, and ast_frame::subclass.

Referenced by __ast_pbx_run(), ast_bridge_setup_after_goto(), chan_cleanup(), collect_digits(), gosub_run(), and stasis_app_exec().

◆ ast_channel_cmpwhentohangup_tv()

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
Return values
1
0
-1This 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 524 of file channel.c.

525{
526 struct timeval whentohangup;
527
529 return ast_tvzero(offset) ? 0 : -1;
530
531 if (ast_tvzero(offset))
532 return 1;
533
534 whentohangup = ast_tvadd(offset, ast_tvnow());
535
536 return ast_tvdiff_ms(whentohangup, *ast_channel_whentohangup(chan));
537}
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition time.h:117
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
Definition extconf.c:2280
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition time.h:107

References ast_channel_whentohangup(), ast_tvadd(), ast_tvdiff_ms(), ast_tvnow(), and ast_tvzero().

◆ ast_channel_connected()

struct ast_party_connected_line * ast_channel_connected ( struct ast_channel chan)

◆ ast_channel_connected_effective_id()

struct ast_party_id ast_channel_connected_effective_id ( struct ast_channel chan)

Definition at line 767 of file channel_internal_api.c.

768{
769 return ast_party_id_merge(&chan->connected.id, &chan->connected.priv);
770}
struct ast_party_id priv
Private connected party ID.
Definition channel.h:470
struct ast_party_id id
Connected party ID.
Definition channel.h:460

References ast_party_id_merge().

Referenced by caller_id_outgoing_request(), caller_id_outgoing_response(), generate_status(), handle_showchan(), is_colp_update_allowed(), set_from_header(), and stir_shaken_outgoing_request().

◆ ast_channel_connected_indicated()

struct ast_party_connected_line * ast_channel_connected_indicated ( struct ast_channel chan)

Definition at line 763 of file channel_internal_api.c.

764{
765 return &chan->connected_indicated;
766}
struct ast_party_connected_line connected_indicated
Channel Connected Line ID information that was last indicated.

References ast_channel::connected_indicated.

Referenced by __ast_channel_alloc_ap(), after_bridge_move_channel(), ast_channel_destructor(), ast_dummy_channel_destructor(), and indicate_connected_line().

◆ ast_channel_connected_line_sub()

int ast_channel_connected_line_sub ( struct ast_channel autoservice_chan,
struct ast_channel sub_chan,
const void *  connected_info,
int  frame 
)

Run a connected line interception subroutine and update a channel's connected line information.

Since
11

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

Parameters
autoservice_chanChannel to place into autoservice while the sub is running. It is perfectly safe for this to be NULL
sub_chanThe channel to run the subroutine on. Also the channel from which we determine which subroutine we need to run.
connected_infoEither an ast_party_connected_line or ast_frame pointer of type AST_CONTROL_CONNECTED_LINE
frameIf true, then connected_info is an ast_frame pointer, otherwise it is an ast_party_connected_line pointer.
Return values
0Success
-1Either the subroutine does not exist, or there was an error while attempting to run the subroutine

Definition at line 10444 of file channel.c.

10445{
10446 const char *sub;
10447 const char *sub_args;
10448 int retval;
10449
10450 ast_channel_lock(sub_chan);
10451 sub = pbx_builtin_getvar_helper(sub_chan, "CONNECTED_LINE_SEND_SUB");
10452 sub = ast_strdupa(S_OR(sub, ""));
10453 sub_args = pbx_builtin_getvar_helper(sub_chan, "CONNECTED_LINE_SEND_SUB_ARGS");
10454 sub_args = ast_strdupa(S_OR(sub_args, ""));
10455
10456 if (ast_strlen_zero(sub)) {
10457 ast_channel_unlock(sub_chan);
10458 return -1;
10459 }
10460
10461 if (is_frame) {
10462 const struct ast_frame *frame = connected_info;
10463
10465 } else {
10466 const struct ast_party_connected_line *connected = connected_info;
10467
10469 }
10470 ast_channel_unlock(sub_chan);
10471
10473 retval = ast_app_run_sub(autoservice_chan, sub_chan, sub, sub_args, 0);
10475 if (!retval) {
10476 struct ast_party_connected_line saved_connected;
10477
10478 ast_party_connected_line_init(&saved_connected);
10479 ast_channel_lock(sub_chan);
10480 ast_party_connected_line_copy(&saved_connected, ast_channel_connected(sub_chan));
10481 ast_channel_unlock(sub_chan);
10482 ast_channel_update_connected_line(sub_chan, &saved_connected, NULL);
10483 ast_party_connected_line_free(&saved_connected);
10484 }
10485
10486 return retval;
10487}
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition astmm.h:298
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition channel.c:2059
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:9199
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:8891
static void channel_set_intercept_mode(int in_intercept_mode)
Definition channel.c:10428
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
Definition channel.c:2009
int ast_app_run_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_location, const char *sub_args, int ignore_hangup)
Run a subroutine on a channel, placing an optional second channel into autoservice.
Definition main/app.c:328
static struct stasis_subscription * sub
Statsd channel stats. Exmaple of how to subscribe to Stasis events.

References ast_app_run_sub(), ast_channel_connected(), 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(), channel_set_intercept_mode(), connected, ast_frame::data, ast_frame::datalen, NULL, pbx_builtin_getvar_helper(), ast_frame::ptr, S_OR, and sub.

Referenced by __ast_read(), app_exec(), ast_do_pickup(), bridge_channel_handle_control(), dial_exec_full(), handle_frame(), update_connected_line_from_peer(), update_connected_line_from_peer(), wait_for_answer(), and wait_for_answer().

◆ ast_channel_connected_set()

void ast_channel_connected_set ( struct ast_channel chan,
struct ast_party_connected_line value 
)

◆ ast_channel_context()

const char * ast_channel_context ( const struct ast_channel chan)

Definition at line 215 of file channel_internal_api.c.

216{
217 return chan->context;
218}

References ast_channel::context.

Referenced by __analog_ss_thread(), __ast_goto_if_exists(), __ast_pbx_run(), _while_exec(), action_blind_transfer(), action_bridge(), action_dialplan_exec(), analog_ss_thread(), ast_bridge_setup_after_goto(), ast_call_forward(), ast_cc_call_init(), ast_channel_log(), ast_channel_yank(), ast_pbx_h_exten_run(), ast_str_retrieve_variable(), AST_TEST_DEFINE(), ast_var_channels_table(), ast_waitstream_exten(), background_detect_exec(), blind_transfer_exec(), bridge_exec(), by_exten_cb(), cc_generic_agent_init(), cc_interfaces_datastore_init(), chan_pjsip_cng_tone_detected(), channel_snapshot_dialplan_create(), channelstorage_exten_cb(), collect_digits(), common_exec(), conf_run(), dahdi_handle_dtmf(), dial_exec_full(), dialout(), do_forward(), eval_exten_read(), expand_gosub_args(), extenspy_exec(), fax_detect_framehook(), feature_blind_transfer(), find_matching_endif(), find_matching_endwhile(), forward_message(), func_channel_read(), func_channel_write_real(), get_cid_name(), get_transfer_context(), gosub_exec(), gosub_run(), goto_exten(), goto_parser(), handle_call_forward(), handle_gosub(), handle_setpriority(), handle_showchan(), iax2_call(), if_helper(), launch_monitor_thread(), leave_voicemail(), leave_voicemail(), log_exec(), lua_pbx_exec(), minivm_greet_exec(), my_handle_dtmf(), onedigit_goto(), onModeChanged(), ooh323_rtp_read(), pbx_builtin_background(), pbx_builtin_goto(), pbx_builtin_setvar_multiple(), pbx_builtin_waitexten(), pbx_extension_helper(), pbx_parse_location(), pickup_exec(), raise_exception(), readexten_exec(), realtime_exec(), ring_entry(), serialize_showchan(), setup_env(), setup_peer_after_bridge_goto(), setup_peer_after_bridge_goto(), try_calling(), vm_authenticate(), vm_execmain(), vmauthenticate(), and wait_for_answer().

◆ ast_channel_context_set()

void ast_channel_context_set ( struct ast_channel chan,
const char *  value 
)

◆ ast_channel_creationtime()

struct timeval ast_channel_creationtime ( struct ast_channel chan)

◆ ast_channel_creationtime_set()

void ast_channel_creationtime_set ( struct ast_channel chan,
struct timeval *  value 
)

◆ ast_channel_data()

const char * ast_channel_data ( const struct ast_channel chan)

◆ ast_channel_data_set()

void ast_channel_data_set ( struct ast_channel chan,
const char *  value 
)

◆ ast_channel_datastore_add()

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

2377{
2378 int res = 0;
2379
2380 AST_LIST_INSERT_HEAD(ast_channel_datastores(chan), datastore, entry);
2381
2382 return res;
2383}

References ast_channel_datastores(), AST_LIST_INSERT_HEAD, and ast_datastore::entry.

Referenced by __after_bridge_set_goto(), acf_curlopt_write(), acf_iaxvar_write(), acf_odbc_read(), add_eprofile_to_channel(), add_features_datastore(), add_inheritable_header(), add_masquerade_store(), add_to_agi(), after_bridge_cb_setup(), apply_plc(), ast_cel_fabricate_channel_from_event(), ast_channel_cc_params_init(), ast_channel_suppress(), ast_do_pickup(), ast_iax2_new(), ast_jb_create_framehook(), ast_setup_cc_recall_datastore(), ast_stir_shaken_add_result_to_channel(), attach_framehook(), audiohook_volume_get(), authenticate_reply(), bridge_channel_impart_add(), bridge_features_ds_set_full(), calendar_query_exec(), cc_interfaces_datastore_init(), chan_cleanup(), channel_feature_hooks_set_full(), command_prestart_queue_command(), create_msg_q_chan(), create_parked_subscription_full(), create_transaction(), detect_write(), dial_exec_full(), dial_masquerade_datastore_add(), do_notify(), dtmfstore_exec(), dundi_query_read(), enable_jack_hook(), enum_query_read(), find_or_create_details(), frame_drop_helper(), frame_trace_helper(), func_channel_write_real(), func_confbridge_helper(), func_write_attestation(), geoloc_profile_write(), get_feature_ds(), get_lock(), get_replace_channel_store(), gosub_exec(), handle_remb_set(), init_hook(), lua_get_state(), max_forwards_datastore_alloc(), msg_datastore_find_or_create(), pitchshift_helper(), raise_exception(), record_exec(), save_dialstring(), scramble_write(), set_hold_intercept(), set_internal_datastore(), set_talk_detect(), set_timeout(), setup_async_playback_datastore(), setup_bridge_roles_datastore(), setup_mixmonitor_ds(), setup_park_common_datastore(), shared_write(), smdi_msg_retrieve_read(), socket_process_helper(), speech_create(), speex_write(), srv_datastore_setup(), stasis_app_broadcast_channel(), stasis_app_channel_set_stasis_end_published(), t38_attach_framehook(), unicast_rtp_request(), and volume_write().

◆ ast_channel_datastore_find()

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

2391{
2392 struct ast_datastore *datastore = NULL;
2393
2394 if (info == NULL)
2395 return NULL;
2396
2398 if (datastore->info != info) {
2399 continue;
2400 }
2401
2402 if (uid == NULL) {
2403 /* matched by type only */
2404 break;
2405 }
2406
2407 if ((datastore->uid != NULL) && !strcasecmp(uid, datastore->uid)) {
2408 /* Matched by type AND uid */
2409 break;
2410 }
2411 }
2412
2413 return datastore;
2414}
const struct ast_datastore_info * info
Definition datastore.h:67
const char * uid
Definition datastore.h:65
struct ast_datastore::@223 entry

References ast_channel_datastores(), AST_LIST_TRAVERSE, ast_datastore::entry, ast_datastore::info, NULL, and ast_datastore::uid.

Referenced by 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_inheritable_header(), add_masquerade_store(), add_to_agi(), after_bridge_cb_find(), after_bridge_cb_setup(), after_bridge_goto_remove(), apply_plc(), ast_bridge_features_ds_get(), ast_bridge_read_after_goto(), 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_feature_hooks_get(), ast_channel_get_cc_config_params(), ast_channel_suppress(), ast_channel_unsuppress(), ast_geoloc_datastore_find(), ast_handle_cc_control_frame(), ast_ignore_cc(), ast_jb_create_framehook(), ast_odbc_retrieve_transaction_obj(), ast_set_cc_interfaces_chanvar(), ast_stir_shaken_add_result_to_channel(), ast_stir_shaken_get_attestation_datastore(), async_play_sound_ready(), attach_framehook(), audiohook_volume_callback(), audiohook_volume_get(), balance_stack(), bridge_channel_impart_add(), bridge_channel_impart_signal(), bridge_features_ds_set_full(), bridge_timeout(), calendar_event_read(), calendar_query_exec(), calendar_query_result_exec(), cc_build_payload(), chan_cleanup(), chan_rtp_get_rtp_peer(), channel_feature_hooks_set_full(), command_prestart_get_container(), command_prestart_queue_command(), conf_find_bridge_profile(), conf_find_user_profile(), conf_set_menu_to_user(), create_transaction(), detect_callback(), detect_read(), detect_write(), dial_exec_full(), dial_masquerade_datastore_find(), dialplan_handle_msg_cb(), disable_jack_hook(), dtmfstore_exec(), dundi_result_read(), enable_jack_hook(), enum_result_read(), exec_odbcfinish(), fetch_bridge_roles_datastore(), find_details(), find_speech(), find_transaction(), fixup_callback(), frame_drop_helper(), frame_trace_helper(), func_channel_read(), func_channel_write_real(), func_confbridge_helper(), func_mixmonitor_read(), func_read_verification(), func_write_attestation(), get_agi_cmd(), get_feature_chan_ds(), get_feature_ds(), get_lock(), get_park_common_datastore_copy(), get_replace_channel_store(), gosub_exec(), gosub_run(), handle_gosub(), handle_remb_set(), has_masquerade_store(), hook_off(), hook_re_enable(), iax2_call(), jack_hook_callback(), local_read(), local_write(), lock_fixup(), lua_get_state(), mark_transaction_active(), max_forwards_datastore_find_or_alloc(), mixmonitor_ds_remove_and_free(), msg_data_func_read(), msg_datastore_find_or_create(), msg_func_read(), msg_send_exec(), mute_mixmonitor_instance(), outgoing_request(), pitchshift_cb(), pitchshift_helper(), pop_exec(), raise_exception(), record_exec(), recording_info_read(), remb_hook_event_cb(), remove_detect(), remove_dtmf_store(), remove_framehook(), remove_hold_intercept(), remove_inheritable_header(), remove_masquerade_store(), remove_scrambler(), remove_stasis_end_published(), remove_talk_detect(), restore_dialstring(), return_exec(), scramble_callback(), scramble_write(), set_hold_intercept(), set_internal_datastore(), set_interval_hook(), set_security_requirements(), set_talk_detect(), setup_async_playback_datastore(), shared_read(), shared_write(), smdi_msg_read(), speech_datastore_destroy(), speex_callback(), speex_read(), speex_write(), srv_query_read(), srv_result_read(), stackpeek_read(), stasis_app_broadcast_channel(), stasis_app_channel_is_internal(), stasis_app_channel_is_stasis_end_published(), stop_mixmonitor_full(), t38_attach_framehook(), talk_detect_audiohook_cb(), unlock_read(), update_inheritable_header(), volume_callback(), volume_read(), volume_write(), wait_for_initiator(), wipe_park_common_datastore(), and wipe_subscription_datastore().

◆ ast_channel_datastore_inherit()

int ast_channel_datastore_inherit ( struct ast_channel from,
struct ast_channel to 
)

Inherit datastores from a parent to a child.

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.

Definition at line 2359 of file channel.c.

2360{
2361 struct ast_datastore *datastore = NULL, *datastore2;
2362
2364 if (datastore->inheritance > 0) {
2365 datastore2 = ast_datastore_alloc(datastore->info, datastore->uid);
2366 if (datastore2) {
2367 datastore2->data = datastore->info->duplicate ? datastore->info->duplicate(datastore->data) : NULL;
2368 datastore2->inheritance = datastore->inheritance == DATASTORE_INHERIT_FOREVER ? DATASTORE_INHERIT_FOREVER : datastore->inheritance - 1;
2370 }
2371 }
2372 }
2373 return 0;
2374}
#define DATASTORE_INHERIT_FOREVER
Definition channel.h:194
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
void *(* duplicate)(void *data)
Definition datastore.h:33
unsigned int inheritance
Definition datastore.h:69

References ast_channel_datastores(), ast_datastore_alloc, AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_datastore::data, DATASTORE_INHERIT_FOREVER, ast_datastore_info::duplicate, ast_datastore::entry, ast_datastore::info, ast_datastore::inheritance, NULL, and ast_datastore::uid.

Referenced by __ast_request_and_dial(), ast_ari_channels_dial(), ast_unreal_call_setup(), begin_dial_prerun(), call_forward_inherit(), common_recall_channel_setup(), copy_caller_data(), dial_exec_full(), do_forward(), findmeexec(), park_local_transfer(), ring_entry(), and wait_for_answer().

◆ ast_channel_datastore_remove()

int ast_channel_datastore_remove ( struct ast_channel chan,
struct ast_datastore datastore 
)

◆ ast_channel_datastores()

struct ast_datastore_list * ast_channel_datastores ( struct ast_channel chan)

◆ ast_channel_defer_dtmf()

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

1316{
1317 int pre = 0;
1318
1319 if (chan) {
1320 ast_channel_lock(chan);
1323 ast_channel_unlock(chan);
1324 }
1325 return pre;
1326}

References ast_channel_flags(), ast_channel_lock, ast_channel_unlock, AST_FLAG_DEFER_DTMF, ast_set_flag, and ast_test_flag.

Referenced by __adsi_transmit_messages().

◆ ast_channel_dialcontext()

const char * ast_channel_dialcontext ( const struct ast_channel chan)

Referenced by ast_channel_log().

◆ ast_channel_dialed()

struct ast_party_dialed * ast_channel_dialed ( struct ast_channel chan)

◆ ast_channel_dialed_causes_add()

int ast_channel_dialed_causes_add ( const struct ast_channel chan,
const struct ast_control_pvt_cause_code cause_code,
int  datalen 
)

Add cause code information to the channel.

Since
11

This function makes use of datastore operations on the channel, so it is important to lock the channel before calling this function. The passed in data is copied and so is still owned by the caller.

Parameters
chanThe channel on which to add information
cause_codeThe cause information to be added to the channel
datalenThe total length of the structure since its length is variable
Return values
0on success
-1on error

Definition at line 1165 of file channel_internal_api.c.

1166{
1167 struct ast_control_pvt_cause_code *ao2_cause_code;
1169 ao2_cause_code = ao2_alloc(datalen, NULL);
1170
1171 if (ao2_cause_code) {
1172 memcpy(ao2_cause_code, cause_code, datalen);
1173 ao2_link(chan->dialed_causes, ao2_cause_code);
1174 ao2_ref(ao2_cause_code, -1);
1175 return 0;
1176 } else {
1177 return -1;
1178 }
1179}
#define ao2_link(container, obj)
Add an object to a container.
Definition astobj2.h:1532
#define OBJ_KEY
Definition astobj2.h:1151
#define ao2_find(container, arg, flags)
Definition astobj2.h:1736
@ OBJ_NODATA
Definition astobj2.h:1044
@ OBJ_UNLINK
Definition astobj2.h:1039
#define ao2_alloc(data_size, destructor_fn)
Definition astobj2.h:409
struct ao2_container * dialed_causes

References ao2_alloc, ao2_find, ao2_link, ao2_ref, ast_control_pvt_cause_code::chan_name, ast_channel::dialed_causes, NULL, OBJ_KEY, OBJ_NODATA, and OBJ_UNLINK.

Referenced by ast_channel_hangupcause_hash_set().

◆ ast_channel_dialed_causes_channels()

struct ast_str * ast_channel_dialed_causes_channels ( const struct ast_channel chan)

Retrieve a comma-separated list of channels for which dialed cause information is available.

Since
11

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 from which to retrieve information
Return values
NULLon allocation failure
Pointerto an ast_str object containing the desired information which must be freed

Definition at line 1147 of file channel_internal_api.c.

1148{
1149 struct ast_str *chanlist = ast_str_create(128);
1150
1151 if (!chanlist) {
1152 return NULL;
1153 }
1154
1156
1157 return chanlist;
1158}
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
Definition astobj2.h:1693
static int collect_names_cb(void *obj, void *arg, int flags)
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition strings.h:659
List of channel drivers.
Definition app_dial.c:804

References ao2_callback, ast_str_create, collect_names_cb(), ast_channel::dialed_causes, and NULL.

Referenced by hangupcause_keys_read().

◆ ast_channel_dialed_causes_clear()

void ast_channel_dialed_causes_clear ( const struct ast_channel chan)

Clear all cause information from the channel.

Since
11

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 from which to clear information

Definition at line 1181 of file channel_internal_api.c.

1182{
1184}
@ OBJ_MULTIPLE
Definition astobj2.h:1049

References ao2_callback, ast_channel::dialed_causes, NULL, OBJ_MULTIPLE, OBJ_NODATA, and OBJ_UNLINK.

Referenced by hangupcause_clear_exec().

◆ ast_channel_dialed_causes_find()

struct ast_control_pvt_cause_code * ast_channel_dialed_causes_find ( const struct ast_channel chan,
const char *  chan_name 
)

Retrieve a ref-counted cause code information structure.

Since
11

This function makes use of datastore operations on the channel, so it is important to lock the channel before calling this function. This function increases the ref count of the returned object, so the calling function must decrease the reference count when it is finished with the object.

Parameters
chanThe channel from which to retrieve information
chan_nameThe name of the channel about which to retrieve information
Return values
NULLon search failure
Pointerto a ref-counted ast_control_pvt_cause_code object containing the desired information

Definition at line 1160 of file channel_internal_api.c.

1161{
1162 return ao2_find(chan->dialed_causes, chan_name, OBJ_KEY);
1163}

References ao2_find, ast_control_pvt_cause_code::chan_name, ast_channel::dialed_causes, and OBJ_KEY.

Referenced by hangupcause_read().

◆ ast_channel_dialed_causes_iterator()

struct ao2_iterator ast_channel_dialed_causes_iterator ( const struct ast_channel chan)

Retrieve an iterator for dialed cause information.

Since
20.19.0
22.9.0
23.3.0

Each call to ao2_iterator_next() will return a pointer to an ast_control_pvt_cause_code structure containing the dialed cause information for one channel. One of the entries may be for the channel itself if the channel was hung up because of a non-2XX SIP response code. The rest of the entries will be for channels bridged to the channel for which dialed cause information is being retrieved. The caller is responsible for cleaning up the reference count of each entry returned and destroying the returned iterator with ao2_iterator_destroy() when it is finished with it.

Parameters
chanThe channel from which to retrieve cause information
Return values
ao2_iterator

Definition at line 1142 of file channel_internal_api.c.

1143{
1144 return ao2_iterator_init(chan->dialed_causes, 0);
1145}
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.

References ao2_iterator_init().

Referenced by chan_pjsip_session_end().

◆ ast_channel_dialed_set()

void ast_channel_dialed_set ( struct ast_channel chan,
struct ast_party_dialed value 
)

◆ ast_channel_dtmf_digit_to_emulate()

char ast_channel_dtmf_digit_to_emulate ( const struct ast_channel chan)

Definition at line 250 of file channel_internal_api.c.

251{
252 return chan->dtmf_digit_to_emulate;
253}
char dtmf_digit_to_emulate

References ast_channel::dtmf_digit_to_emulate.

Referenced by __ast_read().

◆ ast_channel_dtmf_digit_to_emulate_set()

void ast_channel_dtmf_digit_to_emulate_set ( struct ast_channel chan,
char  value 
)

Definition at line 254 of file channel_internal_api.c.

255{
257}

References ast_channel::dtmf_digit_to_emulate, and value.

Referenced by __ast_read().

◆ ast_channel_dtmf_tv()

struct timeval * ast_channel_dtmf_tv ( struct ast_channel chan)

Definition at line 791 of file channel_internal_api.c.

792{
793 return &chan->dtmf_tv;
794}
struct timeval dtmf_tv

References ast_channel::dtmf_tv.

Referenced by __ast_read(), should_skip_dtmf(), and should_trigger_dtmf_emulating().

◆ ast_channel_dtmf_tv_set()

void ast_channel_dtmf_tv_set ( struct ast_channel chan,
struct timeval *  value 
)

Definition at line 831 of file channel_internal_api.c.

832{
833 chan->dtmf_tv = *value;
834}

References ast_channel::dtmf_tv, and value.

Referenced by __ast_read().

◆ ast_channel_dtmff()

struct ast_frame * ast_channel_dtmff ( struct ast_channel chan)

Definition at line 747 of file channel_internal_api.c.

748{
749 return &chan->dtmff;
750}
struct ast_frame dtmff

References ast_channel::dtmff.

Referenced by __ast_read(), and queue_dtmf_readq().

◆ ast_channel_dtmff_set()

void ast_channel_dtmff_set ( struct ast_channel chan,
struct ast_frame value 
)

Definition at line 803 of file channel_internal_api.c.

804{
805 chan->dtmff = *value;
806}

References ast_channel::dtmff, and value.

◆ ast_channel_early_bridge()

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

7487{
7488 /* Make sure we can early bridge, if not error out */
7489 if (!ast_channel_tech(c0)->early_bridge || (c1 && (!ast_channel_tech(c1)->early_bridge || ast_channel_tech(c0)->early_bridge != ast_channel_tech(c1)->early_bridge)))
7490 return -1;
7491
7492 return ast_channel_tech(c0)->early_bridge(c0, c1);
7493}
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:788

References ast_channel_tech::early_bridge.

Referenced by dial_exec_full(), and wait_for_answer().

◆ ast_channel_emulate_dtmf_duration()

unsigned int ast_channel_emulate_dtmf_duration ( const struct ast_channel chan)

Definition at line 381 of file channel_internal_api.c.

382{
383 return chan->emulate_dtmf_duration;
384}
unsigned int emulate_dtmf_duration

References ast_channel::emulate_dtmf_duration.

Referenced by __ast_read().

◆ ast_channel_emulate_dtmf_duration_set()

void ast_channel_emulate_dtmf_duration_set ( struct ast_channel chan,
unsigned int  value 
)

Definition at line 385 of file channel_internal_api.c.

386{
388}

References ast_channel::emulate_dtmf_duration, and value.

Referenced by __ast_read().

◆ ast_channel_end_dtmf()

void ast_channel_end_dtmf ( struct ast_channel chan,
char  digit,
struct timeval  start,
const char *  why 
)

Simulate a DTMF end on a broken bridge channel.

Parameters
chanChannel sending DTMF that has not ended.
digitDTMF digit to stop.
startDTMF digit start time.
whyReason bridge broken.

Definition at line 10979 of file channel.c.

10980{
10981 int dead;
10982 long duration;
10983
10984 ast_channel_lock(chan);
10987 & ~AST_SOFTHANGUP_ASYNCGOTO);
10988 ast_channel_unlock(chan);
10989 if (dead) {
10990 /* Channel is a zombie or a real hangup. */
10991 return;
10992 }
10993
10994 duration = ast_tvdiff_ms(ast_tvnow(), start);
10995 if (duration < option_dtmfminduration) {
10996 duration = option_dtmfminduration;
10997 }
10998 ast_senddigit_end(chan, digit, duration);
10999 ast_log(LOG_DTMF, "DTMF end '%c' simulated on %s due to %s, duration %ld ms\n",
11000 digit, ast_channel_name(chan), why, duration);
11001}
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition channel.c:4981
unsigned int option_dtmfminduration
Definition options.c:84
#define LOG_DTMF

References ast_channel_flags(), ast_channel_lock, ast_channel_name(), ast_channel_softhangup_internal_flag(), ast_channel_unlock, AST_FLAG_ZOMBIE, ast_log, ast_senddigit_end(), ast_test_flag, ast_tvdiff_ms(), ast_tvnow(), digit, LOG_DTMF, and option_dtmfminduration.

Referenced by bridge_channel_internal_join(), and channel_do_masquerade().

◆ ast_channel_endpoint()

struct ast_endpoint * ast_channel_endpoint ( const struct ast_channel chan)

Definition at line 1580 of file channel_internal_api.c.

1581{
1582 return chan->endpoint;
1583}

References ast_channel::endpoint.

◆ ast_channel_endpoint_set()

void ast_channel_endpoint_set ( struct ast_channel chan,
struct ast_endpoint endpoint 
)

Definition at line 1585 of file channel_internal_api.c.

1586{
1587 if (chan->endpoint) {
1589 ao2_ref(chan->endpoint, -1);
1590 }
1591
1592 chan->endpoint = ao2_bump(endpoint);
1593
1594 if (chan->endpoint) {
1596 }
1597}
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition astobj2.h:480
int ast_endpoint_add_channel(struct ast_endpoint *endpoint, struct ast_channel *chan)
Adds a channel to the given endpoint.
int ast_endpoint_remove_channel(struct ast_endpoint *endpoint, struct ast_channel *chan)
Removes a channel from the given endpoint.

References ao2_bump, ao2_ref, ast_endpoint_add_channel(), ast_endpoint_remove_channel(), and ast_channel::endpoint.

Referenced by __ast_channel_alloc_ap(), and ast_channel_destructor().

◆ ast_channel_epfd()

int ast_channel_epfd ( const struct ast_channel chan)

◆ ast_channel_epfd_set()

void ast_channel_epfd_set ( struct ast_channel chan,
int  value 
)

◆ ast_channel_errno()

enum ast_channel_error ast_channel_errno ( void  )

Get error code for latest channel operation.

Definition at line 11071 of file channel.c.

11072{
11074}
enum ast_channel_error ast_channel_internal_errno(void)

References ast_channel_internal_errno().

Referenced by ari_channels_handle_originate_with_id(), and ast_ari_channels_create().

◆ ast_channel_exten()

const char * ast_channel_exten ( const struct ast_channel chan)

Definition at line 232 of file channel_internal_api.c.

233{
234 return chan->exten;
235}

References ast_channel::exten.

Referenced by __ast_goto_if_exists(), __ast_pbx_run(), _while_exec(), action_bridge(), action_dialplan_exec(), ast_bridge_setup_after_goto(), ast_cc_call_init(), ast_channel_log(), ast_channel_yank(), ast_pbx_h_exten_run(), ast_str_retrieve_variable(), AST_TEST_DEFINE(), ast_var_channels_table(), bridge_exec(), by_exten_cb(), cc_generic_agent_init(), cc_interfaces_datastore_init(), chan_pjsip_cng_tone_detected(), channel_snapshot_dialplan_create(), channelstorage_exten_cb(), dahdi_handle_dtmf(), dial_exec_full(), do_forward(), eval_exten_read(), expand_gosub_args(), fax_detect_framehook(), feature_blind_transfer(), find_matching_endif(), find_matching_endwhile(), forward_message(), func_channel_read(), func_channel_write_real(), get_cid_name(), gosub_exec(), gosub_run(), goto_parser(), handle_frame(), handle_gosub(), handle_setpriority(), handle_showchan(), if_helper(), launch_monitor_thread(), leave_voicemail(), leave_voicemail(), log_exec(), lua_pbx_exec(), my_handle_dtmf(), onModeChanged(), ooh323_rtp_read(), pbx_builtin_goto(), pbx_builtin_setvar_multiple(), pbx_builtin_waitexten(), pbx_extension_helper(), pbx_parse_location(), raise_exception(), realtime_exec(), ring_entry(), send_broadcast_event(), serialize_showchan(), setup_env(), setup_peer_after_bridge_goto(), setup_peer_after_bridge_goto(), setup_privacy_args(), try_calling(), and wait_for_answer().

◆ ast_channel_exten_set()

void ast_channel_exten_set ( struct ast_channel chan,
const char *  value 
)

Definition at line 240 of file channel_internal_api.c.

241{
242 if (!*chan->lastexten || strcmp(value, chan->exten)) {
243 /* only copy to last exten when it changes, unless it's empty to begin with */
244 ast_copy_string(chan->lastexten, chan->exten, sizeof(chan->lastexten));
245 }
246 ast_copy_string(chan->exten, value, sizeof(chan->exten));
248}
char lastexten[AST_MAX_EXTENSION]

References AST_CHANNEL_SNAPSHOT_INVALIDATE_DIALPLAN, ast_channel_snapshot_invalidate_segment(), ast_copy_string(), ast_channel::exten, ast_channel::lastexten, and value.

Referenced by __analog_ss_thread(), __ast_channel_alloc_ap(), __ast_request_and_dial(), action_dialplan_exec(), analog_ss_thread(), ari_originate_dial(), ast_add_extension2_lockopt(), ast_bridge_setup_after_goto(), ast_cel_fabricate_channel_from_event(), ast_explicit_goto(), ast_iax2_new(), ast_pbx_h_exten_run(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), dahdi_new(), dial_exec_full(), dialout(), do_monitor_headset(), do_notify(), forward_message(), generic_recall(), gosub_exec(), gosub_run(), handle_gosub(), handle_response_cmgr(), handle_setextension(), jingle_new(), leave_voicemail(), minivm_greet_exec(), ooh323_new(), pbx_builtin_background(), pbx_extension_helper(), pbx_outgoing_exec(), return_exec(), ring_entry(), select_entry(), set_ext_pri(), unistim_ss(), and wait_for_answer().

◆ ast_channel_fd()

int ast_channel_fd ( const struct ast_channel chan,
int  which 
)

Definition at line 1053 of file channel_internal_api.c.

1054{
1055 return (which >= AST_VECTOR_SIZE(&chan->fds)) ? -1 : AST_VECTOR_GET(&chan->fds, which);
1056}
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition vector.h:620
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition vector.h:691

References AST_VECTOR_GET, and AST_VECTOR_SIZE.

Referenced by __dahdi_exception(), analog_exception(), ast_channel_fd_isset(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), ast_waitfor_nandfds(), build_conf(), channel_do_masquerade(), conf_run(), flash_exec(), meetme_menu_admin_extended(), native_chan_changed(), native_start(), serialize_showchan(), and swap_subs().

◆ ast_channel_fd_add()

int ast_channel_fd_add ( struct ast_channel chan,
int  value 
)

Add a file descriptor to the channel without a fixed position.

Since
15
Parameters
chanThe channel to add the file descriptor to
valueThe file descriptor
Precondition
chan is locked
Returns
The position of the file descriptor

Definition at line 1067 of file channel_internal_api.c.

1068{
1069 int pos = AST_EXTENDED_FDS;
1070
1071 while (ast_channel_fd_isset(chan, pos)) {
1072 pos += 1;
1073 }
1074
1075 AST_VECTOR_REPLACE(&chan->fds, pos, value);
1076
1077 return pos;
1078}
#define AST_EXTENDED_FDS
Definition channel.h:197
int ast_channel_fd_isset(const struct ast_channel *chan, int which)
#define AST_VECTOR_REPLACE(vec, idx, elem)
Replace an element at a specific position in a vector, growing the vector if needed.
Definition vector.h:295

References ast_channel_fd_isset(), AST_EXTENDED_FDS, AST_VECTOR_REPLACE, and value.

Referenced by AST_TEST_DEFINE().

◆ ast_channel_fd_count()

int ast_channel_fd_count ( const struct ast_channel chan)

Retrieve the number of file decriptor positions present on the channel.

Since
15
Parameters
chanThe channel to get the count of
Precondition
chan is locked
Returns
The number of file descriptor positions

Definition at line 1062 of file channel_internal_api.c.

1063{
1064 return AST_VECTOR_SIZE(&chan->fds);
1065}

References AST_VECTOR_SIZE.

Referenced by AST_TEST_DEFINE(), ast_waitfor_nandfds(), and channel_do_masquerade().

◆ ast_channel_fd_isset()

int ast_channel_fd_isset ( const struct ast_channel chan,
int  which 
)

Definition at line 1057 of file channel_internal_api.c.

1058{
1059 return ast_channel_fd(chan, which) > -1;
1060}
int ast_channel_fd(const struct ast_channel *chan, int which)

References ast_channel_fd().

Referenced by __ast_read(), and ast_channel_fd_add().

◆ ast_channel_fdno()

int ast_channel_fdno ( const struct ast_channel chan)

◆ ast_channel_fdno_set()

void ast_channel_fdno_set ( struct ast_channel chan,
int  value 
)

Definition at line 294 of file channel_internal_api.c.

295{
296 chan->fdno = value;
297}

References ast_channel::fdno, and value.

Referenced by __ast_read(), ast_settimeout_full(), ast_waitfor_nandfds(), channel_do_masquerade(), and read_test().

◆ ast_channel_feature_hooks_append()

int ast_channel_feature_hooks_append ( struct ast_channel chan,
struct ast_bridge_features features 
)

Appends to the channel-attached features a channel has access to upon being bridged.

Note
The channel must be locked when calling this function.
Parameters
chanWhich channel to set features for
featuresThe feature set to append to the channel's features
Return values
0on success
-1on failure

Definition at line 11061 of file channel.c.

11062{
11063 return channel_feature_hooks_set_full(chan, features, 0);
11064}
static int channel_feature_hooks_set_full(struct ast_channel *chan, struct ast_bridge_features *features, int replace)
Definition channel.c:11024

References channel_feature_hooks_set_full().

Referenced by AST_TEST_DEFINE(), and AST_TEST_DEFINE().

◆ ast_channel_feature_hooks_get()

struct ast_bridge_features * ast_channel_feature_hooks_get ( struct ast_channel chan)

Gets the channel-attached features a channel has access to upon being bridged.

Note
The channel must be locked when calling this function.
Parameters
chanWhich channel to get features for
Return values
non-NULLThe features currently set for this channel
NULLif the features have not been set

Definition at line 11013 of file channel.c.

11014{
11015 struct ast_datastore *datastore;
11016
11018 if (!datastore) {
11019 return NULL;
11020 }
11021 return datastore->data;
11022}
static const struct ast_datastore_info bridge_features_info
Definition channel.c:11008
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:2390

References ast_channel_datastore_find(), bridge_features_info, ast_datastore::data, and NULL.

Referenced by bridge_channel_internal_join().

◆ ast_channel_feature_hooks_replace()

int ast_channel_feature_hooks_replace ( struct ast_channel chan,
struct ast_bridge_features features 
)

Sets the channel-attached features a channel has access to upon being bridged.

Note
The channel must be locked when calling this function.
Parameters
chanWhich channel to set features for
featuresThe feature set with which to replace the channel's features
Return values
0on success
-1on failure

Definition at line 11066 of file channel.c.

11067{
11068 return channel_feature_hooks_set_full(chan, features, 1);
11069}

References channel_feature_hooks_set_full().

◆ ast_channel_fin()

unsigned int ast_channel_fin ( const struct ast_channel chan)

Definition at line 389 of file channel_internal_api.c.

390{
391 return chan->fin;
392}
unsigned int fin

References ast_channel::fin.

Referenced by __ast_read(), channel_set_debug(), and serialize_showchan().

◆ ast_channel_fin_set()

void ast_channel_fin_set ( struct ast_channel chan,
unsigned int  value 
)

Definition at line 393 of file channel_internal_api.c.

394{
395 chan->fin = value;
396}

References ast_channel::fin, and value.

Referenced by __ast_channel_alloc_ap(), __ast_read(), and channel_set_debug().

◆ ast_channel_flags()

struct ast_flags * ast_channel_flags ( struct ast_channel chan)

Definition at line 1127 of file channel_internal_api.c.

1128{
1129 return &chan->flags;
1130}
struct ast_flags flags

References ast_channel::flags.

Referenced by __analog_ss_thread(), __ast_pbx_run(), __ast_queue_frame(), __ast_read(), __ast_request_and_dial(), action_bridge(), action_redirect(), agent_request_exec(), analog_ss_thread(), ari_channels_handle_originate_with_id(), ast_async_goto(), ast_audiohook_attach(), ast_autoservice_start(), ast_autoservice_stop(), ast_bridge_channel_playfile(), ast_bridge_join(), ast_bridge_setup_after_goto(), ast_call(), ast_can_pickup(), ast_channel_clear_flag(), ast_channel_defer_dtmf(), ast_channel_destructor(), ast_channel_end_dtmf(), ast_channel_move(), ast_channel_publish_snapshot(), ast_channel_set_flag(), ast_channel_snapshot_create(), ast_channel_stage_snapshot(), ast_channel_stage_snapshot_done(), ast_channel_yank(), ast_explicit_goto(), ast_hangup(), ast_iax2_new(), ast_indicate_data(), ast_pbx_h_exten_run(), ast_raw_answer_with_stream_topology(), ast_readstring_full(), ast_rtp_instance_set_stats_vars(), ast_sendtext_data(), ast_setstate(), ast_settimeout_full(), ast_softhangup_nolock(), ast_streamfile(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), ast_transfer_protocol(), ast_unreal_new_channels(), ast_var_channels_table(), ast_waitfor_nandfds(), ast_waitfordigit_full(), ast_write_stream(), audiosocket_request(), bridge_channel_internal_join(), bridge_channel_internal_pull(), bridge_impart_internal(), bridge_reconfigured_connected_line_update(), call_forward_inherit(), channel_do_masquerade(), channel_spy(), common_exec(), dahdi_new(), dahdi_read(), deactivate_generator_nolock(), dial_exec_full(), eivr_comm(), gosub_exec(), gosub_run(), handle_exec(), handle_gosub(), limits_interval_playback(), linear_alloc(), local_ast_moh_start(), local_ast_moh_stop(), multicast_rtp_request(), optimize_lock_chan_stack(), optimize_lock_peer_stack(), pbx_builtin_background(), pbx_outgoing_attempt(), playtones_alloc(), retrydial_exec(), return_exec(), serialize_showchan(), should_skip_dtmf(), should_trigger_dtmf_emulating(), stasis_app_control_snoop(), tonepair_alloc(), unicast_rtp_request(), waitstream_core(), and webchan_request().

◆ ast_channel_forward_endpoint()

int ast_channel_forward_endpoint ( struct ast_channel chan,
struct ast_endpoint endpoint 
)

Forward channel stasis messages to the given endpoint.

Since
12
Parameters
chanThe channel to forward from
endpointThe endpoint to forward to
Return values
0Success
non-zeroFailure

Definition at line 1427 of file channel_internal_api.c.

1429{
1430 ast_assert(chan != NULL);
1431 ast_assert(endpoint != NULL);
1432
1433 chan->endpoint_forward =
1435 ast_endpoint_topic(endpoint));
1436 if (!chan->endpoint_forward) {
1437 return -1;
1438 }
1439
1440 return 0;
1441}
struct stasis_topic * ast_channel_topic(struct ast_channel *chan)
A topic which publishes the events for a particular channel.
struct stasis_topic * ast_endpoint_topic(struct ast_endpoint *endpoint)
Returns the topic for a specific endpoint.
struct stasis_forward * stasis_forward_all(struct stasis_topic *from_topic, struct stasis_topic *to_topic)
Create a subscription which forwards all messages from one topic to another.
Definition stasis.c:1645
struct stasis_forward * endpoint_forward
#define ast_assert(a)
Definition utils.h:779

References ast_assert, ast_channel_topic(), ast_endpoint_topic(), ast_channel::endpoint_forward, NULL, and stasis_forward_all().

Referenced by ast_endpoint_add_channel().

◆ ast_channel_fout()

unsigned int ast_channel_fout ( const struct ast_channel chan)

Definition at line 397 of file channel_internal_api.c.

398{
399 return chan->fout;
400}
unsigned int fout

References ast_channel::fout.

Referenced by ast_write_stream(), channel_set_debug(), and serialize_showchan().

◆ ast_channel_fout_set()

void ast_channel_fout_set ( struct ast_channel chan,
unsigned int  value 
)

Definition at line 401 of file channel_internal_api.c.

402{
403 chan->fout = value;
404}

References ast_channel::fout, and value.

Referenced by __ast_channel_alloc_ap(), ast_write_stream(), and channel_set_debug().

◆ ast_channel_framehooks()

struct ast_framehook_list * ast_channel_framehooks ( const struct ast_channel chan)

◆ ast_channel_framehooks_set()

void ast_channel_framehooks_set ( struct ast_channel chan,
struct ast_framehook_list value 
)

Definition at line 576 of file channel_internal_api.c.

577{
578 chan->framehooks = value;
579}

References ast_channel::framehooks, and value.

Referenced by ast_framehook_attach(), and ast_framehook_list_destroy().

◆ ast_channel_generator()

struct ast_generator * ast_channel_generator ( const struct ast_channel chan)

◆ ast_channel_generator_set()

void ast_channel_generator_set ( struct ast_channel chan,
struct ast_generator value 
)

Definition at line 584 of file channel_internal_api.c.

585{
586 chan->generator = value;
587}

References ast_channel::generator, and value.

Referenced by ast_activate_generator(), ast_hangup(), and deactivate_generator_nolock().

◆ ast_channel_generatordata()

void * ast_channel_generatordata ( const struct ast_channel chan)

◆ ast_channel_generatordata_set()

void ast_channel_generatordata_set ( struct ast_channel chan,
void *  value 
)

◆ ast_channel_get_ari_vars()

struct varshead * ast_channel_get_ari_vars ( struct ast_channel chan)

Gets the variables for a given channel, as specified by ast_channel_set_ari_vars().

Since
14.2.0

The returned variable list is an AO2 object, so ao2_cleanup() to free it.

Parameters
chanChannel to get variables for.
Returns
List of channel variables.
Return values
NULLon error

Definition at line 8035 of file channel.c.

8036{
8037 return channel_get_external_vars(&ari_vars, chan);
8038}
static struct varshead * channel_get_external_vars(struct external_vars *channelvars, struct ast_channel *chan)
Definition channel.c:7983
static struct external_vars ari_vars
Definition channel.c:7879

References ari_vars, and channel_get_external_vars().

Referenced by ast_channel_snapshot_create().

◆ ast_channel_get_bridge()

struct ast_bridge * ast_channel_get_bridge ( const struct ast_channel chan)

Get the bridge associated with a channel.

Since
12.0.0
Parameters
chanThe channel whose bridge we want

The bridge returned has its reference count incremented. Use ao2_cleanup() or ao2_ref() in order to decrement the reference count when you are finished with the bridge.

Note
This function expects the channel to be locked prior to being called and will not grab the channel lock.
Return values
NULLNo bridge present on the channel
non-NULLThe bridge the channel is in

Definition at line 10644 of file channel.c.

10645{
10646 struct ast_bridge *bridge;
10647
10648 bridge = ast_channel_internal_bridge(chan);
10649 if (bridge) {
10650 ao2_ref(bridge, +1);
10651 }
10652 return bridge;
10653}

References ao2_ref, and ast_channel_internal_bridge().

Referenced by ast_bridge_add_channel(), ast_bridge_transfer_acquire_bridge(), ast_channel_bridge_peer(), bridgeadd_exec(), channel_snapshot_bridge_create(), generate_status(), get_transfer_parties(), handle_showchan(), manager_bridge_kick(), native_rtp_framehook(), and serialize_showchan().

◆ ast_channel_get_bridge_channel()

struct ast_bridge_channel * ast_channel_get_bridge_channel ( struct ast_channel chan)

Get a reference to the channel's bridge pointer.

Since
12.0.0
Parameters
chanThe channel whose bridge channel is desired
Note
This increases the reference count of the bridge_channel. Use ao2_ref() or ao2_cleanup() to decrement the refcount when you are finished with it.
It is expected that the channel is locked prior to placing this call.
Return values
NULLThe channel has no bridge_channel
non-NULLA reference to the bridge_channel

Definition at line 10692 of file channel.c.

10693{
10694 struct ast_bridge_channel *bridge_channel;
10695
10696 bridge_channel = ast_channel_internal_bridge_channel(chan);
10697 if (bridge_channel) {
10698 ao2_ref(bridge_channel, +1);
10699 }
10700 return bridge_channel;
10701}

References ao2_ref, ast_channel_internal_bridge_channel(), and ast_bridge_channel::chan.

Referenced by __analog_ss_thread(), agent_bridge_channel_get_lock(), analog_ss_thread(), ast_bridge_add_channel(), ast_bridge_notify_masquerade(), ast_bridge_transfer_attended(), ast_bridge_transfer_blind(), bridge_channel_internal_queue_attended_transfer(), bridge_channel_internal_queue_blind_transfer(), bridge_move(), dial_bridge_after_cb(), hold(), internal_bridge_after_cb(), manager_park_bridged(), parker_parked_call_message_response(), play_sound(), recall_pull(), ringing(), send_message(), set_interval_hook(), transfer_pull(), try_parking(), and unhold().

◆ ast_channel_get_by_exten()

struct ast_channel * ast_channel_get_by_exten ( const char *  exten,
const char *  context 
)

Find a channel by extension and context.

Parameters
extenthe extension to search for
contextthe context to search for

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

1431{
1433 return NULL;
1434 }
1435 if (ast_strlen_zero(exten) || ast_strlen_zero(context)) {
1436 ast_log(LOG_ERROR, "exten and context must be provided\n");
1437 return NULL;
1438 }
1440}
static struct ast_channel * get_by_exten(struct ast_channelstorage_instance *driver, const char *exten, const char *context, int rdlock)

References ast_log, ast_strlen_zero(), CHANNELSTORAGE_API, ast_channel::context, current_channel_storage_instance, ast_channel::exten, get_by_exten(), LOG_ERROR, and NULL.

◆ ast_channel_get_by_name()

struct ast_channel * ast_channel_get_by_name ( const char *  search)

Find a channel by name or uniqueid.

Parameters
searchthe name or uniqueid of the channel to search for

First searches for a channel with a matching name. If not found a search for a channel with a matching uniqueid is done.

Return values
achannel with a matching name or uniqueid
NULLif no channel was found
Note
The fallback search by uniqueid is a historical thing. If you know the search term is a uniqueid, use ast_channel_get_by_uniqueid instead.
Since
1.8

Definition at line 1417 of file channel.c.

1418{
1420 return NULL;
1421 }
1422 if (ast_strlen_zero(name)) {
1423 ast_log(LOG_ERROR, "name must be provided\n");
1424 return NULL;
1425 }
1426
1427 return CHANNELSTORAGE_API(current_channel_storage_instance, get_by_name_prefix_or_uniqueid, name, 0, 1);
1428}

References ast_log, ast_strlen_zero(), CHANNELSTORAGE_API, current_channel_storage_instance, LOG_ERROR, name, and NULL.

Referenced by action_add_agi_cmd(), action_aocmessage(), action_atxfer(), action_blind_transfer(), action_cancel_atxfer(), action_getvar(), action_redirect(), action_sendtext(), action_setvar(), action_status(), action_timeout(), ari_channels_handle_originate_with_id(), ari_channels_handle_snoop_channel(), assign_uuid(), ast_ari_channels_create(), ast_ari_channels_dial(), ast_ari_channels_get_channel_var(), ast_ari_channels_hangup(), ast_ari_channels_rtpstatistics(), ast_ari_channels_transfer_progress(), ast_async_goto_by_name(), ast_manager_hangup_helper(), asyncgoto_exec(), bridge_channel_attended_transfer(), call_forwarded_handler(), channel_find(), channel_hangup_matches(), cli_channelstats_print_body(), common_exec(), controlplayback_manager(), do_broadcast(), find_control(), func_chan_exists_read(), func_export_write(), func_mchan_read(), func_mchan_write(), handle_cli_agi_add_cmd(), handle_core_set_debug_channel(), handle_dump_frames(), handle_getvariablefull(), handle_hangup(), handle_hangup(), handle_redirect(), handle_remb_set(), handle_set_chanvar(), handle_show_chanvar(), handle_show_hangup_channel(), handle_showchan(), handle_softhangup(), import_helper(), inherit_channel_vars_from_id(), manager_bridge_kick(), manager_mixmonitor(), manager_mute_mixmonitor(), manager_mutestream(), manager_optimize_away(), manager_park(), manager_play_dtmf(), manager_play_mf(), manager_send_flash(), manager_stop_mixmonitor(), moh_channel_thread(), parker_parked_call_message_response(), parking_park_bridge_channel(), push_notify_channel(), refer_progress_bridge(), rtp_check_timeout(), senddtmf_exec(), sendmf_exec(), sendsf_exec(), shared_read(), shared_write(), stasis_app_bridge_moh_channel(), stasis_app_bridge_moh_stop(), and stasis_app_bridge_playback_channel_find().

◆ ast_channel_get_by_name_prefix()

struct ast_channel * ast_channel_get_by_name_prefix ( const char *  name,
size_t  name_len 
)

Find a channel by a name prefix.

Parameters
searchThe channel name or uniqueid prefix to search for
lenOnly search for up to this many characters from the search term

Search for a channel that has the same name prefix as specified by the search term. If not found, search for an exact match on the uniqueid. Searching by partial uniqueid doesn't make any sense as it's usually a system-name plus a timestamp and is not supported.

Return values
achannel with a matching name or uniqueid
NULLif no channel was found
Note
The fallback search by uniqueid is a historical thing. If you know the search term is a uniqueid, use ast_channel_get_by_uniqueid instead.
Since
1.8

Definition at line 1400 of file channel.c.

1401{
1403 return NULL;
1404 }
1405 if (ast_strlen_zero(name)) {
1406 ast_log(LOG_ERROR, "name must be provided\n");
1407 return NULL;
1408 }
1409
1410 return CHANNELSTORAGE_API(current_channel_storage_instance, get_by_name_prefix_or_uniqueid, name, name_len, 1);
1411}

References ast_log, ast_strlen_zero(), CHANNELSTORAGE_API, current_channel_storage_instance, LOG_ERROR, name, and NULL.

Referenced by action_aocmessage(), action_bridge(), ast_parse_device_state(), bridge_exec(), bridgeadd_exec(), cc_generic_agent_stop_ringing(), common_exec(), handle_bridge_kick_channel(), handle_cli_mixmonitor(), shared_read(), and shared_write().

◆ ast_channel_get_by_uniqueid()

struct ast_channel * ast_channel_get_by_uniqueid ( const char *  uniqueid)

Find a channel by a uniqueid.

Parameters
uniqueidThe uniqueid to search for
Return values
achannel with the uniqueid specified by the arguments
NULLif no channel was found

Definition at line 1442 of file channel.c.

1443{
1445 return NULL;
1446 }
1447 if (ast_strlen_zero(uniqueid)) {
1448 ast_log(LOG_ERROR, "uniqueid must be provided\n");
1449 return NULL;
1450 }
1452}
static struct ast_channel * get_by_uniqueid(struct ast_channelstorage_instance *driver, const char *uniqueid, int lock)

References ast_log, ast_strlen_zero(), CHANNELSTORAGE_API, current_channel_storage_instance, get_by_uniqueid(), LOG_ERROR, NULL, and ast_channel::uniqueid.

◆ ast_channel_get_cc_agent_type()

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

10624{
10625 int len = size;
10626 char *slash;
10627
10629 return 0;
10630 }
10631
10633 if ((slash = strchr(agent_type, '/'))) {
10634 *slash = '\0';
10635 }
10636 return 0;
10637}
int ast_channel_queryoption(struct ast_channel *chan, int option, void *data, int *datalen, int block)
Checks the value of an option.
Definition channel.c:7516
#define AST_OPTION_CC_AGENT_TYPE

References agent_type, ast_channel_name(), ast_channel_queryoption(), ast_copy_string(), AST_OPTION_CC_AGENT_TYPE, and len().

Referenced by find_agent_callbacks().

◆ ast_channel_get_cc_config_params()

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.

Warning
You should call this function only if ast_cc_is_enabled() returns true.
Parameters
chanChannel to retrieve parameters from
Return values
NULLFailure or CCSS is globally disabled.
non-NULLThe parameters desired

Definition at line 10580 of file channel.c.

10581{
10582 struct ast_datastore *cc_datastore;
10583
10584 if (!ast_cc_is_enabled()) {
10585 return NULL;
10586 }
10587
10588 if (!(cc_datastore = ast_channel_datastore_find(chan, &cc_channel_datastore_info, NULL))) {
10589 /* If we can't find the datastore, it almost definitely means that the channel type being
10590 * used has not had its driver modified to parse CC config parameters. The best action
10591 * to take here is to create the parameters on the spot with the defaults set.
10592 */
10593 if (ast_channel_cc_params_init(chan, NULL)) {
10594 return NULL;
10595 }
10596 if (!(cc_datastore = ast_channel_datastore_find(chan, &cc_channel_datastore_info, NULL))) {
10597 /* Should be impossible */
10598 return NULL;
10599 }
10600 }
10601
10602 ast_assert(cc_datastore->data != NULL);
10603 return cc_datastore->data;
10604}
int ast_cc_is_enabled(void)
Determine if CCSS is enabled.
Definition ccss.c:4540
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:10557

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

Referenced by acf_cc_read(), acf_cc_write(), analog_call(), ast_cc_call_failed(), ast_cc_call_init(), ast_queue_cc_frame(), ast_unreal_call_setup(), ast_unreal_new_channels(), cc_agent_init(), cc_core_init_instance(), and find_agent_callbacks().

◆ ast_channel_get_current_storage_driver_name()

const char * ast_channel_get_current_storage_driver_name ( void  )

Get the name of the current channel storage driver.

Returns
The name of the current channel storage driver

Definition at line 8079 of file channel.c.

8080{
8083}
const struct ast_channelstorage_driver * current_channel_storage_driver
The current channel storage driver.

References current_channel_storage_driver, and ast_channelstorage_driver::driver_name.

Referenced by handle_show_settings().

◆ ast_channel_get_default_stream()

struct ast_stream * ast_channel_get_default_stream ( struct ast_channel chan,
enum ast_media_type  type 
)

Retrieve the default stream of a specific media type on a channel.

Parameters
chanThe channel to get the stream from
typeThe media type of the default stream
Precondition
chan is locked
Return values
non-NULLsuccess
NULLfailure

Definition at line 1535 of file channel_internal_api.c.

1537{
1538 ast_assert(chan != NULL);
1540
1541 return chan->default_streams[type];
1542}
@ AST_MEDIA_TYPE_END
Definition codec.h:36
struct ast_stream * default_streams[AST_MEDIA_TYPE_END]

References ast_assert, AST_MEDIA_TYPE_END, ast_channel::default_streams, NULL, and type.

Referenced by __ast_read(), ast_unreal_write_stream(), ast_write_stream(), and stream_echo_write_error().

◆ ast_channel_get_device_name()

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

10607{
10608 int len = name_buffer_length;
10609 char *dash;
10610 if (!ast_channel_queryoption(chan, AST_OPTION_DEVICE_NAME, device_name, &len, 0)) {
10611 return 0;
10612 }
10613
10614 /* Dang. Do it the old-fashioned way */
10615 ast_copy_string(device_name, ast_channel_name(chan), name_buffer_length);
10616 if ((dash = strrchr(device_name, '-'))) {
10617 *dash = '\0';
10618 }
10619
10620 return 0;
10621}
#define AST_OPTION_DEVICE_NAME

References ast_channel_name(), ast_channel_queryoption(), ast_copy_string(), AST_OPTION_DEVICE_NAME, and len().

Referenced by ast_cc_call_failed(), ast_cc_is_recall(), ast_queue_cc_frame(), cc_core_init_instance(), cccancel_exec(), ccreq_exec(), chan_pjsip_indicate(), dial_exec_full(), and func_channel_read().

◆ ast_channel_get_duration()

int ast_channel_get_duration ( struct ast_channel chan)

Obtain how long the channel since the channel was created.

Since
12
Parameters
chanThe channel object
Return values
0if the time value cannot be computed (or you called this really fast)
Thenumber of seconds the channel has been up

Definition at line 2864 of file channel.c.

2865{
2866 return (ast_channel_get_duration_ms(chan) / 1000);
2867}
int64_t ast_channel_get_duration_ms(struct ast_channel *chan)
Obtain how long it's been, in milliseconds, since the channel was created.
Definition channel.c:2854

References ast_channel_get_duration_ms().

Referenced by end_bridge_callback(), and serialize_showchan().

◆ ast_channel_get_duration_ms()

int64_t ast_channel_get_duration_ms ( struct ast_channel chan)

Obtain how long it's been, in milliseconds, since the channel was created.

Since
13.27.0
16.4.0
Parameters
chanThe channel object
Return values
0if the time value cannot be computed (or you called this really fast)
Thenumber of milliseconds since channel creation

Definition at line 2854 of file channel.c.

2855{
2856 ast_assert(NULL != chan);
2857
2859 return 0;
2860 }
2862}

References ast_assert, ast_channel_creationtime(), ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), and NULL.

Referenced by ast_channel_get_duration(), end_bridge_callback(), end_bridge_callback(), and queue_exec().

◆ ast_channel_get_intercept_mode()

int ast_channel_get_intercept_mode ( void  )

Am I currently running an intercept dialplan routine.

Since
13.14.0

A dialplan intercept routine is equivalent to an interrupt routine. As such, the routine must be done quickly and you do not have access to the media stream. These restrictions are necessary because the media stream is the responsibility of some other code and interfering with or delaying that processing is bad.

Return values
0Not in an intercept routine.
1In an intercept routine.

Definition at line 10439 of file channel.c.

10440{
10441 return ast_threadstorage_get_ptr(&in_intercept_routine) ? 1 : 0;
10442}
void * ast_threadstorage_get_ptr(struct ast_threadstorage *ts)
Retrieve a raw pointer from threadstorage.

References ast_threadstorage_get_ptr().

Referenced by run_agi().

◆ ast_channel_get_manager_vars()

struct varshead * ast_channel_get_manager_vars ( struct ast_channel chan)

Gets the variables for a given channel, as specified by ast_channel_set_manager_vars().

Since
12

The returned variable list is an AO2 object, so ao2_cleanup() to free it.

Parameters
chanChannel to get variables for.
Returns
List of channel variables.
Return values
NULLon error

Definition at line 8030 of file channel.c.

8031{
8032 return channel_get_external_vars(&ami_vars, chan);
8033}
static struct external_vars ami_vars
Definition channel.c:7878

References ami_vars, and channel_get_external_vars().

Referenced by append_channel_vars(), and ast_channel_snapshot_create().

◆ ast_channel_get_stream_topology()

struct ast_stream_topology * ast_channel_get_stream_topology ( const struct ast_channel chan)

◆ ast_channel_get_stream_topology_change_source()

void * ast_channel_get_stream_topology_change_source ( struct ast_channel chan)

Retrieve the source that initiated the last stream topology change.

Parameters
chanThe channel
Return values
Thechannel's stream topology change source

Definition at line 539 of file channel_internal_api.c.

540{
542}
void * stream_topology_change_source

References ast_channel::stream_topology_change_source.

Referenced by native_rtp_stream_topology_changed(), and simple_bridge_stream_topology_changed().

◆ ast_channel_get_t38_state()

static enum ast_t38_state ast_channel_get_t38_state ( struct ast_channel chan)
inlinestatic

Retrieves the current T38 state of a channel.

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

Definition at line 2917 of file channel.h.

2918{
2920 int datalen = sizeof(state);
2921
2923
2924 return state;
2925}

References ast_channel_queryoption(), AST_OPTION_T38_STATE, ast_channel::state, and T38_STATE_UNAVAILABLE.

Referenced by fax_gateway_detect_t38(), fax_gateway_detect_v21(), fax_gateway_framehook(), generic_fax_exec(), receivefax_exec(), receivefax_t38_init(), sendfax_exec(), sendfax_t38_init(), set_fax_t38_caps(), and spandsp_fax_gateway_start().

◆ ast_channel_get_up_time()

int ast_channel_get_up_time ( struct ast_channel chan)

Obtain how long it has been since the channel was answered.

Since
12
Parameters
chanThe channel object
Return values
0if the channel isn't answered (or you called this really fast)
Thenumber of seconds the channel has been up

Definition at line 2879 of file channel.c.

2880{
2881 return (ast_channel_get_up_time_ms(chan) / 1000);
2882}
int64_t ast_channel_get_up_time_ms(struct ast_channel *chan)
Obtain how long it has been since the channel was answered in ms.
Definition channel.c:2869

References ast_channel_get_up_time_ms().

Referenced by action_confbridgelist_item(), chan_pjsip_read_stream(), dahdi_read(), and end_bridge_callback().

◆ ast_channel_get_up_time_ms()

int64_t ast_channel_get_up_time_ms ( struct ast_channel chan)

Obtain how long it has been since the channel was answered in ms.

Since
13.27.0
16.4.0
Parameters
chanThe channel object
Return values
0if the channel isn't answered (or you called this really fast)
Thenumber of milliseconds the channel has been up

Definition at line 2869 of file channel.c.

2870{
2871 ast_assert(NULL != chan);
2872
2874 return 0;
2875 }
2877}

References ast_assert, ast_channel_answertime(), ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), and NULL.

Referenced by ast_channel_get_up_time(), and end_bridge_callback().

◆ ast_channel_get_vars()

struct varshead * ast_channel_get_vars ( struct ast_channel chan)

Gets the variables for a given channel, as set using pbx_builtin_setvar_helper().

Since
12

The returned variable list is an AO2 object, so ao2_cleanup() to free it.

Parameters
chanChannel to get variables for
Returns
List of channel variables.
Return values
NULLon error

Definition at line 7958 of file channel.c.

7959{
7960 RAII_VAR(struct varshead *, ret, NULL, ao2_cleanup);
7961 struct ast_var_t *cv;
7962
7963 ret = ao2_alloc(sizeof(*ret), varshead_dtor);
7964
7965 if (!ret) {
7966 return NULL;
7967 }
7968
7971
7972 if (!var) {
7973 return NULL;
7974 }
7975
7977 }
7978
7979 ao2_ref(ret, +1);
7980 return ret;
7981}
#define var
Definition ast_expr2f.c:605
#define ao2_cleanup(obj)
Definition astobj2.h:1934
static void varshead_dtor(void *obj)
Destructor for lists of variables.
Definition channel.c:7948
const char * ast_var_name(const struct ast_var_t *var)
Definition chanvars.c:60
#define ast_var_assign(name, value)
Definition chanvars.h:40
const char * ast_var_value(const struct ast_var_t *var)
Definition chanvars.c:80
struct ast_var_t::@220 entries
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition utils.h:981

References ao2_alloc, ao2_cleanup, ao2_ref, ast_channel_varshead(), AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_var_assign, ast_var_name(), ast_var_value(), ast_var_t::entries, NULL, RAII_VAR, var, and varshead_dtor().

◆ ast_channel_hangup_handlers()

struct ast_hangup_handler_list * ast_channel_hangup_handlers ( struct ast_channel chan)

◆ ast_channel_hangupcause()

int ast_channel_hangupcause ( const struct ast_channel chan)

◆ ast_channel_hangupcause_hash_set()

void ast_channel_hangupcause_hash_set ( struct ast_channel chan,
const struct ast_control_pvt_cause_code cause_code,
int  datalen 
)

Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash on the given channel.

Parameters
chanchannel on which to set the cause information
cause_codeast_control_pvt_cause_code structure containing cause information
datalentotal length of the structure since it may vary

Definition at line 4402 of file channel.c.

4403{
4404 char causevar[256];
4405
4406 if (ast_channel_dialed_causes_add(chan, cause_code, datalen)) {
4407 ast_log(LOG_WARNING, "Unable to store hangup cause for %s on %s\n", cause_code->chan_name, ast_channel_name(chan));
4408 }
4409
4410 if (cause_code->emulate_sip_cause) {
4411 snprintf(causevar, sizeof(causevar), "HASH(SIP_CAUSE,%s)", cause_code->chan_name);
4412 ast_func_write(chan, causevar, cause_code->code);
4413 }
4414}
int ast_func_write(struct ast_channel *chan, const char *function, const char *value)
executes a write operation on a function

References ast_channel_dialed_causes_add(), ast_channel_name(), ast_func_write(), ast_log, ast_control_pvt_cause_code::chan_name, ast_control_pvt_cause_code::code, ast_frame::datalen, ast_control_pvt_cause_code::emulate_sip_cause, and LOG_WARNING.

Referenced by __analog_handle_event(), __ast_request_and_dial(), chan_pjsip_incoming_response_update_cause(), indicate_data_internal(), jingle_action_session_terminate(), and socket_process_helper().

◆ ast_channel_hangupcause_set()

void ast_channel_hangupcause_set ( struct ast_channel chan,
int  value 
)

◆ ast_channel_hangupsource()

const char * ast_channel_hangupsource ( const struct ast_channel chan)

◆ ast_channel_has_ari_vars()

int ast_channel_has_ari_vars ( void  )

Return whether or not any ARI variables have been set.

Since
14.2.0
Return values
0if no ARI variables are expected
1if ARI variables are expected

Definition at line 7907 of file channel.c.

7908{
7910}
static int channel_has_external_vars(struct external_vars *channelvars)
Definition channel.c:7891

References ari_vars, and channel_has_external_vars().

◆ ast_channel_has_audio_frame_or_monitor()

int ast_channel_has_audio_frame_or_monitor ( struct ast_channel chan)

Check if the channel has active audiohooks, active framehooks, or a monitor.

Since
12.0.0
Parameters
chanThe channel to check.
Return values
non-zeroif channel has active audiohooks, framehooks, or monitor.

Definition at line 2551 of file channel.c.

2552{
2555}
int ast_audiohook_write_list_empty(struct ast_audiohook_list *audiohook_list)
Determine if a audiohook_list is empty or not.
Definition audiohook.c:1108
int ast_framehook_list_contains_no_active(struct ast_framehook_list *framehooks)
Determine if a framehook list is free of active framehooks or not.
Definition framehook.c:282

References ast_audiohook_write_list_empty(), ast_channel_audiohooks(), ast_channel_framehooks(), and ast_framehook_list_contains_no_active().

Referenced by native_bridge_is_capable(), optimize_lock_chan_stack(), and optimize_lock_peer_stack().

◆ ast_channel_has_hook_requiring_audio()

int ast_channel_has_hook_requiring_audio ( struct ast_channel chan)

Check if the channel has any active hooks that require audio.

Since
12.3.0
Parameters
chanThe channel to check.
Return values
non-zeroif channel has active audiohooks, audio framehooks, or monitor.

Definition at line 2557 of file channel.c.

2558{
2561}
int ast_framehook_list_contains_no_active_of_type(struct ast_framehook_list *framehooks, enum ast_frame_type type)
Determine if a framehook list is free of active framehooks consuming a specific type of frame.
Definition framehook.c:287

References ast_audiohook_write_list_empty(), ast_channel_audiohooks(), ast_channel_framehooks(), AST_FRAME_VOICE, and ast_framehook_list_contains_no_active_of_type().

Referenced by native_rtp_bridge_capable().

◆ ast_channel_has_manager_vars()

int ast_channel_has_manager_vars ( void  )

Return whether or not any manager variables have been set.

Since
12.4.0
Return values
0if no manager variables are expected
1if manager variables are expected

Definition at line 7902 of file channel.c.

7903{
7905}

References ami_vars, and channel_has_external_vars().

Referenced by ast_channel_publish_varset().

◆ ast_channel_hold_state()

int ast_channel_hold_state ( const struct ast_channel chan)

◆ ast_channel_hold_state_set()

void ast_channel_hold_state_set ( struct ast_channel chan,
int  value 
)

Definition at line 361 of file channel_internal_api.c.

362{
363 chan->hold_state = value;
364}

References ast_channel::hold_state, and value.

Referenced by __ast_channel_alloc_ap(), __ast_dummy_channel_alloc(), and indicate_data_internal().

◆ ast_channel_inherit_variables()

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

6834{
6835 struct ast_var_t *current;
6836 struct ast_var_t *newvar;
6837 const char *varname;
6838 int vartype;
6839
6841 varname = ast_var_full_name(current);
6842 if (!varname) {
6843 continue;
6844 }
6845
6846 vartype = 0;
6847 if (varname[0] == '_') {
6848 vartype = 1;
6849 if (varname[1] == '_') {
6850 vartype = 2;
6851 }
6852 }
6853
6854 switch (vartype) {
6855 case 1:
6856 newvar = ast_var_assign(&varname[1], ast_var_value(current));
6857 break;
6858 case 2:
6859 newvar = ast_var_assign(varname, ast_var_value(current));
6860 break;
6861 default:
6862 continue;
6863 }
6864 if (newvar) {
6865 ast_debug(1, "Inheriting variable %s from %s to %s.\n",
6866 ast_var_full_name(newvar), ast_channel_name(parent),
6867 ast_channel_name(child));
6870 ast_var_value(newvar));
6871 }
6872 }
6873}
size_t current
const char * ast_var_full_name(const struct ast_var_t *var)
Definition chanvars.c:75
void ast_channel_publish_varset(struct ast_channel *chan, const char *variable, const char *value)
Publish a ast_channel_publish_varset for a channel.

References ast_channel_name(), ast_channel_publish_varset(), ast_channel_varshead(), ast_debug, AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_var_assign, ast_var_full_name(), ast_var_value(), current, and ast_var_t::entries.

Referenced by __ast_request_and_dial(), ast_ari_channels_dial(), begin_dial_prerun(), call_forward_inherit(), common_recall_channel_setup(), copy_caller_data(), dial_exec_full(), do_forward(), findmeexec(), park_local_transfer(), ring_entry(), and wait_for_answer().

◆ ast_channel_insmpl()

unsigned long ast_channel_insmpl ( const struct ast_channel chan)

Definition at line 405 of file channel_internal_api.c.

406{
407 return chan->insmpl;
408}
unsigned long insmpl

References ast_channel::insmpl.

◆ ast_channel_insmpl_set()

void ast_channel_insmpl_set ( struct ast_channel chan,
unsigned long  value 
)

Definition at line 409 of file channel_internal_api.c.

410{
411 chan->insmpl = value;
412}

References ast_channel::insmpl, and value.

◆ ast_channel_internal_alert_flush()

ast_alert_status_t ast_channel_internal_alert_flush ( struct ast_channel chan)

Definition at line 982 of file channel_internal_api.c.

983{
984 return ast_alertpipe_flush(chan->alertpipe);
985}
ast_alert_status_t ast_alertpipe_flush(int alert_pipe[2])
Consume all alerts written to the alert pipe.
Definition alertpipe.c:134

References ast_channel::alertpipe, and ast_alertpipe_flush().

Referenced by chan_cleanup().

◆ ast_channel_internal_alert_read()

ast_alert_status_t ast_channel_internal_alert_read ( struct ast_channel chan)

Definition at line 987 of file channel_internal_api.c.

988{
989 return ast_alertpipe_read(chan->alertpipe);
990}
ast_alert_status_t ast_alertpipe_read(int alert_pipe[2])
Read an event from an alert pipe.
Definition alertpipe.c:102

References ast_channel::alertpipe, and ast_alertpipe_read().

Referenced by __ast_queue_frame(), and __ast_read().

◆ ast_channel_internal_alert_readable()

int ast_channel_internal_alert_readable ( struct ast_channel chan)

Definition at line 997 of file channel_internal_api.c.

998{
999 return ast_alertpipe_readable(chan->alertpipe);
1000}
int attribute_pure ast_alertpipe_readable(int alert_pipe[2])
Determine if the alert pipe is readable.
Definition alertpipe.h:114

References ast_channel::alertpipe, and ast_alertpipe_readable().

◆ ast_channel_internal_alert_readfd()

int ast_channel_internal_alert_readfd ( struct ast_channel chan)

Definition at line 1017 of file channel_internal_api.c.

1018{
1019 return ast_alertpipe_readfd(chan->alertpipe);
1020}
int attribute_pure ast_alertpipe_readfd(int alert_pipe[2])
Get the alert pipe's read file descriptor.
Definition alertpipe.h:146

References ast_channel::alertpipe, and ast_alertpipe_readfd().

Referenced by __ast_channel_alloc_ap().

◆ ast_channel_internal_alertpipe_clear()

void ast_channel_internal_alertpipe_clear ( struct ast_channel chan)

Definition at line 1002 of file channel_internal_api.c.

1003{
1005}
void ast_alertpipe_clear(int alert_pipe[2])
Sets the alert pipe file descriptors to default values.
Definition alertpipe.h:98

References ast_channel::alertpipe, and ast_alertpipe_clear().

Referenced by __ast_channel_alloc_ap(), and __ast_dummy_channel_alloc().

◆ ast_channel_internal_alertpipe_close()

void ast_channel_internal_alertpipe_close ( struct ast_channel chan)

Definition at line 1007 of file channel_internal_api.c.

1008{
1010}
void ast_alertpipe_close(int alert_pipe[2])
Close an alert pipe.
Definition alertpipe.c:79

References ast_channel::alertpipe, and ast_alertpipe_close().

Referenced by ast_channel_destructor().

◆ ast_channel_internal_alertpipe_init()

int ast_channel_internal_alertpipe_init ( struct ast_channel chan)

Definition at line 1012 of file channel_internal_api.c.

1013{
1014 return ast_alertpipe_init(chan->alertpipe);
1015}
int ast_alertpipe_init(int alert_pipe[2])
Initialize an alert pipe.
Definition alertpipe.c:38

References ast_channel::alertpipe, and ast_alertpipe_init().

Referenced by __ast_channel_alloc_ap().

◆ ast_channel_internal_alertpipe_swap()

void ast_channel_internal_alertpipe_swap ( struct ast_channel chan1,
struct ast_channel chan2 
)

Swap the interal alertpipe between two channels.

Note
Handle all of the necessary locking before calling this

Definition at line 1022 of file channel_internal_api.c.

1023{
1024 ast_alertpipe_swap(chan1->alertpipe, chan2->alertpipe);
1025}
void ast_alertpipe_swap(int alert_pipe_1[2], int alert_pipe_2[2])
Swap the file descriptors from two alert pipes.
Definition alertpipe.h:161

References ast_channel::alertpipe, and ast_alertpipe_swap().

Referenced by channel_do_masquerade().

◆ ast_channel_internal_bridge()

struct ast_bridge * ast_channel_internal_bridge ( const struct ast_channel chan)

Definition at line 1107 of file channel_internal_api.c.

1108{
1109 return chan->bridge;
1110}
struct ast_bridge * bridge

References ast_channel::bridge.

Referenced by ast_channel_get_bridge(), ast_channel_is_bridged(), ast_unreal_fixup(), bridge_channel_internal_join(), and try_merge_optimize_out().

◆ ast_channel_internal_bridge_channel()

struct ast_bridge_channel * ast_channel_internal_bridge_channel ( const struct ast_channel chan)

◆ ast_channel_internal_bridge_channel_set()

void ast_channel_internal_bridge_channel_set ( struct ast_channel chan,
struct ast_bridge_channel value 
)

◆ ast_channel_internal_bridge_set()

void ast_channel_internal_bridge_set ( struct ast_channel chan,
struct ast_bridge value 
)

◆ ast_channel_internal_bridged_channel()

struct ast_channel * ast_channel_internal_bridged_channel ( const struct ast_channel chan)

◆ ast_channel_internal_bridged_channel_set()

void ast_channel_internal_bridged_channel_set ( struct ast_channel chan,
struct ast_channel value 
)

◆ ast_channel_internal_copy_linkedid()

void ast_channel_internal_copy_linkedid ( struct ast_channel dest,
struct ast_channel source 
)

Copy the full linkedid channel id structure from one channel to another.

Parameters
destDestination to copy linkedid to
sourceSource channel to copy linkedid from

Definition at line 1304 of file channel_internal_api.c.

1305{
1306 if (dest->linkedid.creation_time == source->linkedid.creation_time
1308 && !strcmp(dest->linkedid.unique_id, source->linkedid.unique_id)) {
1309 return;
1310 }
1311 dest->linkedid = source->linkedid;
1314}
@ AST_CHANNEL_SNAPSHOT_INVALIDATE_PEER
char unique_id[AST_MAX_UNIQUEID]

References ast_channel_publish_snapshot(), AST_CHANNEL_SNAPSHOT_INVALIDATE_PEER, ast_channel_snapshot_invalidate_segment(), ast_channel_id::creation_time, ast_channel_id::creation_unique, ast_channel::linkedid, and ast_channel_id::unique_id.

Referenced by ast_bridge_channel_update_linkedids().

◆ ast_channel_internal_fd_clear()

void ast_channel_internal_fd_clear ( struct ast_channel chan,
int  which 
)

Definition at line 1041 of file channel_internal_api.c.

1042{
1043 if (which >= AST_VECTOR_SIZE(&chan->fds)) {
1044 return;
1045 }
1046
1047 AST_VECTOR_REPLACE(&chan->fds, which, -1);
1048}

References AST_VECTOR_REPLACE, and AST_VECTOR_SIZE.

Referenced by handle_command(), and handle_negotiated_sdp().

◆ ast_channel_internal_fd_clear_all()

void ast_channel_internal_fd_clear_all ( struct ast_channel chan)

Definition at line 1049 of file channel_internal_api.c.

1050{
1052}
#define AST_VECTOR_RESET(vec, cleanup)
Reset vector.
Definition vector.h:636
#define AST_VECTOR_ELEM_CLEANUP_NOOP(elem)
Vector element cleanup that does nothing.
Definition vector.h:582

References AST_VECTOR_ELEM_CLEANUP_NOOP, and AST_VECTOR_RESET.

Referenced by __ast_channel_alloc_ap(), __ast_dummy_channel_alloc(), and channel_do_masquerade().

◆ ast_channel_internal_fd_set()

void ast_channel_internal_fd_set ( struct ast_channel chan,
int  which,
int  value 
)

Definition at line 1028 of file channel_internal_api.c.

1029{
1030 int pos;
1031
1032 /* This ensures that if the vector has to grow with unused positions they will be
1033 * initialized to -1.
1034 */
1035 for (pos = AST_VECTOR_SIZE(&chan->fds); pos < which; pos++) {
1036 AST_VECTOR_REPLACE(&chan->fds, pos, -1);
1037 }
1038
1039 AST_VECTOR_REPLACE(&chan->fds, which, value);
1040}

References AST_VECTOR_REPLACE, AST_VECTOR_SIZE, and value.

Referenced by ast_channel_set_fd(), handle_negotiated_sdp(), start_rtp(), swap_subs(), and unistim_new().

◆ ast_channel_internal_oldest_linkedid()

struct ast_channel * ast_channel_internal_oldest_linkedid ( struct ast_channel a,
struct ast_channel b 
)

Determine which channel has an older linkedid.

Parameters
aFirst channel
bSecond channel
Returns
Returns an ast_channel structure that has oldest linkedid

Definition at line 1287 of file channel_internal_api.c.

1288{
1289 ast_assert(a->linkedid.creation_time != 0);
1290 ast_assert(b->linkedid.creation_time != 0);
1291
1292 if (a->linkedid.creation_time < b->linkedid.creation_time) {
1293 return a;
1294 }
1295 if (b->linkedid.creation_time < a->linkedid.creation_time) {
1296 return b;
1297 }
1298 if (a->linkedid.creation_unique < b->linkedid.creation_unique) {
1299 return a;
1300 }
1301 return b;
1302}

References a, ast_assert, and b.

Referenced by ast_bridge_channel_update_linkedids().

◆ ast_channel_internal_set_fake_ids()

void ast_channel_internal_set_fake_ids ( struct ast_channel chan,
const char *  uniqueid,
const char *  linkedid 
)

Set uniqueid and linkedid string value only (not time)

Parameters
chanThe channel to set the uniqueid to
uniqueidThe uniqueid to set
linkedidThe linkedid to set
Note
This is used only by ast_cel_fabricate_channel_from_event() to create a temporary fake channel - time values are invalid

Definition at line 1381 of file channel_internal_api.c.

1382{
1383 ast_copy_string(chan->uniqueid.unique_id, uniqueid, sizeof(chan->uniqueid.unique_id));
1384 ast_copy_string(chan->linkedid.unique_id, linkedid, sizeof(chan->linkedid.unique_id));
1385}

References ast_copy_string(), ast_channel::linkedid, ast_channel_id::unique_id, and ast_channel::uniqueid.

Referenced by ast_cel_fabricate_channel_from_event().

◆ ast_channel_internal_swap_endpoint_forward()

void ast_channel_internal_swap_endpoint_forward ( struct ast_channel a,
struct ast_channel b 
)

Swap endpoint_forward between two channels.

Parameters
aFirst channel
bSecond channel
Note
This is used in masquerade to exchange endpoint details if one of the two or both the channels were created with endpoint

Definition at line 1354 of file channel_internal_api.c.

1355{
1356 struct stasis_forward *temp;
1357
1358 temp = a->endpoint_forward;
1359 a->endpoint_forward = b->endpoint_forward;
1360 b->endpoint_forward = temp;
1361}
Forwarding information.
Definition stasis.c:1598

References a, and b.

Referenced by channel_do_masquerade().

◆ ast_channel_internal_swap_endpoints()

void ast_channel_internal_swap_endpoints ( struct ast_channel a,
struct ast_channel b 
)

Swap endpoints between two channels.

Parameters
aFirst channel
bSecond channel
Note
This is used in masquerade to exchange endpoints

Definition at line 1372 of file channel_internal_api.c.

1373{
1374 struct ast_endpoint *endpoint;
1375
1376 endpoint = a->endpoint;
1377 a->endpoint = b->endpoint;
1378 b->endpoint = endpoint;
1379}

References a, and b.

Referenced by channel_do_masquerade().

◆ ast_channel_internal_swap_snapshots()

void ast_channel_internal_swap_snapshots ( struct ast_channel a,
struct ast_channel b 
)

Swap snapshots beteween two channels.

Parameters
aFirst channel
bSecond channel
Note
This is used in masquerade to exchange snapshots

Definition at line 1363 of file channel_internal_api.c.

1364{
1365 struct ast_channel_snapshot *snapshot;
1366
1367 snapshot = a->snapshot;
1368 a->snapshot = b->snapshot;
1369 b->snapshot = snapshot;
1370}

References a, and b.

Referenced by channel_do_masquerade().

◆ ast_channel_internal_swap_topics()

void ast_channel_internal_swap_topics ( struct ast_channel a,
struct ast_channel b 
)

Swap topics beteween two channels.

Parameters
aFirst channel
bSecond channel
Note
This is used in masquerade to exchange topics for message routing

Definition at line 1340 of file channel_internal_api.c.

1341{
1342 struct stasis_topic *topic;
1343 struct stasis_forward *forward;
1344
1345 topic = a->topic;
1346 a->topic = b->topic;
1347 b->topic = topic;
1348
1349 forward = a->channel_forward;
1350 a->channel_forward = b->channel_forward;
1351 b->channel_forward = forward;
1352}

References a, and b.

Referenced by channel_do_masquerade().

◆ ast_channel_internal_swap_uniqueid_and_linkedid()

void ast_channel_internal_swap_uniqueid_and_linkedid ( struct ast_channel a,
struct ast_channel b 
)

Swap uniqueid and linkedid beteween two channels.

Parameters
aFirst channel
bSecond channel
Note
This is used in masquerade to exchange identities

Definition at line 1316 of file channel_internal_api.c.

1317{
1318 struct ast_channel_id temp;
1319
1320 /* This operation is used as part of masquerading and so does not invalidate the peer
1321 * segment. This is due to the masquerade process invalidating all segments.
1322 */
1323
1324 /*
1325 * Since unique ids can be a key in the channel storage backend,
1326 * ensure that neither channel is linked in or the keys will be
1327 * invalid.
1328 */
1329 ast_assert(!a->linked_in_container && !b->linked_in_container);
1330
1331 temp = a->uniqueid;
1332 a->uniqueid = b->uniqueid;
1333 b->uniqueid = temp;
1334
1335 temp = a->linkedid;
1336 a->linkedid = b->linkedid;
1337 b->linkedid = temp;
1338}
Channel UniqueId structure.

References a, ast_assert, and b.

Referenced by channel_do_masquerade().

◆ ast_channel_is_bridged()

int ast_channel_is_bridged ( const struct ast_channel chan)

Determine if a channel is in a bridge.

Since
12.0.0
Parameters
chanThe channel to test
Note
This function expects the channel to be locked prior to being called and will not grab the channel lock.
Return values
0The channel is not bridged
non-zeroThe channel is bridged

Definition at line 10655 of file channel.c.

10656{
10657 return ast_channel_internal_bridge(chan) != NULL;
10658}

References ast_channel_internal_bridge(), and NULL.

Referenced by __ast_read(), action_redirect(), app_control_dial(), ast_async_goto(), ast_audiohook_attach(), ast_audiohook_remove(), ast_framehook_attach(), ast_framehook_detach(), ast_framehook_list_fixup(), ast_var_channel_bridge(), attach_barge(), audio_audiohook_write_list(), chan_pjsip_read_stream(), chan_pjsip_set_rtp_peer(), common_exec(), dtmf_audiohook_write_list(), mixmonitor_autochan_is_bridged(), set_caps(), set_timeout(), wait_for_bridged(), wait_for_bridged(), wait_for_unbridged(), and wait_for_unbridged().

◆ ast_channel_is_leaving_bridge()

int ast_channel_is_leaving_bridge ( struct ast_channel chan)

Determine if a channel is leaving a bridge, but not hung up.

Since
12.4.0
Parameters
chanThe channel to test
Note
If a channel is hung up, it is implicitly leaving any bridge it may be in. This function is used to test if a channel is leaving a bridge but may survive the experience, if it has a place to go to (dialplan or otherwise)
Return values
0The channel is not leaving the bridge or is hung up
non-zeroThe channel is leaving the bridge

Definition at line 10660 of file channel.c.

10661{
10662 int hangup_flags = ast_channel_softhangup_internal_flag(chan);
10663 int hangup_test = hangup_flags & AST_SOFTHANGUP_ASYNCGOTO;
10664 int unbridge = ast_channel_unbridged(chan);
10665
10666 /* This function should only return true if either the unbridged flag or
10667 * the ASYNCGOTO soft hangup flag is set and when no other soft hangup
10668 * flags are set. Any other soft hangup flags being set should make it
10669 * return false.
10670 */
10671 return ((hangup_test || unbridge) && (hangup_test == hangup_flags));
10672}

References ast_channel_softhangup_internal_flag(), ast_channel_unbridged(), and AST_SOFTHANGUP_ASYNCGOTO.

Referenced by ast_indicate_data(), and bridge_channel_internal_pull().

◆ ast_channel_is_multistream()

int ast_channel_is_multistream ( struct ast_channel chan)

Determine if a channel is multi-stream capable.

Parameters
chanThe channel to test
Precondition
chan is locked
Return values
trueif the channel is multi-stream capable.

Definition at line 1559 of file channel_internal_api.c.

1560{
1561 return (chan && chan->tech && chan->tech->read_stream && chan->tech->write_stream);
1562}
int(*const write_stream)(struct ast_channel *chan, int stream_num, struct ast_frame *frame)
Write a frame on a specific stream, in standard format (see frame.h)
Definition channel.h:773
struct ast_frame *(*const read_stream)(struct ast_channel *chan)
Read a frame (or chain of frames from the same stream), in standard format (see frame....
Definition channel.h:767

References ast_channel_tech::read_stream, ast_channel::tech, and ast_channel_tech::write_stream.

Referenced by ast_channel_nativeformats_set(), ast_channel_request_stream_topology_change(), ast_channel_set_stream_topology(), ast_channel_stream_topology_changed(), ast_channel_stream_topology_changed_externally(), ast_unreal_indicate(), ast_unreal_new_channels(), bridge_channel_write_frame(), bridge_handle_trip(), and stream_echo_write().

◆ ast_channel_is_t38_active()

int ast_channel_is_t38_active ( struct ast_channel chan)

This function will check if T.38 is active on the channel.

Parameters
chanChannel on which to check the unbridge_eval flag
Returns
Returns 0 if the flag is down or 1 if the flag is up.

Definition at line 913 of file channel_internal_api.c.

914{
915 int res;
916
917 ast_channel_lock(chan);
919 ast_channel_unlock(chan);
920 return res;
921}
int ast_channel_is_t38_active_nolock(struct ast_channel *chan)
ast_channel_is_t38_active variant. Use this if the channel is already locked prior to calling.

References ast_channel_is_t38_active_nolock(), ast_channel_lock, and ast_channel_unlock.

Referenced by bridge_channel_internal_join().

◆ ast_channel_is_t38_active_nolock()

int ast_channel_is_t38_active_nolock ( struct ast_channel chan)

ast_channel_is_t38_active variant. Use this if the channel is already locked prior to calling.

Parameters
chanChannel on which to check the is_t38_active flag
Returns
Returns 0 if the flag is down or 1 if the flag is up.

Definition at line 908 of file channel_internal_api.c.

909{
910 return chan->is_t38_active;
911}

References ast_channel::is_t38_active.

Referenced by ast_channel_is_t38_active().

◆ ast_channel_iterator_all_new()

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.

Note
You must call ast_channel_iterator_destroy() when done.
Return values
NULLon failure
anew channel iterator
Since
1.8

Definition at line 1380 of file channel.c.

1381{
1383 return NULL;
1384 }
1386}
static struct ast_channel_iterator * iterator_all_new(struct ast_channelstorage_instance *driver)

References CHANNELSTORAGE_API, current_channel_storage_instance, iterator_all_new(), and NULL.

Referenced by action_status(), ast_manager_hangup_helper(), ast_var_channel_bridge(), ast_var_channel_types_table(), ast_var_channels_table(), common_exec(), func_channels_read(), and handle_show_hangup_all().

◆ ast_channel_iterator_by_exten_new()

struct ast_channel_iterator * ast_channel_iterator_by_exten_new ( const char *  exten,
const char *  context 
)

Create a new channel iterator based on extension.

Parameters
extenThe extension that channels must be in
contextThe context that channels must be in

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.

Note
You must call ast_channel_iterator_destroy() when done.
Return values
NULLon failure
anew channel iterator based on the specified parameters
Since
1.8

Definition at line 1357 of file channel.c.

1358{
1360 return NULL;
1361 }
1362 if (ast_strlen_zero(exten) || ast_strlen_zero(context)) {
1363 ast_log(LOG_ERROR, "exten and context must be provided\n");
1364 return NULL;
1365 }
1367}
static struct ast_channel_iterator * iterator_by_exten_new(struct ast_channelstorage_instance *driver, const char *exten, const char *context)

References ast_log, ast_strlen_zero(), CHANNELSTORAGE_API, current_channel_storage_instance, iterator_by_exten_new(), LOG_ERROR, and NULL.

Referenced by common_exec(), and pickup_by_exten().

◆ ast_channel_iterator_by_name_new()

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.

Parameters
namechannel name or channel uniqueid to match
name_lennumber 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.

Note
You must call ast_channel_iterator_destroy() when done.
Return values
NULLon failure
anew channel iterator based on the specified parameters
Since
1.8

Definition at line 1368 of file channel.c.

1369{
1371 return NULL;
1372 }
1373 if (ast_strlen_zero(name)) {
1374 ast_log(LOG_ERROR, "name must be provided\n");
1375 return NULL;
1376 }
1378}
static struct ast_channel_iterator * iterator_by_name_new(struct ast_channelstorage_instance *driver, const char *name, size_t name_len)

References ast_log, ast_strlen_zero(), CHANNELSTORAGE_API, current_channel_storage_instance, iterator_by_name_new(), LOG_ERROR, name, and NULL.

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

◆ ast_channel_iterator_destroy()

struct ast_channel_iterator * ast_channel_iterator_destroy ( struct ast_channel_iterator i)

Destroy a channel iterator.

Parameters
ithe itereator to destroy

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

Return values
NULLfor convenience to clear out the pointer to the iterator that was just destroyed.
Since
1.8

Definition at line 1349 of file channel.c.

1350{
1352 return NULL;
1353 }
1355}
static struct ast_channel_iterator * iterator_destroy(struct ast_channelstorage_instance *driver, struct ast_channel_iterator *i)

References CHANNELSTORAGE_API, current_channel_storage_instance, iterator_destroy(), and NULL.

Referenced by action_status(), ast_manager_hangup_helper(), ast_var_channel_bridge(), ast_var_channel_types_table(), ast_var_channels_table(), common_exec(), func_channels_read(), get_device_state_causing_channels(), handle_show_hangup_all(), pickup_by_exten(), and softhangup_exec().

◆ ast_channel_iterator_next()

struct ast_channel * ast_channel_iterator_next ( struct ast_channel_iterator i)

Get the next channel for a channel iterator.

Parameters
ithe channel iterator that was created using one of the channel_iterator_xxx_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.
NULLif no more channels match the iterator parameters.
Since
1.8

Definition at line 1388 of file channel.c.

1389{
1391 return NULL;
1392 }
1394}
static struct ast_channel * iterator_next(struct ast_channelstorage_instance *driver, struct ast_channel_iterator *i)

References CHANNELSTORAGE_API, current_channel_storage_instance, iterator_next(), and NULL.

Referenced by action_status(), ast_manager_hangup_helper(), ast_var_channel_bridge(), ast_var_channel_types_table(), ast_var_channels_table(), func_channels_read(), get_device_state_causing_channels(), handle_show_hangup_all(), next_channel(), pickup_by_exten(), and softhangup_exec().

◆ ast_channel_jb()

struct ast_jb * ast_channel_jb ( struct ast_channel chan)

◆ ast_channel_jb_set()

void ast_channel_jb_set ( struct ast_channel chan,
struct ast_jb value 
)

Definition at line 807 of file channel_internal_api.c.

808{
809 chan->jb = *value;
810}

References ast_channel::jb, and value.

◆ ast_channel_language()

const char * ast_channel_language ( const struct ast_channel chan)
Examples
app_skel.c.

Referenced by __analog_ss_thread(), acf_vm_info(), action_playback_and_continue(), action_toggle_mute_participants(), analog_ss_thread(), announce_to_dial(), announce_user_count(), app_exec(), app_exec(), ast_app_getdata_full(), ast_app_getdata_terminator(), ast_ari_channels_dial(), ast_play_and_wait(), ast_say_counted_adjective(), ast_say_counted_noun(), ast_say_date_with_format_gr(), ast_say_number_full_gr(), ast_send_image(), ast_stream_and_wait(), ast_unreal_call_setup(), ast_var_channels_table(), auth_exec(), background_detect_exec(), begin_dial_prerun(), channel_do_masquerade(), channel_snapshot_base_create(), common_exec(), conf_exec(), conf_get_pin(), conf_run(), confbridge_exec(), control_streamfile(), copy_message(), count_exec(), dial_exec_full(), dictate_exec(), do_directory(), eivr_comm(), find_conf_realtime(), findmeexec(), forward_message(), func_channel_read(), gen_nextfile(), get_folder(), get_folder2(), get_folder_ja(), handle_getoption(), handle_recordfile(), handle_sayalpha(), handle_saydate(), handle_saydatetime(), handle_saydigits(), handle_saynumber(), handle_sayphonetic(), handle_saytime(), handle_showchan(), handle_speechrecognize(), handle_streamfile(), iax2_call(), invent_message(), invent_message(), isAnsweringMachine(), leave_voicemail(), leave_voicemail(), limits_interval_playback(), meetme_menu_admin(), meetme_menu_admin_extended(), meetme_menu_normal(), minivm_greet_exec(), moh_files_next(), page_exec(), pbx_builtin_background(), pbx_builtin_saycharacters(), pbx_builtin_saycharacters_case(), pbx_builtin_saydigits(), pbx_builtin_saymoney(), pbx_builtin_saynumber(), pbx_builtin_sayordinal(), pbx_builtin_sayphonetic(), play_and_wait(), play_file(), play_mailbox_owner(), play_message(), play_message_callerid(), play_message_datetime(), play_message_duration(), play_record_review(), playback_common(), playback_exec(), privacy_exec(), readexten_exec(), record_exec(), retrydial_exec(), say_parking_space(), say_position(), sayfile_exec(), sayunixtime_exec(), select_item_menu(), serialize_showchan(), setup_env(), setup_privacy_args(), speech_background(), try_calling(), vm_authenticate(), vm_browse_messages(), vm_execmain(), vm_instructions(), vm_intro(), vm_intro_cs(), vm_intro_da(), vm_intro_de(), vm_intro_en(), vm_intro_es(), vm_intro_fr(), vm_intro_gr(), vm_intro_he(), vm_intro_is(), vm_intro_it(), vm_intro_ja(), vm_intro_multilang(), vm_intro_nl(), vm_intro_no(), vm_intro_pl(), vm_intro_pt(), vm_intro_pt_BR(), vm_intro_se(), vm_intro_vi(), vm_intro_zh(), vm_play_folder_name(), vmsayname_exec(), wait_for_answer(), and wait_for_winner().

◆ ast_channel_lastcontext()

const char * ast_channel_lastcontext ( const struct ast_channel chan)

Definition at line 219 of file channel_internal_api.c.

220{
221 return chan->lastcontext;
222}

References ast_channel::lastcontext.

Referenced by func_channel_read().

◆ ast_channel_lastexten()

const char * ast_channel_lastexten ( const struct ast_channel chan)

Definition at line 236 of file channel_internal_api.c.

237{
238 return chan->lastexten;
239}

References ast_channel::lastexten.

Referenced by func_channel_read().

◆ ast_channel_latest_musicclass()

const char * ast_channel_latest_musicclass ( const struct ast_channel chan)

◆ ast_channel_linkedid()

const char * ast_channel_linkedid ( const struct ast_channel chan)

◆ ast_channel_make_compatible()

int ast_channel_make_compatible ( struct ast_channel chan,
struct ast_channel peer 
)

Make the frame formats of two channels compatible.

Parameters
chanFirst channel to make compatible. Should be the calling party.
peerOther channel to make compatible. Should be the called party.
Note
Absolutely NO channel locks should be held before calling this function.

Set two channels to compatible frame formats in both directions. The path from peer to chan is made compatible first to allow for in-band audio in case the other direction cannot be made compatible.

Return values
0on success.
-1on error.

Definition at line 6777 of file channel.c.

6778{
6779 /*
6780 * Set up translation from the peer to the chan first in case we
6781 * need to hear any in-band tones and the other direction fails.
6782 */
6783 if (ast_channel_make_compatible_helper(peer, chan)) {
6784 return -1;
6785 }
6786
6787 /* Set up translation from the chan to the peer */
6788 if (ast_channel_make_compatible_helper(chan, peer)) {
6789 return -1;
6790 }
6791
6792 return 0;
6793}
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:6698

References ast_channel_make_compatible_helper().

Referenced by app_exec(), dial_exec_full(), do_forward(), fax_detect_framehook(), fax_gateway_framehook(), native_bridge_join(), simple_bridge_join(), try_calling(), and wait_for_answer().

◆ ast_channel_masq()

struct ast_channel * ast_channel_masq ( const struct ast_channel chan)

Definition at line 472 of file channel_internal_api.c.

473{
474 return chan->masq;
475}
struct ast_channel * masq

References ast_channel::masq.

Referenced by ast_can_pickup(), ast_channel_log(), ast_hangup(), and ast_var_channels_table().

◆ ast_channel_masq_set()

void ast_channel_masq_set ( struct ast_channel chan,
struct ast_channel value 
)

Definition at line 476 of file channel_internal_api.c.

477{
478 chan->masq = value;
479}

References ast_channel::masq, and value.

Referenced by ast_channel_move(), and channel_do_masquerade().

◆ ast_channel_masqr()

struct ast_channel * ast_channel_masqr ( const struct ast_channel chan)

Definition at line 480 of file channel_internal_api.c.

481{
482 return chan->masqr;
483}
struct ast_channel * masqr

References ast_channel::masqr.

Referenced by ast_channel_log(), ast_hangup(), and ast_var_channels_table().

◆ ast_channel_masqr_set()

void ast_channel_masqr_set ( struct ast_channel chan,
struct ast_channel value 
)

Definition at line 484 of file channel_internal_api.c.

485{
486 chan->masqr = value;
487}

References ast_channel::masqr, and value.

Referenced by ast_channel_move(), and channel_do_masquerade().

◆ ast_channel_move()

int ast_channel_move ( struct ast_channel dest,
struct ast_channel source 
)

Move a channel from its current location to a new location.

Since
12

The intention of this function is to have the destination channel take on the identity of the source channel.

Note
This function is NOT intended to be used on bridged channels. If you wish to move an unbridged channel into the place of a bridged channel, then use ast_bridge_join() or ast_bridge_impart(). If you wish to move a bridged channel into the place of another bridged channel, then use ast_bridge_move().
When this function returns succesfully, the source channel is in a state where its continued use is unreliable.
absolutely NO channel locks should be held before calling this function.
Parameters
destThe place to move the source channel
sourceThe channel to move
Return values
0Success
non-zeroFailure

Definition at line 10776 of file channel.c.

10777{
10778 RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
10780
10781 if (dest == source) {
10782 ast_log(LOG_WARNING, "Can't move channel '%s' into itself!\n",
10783 ast_channel_name(dest));
10784 return -1;
10785 }
10786
10787 ast_channel_lock_both(dest, source);
10788
10791 /* Zombies! Run! */
10793 "Can't move channel. One or both is dead (%s <-- %s)\n",
10794 ast_channel_name(dest), ast_channel_name(source));
10795 ast_channel_unlock(source);
10796 ast_channel_unlock(dest);
10797 return -1;
10798 }
10799
10800 ast_channel_masq_set(dest, source);
10801 ast_channel_masqr_set(source, dest);
10802
10803 blob = ast_json_pack("{s: s}",
10804 "newchanneluniqueid", ast_channel_uniqueid(dest));
10806
10807 ast_channel_unlock(dest);
10808 ast_channel_unlock(source);
10809
10810 channel_do_masquerade(dest, source);
10811 return 0;
10812}
ast_mutex_t lock
Definition app_sla.c:337
static void channel_do_masquerade(struct ast_channel *original, struct ast_channel *clonechan)
Masquerade a channel.
Definition channel.c:6919
static ast_mutex_t channel_move_lock
Definition channel.c:10774
struct stasis_message_type * ast_channel_masquerade_type(void)
Message type for when a channel is being masqueraded.
void ast_channel_publish_blob(struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
Publish a channel blob message.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition json.c:73
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition json.c:612
#define SCOPED_MUTEX(varname, lock)
scoped lock specialization for mutexes
Definition lock.h:596
Abstract JSON element (object, array, string, int, ...).

References ast_channel_flags(), ast_channel_lock_both, ast_channel_masq_set(), ast_channel_masqr_set(), ast_channel_masquerade_type(), ast_channel_name(), ast_channel_publish_blob(), ast_channel_uniqueid(), ast_channel_unlock, AST_FLAG_ZOMBIE, ast_json_pack(), ast_json_unref(), ast_log, ast_test_flag, channel_do_masquerade(), channel_move_lock, lock, LOG_WARNING, NULL, RAII_VAR, and SCOPED_MUTEX.

Referenced by after_bridge_move_channel(), ast_channel_yank(), ast_do_pickup(), local_call(), and refer_incoming_invite_request().

◆ ast_channel_music_state()

void * ast_channel_music_state ( const struct ast_channel chan)

◆ ast_channel_music_state_set()

void ast_channel_music_state_set ( struct ast_channel chan,
void *  value 
)

Definition at line 433 of file channel_internal_api.c.

434{
435 chan->music_state = value;
436}

References ast_channel::music_state, and value.

Referenced by local_ast_moh_cleanup(), moh_alloc(), and moh_files_alloc().

◆ ast_channel_musicclass()

const char * ast_channel_musicclass ( const struct ast_channel chan)

◆ ast_channel_name()

const char * ast_channel_name ( const struct ast_channel chan)

Referenced by __adsi_transmit_messages(), __analog_handle_event(), __analog_ss_thread(), __ast_answer(), __ast_change_name_nolink(), __ast_channel_alloc_ap(), __ast_pbx_run(), __ast_play_and_record(), __ast_queue_frame(), __ast_read(), __attempt_transmit(), __dahdi_exception(), __get_from_jb(), __print_debug_details(), _analog_get_index(), _create_event_MEDIA_START(), _dahdi_get_index(), _websocket_request_hangup(), acf_curl_helper(), acf_faxopt_read(), acf_faxopt_write(), acf_jabberreceive_read(), action_add_agi_cmd(), action_bridge(), action_confbridgesetsinglevideosrc(), action_dahdishowchannels(), action_kick_last(), action_meetmelist(), add_agi_cmd(), add_inheritable_header(), adsi_prog(), adsi_search_input(), agent_after_bridge_cb(), agent_after_bridge_cb_failed(), agent_function_read(), agent_handle_show_specific(), agent_request_exec(), agent_run(), agent_show_requested(), agents_sweep(), alarmreceiver_exec(), alloc_playback_chan(), analog_answer(), analog_attempt_transfer(), analog_call(), analog_callwaiting_deluxe(), analog_exception(), analog_fixup(), analog_handle_dtmf(), analog_hangup(), analog_ss_thread(), announce_to_dial(), answer(), aoc_attach_framehook(), aoc_display_decoded_debug(), aoc_framehook(), app_control_redirect(), app_exec(), app_exec(), app_notify(), append_channel_vars(), aqm_exec(), ari_bridges_play_new(), ari_originate_dial(), assign_uuid(), ast_agi_send(), ast_answer(), ast_ari_create_per_call_websocket(), ast_async_goto(), ast_audiohook_set_mute_all(), ast_audiosocket_connect(), ast_autochan_new_channel(), ast_autochan_setup(), ast_autoservice_start(), ast_autoservice_stop(), ast_bridge_add_channel(), ast_bridge_call_with_flags(), ast_bridge_channel_feature_digit(), ast_bridge_channel_kick(), ast_bridge_channel_leave_bridge_nolock(), ast_bridge_channel_queue_frame(), ast_bridge_channel_restore_formats(), ast_bridge_depart(), ast_bridge_features_ds_set_string(), ast_bridge_impart(), ast_bridge_join(), ast_bridge_remove(), ast_bridge_set_single_src_video_mode(), ast_bridge_transfer_attended(), ast_bridge_transfer_blind(), ast_bridge_update_talker_src_video_mode(), ast_call_forward(), ast_cc_call_init(), ast_cc_offer(), ast_channel_add_bridge_role(), ast_channel_callid_set(), ast_channel_clear_bridge_roles(), ast_channel_destructor(), ast_channel_end_dtmf(), ast_channel_get_cc_agent_type(), ast_channel_get_device_name(), ast_channel_hangupcause_hash_set(), ast_channel_inherit_variables(), ast_channel_log(), ast_channel_make_compatible_helper(), ast_channel_move(), ast_channel_nativeformats_set(), ast_channel_publish_final_snapshot(), ast_channel_publish_snapshot(), ast_channel_publish_varset(), ast_channel_remove_bridge_role(), ast_channel_request_stream_topology_change(), ast_channel_set_stream_topology(), ast_channel_softhangup_withcause_locked(), ast_channel_start_silence_generator(), ast_channel_stop_silence_generator(), ast_channel_yank(), ast_check_hangup(), ast_cli_netstats(), ast_dial_append_channel(), ast_do_pickup(), ast_dsp_process(), ast_get_chan_applicationmap(), ast_hangup(), ast_iax2_new(), ast_jb_destroy(), ast_jb_put(), ast_manager_hangup_helper(), ast_pbx_h_exten_run(), ast_pbx_hangup_handler_show(), ast_pbx_outgoing_exten_predial(), ast_pickup_call(), ast_prod(), ast_raw_answer_with_stream_topology(), ast_readaudio_callback(), ast_rtp_instance_early_bridge(), ast_rtp_instance_early_bridge_make_compatible(), ast_senddigit_begin(), ast_senddigit_mf_begin(), ast_sendtext_data(), ast_set_read_format_path(), ast_set_write_format_path(), ast_setstate(), ast_sip_session_get_name(), ast_sip_session_is_pending_stream_default(), ast_sip_session_regenerate_answer(), ast_softhangup_nolock(), ast_stir_shaken_add_result_to_channel(), ast_stir_shaken_as_ctx_create(), ast_stir_shaken_vs_ctx_create(), ast_str_retrieve_variable(), ast_streamfile(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), ast_unreal_answer(), ast_unreal_fixup(), ast_unreal_hangup(), ast_var_channels_table(), ast_waitfor_nandfds(), ast_write_stream(), async_agi_read_frame(), attach_barge(), attach_framehook(), attempt_transfer(), attended_transfer_bridge(), attended_transfer_properties_alloc(), audiosocket_exec(), audiosocket_read(), audiosocket_run(), audiosocket_send_dtmf(), audiosocket_write(), background_detect_exec(), begin_dial_channel(), begin_dial_prerun(), blind_transfer_bridge(), bridge_channel_complete_join(), bridge_channel_dtmf_stream(), bridge_channel_feature_digit_add(), bridge_channel_handle_interval(), bridge_channel_handle_write(), bridge_channel_internal_join(), bridge_channel_internal_pull(), bridge_channel_internal_push_full(), bridge_channel_internal_queue_attended_transfer(), bridge_channel_moving(), bridge_channel_park(), bridge_channel_settle_owed_events(), bridge_channel_talking(), bridge_channel_wait(), bridge_dissolve(), bridge_do_move(), bridge_exec(), bridge_features_duration_callback(), bridge_impart_internal(), bridge_move_locked(), bridge_parking_push(), bridge_stasis_push(), bridge_stasis_push_peek(), bridge_stasis_run_cb(), bridgeadd_exec(), bridgewait_exec(), bridgewait_timeout_callback(), broadcast_exec(), builtin_features_helper(), by_name_cb(), calendar_event_read(), calendar_query_result_exec(), call(), cdr_prop_write(), cdr_prop_write_callback(), cdr_read(), cdr_read_callback(), cdr_retrieve_time(), cdr_write(), cdr_write_callback(), chan_pjsip_answer(), chan_pjsip_cng_tone_detected(), chan_pjsip_digit_end(), chan_pjsip_get_codec(), chan_pjsip_hangup(), chan_pjsip_incoming_response_update_cause(), chan_pjsip_indicate(), chan_pjsip_read_stream(), chan_pjsip_request_with_stream_topology(), chan_pjsip_sendtext_data(), chan_pjsip_session_end(), chan_pjsip_set_rtp_peer(), chan_pjsip_write_stream(), chan_rtp_get_codec(), chanavail_exec(), change_priority_caller_on_queue(), channel_cmp(), channel_cmp_cb(), channel_do_masquerade(), channel_fill_empty_accountcode(), channel_fill_empty_peeraccount(), channel_hash(), channel_read_pjsip(), channel_read_rtcp(), channel_read_rtp(), channel_set_debug(), channel_snapshot_base_create(), channel_spy(), channel_update_peeraccount(), channelstorage_name_cb(), comeback_goto(), common_exec(), complete_bridge_participant(), complete_confbridge_participant(), conf_exec(), conf_play(), conf_queue_dtmf(), conf_run(), conf_run(), conf_send_event_to_participants(), conf_update_user_mute(), confbridge_exec(), confbridge_handle_atxfer(), console_indicate(), control_streamfile(), cpeid_exec(), create_channel_name(), create_jb(), dahdi_call(), dahdi_digit_begin(), dahdi_digit_end(), dahdi_fake_event(), dahdi_fixup(), dahdi_handle_dtmf(), dahdi_handle_event(), dahdi_hangup(), dahdi_indicate(), dahdi_new(), dahdi_queryoption(), dahdi_read(), dahdi_setoption(), dahdi_show_channel(), dahdi_softhangup_all(), dahdi_write(), dahdichan_helper(), deactivate_silence_generator(), defer_action(), defer_incoming_sdp_stream(), dequeue_frame(), detect_callback(), dial_bridge_after_cb(), dial_bridge_after_cb_failed(), dial_exec_full(), dial_masquerade_breakdown(), dial_masquerade_fixup(), dial_transfer(), dial_trunk(), directory_exec(), disa_exec(), disable_t38(), display_parked_call(), do_broadcast(), do_forward(), do_ids_conflict(), do_monitor(), do_waiting(), dtmf_mode_refresh_cb(), dtmfstore_exec(), dumpchan_exec(), dundi_lookup_internal(), dynamic_dtmf_hook_trip(), eagi_exec(), enable_jack_hook(), execute_menu_entry(), fast_originate(), fax_detect_framehook(), fax_gateway_detect_t38(), fax_gateway_detect_v21(), fax_gateway_framehook(), fax_gateway_new(), fax_gateway_request_t38(), fax_session_new(), feature_attended_transfer(), feature_automixmonitor(), feature_blind_transfer(), find_by_name(), find_details(), find_or_create_details(), flash_exec(), forkcdr_exec(), forward_message(), func_channel_read(), func_channels_read(), func_confbridge_channels(), func_get_parkingslot_channel(), func_read_header(), func_read_headers(), func_read_param(), func_read_verification(), func_response_read_header(), func_response_read_headers(), func_write_attestation(), func_write_header(), func_write_param(), generic_fax_exec(), generic_mute_unmute_helper(), generic_mute_unmute_user(), geoloc_profile_read(), geoloc_profile_write(), get_agi_cmd(), gosub_exec(), gosub_run(), grab_transfer(), group_count_function_read(), group_show_channels(), handle_bridge_kick_channel(), handle_call_outgoing(), handle_cli_agi_add_cmd(), handle_cli_confbridge_list_item(), handle_cli_iax2_show_channels(), handle_cli_locks_show(), handle_command(), handle_dump_frames(), handle_frame(), handle_gosub(), handle_incoming_request(), handle_participant_join(), handle_recordfile(), handle_showchan(), handle_softhangup(), handle_streamfile(), hangup(), hash_cb(), holding_bridge_join(), hook_callback(), hook_event_cb(), hook_off(), hook_on(), hook_re_enable(), hook_thread_arg_alloc(), iax2_call(), iax2_hangup(), iax2_request(), iax2_transfer(), incoming_in_dialog_request(), incoming_ws_http_callback(), increase_call_count(), indicate_connected_line(), indicate_data_internal(), inherit_channel_vars_from_id(), init_jack_data(), is_our_turn(), isAnsweringMachine(), jack_hook_callback(), jingle_action_session_terminate(), jingle_queue_hangup_with_cause(), jingle_read(), join_queue(), kick_conference_participant(), launch_asyncagi(), launch_monitor_thread(), leave_queue(), leave_voicemail(), leave_voicemail(), linear_alloc(), linear_release(), local_ast_moh_start(), locals_show(), log_caps(), log_group_write(), log_jitterstats(), lua_get_state(), lua_pbx_exec(), manager_park(), manager_queues_status(), map_source_to_destinations(), mbl_call(), meetme_menu_admin(), meetme_show_cmd(), meetmemute(), milliwatt_generate(), moh_alloc(), moh_files_generator(), moh_files_next(), moh_files_release(), moh_generate(), moh_post_start(), moh_post_stop(), moh_release(), my_handle_dtmf(), my_set_cadence(), native_bridge_changed(), native_bridge_compatible(), native_bridge_is_capable(), native_rtp_bridge_compatible_check(), native_rtp_bridge_framehook_attach(), native_rtp_bridge_framehook_detach(), native_rtp_bridge_join(), native_rtp_bridge_leave(), native_rtp_bridge_start(), native_rtp_bridge_stop(), native_rtp_bridge_suspend(), native_rtp_bridge_unsuspend(), native_start(), native_stop(), next_channel(), notify_channel(), old_milliwatt_exec(), on_personality_change_normal(), onModeChanged(), ooh323_answer(), ooh323_call(), ooh323_destroy(), ooh323_get_codec(), ooh323_get_rtp_peer(), ooh323_new(), ooh323_queryoption(), ooh323_rtp_read(), ooh323_set_rtp_peer(), ooh323_write(), outgoing_request(), page_exec(), park_local_transfer(), parking_park_bridge_channel(), parking_park_call(), participant_idle_mode_setup(), participant_reaction_announcer_join(), pbx_builtin_background(), pbx_builtin_waitexten(), pbx_extension_helper(), pbx_outgoing_exec(), pbx_outgoing_state_callback(), pbx_start_incoming_request(), pickup_by_exten(), pickup_by_group(), pjsip_acf_channel_read(), pjsip_acf_dtmf_mode_read(), pjsip_acf_dtmf_mode_write(), pjsip_acf_session_refresh_write(), pjsip_app_hangup(), pjsip_app_hangup_handler(), pjsip_transfer_handling_write(), play_message(), play_moh_exec(), play_on_channel(), play_record_review(), playback_exec(), playtones_alloc(), polarity_read(), polarity_write(), pre_bridge_setup(), print_escaped_uri(), print_queue(), print_subchannel(), prnt_channel_key(), process_binary_message(), process_text_message(), publish_app_cdr_message(), publish_transfer_fail(), publish_transfer_success(), publish_transfer_threeway(), queue_exec(), queue_frame_from_buffer(), queue_function_queuegetchannel(), queue_option_frame(), read_from_ws_and_queue(), read_mf_digits(), read_pjsip(), read_sf_digits(), readexten_exec(), realtime_exec(), receive_dtmf_digits(), receivefax_exec(), receivefax_t38_init(), record_exec(), recording_info_read(), refer_ari_progress_framehook(), refer_attended_task(), refer_blind_callback(), refer_incoming_ari_request(), refer_incoming_attended_request(), refer_incoming_blind_request(), refer_incoming_invite_request(), refer_incoming_refer_request(), refer_progress_alloc(), refer_progress_bridge(), refer_progress_framehook(), remove_detect(), remove_dtmf_store(), remove_framehook(), remove_header(), remove_hold_intercept(), remove_inheritable_header(), remove_scrambler(), remove_talk_detect(), request_withdraw_caller_from_queue(), resetcdr_exec(), revert_fax_buffers(), ring_entry(), rqm_exec(), rtp_check_timeout(), run_agi(), say_number_full(), say_position(), scan_exec(), send_broadcast_event(), send_direct_media_request(), send_dtmf_end_event(), send_message(), send_start_msg_snapshots(), sendfax_exec(), sendfax_t38_init(), serialize_showchan(), session_inv_on_media_update(), session_inv_on_tsx_state_changed(), set_bridge_peer_vars_multiparty(), set_channel_timer(), set_fax_t38_caps(), set_format(), set_hangup_source_and_cause(), set_hold_intercept(), set_transfer_variables_all(), setup_env(), setup_privacy_args(), setup_udptl_connection(), sfu_topologies_on_join(), sfu_topologies_on_leave(), sfu_topologies_on_source_change(), simple_bridge_join(), smart_bridge_operation(), sms_generate(), socket_process_helper(), softhangup_exec(), softmix_bridge_join(), softmix_bridge_stream_sources_update(), softmix_bridge_stream_topology_changed(), softmix_bridge_write_text(), softmix_bridge_write_voice(), softmix_mixing_loop(), start_automixmonitor(), start_moh_exec(), start_spying(), start_spying(), start_whispering(), start_whispering(), stasis_app_exec(), stasis_broadcast_exec(), stop_automixmonitor(), stream_echo_perform(), stream_echo_write_error(), t38_attach_framehook(), t38_automatic_reject(), t38_change_state(), t38_framehook(), t38_initialize_session(), t38_interpret_parameters(), t38_reinvite_response_cb(), talk_detect_audiohook_cb(), testclient_exec(), testserver_exec(), tonepair_alloc(), transfer_exec(), transfer_redirect(), try_calling(), try_merge_optimize_out(), try_swap_optimize_out(), unistim_answer(), unistim_call(), unistim_fixup(), unistim_hangup(), unistim_indicate(), unistim_new(), update_header(), update_inheritable_header(), update_qe_rule(), user_chan_cb(), vm_exec(), vm_execmain(), vm_options(), wait_exec(), wait_for_answer(), wait_for_answer(), wait_for_signal_or_hangup(), wait_for_winner(), waitsignal_exec(), waitstream_control(), waitstream_core(), webchan_call(), webchan_hangup(), webchan_read(), webchan_request(), webchan_write(), websocket_handoff_to_channel(), and xfer_client_on_evsub_state().

◆ ast_channel_name_to_dial_string()

void ast_channel_name_to_dial_string ( char *  channel_name)

Removes the trailing identifiers from a channel name string.

Since
12.0.0
Parameters
channel_namestring that you wish to turn into a dial string. This string will be edited in place.

Definition at line 6901 of file channel.c.

6902{
6903 char *dash;
6904
6905 /* Truncate after the dash */
6906 dash = strrchr(channel_name, '-');
6907 if (dash) {
6908 *dash = '\0';
6909 }
6910}

Referenced by parked_user_set_parker_dial_string(), and setup_park_common_datastore().

◆ ast_channel_named_callgroups()

struct ast_namedgroups * ast_channel_named_callgroups ( const struct ast_channel chan)

Definition at line 957 of file channel_internal_api.c.

958{
959 return chan->named_callgroups;
960}
struct ast_namedgroups * named_callgroups

References ast_channel::named_callgroups.

Referenced by find_channel_by_group(), and func_channel_read().

◆ ast_channel_named_callgroups_set()

void ast_channel_named_callgroups_set ( struct ast_channel chan,
struct ast_namedgroups *  value 
)

◆ ast_channel_named_pickupgroups()

struct ast_namedgroups * ast_channel_named_pickupgroups ( const struct ast_channel chan)

Definition at line 966 of file channel_internal_api.c.

967{
968 return chan->named_pickupgroups;
969}
struct ast_namedgroups * named_pickupgroups

References ast_channel::named_pickupgroups.

Referenced by find_channel_by_group(), and func_channel_read().

◆ ast_channel_named_pickupgroups_set()

void ast_channel_named_pickupgroups_set ( struct ast_channel chan,
struct ast_namedgroups *  value 
)

◆ ast_channel_nativeformats()

struct ast_format_cap * ast_channel_nativeformats ( const struct ast_channel chan)

◆ ast_channel_nativeformats_set()

void ast_channel_nativeformats_set ( struct ast_channel chan,
struct ast_format_cap value 
)

Definition at line 544 of file channel_internal_api.c.

546{
547 SCOPE_ENTER(2, "%s: %sFormats: %s\n", S_OR(ast_channel_name(chan), "<initializing>"),
548 S_COR(ast_channel_is_multistream(chan), "Multistream", ""),
550
551 ast_assert(chan != NULL);
552
554
555 /* If chan->stream_topology is NULL, the channel is being destroyed
556 * and topology is destroyed.
557 */
558 if (!chan->stream_topology) {
559 SCOPE_EXIT_RTN("Channel is being initialized or destroyed\n");
560 }
561
562 if (!ast_channel_is_multistream(chan) || !value) {
563 struct ast_stream_topology *new_topology;
564
567 SCOPE_EXIT_RTN("New %stopology set\n", value ? "" : "empty ");
568 }
569 SCOPE_EXIT_RTN("Set native formats but not topology\n");
570}
#define ao2_replace(dst, src)
Replace one object reference with another cleaning up the original.
Definition astobj2.h:501
void ast_channel_internal_set_stream_topology(struct ast_channel *chan, struct ast_stream_topology *topology)
int ast_channel_is_multistream(struct ast_channel *chan)
Determine if a channel is multi-stream capable.
const char * ast_format_cap_get_names(const struct ast_format_cap *cap, struct ast_str **buf)
Get the names of codecs of a set of formats.
Definition format_cap.c:734
#define SCOPE_EXIT_RTN(...)
#define SCOPE_ENTER(level,...)
struct ast_stream_topology * ast_stream_topology_create_from_format_cap(struct ast_format_cap *cap)
A helper function that, given a format capabilities structure, creates a topology and separates the m...
Definition stream.c:851
#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:87
#define ast_str_tmp(init_len, __expr)
Provides a temporary ast_str and returns a copy of its buffer.
Definition strings.h:1189

References ao2_replace, ast_assert, ast_channel_internal_set_stream_topology(), ast_channel_is_multistream(), ast_channel_name(), ast_format_cap_get_names(), ast_str_tmp, ast_stream_topology_create_from_format_cap(), ast_channel::nativeformats, NULL, S_COR, S_OR, SCOPE_ENTER, SCOPE_EXIT_RTN, ast_channel::stream_topology, and value.

Referenced by __ast_channel_alloc_ap(), ast_channel_destructor(), ast_iax2_new(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), ast_unreal_new_channels(), audiosocket_request(), chan_pjsip_new(), chan_pjsip_read_stream(), channel_do_masquerade(), console_new(), dahdi_new(), do_notify(), handle_eval_function(), handle_exec(), iax2_request(), jingle_interpret_content(), jingle_new(), jingle_read(), make_channel(), mbl_new(), multicast_rtp_request(), ooh323_new(), ooh323_rtp_read(), ooh323_set_read_format(), ooh323_set_write_format(), rec_request(), set_caps(), set_format(), socket_process_helper(), stasis_app_control_snoop(), unicast_rtp_request(), unistim_new(), unistim_rtp_read(), and webchan_request().

◆ ast_channel_oldest_linkedid()

const char * ast_channel_oldest_linkedid ( const char *  a,
const char *  b 
)

Return the oldest linkedid between two channels.

A channel linkedid is derived from the channel uniqueid which is formed like this: [systemname-]ctime.seq

The systemname, and the dash are optional, followed by the epoch time followed by an integer sequence. Note that this is not a decimal number, since 1.2 is less than 1.11 in uniqueid land.

To compare two uniqueids, we parse out the integer values of the time and the sequence numbers and compare them, with time trumping sequence.

Parameters
aThe linkedid value of the first channel to compare
bThe linkedid value of the second channel to compare
Return values
NULLon failure
Theoldest linkedid value
Since
12.0.0

◆ ast_channel_oldwriteformat()

struct ast_format * ast_channel_oldwriteformat ( struct ast_channel chan)

Definition at line 711 of file channel_internal_api.c.

712{
713 return chan->oldwriteformat;
714}
struct ast_format * oldwriteformat

References ast_channel::oldwriteformat.

Referenced by ast_stopstream().

◆ ast_channel_outsmpl()

unsigned long ast_channel_outsmpl ( const struct ast_channel chan)

Definition at line 413 of file channel_internal_api.c.

414{
415 return chan->outsmpl;
416}
unsigned long outsmpl

References ast_channel::outsmpl.

◆ ast_channel_outsmpl_set()

void ast_channel_outsmpl_set ( struct ast_channel chan,
unsigned long  value 
)

Definition at line 417 of file channel_internal_api.c.

418{
419 chan->outsmpl = value;
420}

References ast_channel::outsmpl, and value.

◆ ast_channel_parkinglot()

const char * ast_channel_parkinglot ( const struct ast_channel chan)

◆ ast_channel_pbx()

struct ast_pbx * ast_channel_pbx ( const struct ast_channel chan)

◆ ast_channel_pbx_set()

void ast_channel_pbx_set ( struct ast_channel chan,
struct ast_pbx value 
)

◆ ast_channel_peeraccount()

const char * ast_channel_peeraccount ( const struct ast_channel chan)

◆ ast_channel_pickupgroup()

ast_group_t ast_channel_pickupgroup ( const struct ast_channel chan)

◆ ast_channel_pickupgroup_set()

void ast_channel_pickupgroup_set ( struct ast_channel chan,
ast_group_t  value 
)
Precondition
chan is locked

Definition at line 953 of file channel_internal_api.c.

954{
955 chan->pickupgroup = value;
956}

References ast_channel::pickupgroup, and value.

Referenced by chan_pjsip_new(), dahdi_new(), func_channel_write_real(), jingle_new(), and unistim_new().

◆ ast_channel_priority()

int ast_channel_priority ( const struct ast_channel chan)

◆ ast_channel_priority_set()

void ast_channel_priority_set ( struct ast_channel chan,
int  value 
)

◆ ast_channel_queryoption()

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

7517{
7518 int res;
7519
7520 ast_channel_lock(chan);
7521 if (!ast_channel_tech(chan)->queryoption) {
7522 errno = ENOSYS;
7523 ast_channel_unlock(chan);
7524 return -1;
7525 }
7526
7527 if (block)
7528 ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n");
7529
7530 res = ast_channel_tech(chan)->queryoption(chan, option, data, datalen);
7531 ast_channel_unlock(chan);
7532
7533 return res;
7534}
int(*const queryoption)(struct ast_channel *chan, int option, void *data, int *datalen)
Query a given option. Called with chan locked.
Definition channel.h:800

References ast_channel_lock, ast_channel_unlock, ast_log, ast_datastore::data, errno, LOG_ERROR, and ast_channel_tech::queryoption.

Referenced by ast_channel_get_cc_agent_type(), ast_channel_get_device_name(), ast_channel_get_t38_state(), ast_unreal_queryoption(), and func_channel_read().

◆ ast_channel_queue_connected_line_update()

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.

Definition at line 9212 of file channel.c.

9213{
9214 unsigned char data[1024]; /* This should be large enough */
9215 size_t datalen;
9216
9217 datalen = ast_connected_line_build_data(data, sizeof(data), connected, update);
9218 if (datalen == (size_t) -1) {
9219 return;
9220 }
9221
9223}
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:1296
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:8803

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

Referenced by after_bridge_move_channel(), ast_do_pickup(), onAlerting(), onCallEstablished(), onProgress(), queue_connected_line_update(), and update_initial_connected_line().

◆ ast_channel_queue_redirecting_update()

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.

Definition at line 10403 of file channel.c.

10404{
10405 unsigned char data[1024]; /* This should be large enough */
10406 size_t datalen;
10407
10408 datalen = ast_redirecting_build_data(data, sizeof(data), redirecting, update);
10409 if (datalen == (size_t) -1) {
10410 return;
10411 }
10412
10413 ast_queue_control_data(chan, AST_CONTROL_REDIRECTING, data, datalen);
10414}
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:9374

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

Referenced by set_redirecting().

◆ ast_channel_rawreadformat()

struct ast_format * ast_channel_rawreadformat ( struct ast_channel chan)

◆ ast_channel_rawwriteformat()

struct ast_format * ast_channel_rawwriteformat ( struct ast_channel chan)

◆ ast_channel_readformat()

struct ast_format * ast_channel_readformat ( struct ast_channel chan)

◆ ast_channel_readq()

struct ast_readq_list * ast_channel_readq ( struct ast_channel chan)

◆ ast_channel_readtrans()

struct ast_trans_pvt * ast_channel_readtrans ( const struct ast_channel chan)

◆ ast_channel_readtrans_set()

void ast_channel_readtrans_set ( struct ast_channel chan,
struct ast_trans_pvt value 
)

Definition at line 624 of file channel_internal_api.c.

625{
626 chan->readtrans = value;
627}

References ast_channel::readtrans, and value.

Referenced by ast_set_read_format_path(), and free_translation().

◆ ast_channel_reason2str()

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

5884{
5885 switch (reason) /* the following appear to be the only ones actually returned by request_and_dial */
5886 {
5887 case 0:
5888 return "Call Failure (not BUSY, and not NO_ANSWER, maybe Circuit busy or down?)";
5889 case AST_CONTROL_HANGUP:
5890 return "Hangup";
5891 case AST_CONTROL_RING:
5892 return "Local Ring";
5894 return "Remote end Ringing";
5895 case AST_CONTROL_ANSWER:
5896 return "Remote end has Answered";
5897 case AST_CONTROL_BUSY:
5898 return "Remote end is Busy";
5900 return "Congestion (circuits busy)";
5901 default:
5902 return "Unknown Reason!!";
5903 }
5904}

References AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_HANGUP, AST_CONTROL_RING, and AST_CONTROL_RINGING.

Referenced by attempt_thread().

◆ ast_channel_redirecting()

struct ast_party_redirecting * ast_channel_redirecting ( struct ast_channel chan)

◆ ast_channel_redirecting_effective_from()

struct ast_party_id ast_channel_redirecting_effective_from ( struct ast_channel chan)

Definition at line 783 of file channel_internal_api.c.

784{
786}
struct ast_party_id priv_from
Who is redirecting the call (Sent to the party the call is redirected toward) - private representatio...
Definition channel.h:538
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition channel.h:529

References ast_party_id_merge().

◆ ast_channel_redirecting_effective_orig()

struct ast_party_id ast_channel_redirecting_effective_orig ( struct ast_channel chan)

Definition at line 779 of file channel_internal_api.c.

780{
782}
struct ast_party_id orig
Who originally redirected the call (Sent to the party the call is redirected toward)
Definition channel.h:526
struct ast_party_id priv_orig
Who originally redirected the call (Sent to the party the call is redirected toward) - private repres...
Definition channel.h:535

References ast_party_id_merge().

◆ ast_channel_redirecting_effective_to()

struct ast_party_id ast_channel_redirecting_effective_to ( struct ast_channel chan)

Definition at line 787 of file channel_internal_api.c.

788{
789 return ast_party_id_merge(&chan->redirecting.to, &chan->redirecting.priv_to);
790}
struct ast_party_id priv_to
Call is redirecting to a new party (Sent to the caller) - private representation.
Definition channel.h:541
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition channel.h:532

References ast_party_id_merge().

◆ ast_channel_redirecting_set()

void ast_channel_redirecting_set ( struct ast_channel chan,
struct ast_party_redirecting value 
)

◆ ast_channel_redirecting_sub()

int ast_channel_redirecting_sub ( struct ast_channel autoservice_chan,
struct ast_channel sub_chan,
const void *  redirecting_info,
int  is_frame 
)

Run a redirecting interception subroutine and update a channel's redirecting information.

Since
11

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

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

Definition at line 10489 of file channel.c.

10490{
10491 const char *sub;
10492 const char *sub_args;
10493 int retval;
10494
10495 ast_channel_lock(sub_chan);
10496 sub = pbx_builtin_getvar_helper(sub_chan, "REDIRECTING_SEND_SUB");
10497 sub = ast_strdupa(S_OR(sub, ""));
10498 sub_args = pbx_builtin_getvar_helper(sub_chan, "REDIRECTING_SEND_SUB_ARGS");
10499 sub_args = ast_strdupa(S_OR(sub_args, ""));
10500
10501 if (ast_strlen_zero(sub)) {
10502 ast_channel_unlock(sub_chan);
10503 return -1;
10504 }
10505
10506 if (is_frame) {
10507 const struct ast_frame *frame = redirecting_info;
10508
10510 } else {
10511 const struct ast_party_redirecting *redirecting = redirecting_info;
10512
10514 }
10515 ast_channel_unlock(sub_chan);
10516
10518 retval = ast_app_run_sub(autoservice_chan, sub_chan, sub, sub_args, 0);
10520 if (!retval) {
10521 struct ast_party_redirecting saved_redirecting;
10522
10523 ast_party_redirecting_init(&saved_redirecting);
10524 ast_channel_lock(sub_chan);
10525 ast_party_redirecting_copy(&saved_redirecting, ast_channel_redirecting(sub_chan));
10526 ast_channel_unlock(sub_chan);
10527 ast_channel_update_redirecting(sub_chan, &saved_redirecting, NULL);
10528 ast_party_redirecting_free(&saved_redirecting);
10529 }
10530
10531 return retval;
10532}
void ast_party_redirecting_init(struct ast_party_redirecting *init)
Initialize the given redirecting structure.
Definition channel.c:2109
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:10390
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:9585
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition channel.c:2166

References ast_app_run_sub(), ast_channel_lock, ast_channel_redirecting(), 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(), channel_set_intercept_mode(), ast_frame::data, ast_frame::datalen, NULL, pbx_builtin_getvar_helper(), ast_frame::ptr, S_OR, and sub.

Referenced by bridge_channel_handle_control(), call_forward_inherit(), do_forward(), handle_frame(), wait_for_answer(), and wait_for_answer().

◆ ast_channel_register()

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

541{
542 struct chanlist *chan;
543
545
547 if (!strcasecmp(tech->type, chan->tech->type)) {
548 ast_log(LOG_WARNING, "Already have a handler for type '%s'\n", tech->type);
550 return -1;
551 }
552 }
553
554 if (!(chan = ast_calloc(1, sizeof(*chan)))) {
556 return -1;
557 }
558 chan->tech = tech;
560
561 ast_debug(5, "Registered handler for '%s' (%s)\n", chan->tech->type, chan->tech->description);
562
563 ast_verb(5, "Registered channel type '%s' (%s)\n", chan->tech->type, chan->tech->description);
564
566
567 return 0;
568}
#define ast_verb(level,...)
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition linkedlists.h:52
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
#define AST_RWLIST_TRAVERSE
#define AST_RWLIST_INSERT_HEAD
const char *const type
Definition channel.h:649
const char *const description
Definition channel.h:650
the list of registered channel types
Definition channel.c:125
struct ast_channel * chan
Definition app_dial.c:806
struct chanlist::@348 list
const char * tech
Definition app_dial.c:810

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, chanlist::list, LOG_WARNING, chanlist::tech, ast_channel::tech, and ast_channel_tech::type.

Referenced by ast_channels_init(), ast_local_init(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), and register_channel_tech().

◆ ast_channel_release()

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.

Return values
NULLconvenient for clearing invalid pointers
Note
Absolutely NO channel locks should be held before calling this function.
Since
1.8

Definition at line 1571 of file channel.c.

1572{
1573 /* Safe, even if already unlinked. */
1574 ast_channel_unlink(chan);
1575 return ast_channel_unref(chan);
1576}
void ast_channel_unlink(struct ast_channel *chan)
Remove a channel from the global channels container.
Definition channel.c:10639
#define ast_channel_unref(c)
Decrease channel reference count.
Definition channel.h:3025

References ast_channel_unlink(), and ast_channel_unref.

Referenced by ast_iax2_new(), ast_unreal_new_channels(), destroy_msg_q_chan(), do_notify(), rec_request(), safe_channel_release(), safe_channel_release(), safe_channel_release(), safe_channel_release(), and safe_channel_release().

◆ ast_channel_req_accountcodes()

void ast_channel_req_accountcodes ( struct ast_channel chan,
const struct ast_channel requestor,
enum ast_channel_requestor_relationship  relationship 
)

Setup new channel accountcodes from the requestor channel after ast_request().

Since
13.0.0
Parameters
chanNew channel to get accountcodes setup.
requestorRequesting channel to get accountcodes from.
relationshipWhat the new channel was created for.
Precondition
The chan and requestor channels are already locked.
Note
Pre-existing accountcodes on chan will be overwritten.

Definition at line 6491 of file channel.c.

6492{
6493 channel_req_accountcodes(chan, requestor, relationship, 0);
6494}
static void channel_req_accountcodes(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship, int precious)
Definition channel.c:6433

References channel_req_accountcodes().

Referenced by __ast_request_and_dial(), ast_ari_channels_dial(), ast_call_forward(), attended_transfer_bridge(), begin_dial_prerun(), blind_transfer_bridge(), common_recall_channel_setup(), dial_exec_full(), dial_transfer(), do_forward(), findmeexec(), park_local_transfer(), and wait_for_answer().

◆ ast_channel_req_accountcodes_precious()

void ast_channel_req_accountcodes_precious ( struct ast_channel chan,
const struct ast_channel requestor,
enum ast_channel_requestor_relationship  relationship 
)

Setup new channel accountcodes from the requestor channel after ast_request().

Since
13.0.0
Parameters
chanNew channel to get accountcodes setup.
requestorRequesting channel to get accountcodes from.
relationshipWhat the new channel was created for.
Precondition
The chan and requestor channels are already locked.
Note
Pre-existing accountcodes on chan will not be overwritten.

Definition at line 6496 of file channel.c.

6497{
6498 channel_req_accountcodes(chan, requestor, relationship, 1);
6499}

References channel_req_accountcodes().

Referenced by ring_entry().

◆ ast_channel_request_stream_topology_change()

int ast_channel_request_stream_topology_change ( struct ast_channel chan,
struct ast_stream_topology topology,
void *  change_source 
)

Request that the stream topology of a channel change.

Parameters
chanThe channel to change
topologyThe new stream topology
change_sourceThe source that initiated the change
Note
Absolutely NO channel locks should be held before calling this function.
Return values
0request has been accepted to be attempted
-1request could not be attempted
Note
This function initiates an asynchronous request to change the stream topology. It is not guaranteed that the topology will change and until an AST_CONTROL_STREAM_TOPOLOGY_CHANGED frame is received from the channel the current handler of the channel must tolerate the stream topology as it currently exists.
This interface is provided for applications and resources to request that the topology change. It is not for use by the channel driver itself.

Definition at line 11076 of file channel.c.

11078{
11079 int res;
11080
11081 ast_assert(chan != NULL);
11082 ast_assert(topology != NULL);
11083
11084 ast_channel_lock(chan);
11086 ast_channel_unlock(chan);
11087 return -1;
11088 }
11089
11091 ast_debug(2, "%s: Topologies already match. Current: %s Requested: %s\n",
11092 ast_channel_name(chan),
11094 ast_str_tmp(256, ast_stream_topology_to_str(topology, &STR_TMP)));
11095 ast_channel_unlock(chan);
11096 return 0;
11097 }
11098
11100
11101 res = ast_channel_tech(chan)->indicate(chan, AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE, topology, sizeof(topology));
11102 ast_channel_unlock(chan);
11103 return res;
11104}
static int indicate(void *data)
void ast_channel_internal_set_stream_topology_change_source(struct ast_channel *chan, void *change_source)
@ AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE
const char * ast_stream_topology_to_str(const struct ast_stream_topology *topology, struct ast_str **buf)
Get a string representing the topology for debugging/display purposes.
Definition stream.c:939
int ast_stream_topology_equal(const struct ast_stream_topology *left, const struct ast_stream_topology *right)
Compare two stream topologies to see if they are equal.
Definition stream.c:699
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:791

References ast_assert, ast_channel_get_stream_topology(), ast_channel_internal_set_stream_topology_change_source(), ast_channel_is_multistream(), ast_channel_lock, ast_channel_name(), ast_channel_unlock, AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE, ast_debug, ast_str_tmp, ast_stream_topology_equal(), ast_stream_topology_to_str(), indicate(), ast_channel_tech::indicate, and NULL.

Referenced by AST_TEST_DEFINE(), AST_TEST_DEFINE(), native_rtp_bridge_join(), native_rtp_stream_topology_changed(), sfu_topologies_on_join(), sfu_topologies_on_leave(), sfu_topologies_on_source_change(), simple_bridge_join(), simple_bridge_stream_topology_changed(), softmix_bridge_stream_sources_update(), and stream_echo_perform().

◆ ast_channel_rings()

int ast_channel_rings ( const struct ast_channel chan)

Definition at line 325 of file channel_internal_api.c.

326{
327 return chan->rings;
328}

References ast_channel::rings.

Referenced by __analog_handle_event(), ast_var_channels_table(), and serialize_showchan().

◆ ast_channel_rings_set()

void ast_channel_rings_set ( struct ast_channel chan,
int  value 
)

◆ ast_channel_sched()

struct ast_sched_context * ast_channel_sched ( const struct ast_channel chan)

◆ ast_channel_sched_set()

void ast_channel_sched_set ( struct ast_channel chan,
struct ast_sched_context value 
)

Definition at line 600 of file channel_internal_api.c.

601{
602 chan->sched = value;
603}

References ast_channel::sched, and value.

Referenced by __ast_channel_alloc_ap(), and ast_hangup().

◆ ast_channel_sendhtml()

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

6686{
6687 if (ast_channel_tech(chan)->send_html)
6688 return ast_channel_tech(chan)->send_html(chan, subclass, data, datalen);
6689 return -1;
6690}
int(*const send_html)(struct ast_channel *chan, int subclass, const char *data, int len)
Send HTML data.
Definition channel.h:782

References ast_channel_tech::send_html.

Referenced by ast_channel_sendurl(), and wait_for_answer().

◆ ast_channel_sending_dtmf_digit()

char ast_channel_sending_dtmf_digit ( const struct ast_channel chan)

Definition at line 259 of file channel_internal_api.c.

260{
261 return chan->sending_dtmf_digit;
262}

References ast_channel::sending_dtmf_digit.

Referenced by ast_senddigit_end(), bridge_channel_internal_join(), and channel_do_masquerade().

◆ ast_channel_sending_dtmf_digit_set()

void ast_channel_sending_dtmf_digit_set ( struct ast_channel chan,
char  value 
)

Definition at line 263 of file channel_internal_api.c.

264{
266}

References ast_channel::sending_dtmf_digit, and value.

Referenced by ast_senddigit_begin(), and ast_senddigit_end().

◆ ast_channel_sending_dtmf_tv()

struct timeval ast_channel_sending_dtmf_tv ( const struct ast_channel chan)

Definition at line 268 of file channel_internal_api.c.

269{
270 return chan->sending_dtmf_tv;
271}
struct timeval sending_dtmf_tv

Referenced by bridge_channel_internal_join(), and channel_do_masquerade().

◆ ast_channel_sending_dtmf_tv_set()

void ast_channel_sending_dtmf_tv_set ( struct ast_channel chan,
struct timeval  value 
)

Definition at line 272 of file channel_internal_api.c.

273{
274 chan->sending_dtmf_tv = value;
275}

References ast_channel::sending_dtmf_tv, and value.

Referenced by ast_senddigit_begin().

◆ ast_channel_sendurl()

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

6693{
6694 return ast_channel_sendhtml(chan, AST_HTML_URL, url, strlen(url) + 1);
6695}
int ast_channel_sendhtml(struct ast_channel *chan, int subclass, const char *data, int datalen)
Sends HTML on given channel Send HTML or URL on link.
Definition channel.c:6685
#define AST_HTML_URL

References ast_channel_sendhtml(), AST_HTML_URL, and url.

Referenced by dial_exec_full(), and try_calling().

◆ ast_channel_set_ari_vars()

void ast_channel_set_ari_vars ( size_t  varc,
char **  vars 
)

Sets the variables to be stored in the ari_vars field of all snapshots.

Since
14.2.0
Parameters
varcNumber of variable names.
varsArray of variable names.

Definition at line 7939 of file channel.c.

7940{
7941 channel_set_external_vars(&ari_vars, varc, vars);
7942}
static void channel_set_external_vars(struct external_vars *channelvars, size_t varc, char **vars)
Definition channel.c:7912

References ari_vars, and channel_set_external_vars().

Referenced by general_apply().

◆ ast_channel_set_caller()

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.
Note
The channel does not need to be locked before calling this function.

Definition at line 7433 of file channel.c.

7434{
7435 if (ast_channel_caller(chan) == caller) {
7436 /* Don't set to self */
7437 return;
7438 }
7439
7440 ast_channel_lock(chan);
7443 ast_channel_unlock(chan);
7444}
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:1994

References ast_channel_caller(), ast_channel_lock, AST_CHANNEL_SNAPSHOT_INVALIDATE_CALLER, ast_channel_snapshot_invalidate_segment(), ast_channel_unlock, ast_party_caller_set(), and update().

◆ ast_channel_set_caller_event()

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.
Note
The channel does not need to be locked before calling this function.

Definition at line 7446 of file channel.c.

7447{
7448 if (ast_channel_caller(chan) == caller) {
7449 /* Don't set to self */
7450 return;
7451 }
7452
7453 ast_channel_lock(chan);
7457 ast_channel_unlock(chan);
7458}

References ast_channel_caller(), ast_channel_lock, ast_channel_publish_snapshot(), AST_CHANNEL_SNAPSHOT_INVALIDATE_CALLER, ast_channel_snapshot_invalidate_segment(), ast_channel_unlock, ast_party_caller_set(), and update().

Referenced by callerid_write(), dial_exec_full(), do_forward(), queue_connected_line_update(), and ring_entry().

◆ ast_channel_set_connected_line()

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.
Note
The channel does not need to be locked before calling this function.

Definition at line 8414 of file channel.c.

8415{
8416 if (ast_channel_connected(chan) == connected) {
8417 /* Don't set to self */
8418 return;
8419 }
8420
8421 ast_channel_lock(chan);
8425 ast_channel_unlock(chan);
8426}
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:2041

References ast_channel_connected(), ast_channel_lock, ast_channel_publish_snapshot(), AST_CHANNEL_SNAPSHOT_INVALIDATE_CONNECTED, ast_channel_snapshot_invalidate_segment(), ast_channel_unlock, ast_party_connected_line_set(), connected, and update().

Referenced by __ast_request_and_dial(), ari_channels_handle_originate_with_id(), connectedline_write(), dial_exec_full(), indicate_connected_line(), and pbx_outgoing_attempt().

◆ ast_channel_set_fd()

void ast_channel_set_fd ( struct ast_channel chan,
int  which,
int  fd 
)

◆ ast_channel_set_flag()

void ast_channel_set_flag ( struct ast_channel chan,
unsigned int  flag 
)

Set a flag on a channel.

Since
13.17.0
Parameters
chanThe channel to set the flag on
flagThe flag to set
Note
This will lock the channel internally. If the channel is already locked it is still safe to call.

Definition at line 11137 of file channel.c.

11138{
11139 ast_channel_lock(chan);
11141 ast_channel_unlock(chan);
11142}

References ast_channel_flags(), ast_channel_lock, ast_channel_unlock, and ast_set_flag.

Referenced by ast_call_forward(), ast_waitfordigit_full(), channel_spy(), common_exec(), dial_exec_full(), disa_exec(), do_broadcast(), and waitstream_core().

◆ ast_channel_set_is_t38_active()

void ast_channel_set_is_t38_active ( struct ast_channel chan,
int  is_t38_active 
)

Sets the is_t38_active flag.

Parameters
chanWhich channel is having its is_t38_active value set
is_t38_activeNon-zero if T.38 is active

Definition at line 928 of file channel_internal_api.c.

929{
930 ast_channel_lock(chan);
931 ast_channel_set_is_t38_active_nolock(chan, is_t38_active);
932 ast_channel_unlock(chan);
933}
void ast_channel_set_is_t38_active_nolock(struct ast_channel *chan, int is_t38_active)
Variant of ast_channel_set_is_t38_active. Use this if the channel is already locked prior to calling.

References ast_channel_lock, ast_channel_set_is_t38_active_nolock(), and ast_channel_unlock.

◆ ast_channel_set_is_t38_active_nolock()

void ast_channel_set_is_t38_active_nolock ( struct ast_channel chan,
int  is_t38_active 
)

Variant of ast_channel_set_is_t38_active. Use this if the channel is already locked prior to calling.

Parameters
chanWhich channel is having its is_t38_active value set
is_t38_activeNon-zero if T.38 is active

Definition at line 923 of file channel_internal_api.c.

924{
925 chan->is_t38_active = !!is_t38_active;
926}

References ast_channel::is_t38_active.

Referenced by ast_channel_set_is_t38_active(), and indicate_data_internal().

◆ ast_channel_set_manager_vars()

void ast_channel_set_manager_vars ( size_t  varc,
char **  vars 
)

Sets the variables to be stored in the manager_vars field of all snapshots.

Since
12
Parameters
varcNumber of variable names.
varsArray of variable names.

Definition at line 7934 of file channel.c.

7935{
7936 channel_set_external_vars(&ami_vars, varc, vars);
7937}

References ami_vars, and channel_set_external_vars().

Referenced by load_channelvars().

◆ ast_channel_set_oldwriteformat()

void ast_channel_set_oldwriteformat ( struct ast_channel chan,
struct ast_format format 
)

Definition at line 691 of file channel_internal_api.c.

692{
693 ao2_replace(chan->oldwriteformat, format);
694}

References ao2_replace, and ast_channel::oldwriteformat.

Referenced by ast_channel_destructor(), and openstream_internal().

◆ ast_channel_set_rawreadformat()

void ast_channel_set_rawreadformat ( struct ast_channel chan,
struct ast_format format 
)

◆ ast_channel_set_rawwriteformat()

void ast_channel_set_rawwriteformat ( struct ast_channel chan,
struct ast_format format 
)

◆ ast_channel_set_readformat()

void ast_channel_set_readformat ( struct ast_channel chan,
struct ast_format format 
)

◆ ast_channel_set_redirecting()

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.
Note
The channel does not need to be locked before calling this function.

Definition at line 9225 of file channel.c.

9226{
9227 if (ast_channel_redirecting(chan) == redirecting) {
9228 /* Don't set to self */
9229 return;
9230 }
9231
9232 ast_channel_lock(chan);
9236 ast_channel_unlock(chan);
9237}
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:2153

References ast_channel_lock, ast_channel_publish_snapshot(), ast_channel_redirecting(), AST_CHANNEL_SNAPSHOT_INVALIDATE_CALLER, ast_channel_snapshot_invalidate_segment(), ast_channel_unlock, ast_party_redirecting_set(), and update().

Referenced by AST_TEST_DEFINE(), indicate_redirecting(), redirecting_write(), and set_redirecting().

◆ ast_channel_set_stream_topology()

struct ast_stream_topology * ast_channel_set_stream_topology ( struct ast_channel chan,
struct ast_stream_topology topology 
)

Set the topology of streams on a channel.

Parameters
chanThe channel to set the stream topology on
topologyThe stream topology to set
Precondition
chan is locked
Note
If topology is NULL a new empty topology will be created and returned.
Return values
non-NULLSuccess
NULLfailure

Definition at line 1507 of file channel_internal_api.c.

1509{
1510 struct ast_stream_topology *new_topology;
1511 SCOPE_ENTER(1, "%s: %s\n", ast_channel_name(chan),
1512 ast_str_tmp(256, ast_stream_topology_to_str(topology, &STR_TMP)));
1513
1514 ast_assert(chan != NULL);
1515
1516 /* A non-MULTISTREAM channel can't manipulate topology directly */
1518
1519 /* Unless the channel is being destroyed, we always want a topology on
1520 * it even if its empty.
1521 */
1522 if (!topology) {
1523 new_topology = ast_stream_topology_alloc();
1524 } else {
1525 new_topology = topology;
1526 }
1527
1528 if (new_topology) {
1529 ast_channel_internal_set_stream_topology(chan, new_topology);
1530 }
1531
1532 SCOPE_EXIT_RTN_VALUE(new_topology, "Used %s topology\n", topology ? "provided" : "empty");
1533}
#define SCOPE_EXIT_RTN_VALUE(__return_value,...)
struct ast_stream_topology * ast_stream_topology_alloc(void)
Create a stream topology.
Definition stream.c:652

References ast_assert, ast_channel_internal_set_stream_topology(), ast_channel_is_multistream(), ast_channel_name(), ast_str_tmp, ast_stream_topology_alloc(), ast_stream_topology_to_str(), NULL, SCOPE_ENTER, and SCOPE_EXIT_RTN_VALUE.

Referenced by AST_TEST_DEFINE(), AST_TEST_DEFINE(), ast_unreal_indicate(), ast_unreal_new_channels(), chan_pjsip_new(), handle_negotiated_sdp(), make_channel(), and unreal_colp_stream_topology_request_change().

◆ ast_channel_set_unbridged()

void ast_channel_set_unbridged ( struct ast_channel chan,
int  value 
)

Sets the unbridged flag and queues a NULL frame on the channel to trigger a check by bridge_channel_wait.

Parameters
chanWhich channel is having its unbridged value set
valueWhat the unbridge value is being set to

Definition at line 901 of file channel_internal_api.c.

902{
903 ast_channel_lock(chan);
905 ast_channel_unlock(chan);
906}
void ast_channel_set_unbridged_nolock(struct ast_channel *chan, int value)
Variant of ast_channel_set_unbridged. Use this if the channel is already locked prior to calling.

References ast_channel_lock, ast_channel_set_unbridged_nolock(), ast_channel_unlock, and value.

Referenced by ast_bridge_setup_after_goto(), bridge_channel_wait(), and t38_change_state().

◆ ast_channel_set_unbridged_nolock()

void ast_channel_set_unbridged_nolock ( struct ast_channel chan,
int  value 
)

Variant of ast_channel_set_unbridged. Use this if the channel is already locked prior to calling.

Parameters
chanWhich channel is having its unbridged value set
valueWhat the unbridge value is being set to

Definition at line 895 of file channel_internal_api.c.

896{
897 chan->unbridged = !!value;
899}
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
Definition channel.c:1171
struct ast_frame ast_null_frame
Definition main/frame.c:79

References ast_null_frame, ast_queue_frame(), ast_channel::unbridged, and value.

Referenced by ast_audiohook_attach(), ast_audiohook_remove(), ast_channel_set_unbridged(), ast_framehook_attach(), ast_framehook_detach(), ast_framehook_list_fixup(), audio_audiohook_write_list(), chan_pjsip_read_stream(), dtmf_audiohook_write_list(), and set_caps().

◆ ast_channel_set_writeformat()

void ast_channel_set_writeformat ( struct ast_channel chan,
struct ast_format format 
)

◆ ast_channel_setoption()

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

7497{
7498 int res;
7499
7500 ast_channel_lock(chan);
7501 if (!ast_channel_tech(chan)->setoption) {
7502 errno = ENOSYS;
7503 ast_channel_unlock(chan);
7504 return -1;
7505 }
7506
7507 if (block)
7508 ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n");
7509
7510 res = ast_channel_tech(chan)->setoption(chan, option, data, datalen);
7511 ast_channel_unlock(chan);
7512
7513 return res;
7514}
int(*const setoption)(struct ast_channel *chan, int option, void *data, int datalen)
Set a given option. Called with chan locked.
Definition channel.h:797

References ast_channel_lock, ast_channel_unlock, ast_log, ast_datastore::data, errno, LOG_ERROR, and ast_channel_tech::setoption.

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

◆ ast_channel_setwhentohangup_tv()

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

Precondition
chan is locked
Since
1.6.1

Set when to hang a channel up.

Definition at line 511 of file channel.c.

512{
513 if (ast_tvzero(offset)) {
514 ast_channel_whentohangup_set(chan, &offset);
515 } else {
516 struct timeval tv = ast_tvadd(offset, ast_tvnow());
518 }
520 return;
521}
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to a channel's frame queue.
Definition channel.c:1171

References ast_channel_whentohangup_set(), ast_null_frame, ast_queue_frame(), ast_tvadd(), ast_tvnow(), and ast_tvzero().

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

◆ ast_channel_snapshot()

struct ast_channel_snapshot * ast_channel_snapshot ( const struct ast_channel chan)

Definition at line 1564 of file channel_internal_api.c.

1565{
1566 return chan->snapshot;
1567}
struct ast_channel_snapshot * snapshot

References ast_channel::snapshot.

◆ ast_channel_snapshot_segment_flags()

struct ast_flags * ast_channel_snapshot_segment_flags ( struct ast_channel chan)

◆ ast_channel_snapshot_set()

void ast_channel_snapshot_set ( struct ast_channel chan,
struct ast_channel_snapshot snapshot 
)

Definition at line 1569 of file channel_internal_api.c.

1570{
1571 ao2_cleanup(chan->snapshot);
1572 chan->snapshot = ao2_bump(snapshot);
1573}

References ao2_bump, ao2_cleanup, and ast_channel::snapshot.

Referenced by ast_channel_publish_final_snapshot(), and ast_channel_publish_snapshot().

◆ ast_channel_softhangup_internal_flag()

int ast_channel_softhangup_internal_flag ( struct ast_channel chan)

◆ ast_channel_softhangup_internal_flag_add()

void ast_channel_softhangup_internal_flag_add ( struct ast_channel chan,
int  value 
)

◆ ast_channel_softhangup_internal_flag_clear()

void ast_channel_softhangup_internal_flag_clear ( struct ast_channel chan,
int  value 
)

Definition at line 876 of file channel_internal_api.c.

877{
878 chan ->softhangup &= ~value;
879}

References ast_channel::softhangup.

Referenced by ast_channel_clear_softhangup().

◆ ast_channel_softhangup_internal_flag_set()

void ast_channel_softhangup_internal_flag_set ( struct ast_channel chan,
int  value 
)

Definition at line 868 of file channel_internal_api.c.

869{
870 chan->softhangup = value;
871}

References ast_channel::softhangup, and value.

Referenced by channel_do_masquerade().

◆ ast_channel_softhangup_withcause_locked()

void ast_channel_softhangup_withcause_locked ( struct ast_channel chan,
int  causecode 
)

Lock the given channel, then request softhangup on the channel with the given causecode.

Parameters
chanchannel on which to hang up
causecodecause code to use (Zero if don't use cause code)

Definition at line 469 of file channel.c.

470{
471 ast_channel_lock(chan);
472
473 if (causecode > 0) {
474 ast_debug(1, "Setting hangupcause of channel %s to %d (is %d now)\n",
475 ast_channel_name(chan), causecode, ast_channel_hangupcause(chan));
476
477 ast_channel_hangupcause_set(chan, causecode);
478 }
479
481
482 ast_channel_unlock(chan);
483}
int ast_softhangup_nolock(struct ast_channel *chan, int cause)
Softly hangup a channel, don't lock.
Definition channel.c:2449

References ast_channel_hangupcause(), ast_channel_hangupcause_set(), ast_channel_lock, ast_channel_name(), ast_channel_unlock, ast_debug, AST_SOFTHANGUP_EXPLICIT, and ast_softhangup_nolock().

Referenced by action_hangup().

◆ ast_channel_start_silence_generator()

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

8271{
8273
8274 if (!(state = ast_calloc(1, sizeof(*state)))) {
8275 return NULL;
8276 }
8277
8278 state->old_write_format = ao2_bump(ast_channel_writeformat(chan));
8279
8280 if (ast_set_write_format(chan, ast_format_slin) < 0) {
8281 ast_log(LOG_ERROR, "Could not set write format to SLINEAR\n");
8282 ast_free(state);
8283 return NULL;
8284 }
8285
8287
8288 ast_debug(1, "Started silence generator on '%s'\n", ast_channel_name(chan));
8289
8290 return state;
8291}
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
Definition channel.c:2989
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
Definition channel.c:5860
static struct ast_generator silence_generator
Definition channel.c:8260
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.

References ao2_bump, ast_activate_generator(), ast_calloc, ast_channel_name(), ast_channel_writeformat(), ast_debug, ast_format_slin, ast_free, ast_log, ast_set_write_format(), LOG_ERROR, NULL, and silence_generator.

Referenced by __ast_play_and_record(), app_control_silence_start(), ast_readstring_full(), channel_spy(), control_streamfile(), do_broadcast(), dtmf_stream(), handle_recordfile(), mf_stream(), participant_entertainment_start(), record_exec(), safe_sleep_conditional(), sf_stream(), sub_start_silence(), waitfor_exec(), and waitforring_exec().

◆ ast_channel_state()

enum ast_channel_state ast_channel_state ( const struct ast_channel chan)

Definition at line 656 of file channel_internal_api.c.

657{
658 return chan->state;
659}

References ast_channel::state.

◆ ast_channel_state_set()

void ast_channel_state_set ( struct ast_channel chan,
enum  ast_channel_state 
)

◆ ast_channel_stop_silence_generator()

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.

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

Definition at line 8316 of file channel.c.

8317{
8318 if (!state) {
8319 return;
8320 }
8321
8322 if (deactivate_silence_generator(chan)) {
8323 ast_debug(1, "Stopped silence generator on '%s'\n", ast_channel_name(chan));
8324 if (ast_set_write_format(chan, state->old_write_format) < 0) {
8325 ast_log(LOG_ERROR, "Could not return write format to its original state\n");
8326 }
8327 }
8328 ao2_cleanup(state->old_write_format);
8329 ast_free(state);
8330}
static int deactivate_silence_generator(struct ast_channel *chan)
Definition channel.c:8293

References ao2_cleanup, ast_channel_name(), ast_debug, ast_free, ast_log, ast_set_write_format(), deactivate_silence_generator(), and LOG_ERROR.

Referenced by __ast_play_and_record(), app_control_silence_start(), ast_readstring_full(), channel_spy(), control_silence_stop_now(), control_streamfile(), do_broadcast(), dtmf_stream(), handle_recordfile(), mf_stream(), participant_entertainment_stop(), record_exec(), safe_sleep_conditional(), sf_stream(), sub_stop_silence(), waitfor_exec(), and waitforring_exec().

◆ ast_channel_stream()

struct ast_filestream * ast_channel_stream ( const struct ast_channel chan)

◆ ast_channel_stream_set()

void ast_channel_stream_set ( struct ast_channel chan,
struct ast_filestream value 
)

◆ ast_channel_stream_topology_changed()

int ast_channel_stream_topology_changed ( struct ast_channel chan,
struct ast_stream_topology topology 
)

Provide notice to a channel that the stream topology has changed.

Parameters
chanThe channel to provide notice to
topologyThe new stream topology
Precondition
chan is locked Absolutely NO other channels can be locked.
Return values
0success
-1failure
Note
This interface is provided for applications and resources to accept a topology change. It is not for use by the channel driver itself.

Definition at line 11106 of file channel.c.

11107{
11108 ast_assert(chan != NULL);
11109 ast_assert(topology != NULL);
11110
11112 return -1;
11113 }
11114
11115 return ast_channel_tech(chan)->indicate(chan, AST_CONTROL_STREAM_TOPOLOGY_CHANGED, topology, sizeof(topology));
11116}
@ AST_CONTROL_STREAM_TOPOLOGY_CHANGED

References ast_assert, ast_channel_is_multistream(), AST_CONTROL_STREAM_TOPOLOGY_CHANGED, indicate(), ast_channel_tech::indicate, and NULL.

Referenced by __ast_read(), AST_TEST_DEFINE(), and AST_TEST_DEFINE().

◆ ast_channel_stream_topology_changed_externally()

int ast_channel_stream_topology_changed_externally ( struct ast_channel chan)

Provide notice from a channel that the topology has changed on it as a result of the remote party renegotiating.

Parameters
chanThe channel to provide notice from
Return values
0success
-1failure
Note
This interface is provided for channels to provide notice that a topology change has occurred as a result of a remote party renegotiating the stream topology.

Definition at line 11118 of file channel.c.

11119{
11120 int res;
11122
11123 ast_assert(chan != NULL);
11124
11125 if (!ast_channel_is_multistream(chan)) {
11126 return -1;
11127 }
11128
11129 ast_channel_lock(chan);
11131 res = ast_queue_frame(chan, &f);
11132 ast_channel_unlock(chan);
11133
11134 return res;
11135}
static const char ast_stream_topology_changed_external[]
Set as the change source reason when a channel stream topology has been changed externally as a resul...
Definition channel.h:223

References ast_assert, ast_channel_internal_set_stream_topology_change_source(), ast_channel_is_multistream(), ast_channel_lock, ast_channel_unlock, AST_CONTROL_STREAM_TOPOLOGY_CHANGED, AST_FRAME_CONTROL, ast_queue_frame(), ast_stream_topology_changed_external, ast_frame_subclass::integer, NULL, and ast_frame::subclass.

Referenced by handle_negotiated_sdp(), and unreal_colp_stream_topology_request_change().

◆ ast_channel_streamid()

int ast_channel_streamid ( const struct ast_channel chan)

Definition at line 333 of file channel_internal_api.c.

334{
335 return chan->streamid;
336}

References ast_channel::streamid.

Referenced by filestream_close(), handle_speechrecognize(), and speech_background().

◆ ast_channel_streamid_set()

void ast_channel_streamid_set ( struct ast_channel chan,
int  value 
)

Definition at line 337 of file channel_internal_api.c.

338{
339 chan->streamid = value;
340}

References ast_channel::streamid, and value.

Referenced by __ast_channel_alloc_ap(), ast_readaudio_callback(), and filestream_close().

◆ ast_channel_string2amaflag()

enum ama_flags ast_channel_string2amaflag ( const char *  flag)

Convert a string to a detail record AMA flag.

Since
12
Parameters
flagstring form of flag
Return values
theenum (integer) form of the flag

Definition at line 4416 of file channel.c.

4417{
4418 if (!strcasecmp(flag, "default"))
4419 return DEFAULT_AMA_FLAGS;
4420 if (!strcasecmp(flag, "omit"))
4421 return AST_AMA_OMIT;
4422 if (!strcasecmp(flag, "billing"))
4423 return AST_AMA_BILLING;
4424 if (!strcasecmp(flag, "documentation"))
4425 return AST_AMA_DOCUMENTATION;
4426 return AST_AMA_NONE;
4427}
#define DEFAULT_AMA_FLAGS
Definition channel.c:112

References AST_AMA_BILLING, AST_AMA_DOCUMENTATION, AST_AMA_NONE, AST_AMA_OMIT, and DEFAULT_AMA_FLAGS.

Referenced by build_device(), build_peer(), build_user(), build_user(), cdr_write(), func_channel_write_real(), process_dahdi(), reload_config(), and set_config().

◆ ast_channel_supports_html()

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

6681{
6682 return (ast_channel_tech(chan)->send_html) ? 1 : 0;
6683}

Referenced by dial_exec_full(), and try_calling().

◆ ast_channel_suppress()

int ast_channel_suppress ( struct ast_channel chan,
unsigned int  direction,
enum ast_frame_type  frametype 
)

Suppress passing of a frame type on a channel.

Note
The channel should be locked before calling this function.
Parameters
chanThe channel to suppress
directionThe direction in which to suppress
frametypeThe type of frame (AST_FRAME_VOICE, etc) to suppress
Return values
0Success
-1Failure

Definition at line 10887 of file channel.c.

10888{
10889 struct suppress_data *suppress;
10890 const struct ast_datastore_info *datastore_info = NULL;
10891 struct ast_datastore *datastore = NULL;
10892 struct ast_framehook_interface interface = {
10894 .event_cb = suppress_framehook_event_cb,
10895 .destroy_cb = suppress_framehook_destroy_cb,
10896 .chan_fixup_cb = suppress_framehook_fixup_cb,
10897 };
10898 int framehook_id;
10899
10900 if (!(datastore_info = suppress_get_datastore_information(frametype))) {
10901 ast_log(LOG_WARNING, "Attempted to suppress an unsupported frame type (%u).\n", frametype);
10902 return -1;
10903 }
10904
10905 if ((datastore = ast_channel_datastore_find(chan, datastore_info, NULL))) {
10906 suppress = datastore->data;
10907 suppress->direction |= direction;
10908 return 0;
10909 }
10910
10911 if (!(suppress = ao2_alloc(sizeof(*suppress), NULL))) {
10912 ast_log(LOG_WARNING, "Failed to allocate data while attempting to suppress a stream.\n");
10913 return -1;
10914 }
10915
10916 suppress->frametype = frametype;
10917 suppress->direction |= direction;
10918
10919 interface.data = suppress;
10920
10921 framehook_id = ast_framehook_attach(chan, &interface);
10922 if (framehook_id < 0) {
10923 /* Hook attach failed. Get rid of the evidence. */
10924 ast_log(LOG_WARNING, "Failed to attach framehook while attempting to suppress a stream.\n");
10925 ao2_ref(suppress, -1);
10926 return -1;
10927 }
10928
10929 /* One ref for the framehook */
10930 ao2_ref(suppress, +1);
10931
10932 suppress->framehook_id = framehook_id;
10933
10934 if (!(datastore = ast_datastore_alloc(datastore_info, NULL))) {
10935 ast_log(LOG_WARNING, "Failed to allocate datastore while attempting to suppress a stream.\n");
10936 ast_framehook_detach(chan, framehook_id);
10937 ao2_ref(suppress, -1);
10938 return -1;
10939 }
10940
10941 /* the ref provided by the allocation is taken by the datastore */
10942 datastore->data = suppress;
10943
10944 ast_channel_datastore_add(chan, datastore);
10945
10946 return 0;
10947}
static void suppress_framehook_fixup_cb(void *data, int framehook_id, struct ast_channel *old_chan, struct ast_channel *new_chan)
Definition channel.c:10835
static const struct ast_datastore_info * suppress_get_datastore_information(enum ast_frame_type frametype)
Definition channel.c:10877
static void suppress_framehook_destroy_cb(void *data)
Definition channel.c:10824
static struct ast_frame * suppress_framehook_event_cb(struct ast_channel *chan, struct ast_frame *frame, enum ast_framehook_event event, void *data)
Definition channel.c:10842
int ast_framehook_attach(struct ast_channel *chan, struct ast_framehook_interface *i)
Attach an framehook onto a channel for frame interception.
Definition framehook.c:132
int ast_framehook_detach(struct ast_channel *chan, int framehook_id)
Detach an framehook from a channel.
Definition framehook.c:177
#define AST_FRAMEHOOK_INTERFACE_VERSION
Definition framehook.h:227
Structure for a data store type.
Definition datastore.h:31
enum ast_frame_type frametype
Definition channel.c:10830
unsigned int direction
Definition channel.c:10831

References ao2_alloc, ao2_ref, ast_channel_datastore_add(), ast_channel_datastore_find(), ast_datastore_alloc, ast_framehook_attach(), ast_framehook_detach(), AST_FRAMEHOOK_INTERFACE_VERSION, ast_log, ast_datastore::data, ast_framehook_interface::data, suppress_data::direction, suppress_data::framehook_id, suppress_data::frametype, LOG_WARNING, NULL, suppress_framehook_destroy_cb(), suppress_framehook_event_cb(), suppress_framehook_fixup_cb(), suppress_get_datastore_information(), and ast_framehook_interface::version.

Referenced by app_control_mute(), and mute_channel().

◆ ast_channel_tech()

const struct ast_channel_tech * ast_channel_tech ( const struct ast_channel chan)

Definition at line 636 of file channel_internal_api.c.

637{
638 return chan->tech;
639}

References ast_channel::tech.

◆ ast_channel_tech_hangupcause()

int ast_channel_tech_hangupcause ( const struct ast_channel chan)

◆ ast_channel_tech_hangupcause_set()

void ast_channel_tech_hangupcause_set ( struct ast_channel chan,
int  value 
)

◆ ast_channel_tech_pvt()

void * ast_channel_tech_pvt ( const struct ast_channel chan)

Definition at line 437 of file channel_internal_api.c.

438{
439 return chan->tech_pvt;
440}

References ast_channel::tech_pvt.

Referenced by __analog_ss_thread(), __dahdi_exception(), acf_channel_read(), analog_hangup(), analog_ss_thread(), announce_hangup(), aoc_framehook(), ast_channel_destructor(), ast_local_get_peer(), ast_local_lock_all(), ast_local_setup_bridge(), ast_local_setup_masquerade(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), ast_unreal_answer(), ast_unreal_channel_push_to_bridge(), ast_unreal_digit_begin(), ast_unreal_digit_end(), ast_unreal_fixup(), ast_unreal_indicate(), ast_unreal_queryoption(), ast_unreal_sendhtml(), ast_unreal_sendtext(), ast_unreal_setoption(), ast_unreal_write_stream(), audiosocket_call(), audiosocket_hangup(), audiosocket_read(), audiosocket_send_dtmf(), audiosocket_write(), chan_pjsip_answer(), chan_pjsip_call(), chan_pjsip_digit_begin(), chan_pjsip_digit_end(), chan_pjsip_fixup(), chan_pjsip_get_rtp_peer(), chan_pjsip_get_uniqueid(), chan_pjsip_get_vrtp_peer(), chan_pjsip_hangup(), chan_pjsip_indicate(), chan_pjsip_queryoption(), chan_pjsip_read_stream(), chan_pjsip_sendtext_data(), chan_pjsip_set_rtp_peer(), chan_pjsip_transfer(), chan_pjsip_write_stream(), chan_rtp_get_rtp_peer(), channel_do_masquerade(), channel_read_pjsip(), channel_read_rtcp(), channel_read_rtp(), channel_to_session(), cli_channelstats_print_body(), conf_announce_channel_push(), console_answer(), console_call(), console_fixup(), console_hangup(), console_indicate(), console_write(), dahdi_answer(), dahdi_call(), dahdi_callwait(), dahdi_digit_begin(), dahdi_digit_end(), dahdi_exception(), dahdi_fixup(), dahdi_func_read(), dahdi_func_write(), dahdi_handle_dtmf(), dahdi_handle_event(), dahdi_hangup(), dahdi_indicate(), dahdi_queryoption(), dahdi_read(), dahdi_sendtext(), dahdi_setoption(), dahdi_write(), dahdichan_helper(), func_read_header(), func_read_headers(), func_read_param(), func_response_read_header(), func_response_read_headers(), func_write_header(), func_write_param(), function_iaxpeer(), function_ooh323_read(), function_ooh323_write(), hangup(), iax2_answer(), iax2_call(), iax2_digit_begin(), iax2_digit_end(), iax2_fixup(), iax2_hangup(), iax2_indicate(), iax2_prov_app(), iax2_queryoption(), iax2_sendhtml(), iax2_sendimage(), iax2_sendtext(), iax2_setoption(), iax2_transfer(), iax2_write(), jingle_answer(), jingle_call(), jingle_digit_begin(), jingle_digit_end(), jingle_fixup(), jingle_get_rtp_peer(), jingle_hangup(), jingle_indicate(), jingle_read(), jingle_sendtext(), jingle_write(), load_stream_readqueue(), local_call(), local_hangup(), manager_optimize_away(), mbl_answer(), mbl_call(), mbl_digit_end(), mbl_fixup(), mbl_hangup(), mbl_read(), mbl_write(), media_hangup(), mock_channel_hangup(), mock_channel_indicate(), mock_channel_read(), mock_channel_write(), mock_channel_write_stream(), my_get_sigpvt_bridged_channel(), native_bridge_is_capable(), native_chan_changed(), native_start(), native_stop(), ooh323_answer(), ooh323_call(), ooh323_digit_begin(), ooh323_digit_end(), ooh323_fixup(), ooh323_get_codec(), ooh323_get_rtp_peer(), ooh323_get_vrtp_peer(), ooh323_hangup(), ooh323_indicate(), ooh323_queryoption(), ooh323_read(), ooh323_set_rtp_peer(), ooh323_write(), pjsip_acf_channel_read(), pjsip_acf_dtmf_mode_read(), pjsip_acf_dtmf_mode_write(), pjsip_acf_media_offer_read(), pjsip_acf_media_offer_write(), pjsip_acf_moh_passthrough_read(), pjsip_acf_moh_passthrough_write(), pjsip_acf_session_refresh_write(), pjsip_app_hangup_handler(), pjsip_transfer_handling_write(), polarity_read(), polarity_write(), push_notify_channel(), read_test(), rtp_call(), rtp_hangup(), rtp_read(), rtp_write(), send_direct_media_request(), sendtext_data_create(), snoop_fixup(), snoop_hangup(), snoop_read(), snoop_write(), stasis_app_channel_unreal_set_internal(), t38_framehook(), test_bridging_chan_hangup(), test_bridging_chan_indicate(), unistim_answer(), unistim_call(), unistim_fixup(), unistim_get_rtp_peer(), unistim_hangup(), unistim_indicate(), unistim_read(), unistim_set_rtp_peer(), unistim_ss(), unistim_write(), webchan_call(), webchan_hangup(), webchan_read(), webchan_send_dtmf_text(), and webchan_write().

◆ ast_channel_tech_pvt_set()

void ast_channel_tech_pvt_set ( struct ast_channel chan,
void *  value 
)

◆ ast_channel_tech_set()

void ast_channel_tech_set ( struct ast_channel chan,
const struct ast_channel_tech value 
)

◆ ast_channel_tenantid()

const char * ast_channel_tenantid ( const struct ast_channel chan)

Definition at line 173 of file channel_internal_api.c.

174{
175 /* It's ok for tenantid to be empty, so no need to assert */
176 return chan->linkedid.tenant_id;
177}
char tenant_id[AST_MAX_TENANT_ID]

References ast_channel::linkedid, and ast_channel_id::tenant_id.

Referenced by channel_snapshot_base_create(), func_channel_read(), and handle_showchan().

◆ ast_channel_tenantid_set()

void ast_channel_tenantid_set ( struct ast_channel chan,
const char *  value 
)

◆ ast_channel_timer()

struct ast_timer * ast_channel_timer ( const struct ast_channel chan)

◆ ast_channel_timer_set()

void ast_channel_timer_set ( struct ast_channel chan,
struct ast_timer value 
)

Definition at line 608 of file channel_internal_api.c.

609{
610 chan->timer = value;
611}

References ast_channel::timer, and value.

Referenced by __ast_channel_alloc_ap(), and ast_channel_destructor().

◆ ast_channel_timingdata()

void * ast_channel_timingdata ( const struct ast_channel chan)

Definition at line 448 of file channel_internal_api.c.

449{
450 return chan->timingdata;
451}

References ast_channel::timingdata.

Referenced by __ast_read(), and ast_settimeout_full().

◆ ast_channel_timingdata_set()

void ast_channel_timingdata_set ( struct ast_channel chan,
void *  value 
)

Definition at line 452 of file channel_internal_api.c.

453{
454 chan->timingdata = value;
455}

References ast_channel::timingdata, and value.

Referenced by ast_settimeout_full().

◆ ast_channel_timingfd()

int ast_channel_timingfd ( const struct ast_channel chan)

◆ ast_channel_timingfd_set()

void ast_channel_timingfd_set ( struct ast_channel chan,
int  value 
)

Definition at line 345 of file channel_internal_api.c.

346{
347 chan->timingfd = value;
348}

References ast_channel::timingfd, and value.

Referenced by __ast_channel_alloc_ap(), and __ast_dummy_channel_alloc().

◆ ast_channel_timingfunc()

ast_timing_func_t ast_channel_timingfunc ( const struct ast_channel chan)

◆ ast_channel_timingfunc_set()

void ast_channel_timingfunc_set ( struct ast_channel chan,
ast_timing_func_t  value 
)

Definition at line 1102 of file channel_internal_api.c.

1103{
1104 chan->timingfunc = value;
1105}

References ast_channel::timingfunc, and value.

Referenced by ast_settimeout_full().

◆ ast_channel_topic()

struct stasis_topic * ast_channel_topic ( struct ast_channel chan)

A topic which publishes the events for a particular channel.

Since
12

If the given chan is NULL, ast_channel_topic_all() is returned.

Parameters
chanChannel, or NULL.
Return values
Topicfor channel's events.
ast_channel_topic_all()if chan is NULL.

Definition at line 1418 of file channel_internal_api.c.

1419{
1420 if (!chan) {
1421 return ast_channel_topic_all();
1422 }
1423
1424 return chan->topic;
1425}
struct stasis_topic * ast_channel_topic_all(void)
A topic which publishes the events for all channels.
struct stasis_topic * topic

References ast_channel_topic_all(), and ast_channel::topic.

Referenced by ari_bridges_play_new(), ast_ari_bridges_record(), ast_channel_forward_endpoint(), ast_channel_internal_setup_topics(), ast_channel_publish_blob(), ast_channel_publish_cached_blob(), ast_channel_publish_final_snapshot(), ast_channel_publish_snapshot(), ast_multi_object_blob_single_channel_publish(), ast_refer_notify_transfer_request(), AST_TEST_DEFINE(), detect_callback(), forwards_create_channel(), local_optimization_finished_cb(), local_optimization_started_cb(), manager_mute_mixmonitor(), meetme_stasis_generate_msg(), mixmonitor_exec(), moh_post_start(), moh_post_stop(), publish_chanspy_message(), publish_chanspy_message(), publish_local_bridge_message(), publish_message_for_channel_topics(), queue_publish_multi_channel_blob(), report_fax_status(), report_receive_fax_status(), report_send_fax_status(), send_call_pickup_stasis_message(), send_conf_stasis(), stasis_app_control_publish(), stop_mixmonitor_full(), and talk_detect_audiohook_cb().

◆ ast_channel_transfercapability()

unsigned short ast_channel_transfercapability ( const struct ast_channel chan)

◆ ast_channel_transfercapability_set()

void ast_channel_transfercapability_set ( struct ast_channel chan,
unsigned short  value 
)

◆ ast_channel_unbridged()

int ast_channel_unbridged ( struct ast_channel chan)

This function will check if the bridge needs to be re-evaluated due to external changes.

Parameters
chanChannel on which to check the unbridge_eval flag
Returns
Returns 0 if the flag is down or 1 if the flag is up.

Definition at line 886 of file channel_internal_api.c.

887{
888 int res;
889 ast_channel_lock(chan);
891 ast_channel_unlock(chan);
892 return res;
893}
int ast_channel_unbridged_nolock(struct ast_channel *chan)
ast_channel_unbridged variant. Use this if the channel is already locked prior to calling.

References ast_channel_lock, ast_channel_unbridged_nolock(), and ast_channel_unlock.

Referenced by ast_channel_is_leaving_bridge(), and bridge_channel_wait().

◆ ast_channel_unbridged_nolock()

int ast_channel_unbridged_nolock ( struct ast_channel chan)

ast_channel_unbridged variant. Use this if the channel is already locked prior to calling.

Parameters
chanChannel on which to check the unbridge flag
Returns
Returns 0 if the flag is down or 1 if the flag is up.

Definition at line 881 of file channel_internal_api.c.

882{
883 return chan->unbridged;
884}

References ast_channel::unbridged.

Referenced by ast_channel_unbridged().

◆ ast_channel_undefer_dtmf()

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

1330{
1331 if (chan) {
1333 }
1334}
void ast_channel_clear_flag(struct ast_channel *chan, unsigned int flag)
Clear a flag on a channel.
Definition channel.c:11144

References ast_channel_clear_flag(), and AST_FLAG_DEFER_DTMF.

Referenced by __adsi_transmit_messages().

◆ ast_channel_uniqueid()

const char * ast_channel_uniqueid ( const struct ast_channel chan)

Definition at line 161 of file channel_internal_api.c.

162{
163 ast_assert(chan->uniqueid.unique_id[0] != '\0');
164 return chan->uniqueid.unique_id;
165}

References ast_assert, ast_channel_id::unique_id, and ast_channel::uniqueid.

Referenced by __ast_change_name_nolink(), _create_event_DTMF_END(), _create_event_ERROR(), _create_event_MEDIA_BUFFERING_COMPLETED(), _create_event_MEDIA_MARK_PROCESSED(), _create_event_MEDIA_START(), _create_event_nodata(), _create_event_STATUS(), action_confbridgelist_item(), action_dahdishowchannels(), app_exec(), app_subscribe_channel(), app_unsubscribe_channel(), apply_negotiated_sdp_stream(), aqm_exec(), ari_channels_handle_originate_with_id(), ari_channels_handle_snoop_channel(), ast_ari_channels_create(), ast_ari_create_per_call_websocket(), ast_attended_transfer_message_add_app(), ast_attended_transfer_message_add_link(), ast_attended_transfer_message_add_threeway(), ast_attended_transfer_message_create(), ast_blind_transfer_message_create(), ast_bridge_blob_create(), ast_bridge_publish_enter(), ast_bridge_set_single_src_video_mode(), ast_bridge_snapshot_create(), ast_bridge_transfer_blind(), ast_bridge_update_talker_src_video_mode(), ast_cel_publish_event(), ast_channel_log(), ast_channel_move(), ast_channel_publish_cached_blob(), ast_channel_publish_dial_internal(), ast_channel_publish_final_snapshot(), ast_channel_publish_snapshot(), ast_do_pickup(), ast_endpoint_add_channel(), ast_endpoint_remove_channel(), ast_str_retrieve_variable(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), ast_var_channels_table(), blind_transfer_bridge(), bridge_channel_depart(), bridge_channel_snapshot_pair_init(), bridge_moh_create(), bridge_stasis_push_peek(), build_conf(), by_uniqueid_cb(), call(), chan_pjsip_fixup(), chan_pjsip_indicate(), chan_pjsip_new(), chan_pjsip_session_end(), channel_replaced_cb(), channel_snapshot_base_create(), channelstorage_uniqueid_cb(), conf_rec_name(), conf_run(), conf_send_event_to_participants(), create_parked_subscription_full(), detect_callback(), fast_originate(), fax_session_new(), find_by_uniqueid(), find_conf_realtime(), forwards_create_channel(), func_channel_read(), generate_status(), handle_showchan(), internal_bridge_after_cb(), jingle_enable_video(), jingle_set_owner(), local_channel_optimization_blob(), local_optimization_started_cb(), manager_mute_mixmonitor(), manager_park(), manager_park_bridged(), manager_queues_status(), masq_match_cb(), meetme_menu_admin_extended(), meetmemute(), minivm_mwi_exec(), mixmonitor_exec(), moh_post_start(), moh_post_stop(), multicast_rtp_request(), notify_new_message(), notify_new_message(), pack_channel_into_message(), park_and_announce_app_exec(), park_common_setup2(), park_local_transfer(), parking_blind_transfer_park(), parking_park_bridge_channel(), play_on_channel(), publish_chanspy_message(), publish_local_bridge_message(), queue_exec(), queue_stasis_data_alloc(), record_file(), refer_blind_callback(), report_fax_status(), report_receive_fax_status(), report_send_fax_status(), rna(), rqm_exec(), send_broadcast_event(), serialize_showchan(), setup_env(), setup_mixmonitor(), sfu_topologies_on_join(), sfu_topologies_on_source_change(), softmix_bridge_stream_sources_update(), start_rtp(), stasis_app_bridge_playback_channel_add(), stasis_app_broadcast_channel(), stasis_app_broadcast_wait(), stasis_app_control_find_by_channel(), stasis_app_control_get_channel_id(), stasis_app_control_snoop(), stasis_app_exec(), stasis_app_subscribe_channel(), stasis_broadcast_exec(), stop_mixmonitor_full(), talk_detect_audiohook_cb(), test_cel_generate_peer_str(), try_calling(), unicast_rtp_request(), unistim_set_owner(), vm_execmain(), wait_for_answer(), and wait_our_turn().

◆ ast_channel_unlink()

void ast_channel_unlink ( struct ast_channel chan)

Remove a channel from the global channels container.

Parameters
chanchannel to remove

In a case where it is desired that a channel not be available in any lookups in the global channels conatiner, use this function.

Definition at line 10639 of file channel.c.

References CHANNELSTORAGE_API, current_channel_storage_instance, and remove.

Referenced by ast_channel_release(), ast_hangup(), and create_msg_q_chan().

◆ ast_channel_unregister()

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

Unregister a channel technology.

Definition at line 571 of file channel.c.

572{
573 struct chanlist *chan;
574
575 ast_debug(5, "Unregistering channel type '%s'\n", tech->type);
576
578
580 if (chan->tech == tech) {
582 ast_free(chan);
583 ast_verb(5, "Unregistered channel type '%s'\n", tech->type);
584 break;
585 }
586 }
588
590}
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN

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

Referenced by __unload_module(), __unload_module(), channels_shutdown(), load_module(), load_module(), local_shutdown(), unload_module(), unload_module(), unload_module(), unload_module(), unload_module(), unload_module(), unload_module(), unload_module(), unload_module(), unload_module(), unload_module(), unload_module(), unload_module(), unload_module(), unload_module(), and unregister_channel_tech().

◆ ast_channel_unsuppress()

int ast_channel_unsuppress ( struct ast_channel chan,
unsigned int  direction,
enum ast_frame_type  frametype 
)

Stop suppressing of a frame type on a channel.

Note
The channel should be locked before calling this function.
Parameters
chanThe channel to stop suppressing
directionThe direction in which to stop suppressing
frametypeThe type of frame (AST_FRAME_VOICE, etc) to stop suppressing
Return values
0Success
-1Failure

Definition at line 10949 of file channel.c.

10950{
10951 const struct ast_datastore_info *datastore_info = NULL;
10952 struct ast_datastore *datastore = NULL;
10953 struct suppress_data *suppress;
10954
10955 if (!(datastore_info = suppress_get_datastore_information(frametype))) {
10956 ast_log(LOG_WARNING, "Attempted to unsuppress an unsupported frame type (%u).\n", frametype);
10957 return -1;
10958 }
10959
10960 if (!(datastore = ast_channel_datastore_find(chan, datastore_info, NULL))) {
10961 /* Nothing to do! */
10962 return 0;
10963 }
10964
10965 suppress = datastore->data;
10966
10967 suppress->direction &= ~(direction);
10968
10969 if (suppress->direction == 0) {
10970 /* Nothing left to suppress. Bye! */
10971 ast_framehook_detach(chan, suppress->framehook_id);
10972 ast_channel_datastore_remove(chan, datastore);
10973 ast_datastore_free(datastore);
10974 }
10975
10976 return 0;
10977}
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
Definition channel.c:2385
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Definition datastore.c:68

References ast_channel_datastore_find(), ast_channel_datastore_remove(), ast_datastore_free(), ast_framehook_detach(), ast_log, ast_datastore::data, suppress_data::direction, suppress_data::framehook_id, suppress_data::frametype, LOG_WARNING, NULL, and suppress_get_datastore_information().

Referenced by app_control_unmute(), and mute_channel().

◆ ast_channel_update_connected_line()

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.

Definition at line 9199 of file channel.c.

9200{
9201 unsigned char data[1024]; /* This should be large enough */
9202 size_t datalen;
9203
9204 datalen = ast_connected_line_build_data(data, sizeof(data), connected, update);
9205 if (datalen == (size_t) -1) {
9206 return;
9207 }
9208
9209 ast_indicate_data(chan, AST_CONTROL_CONNECTED_LINE, data, datalen);
9210}
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:4710

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

Referenced by agent_run(), app_exec(), ast_channel_connected_line_sub(), ast_do_pickup(), connectedline_write(), update_connected_line_from_peer(), update_connected_line_from_peer(), wait_for_answer(), and wait_for_answer().

◆ ast_channel_update_redirecting()

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.

Definition at line 10390 of file channel.c.

10391{
10392 unsigned char data[1024]; /* This should be large enough */
10393 size_t datalen;
10394
10395 datalen = ast_redirecting_build_data(data, sizeof(data), redirecting, update);
10396 if (datalen == (size_t) -1) {
10397 return;
10398 }
10399
10400 ast_indicate_data(chan, AST_CONTROL_REDIRECTING, data, datalen);
10401}

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

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

◆ ast_channel_userfield()

const char * ast_channel_userfield ( const struct ast_channel chan)

◆ ast_channel_varshead()

struct varshead * ast_channel_varshead ( struct ast_channel chan)

◆ ast_channel_varshead_set()

void ast_channel_varshead_set ( struct ast_channel chan,
struct varshead value 
)

Definition at line 839 of file channel_internal_api.c.

840{
841 chan->varshead = *value;
842}

References value, and ast_channel::varshead.

◆ ast_channel_visible_indication()

int ast_channel_visible_indication ( const struct ast_channel chan)

Definition at line 349 of file channel_internal_api.c.

350{
351 return chan->visible_indication;
352}

References ast_channel::visible_indication.

Referenced by channel_do_masquerade(), and pre_bridge_setup().

◆ ast_channel_visible_indication_set()

void ast_channel_visible_indication_set ( struct ast_channel chan,
int  value 
)

Definition at line 353 of file channel_internal_api.c.

354{
356}

References value, and ast_channel::visible_indication.

Referenced by dial_exec_full(), and indicate_data_internal().

◆ ast_channel_vstream()

struct ast_filestream * ast_channel_vstream ( const struct ast_channel chan)

Definition at line 496 of file channel_internal_api.c.

497{
498 return chan->vstream;
499}
struct ast_filestream * vstream

References ast_channel::vstream.

Referenced by ast_hangup(), ast_openvstream(), ast_stopstream(), and filehelper().

◆ ast_channel_vstream_set()

void ast_channel_vstream_set ( struct ast_channel chan,
struct ast_filestream value 
)

Definition at line 500 of file channel_internal_api.c.

501{
502 chan->vstream = value;
503}

References value, and ast_channel::vstream.

Referenced by ast_hangup(), ast_stopstream(), filehelper(), and filestream_close().

◆ ast_channel_vstreamid()

int ast_channel_vstreamid ( const struct ast_channel chan)

Definition at line 365 of file channel_internal_api.c.

366{
367 return chan->vstreamid;
368}

References ast_channel::vstreamid.

Referenced by filestream_close().

◆ ast_channel_vstreamid_set()

void ast_channel_vstreamid_set ( struct ast_channel chan,
int  value 
)

Definition at line 369 of file channel_internal_api.c.

370{
371 chan->vstreamid = value;
372}

References value, and ast_channel::vstreamid.

Referenced by __ast_channel_alloc_ap(), ast_readvideo_callback(), and filestream_close().

◆ ast_channel_whentohangup()

struct timeval * ast_channel_whentohangup ( struct ast_channel chan)

◆ ast_channel_whentohangup_set()

void ast_channel_whentohangup_set ( struct ast_channel chan,
struct timeval *  value 
)
Precondition
chan is locked

Definition at line 835 of file channel_internal_api.c.

836{
837 chan->whentohangup = *value;
838}

References value, and ast_channel::whentohangup.

Referenced by ast_channel_setwhentohangup_tv(), and dial_exec_full().

◆ ast_channel_writeformat()

struct ast_format * ast_channel_writeformat ( struct ast_channel chan)

◆ ast_channel_writetrans()

struct ast_trans_pvt * ast_channel_writetrans ( const struct ast_channel chan)

◆ ast_channel_writetrans_set()

void ast_channel_writetrans_set ( struct ast_channel chan,
struct ast_trans_pvt value 
)

Definition at line 632 of file channel_internal_api.c.

633{
634 chan->writetrans = value;
635}

References value, and ast_channel::writetrans.

Referenced by ast_set_write_format_path(), and free_translation().

◆ ast_channel_yank()

struct ast_channel * ast_channel_yank ( struct ast_channel yankee)

Gain control of a channel in the system.

Since
12

The intention of this function is to take a channel that currently is running in one thread and gain control of it in the current thread. This can be used to redirect a channel to a different place in the dialplan, for instance.

Note
This function is NOT intended to be used on bridged channels. If you need to control a bridged channel, you can set a callback to be called once the channel exits the bridge, and run your controlling logic in that callback

XXX Put name of callback-setting function in above paragraph once it is written

Note
When this function returns successfully, the yankee channel is in a state where it cannot be used any further. Always use the returned channel instead.
absolutely NO channel locks should be held before calling this function.
The dialplan location on the returned channel is where the channel should be started in the dialplan if it is returned to it.
Parameters
yankeeThe channel to gain control of
Return values
NULLCould not gain control of the channel
non-NULLThe channel

Definition at line 10703 of file channel.c.

10704{
10705 struct ast_channel *yanked_chan;
10706 struct {
10707 char *accountcode;
10708 char *exten;
10709 char *context;
10710 char *name;
10711 int amaflags;
10712 int priority;
10713 struct ast_format *readformat;
10714 struct ast_format *writeformat;
10715 } my_vars = { 0, };
10716
10717 ast_channel_lock(yankee);
10718 my_vars.accountcode = ast_strdupa(ast_channel_accountcode(yankee));
10719 my_vars.exten = ast_strdupa(ast_channel_exten(yankee));
10720 my_vars.context = ast_strdupa(ast_channel_context(yankee));
10721 my_vars.name = ast_strdupa(ast_channel_name(yankee));
10722 my_vars.amaflags = ast_channel_amaflags(yankee);
10723 my_vars.priority = ast_channel_priority(yankee);
10724 /* The priority as returned by ast_channel_yank is where the channel
10725 * should go if the dialplan is executed on it. If the channel is
10726 * already executing dialplan then the priority currently set is
10727 * where it is currently. We increment it so it becomes where it should
10728 * execute.
10729 */
10731 my_vars.priority++;
10732 }
10733 my_vars.writeformat = ao2_bump(ast_channel_writeformat(yankee));
10734 my_vars.readformat = ao2_bump(ast_channel_readformat(yankee));
10735 ast_channel_unlock(yankee);
10736
10737 /* Do not hold any channel locks while calling channel_alloc() since the function
10738 * locks the channel container when linking the new channel in. */
10739 if (!(yanked_chan = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, my_vars.accountcode,
10740 my_vars.exten, my_vars.context, NULL, yankee, my_vars.amaflags,
10741 "Surrogate/%s", my_vars.name))) {
10742 ao2_cleanup(my_vars.writeformat);
10743 ao2_cleanup(my_vars.readformat);
10744 return NULL;
10745 }
10746
10747 /* Make formats okay */
10748 ast_channel_set_readformat(yanked_chan, my_vars.readformat);
10749 ast_channel_set_writeformat(yanked_chan, my_vars.writeformat);
10750 ao2_cleanup(my_vars.readformat);
10751 ao2_cleanup(my_vars.writeformat);
10752 ast_channel_priority_set(yanked_chan, my_vars.priority);
10753
10754 ast_channel_unlock(yanked_chan);
10755
10756 if (ast_channel_move(yanked_chan, yankee)) {
10757 ast_hangup(yanked_chan);
10758 return NULL;
10759 }
10760
10761 return yanked_chan;
10762}
int ast_channel_move(struct ast_channel *dest, struct ast_channel *source)
Move a channel from its current location to a new location.
Definition channel.c:10776
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
Definition channel.h:1299
@ AST_STATE_DOWN

References accountcode, ast_channel::amaflags, ao2_bump, ao2_cleanup, ast_channel_accountcode(), ast_channel_alloc, ast_channel_amaflags(), ast_channel_context(), ast_channel_exten(), ast_channel_flags(), ast_channel_lock, ast_channel_move(), ast_channel_name(), ast_channel_priority(), ast_channel_priority_set(), ast_channel_readformat(), ast_channel_set_readformat(), ast_channel_set_writeformat(), ast_channel_unlock, ast_channel_writeformat(), AST_FLAG_IN_AUTOLOOP, ast_hangup(), AST_STATE_DOWN, ast_strdupa, ast_test_flag, ast_channel::context, ast_channel::exten, name, NULL, ast_channel::priority, ast_channel::readformat, and ast_channel::writeformat.

Referenced by ast_async_goto(), and ast_bridge_add_channel().

◆ ast_channel_zone()

struct ast_tone_zone * ast_channel_zone ( const struct ast_channel chan)

◆ ast_channel_zone_set()

void ast_channel_zone_set ( struct ast_channel chan,
struct ast_tone_zone value 
)

Definition at line 616 of file channel_internal_api.c.

617{
618 chan->zone = value;
619}

References value, and ast_channel::zone.

Referenced by ast_channel_destructor(), chan_pjsip_new(), and func_channel_write_real().

◆ ast_channeltype_list()

struct ast_variable * ast_channeltype_list ( void  )

return an ast_variable list of channeltypes

Definition at line 189 of file channel.c.

190{
191 struct chanlist *cl;
192 struct ast_variable *var = NULL, *prev = NULL;
193
195 AST_RWLIST_TRAVERSE(&backends, cl, list) {
196 if (prev) {
197 if ((prev->next = ast_variable_new(cl->tech->type, cl->tech->description, "")))
198 prev = prev->next;
199 } else {
200 var = ast_variable_new(cl->tech->type, cl->tech->description, "");
201 prev = var;
202 }
203 }
205
206 return var;
207}
#define ast_variable_new(name, value, filename)
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition linkedlists.h:78

References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_variable_new, NULL, chanlist::tech, and var.

Referenced by ast_var_channel_types(), and ast_var_channel_types_table().

◆ ast_check_hangup()

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

447{
448 if (ast_channel_softhangup_internal_flag(chan)) /* yes if soft hangup flag set */
449 return 1;
450 if (ast_tvzero(*ast_channel_whentohangup(chan))) /* no if no hangup scheduled */
451 return 0;
452 if (ast_tvdiff_ms(*ast_channel_whentohangup(chan), ast_tvnow()) > 0) /* no if hangup time has not come yet. */
453 return 0;
454 ast_debug(4, "Hangup time has come: %" PRIi64 "\n", ast_tvdiff_ms(*ast_channel_whentohangup(chan), ast_tvnow()));
455 ast_test_suite_event_notify("HANGUP_TIME", "Channel: %s", ast_channel_name(chan));
457 return 1;
458}

References ast_channel_name(), ast_channel_softhangup_internal_flag(), ast_channel_softhangup_internal_flag_add(), ast_channel_whentohangup(), ast_debug, AST_SOFTHANGUP_TIMEOUT, ast_test_suite_event_notify, ast_tvdiff_ms(), ast_tvnow(), and ast_tvzero().

Referenced by __ast_pbx_run(), __ast_read(), agent_request_exec(), agi_exec(), announce_thread(), app_exec(), ast_bridge_setup_after_goto(), ast_call(), ast_check_hangup_locked(), ast_indicate_data(), ast_raw_answer_with_stream_topology(), ast_readstring_full(), ast_recvtext(), ast_sendtext_data(), ast_transfer_protocol(), ast_unreal_fixup(), ast_waitfordigit_full(), ast_write_stream(), autoservice_run(), call_forward_inherit(), channel_spy(), common_exec(), conf_play(), conf_run(), confbridge_exec(), dahdi_sendtext(), dahdi_setoption(), depart_channel(), dial_exec_full(), directory_exec(), dundi_lookup_internal(), eagi_exec(), eivr_comm(), fax_gateway_framehook(), find_cache(), findmeexec(), func_channel_read(), gosub_run(), handle_sendimage(), join_conference_bridge(), launch_asyncagi(), lua_check_hangup(), pbx_builtin_incomplete(), pbx_builtin_waitexten(), play_on_channel(), playback_exec(), read_exec(), readexten_exec(), run_agi(), stasis_app_broadcast_wait(), stasis_app_exec(), stasis_broadcast_exec(), transfer_target_framehook_cb(), try_calling(), vm_authenticate(), and wait_for_answer().

◆ ast_check_hangup_locked()

int ast_check_hangup_locked ( struct ast_channel chan)

◆ ast_connected_line_build_data()

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

8804{
8805 int32_t value;
8806 size_t pos = 0;
8807 int res;
8808
8809 static const struct ast_party_id_ies ies = {
8811 .name.char_set = AST_CONNECTED_LINE_NAME_CHAR_SET,
8812 .name.presentation = AST_CONNECTED_LINE_NAME_PRESENTATION,
8813 .name.valid = AST_CONNECTED_LINE_NAME_VALID,
8814
8815 .number.str = AST_CONNECTED_LINE_NUMBER,
8816 .number.plan = AST_CONNECTED_LINE_NUMBER_PLAN,
8817 .number.presentation = AST_CONNECTED_LINE_NUMBER_PRESENTATION,
8818 .number.valid = AST_CONNECTED_LINE_NUMBER_VALID,
8819
8820 .subaddress.str = AST_CONNECTED_LINE_SUBADDRESS,
8821 .subaddress.type = AST_CONNECTED_LINE_SUBADDRESS_TYPE,
8822 .subaddress.odd_even_indicator = AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN,
8823 .subaddress.valid = AST_CONNECTED_LINE_SUBADDRESS_VALID,
8824
8826 .combined_presentation = AST_CONNECTED_LINE_ID_PRESENTATION,
8827 };
8828
8829 static const struct ast_party_id_ies priv_ies = {
8832 .name.presentation = AST_CONNECTED_LINE_PRIV_NAME_PRESENTATION,
8834
8835 .number.str = AST_CONNECTED_LINE_PRIV_NUMBER,
8837 .number.presentation = AST_CONNECTED_LINE_PRIV_NUMBER_PRESENTATION,
8839
8840 .subaddress.str = AST_CONNECTED_LINE_PRIV_SUBADDRESS,
8841 .subaddress.type = AST_CONNECTED_LINE_PRIV_SUBADDRESS_TYPE,
8842 .subaddress.odd_even_indicator = AST_CONNECTED_LINE_PRIV_SUBADDRESS_ODD_EVEN,
8843 .subaddress.valid = AST_CONNECTED_LINE_PRIV_SUBADDRESS_VALID,
8844
8846 .combined_presentation = 0,/* Not sent. */
8847 };
8848
8849 /*
8850 * The size of integer values must be fixed in case the frame is
8851 * shipped to another machine.
8852 */
8853
8854 /* Connected line frame version */
8855 if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8856 ast_log(LOG_WARNING, "No space left for connected line frame version\n");
8857 return -1;
8858 }
8859 data[pos++] = AST_CONNECTED_LINE_VERSION;
8860 data[pos++] = 1;
8861 data[pos++] = 2;/* Version 1 did not have a version ie */
8862
8863 res = party_id_build_data(data + pos, datalen - pos, &connected->id,
8864 "connected line", &ies, update ? &update->id : NULL);
8865 if (res < 0) {
8866 return -1;
8867 }
8868 pos += res;
8869
8870 res = party_id_build_data(data + pos, datalen - pos, &connected->priv,
8871 "connected line priv", &priv_ies, update ? &update->priv : NULL);
8872 if (res < 0) {
8873 return -1;
8874 }
8875 pos += res;
8876
8877 /* Connected line source */
8878 if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) {
8879 ast_log(LOG_WARNING, "No space left for connected line source\n");
8880 return -1;
8881 }
8882 data[pos++] = AST_CONNECTED_LINE_SOURCE;
8883 data[pos++] = sizeof(value);
8884 value = htonl(connected->source);
8885 memcpy(data + pos, &value, sizeof(value));
8886 pos += sizeof(value);
8887
8888 return pos;
8889}
@ AST_CONNECTED_LINE_NUMBER_VALID
Definition channel.c:8786
@ AST_CONNECTED_LINE_SOURCE
Definition channel.c:8772
@ AST_CONNECTED_LINE_PRIV_SUBADDRESS_VALID
Definition channel.c:8799
@ AST_CONNECTED_LINE_PRIV_SUBADDRESS_ODD_EVEN
Definition channel.c:8798
@ AST_CONNECTED_LINE_PRIV_NAME_VALID
Definition channel.c:8793
@ AST_CONNECTED_LINE_PRIV_SUBADDRESS_TYPE
Definition channel.c:8797
@ AST_CONNECTED_LINE_PRIV_NUMBER_PRESENTATION
Definition channel.c:8791
@ AST_CONNECTED_LINE_NAME_CHAR_SET
Definition channel.c:8784
@ AST_CONNECTED_LINE_SUBADDRESS_VALID
Definition channel.c:8776
@ AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN
Definition channel.c:8775
@ AST_CONNECTED_LINE_SUBADDRESS
Definition channel.c:8773
@ AST_CONNECTED_LINE_PRIV_NUMBER_PLAN
Definition channel.c:8789
@ AST_CONNECTED_LINE_NUMBER
Definition channel.c:8768
@ AST_CONNECTED_LINE_ID_PRESENTATION
Definition channel.c:8771
@ AST_CONNECTED_LINE_PRIV_NAME_PRESENTATION
Definition channel.c:8795
@ AST_CONNECTED_LINE_PRIV_NAME
Definition channel.c:8792
@ AST_CONNECTED_LINE_TAG
Definition channel.c:8777
@ AST_CONNECTED_LINE_PRIV_NUMBER_VALID
Definition channel.c:8790
@ AST_CONNECTED_LINE_NUMBER_PRESENTATION
Definition channel.c:8787
@ AST_CONNECTED_LINE_PRIV_NAME_CHAR_SET
Definition channel.c:8794
@ AST_CONNECTED_LINE_NAME
Definition channel.c:8769
@ AST_CONNECTED_LINE_NAME_PRESENTATION
Definition channel.c:8785
@ AST_CONNECTED_LINE_SUBADDRESS_TYPE
Definition channel.c:8774
@ AST_CONNECTED_LINE_PRIV_SUBADDRESS
Definition channel.c:8796
@ AST_CONNECTED_LINE_PRIV_TAG
Definition channel.c:8800
@ AST_CONNECTED_LINE_NAME_VALID
Definition channel.c:8783
@ AST_CONNECTED_LINE_PRIV_NUMBER
Definition channel.c:8788
@ AST_CONNECTED_LINE_NUMBER_PLAN
Definition channel.c:8770
@ AST_CONNECTED_LINE_VERSION
Definition channel.c:8778
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:8683
struct ast_party_name_ies name
Subscriber name ies.
Definition channel.c:8654
int str
Subscriber name ie.
Definition channel.c:8431

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_PRIV_NAME, AST_CONNECTED_LINE_PRIV_NAME_CHAR_SET, AST_CONNECTED_LINE_PRIV_NAME_PRESENTATION, AST_CONNECTED_LINE_PRIV_NAME_VALID, AST_CONNECTED_LINE_PRIV_NUMBER, AST_CONNECTED_LINE_PRIV_NUMBER_PLAN, AST_CONNECTED_LINE_PRIV_NUMBER_PRESENTATION, AST_CONNECTED_LINE_PRIV_NUMBER_VALID, AST_CONNECTED_LINE_PRIV_SUBADDRESS, AST_CONNECTED_LINE_PRIV_SUBADDRESS_ODD_EVEN, AST_CONNECTED_LINE_PRIV_SUBADDRESS_TYPE, AST_CONNECTED_LINE_PRIV_SUBADDRESS_VALID, AST_CONNECTED_LINE_PRIV_TAG, AST_CONNECTED_LINE_SOURCE, AST_CONNECTED_LINE_SUBADDRESS, AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN, AST_CONNECTED_LINE_SUBADDRESS_TYPE, AST_CONNECTED_LINE_SUBADDRESS_VALID, AST_CONNECTED_LINE_TAG, AST_CONNECTED_LINE_VERSION, ast_log, connected, LOG_WARNING, ast_party_id_ies::name, NULL, party_id_build_data(), ast_party_name_ies::str, update(), and value.

Referenced by after_bridge_move_channel(), ast_channel_queue_connected_line_update(), ast_channel_update_connected_line(), bridge_reconfigured_connected_line_update(), indicate_connected_line(), send_colp_to_agent(), and unreal_colp_redirect_indicate().

◆ ast_connected_line_copy_from_caller()

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
Note
Assumes locks are already acquired

Definition at line 8399 of file channel.c.

8400{
8401 ast_party_id_copy(&dest->id, &src->id);
8402 ast_party_id_copy(&dest->ani, &src->ani);
8403 dest->ani2 = src->ani2;
8404}
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:1752
struct ast_party_id id
Caller party ID.
Definition channel.h:422
int ani2
Automatic Number Identification 2 (Info Digits)
Definition channel.h:435
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition channel.h:429
int ani2
Automatic Number Identification 2 (Info Digits)
Definition channel.h:477
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition channel.h:467

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 after_bridge_move_channel(), agent_request_exec(), app_exec(), ast_ari_channels_dial(), ast_do_pickup(), ast_unreal_call_setup(), begin_dial_prerun(), bridge_reconfigured_connected_line_update(), copy_caller_data(), dial_exec_full(), do_forward(), findmeexec(), park_local_transfer(), ring_entry(), update_connected_line_from_peer(), update_connected_line_from_peer(), and wait_for_answer().

◆ ast_connected_line_copy_to_caller()

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
Note
Assumes locks are already acquired

Definition at line 8406 of file channel.c.

8407{
8408 ast_party_id_copy(&dest->id, &src->id);
8409 ast_party_id_copy(&dest->ani, &src->ani);
8410
8411 dest->ani2 = src->ani2;
8412}

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

Referenced by ast_unreal_call_setup(), and unreal_colp_redirect_indicate().

◆ ast_connected_line_parse_data()

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

8892{
8893 size_t pos;
8894 unsigned char ie_len;
8895 unsigned char ie_id;
8896 int32_t value;
8897 int frame_version = 1;
8898 int combined_presentation = 0;
8899 int got_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
8900
8901 for (pos = 0; pos < datalen; pos += ie_len) {
8902 if (datalen < pos + sizeof(ie_id) + sizeof(ie_len)) {
8903 ast_log(LOG_WARNING, "Invalid connected line update\n");
8904 return -1;
8905 }
8906 ie_id = data[pos++];
8907 ie_len = data[pos++];
8908 if (datalen < pos + ie_len) {
8909 ast_log(LOG_WARNING, "Invalid connected line update\n");
8910 return -1;
8911 }
8912
8913 switch (ie_id) {
8914/* Connected line party frame version */
8916 if (ie_len != 1) {
8917 ast_log(LOG_WARNING, "Invalid connected line frame version (%u)\n",
8918 (unsigned) ie_len);
8919 break;
8920 }
8921 frame_version = data[pos];
8922 break;
8923/* Connected line party id name */
8925 ast_free(connected->id.name.str);
8926 connected->id.name.str = ast_malloc(ie_len + 1);
8927 if (connected->id.name.str) {
8928 memcpy(connected->id.name.str, data + pos, ie_len);
8929 connected->id.name.str[ie_len] = 0;
8930 }
8931 break;
8933 if (ie_len != 1) {
8934 ast_log(LOG_WARNING, "Invalid connected line name char set (%u)\n",
8935 (unsigned) ie_len);
8936 break;
8937 }
8938 connected->id.name.char_set = data[pos];
8939 break;
8941 if (ie_len != 1) {
8942 ast_log(LOG_WARNING, "Invalid connected line name presentation (%u)\n",
8943 (unsigned) ie_len);
8944 break;
8945 }
8946 connected->id.name.presentation = data[pos];
8947 break;
8949 if (ie_len != 1) {
8950 ast_log(LOG_WARNING, "Invalid connected line name valid (%u)\n",
8951 (unsigned) ie_len);
8952 break;
8953 }
8954 connected->id.name.valid = data[pos];
8955 break;
8956/* Connected line party id number */
8958 ast_free(connected->id.number.str);
8959 connected->id.number.str = ast_malloc(ie_len + 1);
8960 if (connected->id.number.str) {
8961 memcpy(connected->id.number.str, data + pos, ie_len);
8962 connected->id.number.str[ie_len] = 0;
8963 }
8964 break;
8966 if (ie_len != 1) {
8967 ast_log(LOG_WARNING, "Invalid connected line numbering plan (%u)\n",
8968 (unsigned) ie_len);
8969 break;
8970 }
8971 connected->id.number.plan = data[pos];
8972 break;
8974 if (ie_len != 1) {
8975 ast_log(LOG_WARNING, "Invalid connected line number presentation (%u)\n",
8976 (unsigned) ie_len);
8977 break;
8978 }
8979 connected->id.number.presentation = data[pos];
8980 break;
8982 if (ie_len != 1) {
8983 ast_log(LOG_WARNING, "Invalid connected line number valid (%u)\n",
8984 (unsigned) ie_len);
8985 break;
8986 }
8987 connected->id.number.valid = data[pos];
8988 break;
8989/* Connected line party id subaddress */
8991 ast_free(connected->id.subaddress.str);
8992 connected->id.subaddress.str = ast_malloc(ie_len + 1);
8993 if (connected->id.subaddress.str) {
8994 memcpy(connected->id.subaddress.str, data + pos, ie_len);
8995 connected->id.subaddress.str[ie_len] = 0;
8996 }
8997 break;
8999 if (ie_len != 1) {
9000 ast_log(LOG_WARNING, "Invalid connected line type of subaddress (%u)\n",
9001 (unsigned) ie_len);
9002 break;
9003 }
9004 connected->id.subaddress.type = data[pos];
9005 break;
9007 if (ie_len != 1) {
9009 "Invalid connected line subaddress odd-even indicator (%u)\n",
9010 (unsigned) ie_len);
9011 break;
9012 }
9013 connected->id.subaddress.odd_even_indicator = data[pos];
9014 break;
9016 if (ie_len != 1) {
9017 ast_log(LOG_WARNING, "Invalid connected line subaddress valid (%u)\n",
9018 (unsigned) ie_len);
9019 break;
9020 }
9021 connected->id.subaddress.valid = data[pos];
9022 break;
9023/* Connected line party tag */
9025 ast_free(connected->id.tag);
9026 connected->id.tag = ast_malloc(ie_len + 1);
9027 if (connected->id.tag) {
9028 memcpy(connected->id.tag, data + pos, ie_len);
9029 connected->id.tag[ie_len] = 0;
9030 }
9031 break;
9032/* Connected line party id combined presentation */
9034 if (ie_len != 1) {
9035 ast_log(LOG_WARNING, "Invalid connected line combined presentation (%u)\n",
9036 (unsigned) ie_len);
9037 break;
9038 }
9039 combined_presentation = data[pos];
9040 got_combined_presentation = 1;
9041 break;
9042/* Private connected line party id name */
9044 ast_free(connected->priv.name.str);
9045 connected->priv.name.str = ast_malloc(ie_len + 1);
9046 if (connected->priv.name.str) {
9047 memcpy(connected->priv.name.str, data + pos, ie_len);
9048 connected->priv.name.str[ie_len] = 0;
9049 }
9050 break;
9052 if (ie_len != 1) {
9053 ast_log(LOG_WARNING, "Invalid connected line private name char set (%u)\n",
9054 (unsigned) ie_len);
9055 break;
9056 }
9057 connected->priv.name.char_set = data[pos];
9058 break;
9060 if (ie_len != 1) {
9061 ast_log(LOG_WARNING, "Invalid connected line private name presentation (%u)\n",
9062 (unsigned) ie_len);
9063 break;
9064 }
9065 connected->priv.name.presentation = data[pos];
9066 break;
9068 if (ie_len != 1) {
9069 ast_log(LOG_WARNING, "Invalid connected line private name valid (%u)\n",
9070 (unsigned) ie_len);
9071 break;
9072 }
9073 connected->priv.name.valid = data[pos];
9074 break;
9075/* Private connected line party id number */
9077 ast_free(connected->priv.number.str);
9078 connected->priv.number.str = ast_malloc(ie_len + 1);
9079 if (connected->priv.number.str) {
9080 memcpy(connected->priv.number.str, data + pos, ie_len);
9081 connected->priv.number.str[ie_len] = 0;
9082 }
9083 break;
9085 if (ie_len != 1) {
9086 ast_log(LOG_WARNING, "Invalid connected line private numbering plan (%u)\n",
9087 (unsigned) ie_len);
9088 break;
9089 }
9090 connected->priv.number.plan = data[pos];
9091 break;
9093 if (ie_len != 1) {
9094 ast_log(LOG_WARNING, "Invalid connected line private number presentation (%u)\n",
9095 (unsigned) ie_len);
9096 break;
9097 }
9098 connected->priv.number.presentation = data[pos];
9099 break;
9101 if (ie_len != 1) {
9102 ast_log(LOG_WARNING, "Invalid connected line private number valid (%u)\n",
9103 (unsigned) ie_len);
9104 break;
9105 }
9106 connected->priv.number.valid = data[pos];
9107 break;
9108/* Private connected line party id subaddress */
9110 ast_free(connected->priv.subaddress.str);
9111 connected->priv.subaddress.str = ast_malloc(ie_len + 1);
9112 if (connected->priv.subaddress.str) {
9113 memcpy(connected->priv.subaddress.str, data + pos, ie_len);
9114 connected->priv.subaddress.str[ie_len] = 0;
9115 }
9116 break;
9118 if (ie_len != 1) {
9119 ast_log(LOG_WARNING, "Invalid connected line private type of subaddress (%u)\n",
9120 (unsigned) ie_len);
9121 break;
9122 }
9123 connected->priv.subaddress.type = data[pos];
9124 break;
9126 if (ie_len != 1) {
9128 "Invalid connected line private subaddress odd-even indicator (%u)\n",
9129 (unsigned) ie_len);
9130 break;
9131 }
9132 connected->priv.subaddress.odd_even_indicator = data[pos];
9133 break;
9135 if (ie_len != 1) {
9136 ast_log(LOG_WARNING, "Invalid connected line private subaddress valid (%u)\n",
9137 (unsigned) ie_len);
9138 break;
9139 }
9140 connected->priv.subaddress.valid = data[pos];
9141 break;
9142/* Private connected line party tag */
9144 ast_free(connected->priv.tag);
9145 connected->priv.tag = ast_malloc(ie_len + 1);
9146 if (connected->priv.tag) {
9147 memcpy(connected->priv.tag, data + pos, ie_len);
9148 connected->priv.tag[ie_len] = 0;
9149 }
9150 break;
9151/* Connected line party source */
9153 if (ie_len != sizeof(value)) {
9154 ast_log(LOG_WARNING, "Invalid connected line source (%u)\n",
9155 (unsigned) ie_len);
9156 break;
9157 }
9158 memcpy(&value, data + pos, sizeof(value));
9159 connected->source = ntohl(value);
9160 break;
9161/* Connected line party unknown element */
9162 default:
9163 ast_debug(1, "Unknown connected line element: %u (%u)\n",
9164 (unsigned) ie_id, (unsigned) ie_len);
9165 break;
9166 }
9167 }
9168
9169 switch (frame_version) {
9170 case 1:
9171 /*
9172 * The other end is an earlier version that we need to adjust
9173 * for compatibility.
9174 */
9175 connected->id.name.valid = 1;
9176 connected->id.name.char_set = AST_PARTY_CHAR_SET_ISO8859_1;
9177 connected->id.number.valid = 1;
9178 if (got_combined_presentation) {
9179 connected->id.name.presentation = combined_presentation;
9180 connected->id.number.presentation = combined_presentation;
9181 }
9182 break;
9183 case 2:
9184 /* The other end is at the same level as we are. */
9185 break;
9186 default:
9187 /*
9188 * The other end is newer than we are.
9189 * We need to assume that they are compatible with us.
9190 */
9191 ast_debug(1, "Connected line frame has newer version: %u\n",
9192 (unsigned) frame_version);
9193 break;
9194 }
9195
9196 return 0;
9197}
#define ast_malloc(len)
A wrapper for malloc()
Definition astmm.h:191

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_PRIV_NAME, AST_CONNECTED_LINE_PRIV_NAME_CHAR_SET, AST_CONNECTED_LINE_PRIV_NAME_PRESENTATION, AST_CONNECTED_LINE_PRIV_NAME_VALID, AST_CONNECTED_LINE_PRIV_NUMBER, AST_CONNECTED_LINE_PRIV_NUMBER_PLAN, AST_CONNECTED_LINE_PRIV_NUMBER_PRESENTATION, AST_CONNECTED_LINE_PRIV_NUMBER_VALID, AST_CONNECTED_LINE_PRIV_SUBADDRESS, AST_CONNECTED_LINE_PRIV_SUBADDRESS_ODD_EVEN, AST_CONNECTED_LINE_PRIV_SUBADDRESS_TYPE, AST_CONNECTED_LINE_PRIV_SUBADDRESS_VALID, AST_CONNECTED_LINE_PRIV_TAG, 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_debug, ast_free, ast_log, ast_malloc, AST_PARTY_CHAR_SET_ISO8859_1, ast_party_id_ies::combined_presentation, connected, LOG_WARNING, and value.

Referenced by __ast_read(), ast_channel_connected_line_sub(), indicate_connected_line(), socket_process_helper(), wait_for_answer(), wait_for_answer(), and wait_for_winner().

◆ ast_deactivate_generator()

void ast_deactivate_generator ( struct ast_channel chan)

Deactivate an active generator

Definition at line 2926 of file channel.c.

2927{
2928 ast_channel_lock(chan);
2931 /* if in the middle of dtmf emulation keep 50 tick per sec timer on rolling */
2932 struct ast_timer *timer = ast_channel_timer(chan);
2933 if (timer) {
2935 } else {
2936 ast_log(LOG_WARNING, "No timing module loaded, DTMF length may be inaccurate\n");
2937 }
2938 }
2939 ast_channel_unlock(chan);
2940}
static struct ast_timer * timer
Definition chan_iax2.c:401
static void deactivate_generator_nolock(struct ast_channel *chan)
Definition channel.c:2911
static int should_trigger_dtmf_emulating(struct ast_channel *chan)
Determine whether or not we have to trigger dtmf emulating using 50 fps timer events especially when ...
Definition channel.c:2889
int ast_timer_set_rate(const struct ast_timer *handle, unsigned int rate)
Set the timing tick rate.
Definition timing.c:166

References ast_channel_lock, ast_channel_timer(), ast_channel_unlock, ast_log, ast_timer_set_rate(), deactivate_generator_nolock(), LOG_WARNING, should_trigger_dtmf_emulating(), and timer.

Referenced by __ast_read(), app_exec(), app_exec(), ast_playtones_stop(), ast_read_generator_actions(), ast_tonepair_stop(), ast_write_stream(), channel_spy(), dial_exec_full(), do_broadcast(), generator_force(), local_ast_moh_stop(), old_milliwatt_exec(), openstream_internal(), and wait_for_answer().

◆ ast_fdisset()

static int ast_fdisset ( struct pollfd *  pfds,
int  fd,
int  maximum,
int *  start 
)
inlinestatic

Helper function for migrating select to poll.

Definition at line 2894 of file channel.h.

2895{
2896 int x;
2897 int dummy = 0;
2898
2899 if (fd < 0)
2900 return 0;
2901 if (!start)
2902 start = &dummy;
2903 for (x = *start; x < maximum; x++)
2904 if (pfds[x].fd == fd) {
2905 if (x == *start)
2906 (*start)++;
2907 return pfds[x].revents;
2908 }
2909 return 0;
2910}

References dummy(), and ast_channel::x.

Referenced by do_monitor().

◆ ast_get_channel_tech()

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

594{
595 struct chanlist *chanls;
596 const struct ast_channel_tech *ret = NULL;
597
599
600 AST_RWLIST_TRAVERSE(&backends, chanls, list) {
601 if (!strcasecmp(name, chanls->tech->type)) {
602 ret = chanls->tech;
603 break;
604 }
605 }
606
608
609 return ret;
610}

References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, name, NULL, and chanlist::tech.

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

◆ ast_get_group()

ast_group_t ast_get_group ( const char *  s)

Definition at line 7692 of file channel.c.

7693{
7694 char *piece;
7695 char *c;
7696 int start=0, finish=0, x;
7697 ast_group_t group = 0;
7698
7699 if (ast_strlen_zero(s))
7700 return 0;
7701
7702 c = ast_strdupa(s);
7703
7704 while ((piece = strsep(&c, ","))) {
7705 if (sscanf(piece, "%30d-%30d", &start, &finish) == 2) {
7706 /* Range */
7707 } else if (sscanf(piece, "%30d", &start)) {
7708 /* Just one */
7709 finish = start;
7710 } else {
7711 ast_log(LOG_ERROR, "Syntax error parsing group configuration '%s' at '%s'. Ignoring.\n", s, piece);
7712 continue;
7713 }
7714 for (x = start; x <= finish; x++) {
7715 if ((x > 63) || (x < 0)) {
7716 ast_log(LOG_WARNING, "Ignoring invalid group %d (maximum group is 63)\n", x);
7717 } else
7718 group |= ((ast_group_t) 1 << x);
7719 }
7720 }
7721 return group;
7722}
char * strsep(char **str, const char *delims)

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

Referenced by build_device(), custom_group_handler(), func_channel_write_real(), group_handler(), and process_dahdi().

◆ ast_get_namedgroups()

struct ast_namedgroups * ast_get_namedgroups ( const char *  s)

Create an ast_namedgroups set with group names from comma separated string.

Remove leading and trailing whitespace

Definition at line 7749 of file channel.c.

7750{
7751 struct ao2_container *namedgroups;
7752 char *piece;
7753 char *c;
7754
7755 if (!s) {
7756 return NULL;
7757 }
7758
7759 /*! \brief Remove leading and trailing whitespace */
7761 if (ast_strlen_zero(c)) {
7762 return NULL;
7763 }
7764
7767 if (!namedgroups) {
7768 return NULL;
7769 }
7770
7771 while ((piece = strsep(&c, ","))) {
7772 struct namedgroup_member *member;
7773 size_t len;
7774
7775 /* remove leading/trailing whitespace */
7776 piece = ast_strip(piece);
7777
7778 len = strlen(piece);
7779 if (!len) {
7780 continue;
7781 }
7782
7784 if (!member) {
7785 ao2_ref(namedgroups, -1);
7786 return NULL;
7787 }
7788 strcpy(member->name, piece);/* Safe */
7789 member->hash = ast_str_hash(member->name);
7790
7791 /* every group name may exist only once, delete duplicates */
7792 ao2_find(namedgroups, member, OBJ_POINTER | OBJ_UNLINK | OBJ_NODATA);
7793 ao2_link(namedgroups, member);
7794 ao2_ref(member, -1);
7795 }
7796
7797 if (!ao2_container_count(namedgroups)) {
7798 /* There were no group names specified. */
7799 ao2_ref(namedgroups, -1);
7800 namedgroups = NULL;
7801 }
7802
7803 return (struct ast_namedgroups *) namedgroups;
7804}
#define OBJ_POINTER
Definition astobj2.h:1150
@ AO2_ALLOC_OPT_LOCK_NOLOCK
Definition astobj2.h:367
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
#define ao2_alloc_options(data_size, destructor_fn, options)
Definition astobj2.h:404
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
Definition astobj2.h:1303
static int namedgroup_cmp_cb(void *obj, void *arg, int flags)
Comparison function used for named group container.
Definition channel.c:7733
static int namedgroup_hash_cb(const void *obj, const int flags)
Hashing function used for named group container.
Definition channel.c:7742
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
Definition strings.h:1259
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
Definition strings.h:186
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Definition strings.h:223
char *attribute_pure ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
Definition strings.h:161
Generic container type.
Named group member structure.
Definition channel.c:7725

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_container_alloc_hash, ao2_container_count(), ao2_find, ao2_link, ao2_ref, ast_skip_blanks(), ast_str_hash(), ast_strdupa, ast_strip(), ast_strlen_zero(), ast_trim_blanks(), c, len(), namedgroup_cmp_cb(), namedgroup_hash_cb(), NULL, OBJ_NODATA, OBJ_POINTER, OBJ_UNLINK, and strsep().

Referenced by func_channel_write_real(), named_groups_handler(), and process_dahdi().

◆ ast_hangup()

void 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 (NULL tolerant)

Hang up a channel.

Definition at line 2574 of file channel.c.

2575{
2576 /* Be NULL safe for RAII_VAR() usage. */
2577 if (!chan) {
2578 return;
2579 }
2580
2581 ast_debug(1, "Channel %p '%s' hanging up. Refs: %d\n", chan, ast_channel_name(chan),
2582 ao2_ref(chan, 0));
2583
2585
2586 ast_channel_lock(chan);
2587
2588 while (ast_channel_masq(chan) || ast_channel_masqr(chan)) {
2590 }
2591
2592 /* Mark as a zombie so a masquerade cannot be setup on this channel. */
2594
2595 ast_channel_unlock(chan);
2596
2597 /*
2598 * XXX if running the hangup handlers here causes problems
2599 * because the handlers take too long to execute, we could move
2600 * the meat of this function into another thread. A thread
2601 * where channels go to die.
2602 *
2603 * If this is done, ast_autoservice_chan_hangup_peer() will no
2604 * longer be needed.
2605 */
2607 ast_channel_unlink(chan);
2608 ast_channel_lock(chan);
2609
2610 destroy_hooks(chan);
2611
2612 free_translation(chan);
2613 /* Close audio stream */
2614 if (ast_channel_stream(chan)) {
2617 }
2618 /* Close video stream */
2619 if (ast_channel_vstream(chan)) {
2622 }
2623 if (ast_channel_sched(chan)) {
2626 }
2627
2628 if (ast_channel_generatordata(chan)) { /* Clear any tone stuff remaining */
2629 if (ast_channel_generator(chan) && ast_channel_generator(chan)->release) {
2631 }
2632 }
2635
2637 ast_log(LOG_WARNING, "Hard hangup called by thread LWP %d on %s, while blocked by thread LWP %d in procedure %s! Expect a failure\n",
2639 ast_channel_blockproc(chan));
2640 ast_assert(0);
2641 }
2642
2643 if (ast_channel_tech(chan)->hangup) {
2644 ast_channel_tech(chan)->hangup(chan);
2645 }
2646
2647 ast_channel_unlock(chan);
2648
2649 ast_cc_offer(chan);
2650
2651 ast_channel_unref(chan);
2652}
int ast_cc_offer(struct ast_channel *caller_chan)
Offer CC to a caller.
Definition ccss.c:3780
static int hangup(void *data)
static void destroy_hooks(struct ast_channel *chan)
Definition channel.c:2563
static void free_translation(struct ast_channel *clonechan)
Definition channel.c:2520
int ast_closestream(struct ast_filestream *f)
Closes a stream.
Definition file.c:1130
#define CHANNEL_DEADLOCK_AVOIDANCE(chan)
Definition lock.h:481
int ast_pbx_hangup_handler_run(struct ast_channel *chan)
Run all hangup handlers on the channel.
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
Definition sched.c:271
int(*const hangup)(struct ast_channel *chan)
Hangup (and possibly destroy) the channel.
Definition channel.h:724

References ao2_ref, ast_assert, ast_autoservice_stop(), ast_cc_offer(), ast_channel_blocker_tid(), ast_channel_blockproc(), ast_channel_flags(), ast_channel_generator(), ast_channel_generator_set(), ast_channel_generatordata(), ast_channel_generatordata_set(), ast_channel_lock, ast_channel_masq(), ast_channel_masqr(), ast_channel_name(), ast_channel_sched(), ast_channel_sched_set(), ast_channel_stream(), ast_channel_stream_set(), ast_channel_unlink(), ast_channel_unlock, ast_channel_unref, ast_channel_vstream(), ast_channel_vstream_set(), ast_closestream(), ast_debug, AST_FLAG_BLOCKING, AST_FLAG_ZOMBIE, ast_get_tid(), ast_log, ast_pbx_hangup_handler_run(), ast_sched_context_destroy(), ast_set_flag, ast_test_flag, CHANNEL_DEADLOCK_AVOIDANCE, destroy_hooks(), free_translation(), hangup(), ast_channel_tech::hangup, LOG_WARNING, NULL, and ast_generator::release.

Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_pbx_run(), __ast_request_and_dial(), alloc_playback_chan(), analog_handle_init_event(), analog_ss_thread(), announce_request(), announce_to_dial(), answer_exec_run(), ari_bridges_play_new(), ast_ari_bridges_record(), ast_async_goto(), ast_autoservice_chan_hangup_peer(), ast_bridge_add_channel(), ast_bridge_run_after_goto(), ast_call_forward(), ast_channel_yank(), ast_dial_destroy(), ast_dial_hangup(), ast_iax2_new(), ast_pbx_outgoing_exten_predial(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), ast_unreal_hangup(), attended_transfer_bridge(), begin_dial_channel(), blind_transfer_bridge(), bridge_channel_control_thread(), bridge_moh_create(), build_conf(), call_pickup_incoming_request(), chan_data_destroy(), chan_pjsip_new(), chanavail_exec(), clear_caller(), conf_free(), conf_run(), conf_start_record(), console_new(), create_msg_q_chan(), dahdi_handle_event(), dahdi_new(), destroy_conference_bridge(), dial_exec_full(), do_forward(), do_hang(), do_monitor(), do_monitor_headset(), feature_attended_transfer(), generic_recall(), handle_call_forward(), handle_call_outgoing(), handle_eval_function(), handle_exec(), handle_frame(), handle_init_event(), handle_timeout_trip(), hangup_playback(), hangupcalls(), hanguptree(), iax2_request(), jingle_action_session_initiate(), local_call(), make_channel(), mbl_ast_hangup(), media_request_helper(), meetme_menu_admin_extended(), moh_channel_thread(), monitor_dial(), mwi_thread(), my_distinctive_ring(), my_handle_notify_message(), ooh323_new(), park_local_transfer(), parking_blind_transfer_park(), pbx_outgoing_exec(), pbx_start_incoming_request(), push_announcer(), read_test(), recalling_exit(), refer_incoming_invite_request(), reject_incoming_call(), request_channel(), retransfer_enter(), safe_hangup(), snoop_stasis_thread(), stasis_app_control_snoop(), unistim_new(), wait_for_answer(), and wait_for_answer().

◆ ast_indicate()

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

4333{
4334 return ast_indicate_data(chan, condition, NULL, 0);
4335}

References ast_indicate_data(), and NULL.

Referenced by __ast_play_and_record(), answer_trunk_chan(), app_control_dtmf(), app_control_hold(), app_control_moh_start(), app_control_progress(), app_control_ring(), app_control_ring_stop(), app_control_silence_start(), app_control_unhold(), app_exec(), ast_bridge_channel_feature_digit(), ast_bridge_set_single_src_video_mode(), ast_bridge_update_talker_src_video_mode(), ast_raw_answer_with_stream_topology(), bridge_channel_do_callback(), bridge_channel_event_join_leave(), bridge_channel_handle_action(), bridge_channel_handle_control(), bridge_channel_handle_interval(), bridge_channel_internal_join(), caller_joined_bridge(), channel_do_masquerade(), cli_console_answer(), conf_run(), console_call(), dial_exec_full(), dial_trunk(), disa_exec(), do_forward(), dtmf_stream(), handle_frame(), handle_recordfile(), indicate_busy(), indicate_congestion(), mf_stream(), monitor_dial(), participant_entertainment_start(), participant_entertainment_stop(), pbx_builtin_incomplete(), pbx_builtin_proceeding(), pbx_builtin_progress(), pbx_builtin_ringing(), pbx_builtin_waitexten(), play_on_channel(), pre_bridge_setup(), queue_exec(), record_exec(), rna(), say_periodic_announcement(), say_position(), send_waveform_to_channel(), sf_stream(), simple_bridge_join(), sla_handle_hold_event(), sla_station_exec(), sla_trunk_exec(), softmix_bridge_join(), try_calling(), vm_exec(), wait_for_answer(), and wait_for_answer().

◆ ast_indicate_data()

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

Definition at line 4710 of file channel.c.

4711{
4712 int res;
4713 /* this frame is used by framehooks. if it is set, we must free it at the end of this function */
4714 struct ast_frame *awesome_frame = NULL;
4715
4716 ast_channel_lock(chan);
4717
4718 /* Don't bother if the channel is about to go away, anyway. */
4721 && _condition != AST_CONTROL_MASQUERADE_NOTIFY) {
4722 res = -1;
4723 goto indicate_cleanup;
4724 }
4725
4727 /* Do framehooks now, do it, go, go now */
4728 struct ast_frame frame = {
4730 .subclass.integer = _condition,
4731 .data.ptr = (void *) data, /* this cast from const is only okay because we do the ast_frdup below */
4732 .datalen = datalen
4733 };
4734
4735 /* we have now committed to freeing this frame */
4736 awesome_frame = ast_frdup(&frame);
4737
4738 /* who knows what we will get back! the anticipation is killing me. */
4740 awesome_frame);
4741 if (!awesome_frame
4742 || awesome_frame->frametype != AST_FRAME_CONTROL) {
4743 res = 0;
4744 goto indicate_cleanup;
4745 }
4746
4747 _condition = awesome_frame->subclass.integer;
4748 data = awesome_frame->data.ptr;
4749 datalen = awesome_frame->datalen;
4750 }
4751
4752 res = indicate_data_internal(chan, _condition, data, datalen);
4753
4754indicate_cleanup:
4755 ast_channel_unlock(chan);
4756 if (awesome_frame) {
4757 ast_frfree(awesome_frame);
4758 }
4759
4760 return res;
4761}
int ast_channel_is_leaving_bridge(struct ast_channel *chan)
Determine if a channel is leaving a bridge, but not hung up.
Definition channel.c:10660
static int indicate_data_internal(struct ast_channel *chan, int _condition, const void *data, size_t datalen)
Definition channel.c:4526
int ast_framehook_list_is_empty(struct ast_framehook_list *framehooks)
Determine if an framehook list is empty or not.
Definition framehook.c:274
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's framehook list.
Definition framehook.c:313
#define ast_frdup(fr)
Copies a frame.
@ AST_CONTROL_MASQUERADE_NOTIFY

References ast_channel_flags(), ast_channel_framehooks(), ast_channel_is_leaving_bridge(), ast_channel_lock, ast_channel_unlock, ast_check_hangup(), AST_CONTROL_MASQUERADE_NOTIFY, AST_FLAG_ZOMBIE, AST_FRAME_CONTROL, ast_framehook_list_is_empty(), ast_framehook_list_write_event(), ast_frdup, ast_frfree, ast_test_flag, ast_frame::data, ast_frame::datalen, ast_frame::frametype, indicate_data_internal(), ast_frame_subclass::integer, NULL, ast_frame::ptr, and ast_frame::subclass.

Referenced by __ast_read(), action_aocmessage(), app_exec(), ast_ari_channels_transfer_progress(), ast_channel_update_connected_line(), ast_channel_update_redirecting(), ast_handle_cc_control_frame(), ast_indicate(), bridge_channel_handle_control(), bridge_channel_internal_join(), channel_do_masquerade(), dial_exec_full(), disable_t38(), fax_gateway_indicate_t38(), generic_fax_exec(), handle_frame(), participant_entertainment_start(), pbx_builtin_waitexten(), receivefax_t38_init(), sendfax_t38_init(), set_fax_t38_caps(), wait_for_answer(), wait_for_answer(), and wait_for_winner().

◆ ast_is_deferrable_frame()

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

1455{
1456 /* Do not add a default entry in this switch statement. Each new
1457 * frame type should be addressed directly as to whether it should
1458 * be queued up or not.
1459 */
1460 switch (frame->frametype) {
1463 case AST_FRAME_CONTROL:
1464 case AST_FRAME_TEXT:
1466 case AST_FRAME_IMAGE:
1467 case AST_FRAME_HTML:
1468 return 1;
1469
1470 case AST_FRAME_DTMF_END:
1472 case AST_FRAME_VOICE:
1473 case AST_FRAME_VIDEO:
1474 case AST_FRAME_NULL:
1475 case AST_FRAME_IAX:
1476 case AST_FRAME_CNG:
1477 case AST_FRAME_MODEM:
1478 case AST_FRAME_RTCP:
1479 return 0;
1480 }
1481 return 0;
1482}

References AST_FRAME_BRIDGE_ACTION, AST_FRAME_BRIDGE_ACTION_SYNC, 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_RTCP, AST_FRAME_TEXT, AST_FRAME_TEXT_DATA, AST_FRAME_VIDEO, AST_FRAME_VOICE, and ast_frame::frametype.

Referenced by ast_bridge_channel_queue_frame(), autoservice_run(), and safe_sleep_conditional().

◆ ast_namedgroups_intersect()

int ast_namedgroups_intersect ( struct ast_namedgroups *  a,
struct ast_namedgroups *  b 
)

Return TRUE if group a and b contain at least one common groupname.

Definition at line 8196 of file channel.c.

8197{
8198 void *match;
8199 struct ao2_container *group_a = (struct ao2_container *) a;
8200 struct ao2_container *group_b = (struct ao2_container *) b;
8201
8202 if (!a || !b) {
8203 return 0;
8204 }
8205
8206 /*
8207 * Do groups a and b intersect? Since a and b are hash tables,
8208 * the average time complexity is:
8209 * O(a.count <= b.count ? a.count : b.count)
8210 */
8211 if (ao2_container_count(group_b) < ao2_container_count(group_a)) {
8212 /* Traverse over the smaller group. */
8213 SWAP(group_a, group_b);
8214 }
8215 match = ao2_callback(group_a, 0, namedgroup_match, group_b);
8217
8218 return match != NULL;
8219}
static int match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
Definition chan_iax2.c:2401
static int namedgroup_match(void *obj, void *arg, int flags)
Definition channel.c:8186
#define SWAP(a, b)
Definition utils.h:256

References a, ao2_callback, ao2_cleanup, ao2_container_count(), b, match(), namedgroup_match(), NULL, and SWAP.

Referenced by find_channel_by_group().

◆ ast_party_caller_copy()

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

Definition at line 1973 of file channel.c.

1974{
1975 if (dest == src) {
1976 /* Don't copy to self */
1977 return;
1978 }
1979
1980 ast_party_id_copy(&dest->id, &src->id);
1981 ast_party_id_copy(&dest->ani, &src->ani);
1982 ast_party_id_copy(&dest->priv, &src->priv);
1983 dest->ani2 = src->ani2;
1984}
struct ast_party_id priv
Private caller party ID.
Definition channel.h:432

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

Referenced by recalling_enter().

◆ ast_party_caller_free()

void ast_party_caller_free ( struct ast_party_caller doomed)

Destroy the caller party contents.

Since
1.8
Parameters
doomedThe caller party to destroy.

Definition at line 2002 of file channel.c.

2003{
2004 ast_party_id_free(&doomed->id);
2005 ast_party_id_free(&doomed->ani);
2006 ast_party_id_free(&doomed->priv);
2007}
void ast_party_id_free(struct ast_party_id *doomed)
Destroy the party id contents.
Definition channel.c:1798

References ast_party_caller::ani, ast_party_id_free(), ast_party_caller::id, and ast_party_caller::priv.

Referenced by ast_channel_destructor(), ast_dummy_channel_destructor(), callerid_write(), dial_trunk(), my_get_callerid(), and sla_ring_station().

◆ ast_party_caller_init()

void ast_party_caller_init ( struct ast_party_caller init)

Initialize the given caller structure.

Since
1.8
Parameters
initCaller structure to initialize.

Definition at line 1965 of file channel.c.

1966{
1967 ast_party_id_init(&init->id);
1968 ast_party_id_init(&init->ani);
1969 ast_party_id_init(&init->priv);
1970 init->ani2 = 0;
1971}
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition channel.c:1744

References ast_party_caller::ani, ast_party_caller::ani2, ast_party_id_init(), ast_party_caller::id, and ast_party_caller::priv.

Referenced by __ast_channel_alloc_ap(), dial_trunk(), queue_connected_line_update(), and sla_ring_station().

◆ ast_party_caller_set()

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.

Definition at line 1994 of file channel.c.

1995{
1996 ast_party_id_set(&dest->id, &src->id, update ? &update->id : NULL);
1997 ast_party_id_set(&dest->ani, &src->ani, update ? &update->ani : NULL);
1998 ast_party_id_set(&dest->priv, &src->priv, update ? &update->priv : NULL);
1999 dest->ani2 = src->ani2;
2000}
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:1775

References ast_party_caller::ani, ast_party_caller::ani2, ast_party_id_set(), ast_party_caller::id, NULL, ast_party_caller::priv, and update().

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

◆ ast_party_caller_set_init()

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.

Definition at line 1986 of file channel.c.

1987{
1988 ast_party_id_set_init(&init->id, &guide->id);
1989 ast_party_id_set_init(&init->ani, &guide->ani);
1990 ast_party_id_set_init(&init->priv, &guide->priv);
1991 init->ani2 = guide->ani2;
1992}
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:1767

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

Referenced by callerid_write(), dial_exec_full(), do_forward(), my_get_callerid(), and ring_entry().

◆ ast_party_connected_line_collect_caller()

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.
Warning
This is a shallow copy.
DO NOT call ast_party_connected_line_free() on the filled in connected line structure!

Definition at line 2050 of file channel.c.

2051{
2052 connected->id = caller->id;
2053 connected->ani = caller->ani;
2054 connected->priv = caller->priv;
2055 connected->ani2 = caller->ani2;
2057}
@ AST_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN
Definition callerid.h:552

References ast_party_caller::ani, ast_party_caller::ani2, AST_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN, connected, ast_party_caller::id, and ast_party_caller::priv.

◆ ast_party_connected_line_copy()

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

Definition at line 2018 of file channel.c.

2019{
2020 if (dest == src) {
2021 /* Don't copy to self */
2022 return;
2023 }
2024
2025 ast_party_id_copy(&dest->id, &src->id);
2026 ast_party_id_copy(&dest->ani, &src->ani);
2027 ast_party_id_copy(&dest->priv, &src->priv);
2028 dest->ani2 = src->ani2;
2029 dest->source = src->source;
2030}
int source
Information about the source of an update.
Definition channel.h:484

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

Referenced by __ast_read(), after_bridge_move_channel(), agent_login_channel_config(), ast_call_forward(), ast_channel_connected_line_sub(), ast_do_pickup(), attended_transfer_properties_alloc(), dial_exec_full(), do_forward(), indicate_connected_line(), recalling_enter(), retransfer_enter(), try_calling(), wait_for_answer(), and wait_for_answer().

◆ ast_party_connected_line_free()

void ast_party_connected_line_free ( struct ast_party_connected_line doomed)

◆ ast_party_connected_line_init()

void ast_party_connected_line_init ( struct ast_party_connected_line init)

◆ ast_party_connected_line_set()

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.

Definition at line 2041 of file channel.c.

2042{
2043 ast_party_id_set(&dest->id, &src->id, update ? &update->id : NULL);
2044 ast_party_id_set(&dest->ani, &src->ani, update ? &update->ani : NULL);
2045 ast_party_id_set(&dest->priv, &src->priv, update ? &update->priv : NULL);
2046 dest->ani2 = src->ani2;
2047 dest->source = src->source;
2048}

References ast_party_connected_line::ani, ast_party_connected_line::ani2, ast_party_id_set(), ast_party_connected_line::id, NULL, ast_party_connected_line::priv, ast_party_connected_line::source, and update().

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

◆ ast_party_connected_line_set_init()

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.

Definition at line 2032 of file channel.c.

2033{
2034 ast_party_id_set_init(&init->id, &guide->id);
2035 ast_party_id_set_init(&init->ani, &guide->ani);
2036 ast_party_id_set_init(&init->priv, &guide->priv);
2037 init->ani2 = guide->ani2;
2038 init->source = guide->source;
2039}

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

Referenced by __ast_request_and_dial(), ari_channels_handle_originate_with_id(), connectedline_write(), dial_exec_full(), indicate_connected_line(), pbx_outgoing_attempt(), wait_for_answer(), wait_for_answer(), and wait_for_winner().

◆ ast_party_dialed_copy()

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

Definition at line 1923 of file channel.c.

1924{
1925 if (dest == src) {
1926 /* Don't copy to self */
1927 return;
1928 }
1929
1930 ast_free(dest->number.str);
1931 dest->number.str = ast_strdup(src->number.str);
1932 dest->number.plan = src->number.plan;
1935}
#define ast_strdup(str)
A wrapper for strdup()
Definition astmm.h:241
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:1692
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition channel.h:393
char * str
Subscriber phone number (Malloced)
Definition channel.h:388
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition channel.h:390
struct ast_party_dialed::@217 number
Dialed/Called number.
int transit_network_select
Transit Network Select.
Definition channel.h:399

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

◆ ast_party_dialed_free()

void ast_party_dialed_free ( struct ast_party_dialed doomed)

Destroy the dialed party contents.

Since
1.8
Parameters
doomedThe dialed party to destroy.

Definition at line 1958 of file channel.c.

1959{
1960 ast_free(doomed->number.str);
1961 doomed->number.str = NULL;
1963}
void ast_party_subaddress_free(struct ast_party_subaddress *doomed)
Destroy the party subaddress contents.
Definition channel.c:1731

References ast_free, ast_party_subaddress_free(), NULL, ast_party_dialed::number, ast_party_dialed::str, and ast_party_dialed::subaddress.

Referenced by ast_channel_destructor(), ast_dummy_channel_destructor(), and callerid_write().

◆ ast_party_dialed_init()

void ast_party_dialed_init ( struct ast_party_dialed init)

Initialize the given dialed structure.

Since
1.8
Parameters
initDialed structure to initialize.

Definition at line 1915 of file channel.c.

1916{
1917 init->number.str = NULL;
1918 init->number.plan = 0;/* Unknown */
1920 init->transit_network_select = 0;
1921}
void ast_party_subaddress_init(struct ast_party_subaddress *init)
Initialize the given subaddress structure.
Definition channel.c:1684

References ast_party_subaddress_init(), NULL, 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().

◆ ast_party_dialed_set()

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

Definition at line 1945 of file channel.c.

1946{
1947 if (src->number.str && src->number.str != dest->number.str) {
1948 ast_free(dest->number.str);
1949 dest->number.str = ast_strdup(src->number.str);
1950 }
1951 dest->number.plan = src->number.plan;
1952
1954
1956}
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:1714

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

◆ ast_party_dialed_set_init()

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.

Definition at line 1937 of file channel.c.

1938{
1939 init->number.str = NULL;
1940 init->number.plan = guide->number.plan;
1943}
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:1706

References ast_party_subaddress_set_init(), NULL, 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().

◆ ast_party_id_copy()

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

Definition at line 1752 of file channel.c.

1753{
1754 if (dest == src) {
1755 /* Don't copy to self */
1756 return;
1757 }
1758
1759 ast_party_name_copy(&dest->name, &src->name);
1760 ast_party_number_copy(&dest->number, &src->number);
1762
1763 ast_free(dest->tag);
1764 dest->tag = ast_strdup(src->tag);
1765}
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:1639
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:1586
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition channel.h:346
char * tag
User-set "tag".
Definition channel.h:356
struct ast_party_name name
Subscriber name.
Definition channel.h:342
struct ast_party_number number
Subscriber phone number.
Definition channel.h:344

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_id_merge_copy(), ast_party_redirecting_copy(), ast_sip_session_create_outgoing(), ast_sip_set_id_from_invite(), caller_id_outgoing_request(), caller_id_outgoing_response(), chan_pjsip_new(), copy_redirecting_id(), queue_connected_line_update(), set_from_header(), stir_shaken_outgoing_request(), and update_initial_connected_line().

◆ ast_party_id_free()

void ast_party_id_free ( struct ast_party_id doomed)

Destroy the party id contents.

Since
1.8
Parameters
doomedThe party id to destroy.

Definition at line 1798 of file channel.c.

1799{
1800 ast_party_name_free(&doomed->name);
1801 ast_party_number_free(&doomed->number);
1803
1804 ast_free(doomed->tag);
1805 doomed->tag = NULL;
1806}
void ast_party_name_free(struct ast_party_name *doomed)
Destroy the party name contents.
Definition channel.c:1625
void ast_party_number_free(struct ast_party_number *doomed)
Destroy the party number contents.
Definition channel.c:1678

References ast_free, ast_party_name_free(), ast_party_number_free(), ast_party_subaddress_free(), ast_party_id::name, NULL, 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_id_reset(), ast_party_redirecting_free(), caller_id_outgoing_request(), caller_id_outgoing_response(), endpoint_destructor(), fetch_callerid_num(), session_destructor(), set_from_header(), stir_shaken_outgoing_request(), and update_incoming_connected_line().

◆ ast_party_id_init()

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.

Definition at line 1744 of file channel.c.

1745{
1746 ast_party_name_init(&init->name);
1749 init->tag = NULL;
1750}
void ast_party_name_init(struct ast_party_name *init)
Initialize the given name structure.
Definition channel.c:1578
void ast_party_number_init(struct ast_party_number *init)
Initialize the given number structure.
Definition channel.c:1631

References ast_party_name_init(), ast_party_number_init(), ast_party_subaddress_init(), ast_party_id::name, NULL, 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_id_reset(), ast_party_redirecting_init(), ast_sip_endpoint_alloc(), ast_sip_session_alloc(), caller_id_outgoing_request(), caller_id_outgoing_response(), dial_exec_full(), fetch_callerid_num(), set_from_header(), stir_shaken_outgoing_request(), and update_incoming_connected_line().

◆ ast_party_id_invalidate()

void ast_party_id_invalidate ( struct ast_party_id id)

Invalidate all components of the given party id.

Since
11.0
Parameters
idThe party id to invalidate.

Definition at line 1876 of file channel.c.

1877{
1878 id->name.valid = 0;
1879 id->number.valid = 0;
1880 id->subaddress.valid = 0;
1881}

◆ ast_party_id_merge()

struct ast_party_id ast_party_id_merge ( struct ast_party_id base,
struct ast_party_id overlay 
)

Merge a given party id into another given party id.

Since
11.0

This function will generate an effective party id.

Each party id component of the party id 'base' is overwritten by components of the party id 'overlay' if the overlay component is marked as valid. However the component 'tag' of the base party id remains untouched.

Parameters
baseThe party id which is merged.
overlayThe party id which is used to merge into.
Returns
The merged party id as a struct, not as a pointer.
Note
The merged party id returned is a shallow copy and must not be freed.

Definition at line 1889 of file channel.c.

1890{
1891 struct ast_party_id merged;
1892
1893 merged = *base;
1894 if (overlay->name.valid) {
1895 merged.name = overlay->name;
1896 }
1897 if (overlay->number.valid) {
1898 merged.number = overlay->number;
1899 }
1900 if (overlay->subaddress.valid) {
1901 merged.subaddress = overlay->subaddress;
1902 }
1903 /* Note the actual structure is returned and not a pointer to it! */
1904 return merged;
1905}
unsigned char valid
TRUE if the name information is valid/present.
Definition channel.h:281
unsigned char valid
TRUE if the number information is valid/present.
Definition channel.h:299
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition channel.h:330

References ast_party_id::name, ast_party_id::number, and ast_party_id::subaddress.

Referenced by ast_channel_connected_effective_id(), ast_channel_redirecting_effective_from(), ast_channel_redirecting_effective_orig(), ast_channel_redirecting_effective_to(), and ast_party_id_merge_copy().

◆ ast_party_id_merge_copy()

void ast_party_id_merge_copy ( struct ast_party_id dest,
struct ast_party_id base,
struct ast_party_id overlay 
)

Copy a merge of a given party id into another given party id to a given destination party id.

Since
11.0

Each party id component of the party id 'base' is overwritten by components of the party id 'overlay' if the 'overlay' component is marked as valid. However the component 'tag' of the 'base' party id remains untouched. The result is copied into the given party id 'dest'.

Note
The resulting merged party id is a real copy and has to be freed.
Parameters
destThe resulting merged party id.
baseThe party id which is merged.
overlayThe party id which is used to merge into.

Definition at line 1907 of file channel.c.

1908{
1909 struct ast_party_id merged;
1910
1911 merged = ast_party_id_merge(base, overlay);
1912 ast_party_id_copy(dest, &merged);
1913}
struct ast_party_id ast_party_id_merge(struct ast_party_id *base, struct ast_party_id *overlay)
Merge a given party id into another given party id.
Definition channel.c:1889

References ast_party_id_copy(), and ast_party_id_merge().

◆ ast_party_id_presentation()

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

1809{
1810 int number_priority;
1811 int number_value;
1812 int number_screening;
1813 int name_priority;
1814 int name_value;
1815
1816 /* Determine name presentation priority. */
1817 if (!id->name.valid) {
1818 name_value = AST_PRES_UNAVAILABLE;
1819 name_priority = 3;
1820 } else {
1821 name_value = id->name.presentation & AST_PRES_RESTRICTION;
1822 switch (name_value) {
1824 name_priority = 0;
1825 break;
1826 case AST_PRES_ALLOWED:
1827 name_priority = 1;
1828 break;
1830 name_priority = 2;
1831 break;
1832 default:
1833 name_value = AST_PRES_UNAVAILABLE;
1834 name_priority = 3;
1835 break;
1836 }
1837 }
1838
1839 /* Determine number presentation priority. */
1840 if (!id->number.valid) {
1841 number_screening = AST_PRES_USER_NUMBER_UNSCREENED;
1842 number_value = AST_PRES_UNAVAILABLE;
1843 number_priority = 3;
1844 } else {
1845 number_screening = id->number.presentation & AST_PRES_NUMBER_TYPE;
1846 number_value = id->number.presentation & AST_PRES_RESTRICTION;
1847 switch (number_value) {
1849 number_priority = 0;
1850 break;
1851 case AST_PRES_ALLOWED:
1852 number_priority = 1;
1853 break;
1855 number_priority = 2;
1856 break;
1857 default:
1858 number_screening = AST_PRES_USER_NUMBER_UNSCREENED;
1859 number_value = AST_PRES_UNAVAILABLE;
1860 number_priority = 3;
1861 break;
1862 }
1863 }
1864
1865 /* Select the wining presentation value. */
1866 if (name_priority < number_priority) {
1867 number_value = name_value;
1868 }
1869 if (number_value == AST_PRES_UNAVAILABLE) {
1871 }
1872
1873 return number_value | number_screening;
1874}
enum queue_result id
Definition app_queue.c:1790
#define AST_PRES_USER_NUMBER_UNSCREENED
Definition callerid.h:426
#define AST_PRES_UNAVAILABLE
Definition callerid.h:434
#define AST_PRES_RESTRICTED
Definition callerid.h:433
#define AST_PRES_ALLOWED
Definition callerid.h:432
#define AST_PRES_NUMBER_NOT_AVAILABLE
Definition callerid.h:461
#define AST_PRES_NUMBER_TYPE
Definition callerid.h:425
#define AST_PRES_RESTRICTION
Definition callerid.h:431

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, and id.

Referenced by add_privacy_header(), add_privacy_params(), ast_json_party_id(), ast_sip_can_present_connected_id(), ast_str_retrieve_variable(), ast_var_channels_table(), channel_snapshot_caller_create(), iax2_call(), is_colp_update_allowed(), my_send_callerid(), party_id_build_data(), party_id_read(), queue_exec(), redirecting_read(), set_from_header(), setup_env(), and socket_process_helper().

◆ ast_party_id_reset()

void ast_party_id_reset ( struct ast_party_id id)

Destroy and initialize the given party id structure.

Since
11.0
Parameters
idThe party id to reset.

Definition at line 1883 of file channel.c.

1884{
1887}

References ast_party_id_free(), and ast_party_id_init().

Referenced by after_bridge_move_channel(), ast_do_pickup(), channel_do_masquerade(), and retransfer_enter().

◆ ast_party_id_set()

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.

Definition at line 1775 of file channel.c.

1776{
1777 if (dest == src) {
1778 /* Don't set to self */
1779 return;
1780 }
1781
1782 if (!update || update->name) {
1783 ast_party_name_set(&dest->name, &src->name);
1784 }
1785 if (!update || update->number) {
1786 ast_party_number_set(&dest->number, &src->number);
1787 }
1788 if (!update || update->subaddress) {
1790 }
1791
1792 if (src->tag && src->tag != dest->tag) {
1793 ast_free(dest->tag);
1794 dest->tag = ast_strdup(src->tag);
1795 }
1796}
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:1661
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:1608

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

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

◆ ast_party_id_set_init()

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.

Definition at line 1767 of file channel.c.

1768{
1769 ast_party_name_set_init(&init->name, &guide->name);
1770 ast_party_number_set_init(&init->number, &guide->number);
1772 init->tag = NULL;
1773}
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:1600
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:1653

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

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

◆ ast_party_name_copy()

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

Definition at line 1586 of file channel.c.

1587{
1588 if (dest == src) {
1589 /* Don't copy to self */
1590 return;
1591 }
1592
1593 ast_free(dest->str);
1594 dest->str = ast_strdup(src->str);
1595 dest->char_set = src->char_set;
1596 dest->presentation = src->presentation;
1597 dest->valid = src->valid;
1598}
int char_set
Character set the name is using.
Definition channel.h:274
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition channel.h:279
char * str
Subscriber name (Malloced)
Definition channel.h:266

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

◆ ast_party_name_free()

void ast_party_name_free ( struct ast_party_name doomed)

Destroy the party name contents.

Since
1.8
Parameters
doomedThe party name to destroy.

Definition at line 1625 of file channel.c.

1626{
1627 ast_free(doomed->str);
1628 doomed->str = NULL;
1629}

References ast_free, NULL, and ast_party_name::str.

Referenced by analog_ss_thread(), and ast_party_id_free().

◆ ast_party_name_init()

void ast_party_name_init ( struct ast_party_name init)

Initialize the given name structure.

Since
1.8
Parameters
initName structure to initialize.

Definition at line 1578 of file channel.c.

1579{
1580 init->str = NULL;
1583 init->valid = 0;
1584}

References AST_PARTY_CHAR_SET_ISO8859_1, AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, ast_party_name::char_set, NULL, ast_party_name::presentation, ast_party_name::str, and ast_party_name::valid.

Referenced by analog_ss_thread(), and ast_party_id_init().

◆ ast_party_name_set()

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

Definition at line 1608 of file channel.c.

1609{
1610 if (dest == src) {
1611 /* Don't set to self */
1612 return;
1613 }
1614
1615 if (src->str && src->str != dest->str) {
1616 ast_free(dest->str);
1617 dest->str = ast_strdup(src->str);
1618 }
1619
1620 dest->char_set = src->char_set;
1621 dest->presentation = src->presentation;
1622 dest->valid = src->valid;
1623}

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

◆ ast_party_name_set_init()

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.

Definition at line 1600 of file channel.c.

1601{
1602 init->str = NULL;
1603 init->char_set = guide->char_set;
1604 init->presentation = guide->presentation;
1605 init->valid = guide->valid;
1606}

References ast_party_name::char_set, NULL, ast_party_name::presentation, ast_party_name::str, and ast_party_name::valid.

Referenced by ast_party_id_set_init().

◆ ast_party_number_copy()

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

Definition at line 1639 of file channel.c.

1640{
1641 if (dest == src) {
1642 /* Don't copy to self */
1643 return;
1644 }
1645
1646 ast_free(dest->str);
1647 dest->str = ast_strdup(src->str);
1648 dest->plan = src->plan;
1649 dest->presentation = src->presentation;
1650 dest->valid = src->valid;
1651}
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition channel.h:297
char * str
Subscriber phone number (Malloced)
Definition channel.h:293
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition channel.h:295

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

◆ ast_party_number_free()

void ast_party_number_free ( struct ast_party_number doomed)

Destroy the party number contents.

Since
1.8
Parameters
doomedThe party number to destroy.

Definition at line 1678 of file channel.c.

1679{
1680 ast_free(doomed->str);
1681 doomed->str = NULL;
1682}

References ast_free, NULL, and ast_party_number::str.

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

◆ ast_party_number_init()

void ast_party_number_init ( struct ast_party_number init)

Initialize the given number structure.

Since
1.8
Parameters
initNumber structure to initialize.

Definition at line 1631 of file channel.c.

1632{
1633 init->str = NULL;
1634 init->plan = 0;/* Unknown */
1636 init->valid = 0;
1637}

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

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

◆ ast_party_number_set()

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

Definition at line 1661 of file channel.c.

1662{
1663 if (dest == src) {
1664 /* Don't set to self */
1665 return;
1666 }
1667
1668 if (src->str && src->str != dest->str) {
1669 ast_free(dest->str);
1670 dest->str = ast_strdup(src->str);
1671 }
1672
1673 dest->plan = src->plan;
1674 dest->presentation = src->presentation;
1675 dest->valid = src->valid;
1676}

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

◆ ast_party_number_set_init()

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.

Definition at line 1653 of file channel.c.

1654{
1655 init->str = NULL;
1656 init->plan = guide->plan;
1657 init->presentation = guide->presentation;
1658 init->valid = guide->valid;
1659}

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

Referenced by ast_party_id_set_init().

◆ ast_party_redirecting_copy()

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

Definition at line 2122 of file channel.c.

2123{
2124 if (dest == src) {
2125 /* Don't copy to self */
2126 return;
2127 }
2128
2129 ast_party_id_copy(&dest->orig, &src->orig);
2130 ast_party_id_copy(&dest->from, &src->from);
2131 ast_party_id_copy(&dest->to, &src->to);
2132 ast_party_id_copy(&dest->priv_orig, &src->priv_orig);
2133 ast_party_id_copy(&dest->priv_from, &src->priv_from);
2134 ast_party_id_copy(&dest->priv_to, &src->priv_to);
2137 dest->count = src->count;
2138}
void ast_party_redirecting_reason_copy(struct ast_party_redirecting_reason *dest, const struct ast_party_redirecting_reason *src)
Copy the source redirecting reason information to the destination redirecting reason.
Definition channel.c:2072
struct ast_party_redirecting_reason orig_reason
Reason for the redirection by the original party.
Definition channel.h:547
struct ast_party_redirecting_reason reason
Reason for the redirection.
Definition channel.h:544
int count
Number of times the call was redirected.
Definition channel.h:550

References ast_party_id_copy(), ast_party_redirecting_reason_copy(), ast_party_redirecting::count, ast_party_redirecting::from, ast_party_redirecting::orig, ast_party_redirecting::orig_reason, ast_party_redirecting::priv_from, ast_party_redirecting::priv_orig, ast_party_redirecting::priv_to, ast_party_redirecting::reason, and ast_party_redirecting::to.

Referenced by ast_ari_channels_dial(), ast_call_forward(), ast_channel_redirecting_sub(), ast_unreal_call_setup(), begin_dial_prerun(), call_forward_inherit(), dial_exec_full(), do_forward(), ring_entry(), and wait_for_answer().

◆ ast_party_redirecting_free()

void ast_party_redirecting_free ( struct ast_party_redirecting doomed)

◆ ast_party_redirecting_init()

void ast_party_redirecting_init ( struct ast_party_redirecting init)

Initialize the given redirecting structure.

Since
1.8
Parameters
initRedirecting structure to initialize.

Definition at line 2109 of file channel.c.

2110{
2111 ast_party_id_init(&init->orig);
2112 ast_party_id_init(&init->from);
2113 ast_party_id_init(&init->to);
2116 ast_party_id_init(&init->priv_to);
2119 init->count = 0;
2120}
void ast_party_redirecting_reason_init(struct ast_party_redirecting_reason *init)
Initialize the given redirecting reason structure.
Definition channel.c:2066

References ast_party_id_init(), ast_party_redirecting_reason_init(), ast_party_redirecting::count, ast_party_redirecting::from, ast_party_redirecting::orig, ast_party_redirecting::orig_reason, ast_party_redirecting::priv_from, ast_party_redirecting::priv_orig, ast_party_redirecting::priv_to, ast_party_redirecting::reason, and ast_party_redirecting::to.

Referenced by __ast_channel_alloc_ap(), ast_channel_redirecting_sub(), AST_TEST_DEFINE(), call_forward_inherit(), do_forward(), set_redirecting(), and wait_for_answer().

◆ ast_party_redirecting_reason_copy()

void ast_party_redirecting_reason_copy ( struct ast_party_redirecting_reason dest,
const struct ast_party_redirecting_reason src 
)

Copy the source redirecting reason information to the destination redirecting reason.

Parameters
destDestination redirecting reason
srcSource redirecting reason

Definition at line 2072 of file channel.c.

2073{
2074 if (dest == src) {
2075 return;
2076 }
2077
2078 ast_free(dest->str);
2079 dest->str = ast_strdup(src->str);
2080 dest->code = src->code;
2081}
int code
enum AST_REDIRECTING_REASON value for redirection
Definition channel.h:512
char * str
a string value for the redirecting reason
Definition channel.h:509

References ast_free, ast_strdup, ast_party_redirecting_reason::code, and ast_party_redirecting_reason::str.

Referenced by ast_party_redirecting_copy().

◆ ast_party_redirecting_reason_free()

void ast_party_redirecting_reason_free ( struct ast_party_redirecting_reason doomed)

Destroy the redirecting reason contents.

Parameters
doomedThe redirecting reason to destroy.

Definition at line 2103 of file channel.c.

2104{
2105 ast_free(doomed->str);
2106}

References ast_free, and ast_party_redirecting_reason::str.

Referenced by ast_party_redirecting_free().

◆ ast_party_redirecting_reason_init()

void ast_party_redirecting_reason_init ( struct ast_party_redirecting_reason init)

Initialize the given redirecting reason structure.

Parameters
initRedirecting reason structure to initialize

Definition at line 2066 of file channel.c.

2067{
2068 init->str = NULL;
2070}
@ AST_REDIRECTING_REASON_UNKNOWN
Definition callerid.h:499

References AST_REDIRECTING_REASON_UNKNOWN, ast_party_redirecting_reason::code, NULL, and ast_party_redirecting_reason::str.

Referenced by ast_party_redirecting_init().

◆ ast_party_redirecting_reason_set()

void ast_party_redirecting_reason_set ( struct ast_party_redirecting_reason dest,
const struct ast_party_redirecting_reason src 
)

Set the redirecting reason information based on another redirecting reason source.

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

Parameters
destThe redirecting reason one wishes to update
srcThe new redirecting reason values to update the dest

Definition at line 2089 of file channel.c.

2090{
2091 if (dest == src) {
2092 return;
2093 }
2094
2095 if (src->str && src->str != dest->str) {
2096 ast_free(dest->str);
2097 dest->str = ast_strdup(src->str);
2098 }
2099
2100 dest->code = src->code;
2101}

References ast_free, ast_strdup, ast_party_redirecting_reason::code, and ast_party_redirecting_reason::str.

Referenced by ast_party_redirecting_set().

◆ ast_party_redirecting_reason_set_init()

void ast_party_redirecting_reason_set_init ( struct ast_party_redirecting_reason init,
const struct ast_party_redirecting_reason guide 
)

Initialize the given redirecting reason structure using the given guide for a set update operation.

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

Parameters
initRedirecting reason structure to initialize.
guideSource redirecting reason to use as a guide in initializing.

Definition at line 2083 of file channel.c.

2084{
2085 init->str = NULL;
2086 init->code = guide->code;
2087}

References ast_party_redirecting_reason::code, NULL, and ast_party_redirecting_reason::str.

Referenced by ast_party_redirecting_set_init().

◆ ast_party_redirecting_set()

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.

Definition at line 2153 of file channel.c.

2154{
2155 ast_party_id_set(&dest->orig, &src->orig, update ? &update->orig : NULL);
2156 ast_party_id_set(&dest->from, &src->from, update ? &update->from : NULL);
2157 ast_party_id_set(&dest->to, &src->to, update ? &update->to : NULL);
2158 ast_party_id_set(&dest->priv_orig, &src->priv_orig, update ? &update->priv_orig : NULL);
2159 ast_party_id_set(&dest->priv_from, &src->priv_from, update ? &update->priv_from : NULL);
2160 ast_party_id_set(&dest->priv_to, &src->priv_to, update ? &update->priv_to : NULL);
2163 dest->count = src->count;
2164}
void ast_party_redirecting_reason_set(struct ast_party_redirecting_reason *dest, const struct ast_party_redirecting_reason *src)
Set the redirecting reason information based on another redirecting reason source.
Definition channel.c:2089

References ast_party_id_set(), ast_party_redirecting_reason_set(), ast_party_redirecting::count, ast_party_redirecting::from, NULL, ast_party_redirecting::orig, ast_party_redirecting::orig_reason, ast_party_redirecting::priv_from, ast_party_redirecting::priv_orig, ast_party_redirecting::priv_to, ast_party_redirecting::reason, ast_party_redirecting::to, and update().

Referenced by ast_channel_set_redirecting().

◆ ast_party_redirecting_set_init()

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.

Definition at line 2140 of file channel.c.

2141{
2142 ast_party_id_set_init(&init->orig, &guide->orig);
2143 ast_party_id_set_init(&init->from, &guide->from);
2144 ast_party_id_set_init(&init->to, &guide->to);
2145 ast_party_id_set_init(&init->priv_orig, &guide->priv_orig);
2146 ast_party_id_set_init(&init->priv_from, &guide->priv_from);
2147 ast_party_id_set_init(&init->priv_to, &guide->priv_to);
2150 init->count = guide->count;
2151}
void ast_party_redirecting_reason_set_init(struct ast_party_redirecting_reason *init, const struct ast_party_redirecting_reason *guide)
Initialize the given redirecting reason structure using the given guide for a set update operation.
Definition channel.c:2083

References ast_party_id_set_init(), ast_party_redirecting_reason_set_init(), ast_party_redirecting::count, ast_party_redirecting::from, ast_party_redirecting::orig, ast_party_redirecting::orig_reason, ast_party_redirecting::priv_from, ast_party_redirecting::priv_orig, ast_party_redirecting::priv_to, ast_party_redirecting::reason, and ast_party_redirecting::to.

Referenced by indicate_redirecting(), and redirecting_write().

◆ ast_party_subaddress_copy()

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

Definition at line 1692 of file channel.c.

1693{
1694 if (dest == src) {
1695 /* Don't copy to self */
1696 return;
1697 }
1698
1699 ast_free(dest->str);
1700 dest->str = ast_strdup(src->str);
1701 dest->type = src->type;
1703 dest->valid = src->valid;
1704}
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition channel.h:328
char * str
Malloced subaddress string.
Definition channel.h:315
int type
Q.931 subaddress type.
Definition channel.h:322

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

◆ ast_party_subaddress_free()

void ast_party_subaddress_free ( struct ast_party_subaddress doomed)

Destroy the party subaddress contents.

Since
1.8
Parameters
doomedThe party subaddress to destroy.

Definition at line 1731 of file channel.c.

1732{
1733 ast_free(doomed->str);
1734 doomed->str = NULL;
1735}

References ast_free, NULL, and ast_party_subaddress::str.

Referenced by ast_party_dialed_free(), and ast_party_id_free().

◆ ast_party_subaddress_init()

void ast_party_subaddress_init ( struct ast_party_subaddress init)

Initialize the given subaddress structure.

Since
1.8
Parameters
initSubaddress structure to initialize.

Definition at line 1684 of file channel.c.

1685{
1686 init->str = NULL;
1687 init->type = 0;
1688 init->odd_even_indicator = 0;
1689 init->valid = 0;
1690}

References NULL, 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(), and ast_party_id_init().

◆ ast_party_subaddress_set()

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

Definition at line 1714 of file channel.c.

1715{
1716 if (dest == src) {
1717 /* Don't set to self */
1718 return;
1719 }
1720
1721 if (src->str && src->str != dest->str) {
1722 ast_free(dest->str);
1723 dest->str = ast_strdup(src->str);
1724 }
1725
1726 dest->type = src->type;
1728 dest->valid = src->valid;
1729}

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

◆ ast_party_subaddress_set_init()

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.

Definition at line 1706 of file channel.c.

1707{
1708 init->str = NULL;
1709 init->type = guide->type;
1711 init->valid = guide->valid;
1712}

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

◆ ast_pre_call()

int ast_pre_call ( struct ast_channel chan,
const char *  sub_args 
)

Execute a Gosub call on the channel before a call is placed.

Since
11.0

This is called between ast_request() and ast_call() to execute a predial routine on the newly created channel.

Parameters
chanChannel to execute Gosub.
sub_argsGosub application parameter string.
Note
Absolutely NO channel locks should be held before calling this function.
Return values
0on success.
-1on error.

Definition at line 6501 of file channel.c.

6502{
6503 int (*pre_call)(struct ast_channel *chan, const char *sub_args);
6504
6505 ast_channel_lock(chan);
6506 pre_call = ast_channel_tech(chan)->pre_call;
6507 if (pre_call) {
6508 int res;
6509
6510 res = pre_call(chan, sub_args);
6511 ast_channel_unlock(chan);
6512 return res;
6513 }
6514 ast_channel_unlock(chan);
6515 return ast_app_exec_sub(NULL, chan, sub_args, 0);
6516}
int ast_app_exec_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_args, int ignore_hangup)
Run a subroutine on a channel, placing an optional second channel into autoservice.
Definition main/app.c:297
int(* pre_call)(struct ast_channel *chan, const char *sub_args)
Execute a Gosub call on the channel in a technology specific way before a call is placed.
Definition channel.h:861

References ast_app_exec_sub(), ast_channel_lock, ast_channel_unlock, NULL, and ast_channel_tech::pre_call.

Referenced by begin_dial_prerun(), dial_exec_full(), findmeexec(), and ring_entry().

◆ ast_print_group()

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

8138{
8139 unsigned int i;
8140 int first = 1;
8141 char num[3];
8142
8143 buf[0] = '\0';
8144
8145 if (!group) /* Return empty string if no group */
8146 return buf;
8147
8148 for (i = 0; i <= 63; i++) { /* Max group is 63 */
8149 if (group & ((ast_group_t) 1 << i)) {
8150 if (!first) {
8151 strncat(buf, ", ", buflen - strlen(buf) - 1);
8152 } else {
8153 first = 0;
8154 }
8155 snprintf(num, sizeof(num), "%u", i);
8156 strncat(buf, num, buflen - strlen(buf) - 1);
8157 }
8158 }
8159 return buf;
8160}
struct sla_ringing_trunk * first
Definition app_sla.c:338

References buf, and first.

Referenced by callgroup_to_str(), func_channel_read(), pickupgroup_to_str(), and serialize_showchan().

◆ ast_print_namedgroups()

char * ast_print_namedgroups ( struct ast_str **  buf,
struct ast_namedgroups *  groups 
)

Print named call groups and named pickup groups.

Definition at line 8162 of file channel.c.

8163{
8164 struct ao2_container *grp = (struct ao2_container *) group;
8165 struct namedgroup_member *ng;
8166 int first = 1;
8167 struct ao2_iterator it;
8168
8169 if (!grp) {
8170 return ast_str_buffer(*buf);
8171 }
8172
8173 for (it = ao2_iterator_init(grp, 0); (ng = ao2_iterator_next(&it)); ao2_ref(ng, -1)) {
8174 if (!first) {
8175 ast_str_append(buf, 0, ", ");
8176 } else {
8177 first = 0;
8178 }
8179 ast_str_append(buf, 0, "%s", ng->name);
8180 }
8182
8183 return ast_str_buffer(*buf);
8184}
#define ao2_iterator_next(iter)
Definition astobj2.h:1911
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition strings.h:1139
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition strings.h:761

References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_str_append(), ast_str_buffer(), buf, first, and namedgroup_member::name.

Referenced by func_channel_read(), named_callgroups_to_str(), and named_pickupgroups_to_str().

◆ ast_prod()

int ast_prod ( struct ast_channel chan)

Send empty audio to prime a channel driver.

Definition at line 5057 of file channel.c.

5058{
5059 struct ast_frame a = { AST_FRAME_VOICE };
5060 char nothing[128];
5061
5062 /* Send an empty audio frame to get things moving */
5063 if (ast_channel_state(chan) != AST_STATE_UP) {
5064 ast_debug(3, "Prodding channel '%s'\n", ast_channel_name(chan));
5065 a.subclass.format = ast_channel_rawwriteformat(chan);
5066 a.data.ptr = nothing + AST_FRIENDLY_OFFSET;
5067 a.src = "ast_prod"; /* this better match check in ast_write */
5068 if (ast_write(chan, &a))
5069 ast_log(LOG_WARNING, "Prodding channel '%s' failed\n", ast_channel_name(chan));
5070 }
5071 return 0;
5072}
int ast_write(struct ast_channel *chan, struct ast_frame *fr)
Write a frame to a channel This function writes the given frame to the indicated channel.
Definition channel.c:5201
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.

References a, ast_channel_name(), ast_channel_rawwriteformat(), ast_debug, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log, AST_STATE_UP, ast_write(), and LOG_WARNING.

Referenced by ast_activate_generator().

◆ ast_queue_answer()

int ast_queue_answer ( struct ast_channel chan,
const struct ast_stream_topology topology 
)

Queue an ANSWER control frame with topology.

Parameters
chanchannel to queue frame onto
topologytopology to be passed through the core to the peer channel
Return values
0success
non-zerofailure

Definition at line 1304 of file channel.c.

1305{
1306 struct ast_frame f = {
1309 .subclass.topology = (struct ast_stream_topology *)topology,
1310 };
1311 return ast_queue_frame(chan, &f);
1312}

References AST_CONTROL_ANSWER, AST_FRAME_CONTROL, ast_queue_frame(), ast_frame_subclass::integer, and ast_frame::subclass.

◆ ast_queue_control()

int ast_queue_control ( struct ast_channel chan,
enum ast_control_frame_type  control 
)

◆ ast_queue_control_data()

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

1298{
1299 struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = control, .data.ptr = (void *) data, .datalen = datalen };
1300 return ast_queue_frame(chan, &f);
1301}

References AST_FRAME_CONTROL, ast_queue_frame(), ast_frame::data, ast_frame::datalen, ast_frame_subclass::integer, and ast_frame::subclass.

Referenced by __analog_handle_event(), after_bridge_move_channel(), analog_callwaiting_deluxe(), ast_channel_queue_connected_line_update(), ast_channel_queue_redirecting_update(), chan_pjsip_incoming_response_update_cause(), close_udptl_connection(), fax_gateway_indicate_t38(), iax2_transfer(), jingle_action_session_terminate(), onModeChanged(), ooh323_indicate(), queue_read_action_payload(), setup_udptl_connection(), socket_process_helper(), t38_change_state(), t38_framehook(), t38_interpret_parameters(), transfer_redirect(), transfer_refer(), and xfer_client_on_evsub_state().

◆ ast_queue_frame()

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

1172{
1173 return __ast_queue_frame(chan, fin, 0, NULL);
1174}
static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, int head, struct ast_frame *after)
Definition channel.c:1041

References __ast_queue_frame(), and NULL.

Referenced by __ast_read(), action_atxfer(), action_cancel_atxfer(), apply_negotiated_sdp_stream(), ast_channel_set_unbridged_nolock(), ast_channel_setwhentohangup_tv(), ast_channel_stream_topology_changed_externally(), ast_dsp_process(), ast_msg_data_queue_frame(), ast_queue_answer(), ast_queue_cc_frame(), ast_queue_control(), ast_queue_control_data(), ast_queue_hangup(), ast_queue_hangup_with_cause(), ast_queue_hold(), ast_queue_unhold(), ast_softhangup_nolock(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), attended_transfer_exec(), bridge_channel_internal_push_full(), bridge_channel_poke(), channel_do_masquerade(), cli_console_dial(), cli_console_sendtext(), conf_stop_record(), dahdi_queue_frame(), dahdi_read(), dictate_exec(), dtmf_info_incoming_request(), exec_command_on_condition(), handle_command(), handle_incoming_request(), handle_negotiated_sdp(), iax2_queue_frame(), load_stream_readqueue(), manager_play_dtmf(), manager_send_flash(), ooh323_onReceivedDigit(), queue_dtmf_readq(), refer_incoming_invite_request(), set_interval_hook(), stream_monitor(), stream_periodic_frames(), stream_periodic_frames(), t38_tx_packet_handler(), unistim_do_senddigit(), unreal_queue_frame(), and wakeup_sub().

◆ ast_queue_frame_head()

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

1177{
1178 return __ast_queue_frame(chan, fin, 1, NULL);
1179}

References __ast_queue_frame(), and NULL.

Referenced by __ast_answer(), __ast_read(), ast_autoservice_stop(), bridge_channel_queue_deferred_frames(), and safe_sleep_conditional().

◆ ast_queue_hangup()

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

1183{
1186 int res, cause, tech_cause;
1187
1188 if (!blob) {
1189 return -1;
1190 }
1191
1192 /* Yeah, let's not change a lock-critical value without locking */
1193 ast_channel_lock(chan);
1195
1196 cause = ast_channel_hangupcause(chan);
1197 if (cause) {
1198 ast_json_object_set(blob, "cause", ast_json_integer_create(cause));
1199 }
1200 tech_cause = ast_channel_tech_hangupcause(chan);
1201 if (tech_cause) {
1202 ast_json_object_set(blob, "tech_cause", ast_json_integer_create(tech_cause));
1203 }
1204
1206
1207 res = ast_queue_frame(chan, &f);
1208 ast_channel_unlock(chan);
1209 return res;
1210}
struct stasis_message_type * ast_channel_hangup_request_type(void)
Message type for when a hangup is requested on a channel.
struct ast_json * ast_json_object_create(void)
Create a new JSON object.
Definition json.c:399
struct ast_json * ast_json_integer_create(intmax_t value)
Create a JSON integer.
Definition json.c:327
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
Set a field in a JSON object.
Definition json.c:414

References ast_channel_hangup_request_type(), ast_channel_hangupcause(), ast_channel_lock, ast_channel_publish_blob(), ast_channel_softhangup_internal_flag_add(), ast_channel_tech_hangupcause(), ast_channel_unlock, AST_CONTROL_HANGUP, AST_FRAME_CONTROL, ast_json_integer_create(), ast_json_object_create(), ast_json_object_set(), ast_json_unref(), ast_queue_frame(), AST_SOFTHANGUP_DEV, ast_frame_subclass::integer, RAII_VAR, and ast_frame::subclass.

Referenced by analog_callwaiting_deluxe(), ast_app_exec_sub(), ast_unreal_fixup(), call(), chan_pjsip_session_end(), cli_console_hangup(), close_call(), iax2_destroy(), iax2_queue_hangup(), mbl_queue_hangup(), refer_incoming_invite_request(), and session_inv_on_media_update().

◆ ast_queue_hangup_with_cause()

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
Return values
0on success
-1on error
Since
1.6.1

Queue a hangup frame with hangupcause set.

Definition at line 1213 of file channel.c.

1214{
1215 RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
1217 int res;
1218 int tech_cause = 0;
1219
1220 if (cause >= 0) {
1221 f.data.uint32 = cause;
1222 }
1223
1224 /* Yeah, let's not change a lock-critical value without locking */
1225 ast_channel_lock(chan);
1227 if (cause < 0) {
1229 }
1230 blob = ast_json_pack("{s: i}",
1231 "cause", cause);
1232 if (!blob) {
1233 ast_channel_unlock(chan);
1234 return -1;
1235 }
1236
1237 tech_cause = ast_channel_tech_hangupcause(chan);
1238 if (tech_cause) {
1239 ast_json_object_set(blob, "tech_cause", ast_json_integer_create(tech_cause));
1240 }
1241
1243
1244 res = ast_queue_frame(chan, &f);
1245 ast_channel_unlock(chan);
1246 return res;
1247}

References ast_channel_hangup_request_type(), ast_channel_hangupcause(), ast_channel_lock, ast_channel_publish_blob(), ast_channel_softhangup_internal_flag_add(), ast_channel_tech_hangupcause(), ast_channel_unlock, AST_CONTROL_HANGUP, AST_FRAME_CONTROL, ast_json_integer_create(), ast_json_object_set(), ast_json_pack(), ast_json_unref(), ast_queue_frame(), AST_SOFTHANGUP_DEV, ast_frame::data, ast_frame_subclass::integer, NULL, RAII_VAR, ast_frame::subclass, and ast_frame::uint32.

Referenced by __analog_handle_event(), _websocket_request_hangup(), ast_unreal_hangup(), close_call(), close_client(), dahdi_handle_event(), discard_call(), handle_call_outgoing(), jingle_action_session_terminate(), jingle_queue_hangup_with_cause(), onCallCleared(), and transfer_cancel_step2().

◆ ast_queue_hold()

int ast_queue_hold ( struct ast_channel chan,
const char *  musicclass 
)

Queue a hold frame.

Parameters
chanchannel to queue frame onto
musicclassThe suggested musicclass for the other end to use
Note
The channel does not need to be locked before calling this function.
Return values
zeroon success
non-zeroon failure

Definition at line 1249 of file channel.c.

1250{
1252 struct ast_json *blob = NULL;
1253 int res;
1254
1255 if (!ast_strlen_zero(musicclass)) {
1256 f.data.ptr = (void *) musicclass;
1257 f.datalen = strlen(musicclass) + 1;
1258
1259 blob = ast_json_pack("{s: s}",
1260 "musicclass", musicclass);
1261 }
1262
1263 ast_channel_lock(chan);
1265 ast_channel_unlock(chan);
1266
1267 res = ast_queue_frame(chan, &f);
1268
1269 ast_json_unref(blob);
1270
1271 return res;
1272}
struct stasis_message_type * ast_channel_hold_type(void)
Message type for when a channel is placed on hold.

References ast_channel_hold_type(), ast_channel_lock, ast_channel_publish_blob(), ast_channel_unlock, AST_CONTROL_HOLD, AST_FRAME_CONTROL, ast_json_pack(), ast_json_unref(), ast_queue_frame(), ast_strlen_zero(), ast_frame::data, ast_frame::datalen, ast_frame_subclass::integer, NULL, ast_frame::ptr, and ast_frame::subclass.

Referenced by __analog_handle_event(), analog_callwaiting_deluxe(), analog_hangup(), apply_negotiated_sdp_stream(), dahdi_handle_event(), dahdi_hangup(), iax2_queue_hold(), jingle_action_session_info(), sub_hold(), and transfer_call_step1().

◆ ast_queue_unhold()

int ast_queue_unhold ( struct ast_channel chan)

Queue an unhold frame.

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

Definition at line 1274 of file channel.c.

1275{
1277 int res;
1278
1279 ast_channel_lock(chan);
1281 ast_channel_unlock(chan);
1282
1283 res = ast_queue_frame(chan, &f);
1284
1285 return res;
1286}
struct stasis_message_type * ast_channel_unhold_type(void)
Message type for when a channel is removed from hold.

References ast_channel_lock, ast_channel_publish_blob(), ast_channel_unhold_type(), ast_channel_unlock, AST_CONTROL_UNHOLD, AST_FRAME_CONTROL, ast_queue_frame(), ast_frame_subclass::integer, NULL, and ast_frame::subclass.

Referenced by __analog_handle_event(), __analog_ss_thread(), __dahdi_exception(), analog_callwaiting_deluxe(), analog_exception(), analog_hangup(), analog_ss_thread(), apply_negotiated_sdp_stream(), dahdi_handle_event(), dahdi_hangup(), iax2_queue_unhold(), jingle_action_session_info(), key_dial_page(), refer_incoming_invite_request(), session_inv_on_create_offer(), sub_unhold(), transfer_cancel_step2(), and unistim_hangup().

◆ ast_raw_answer()

int ast_raw_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.
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 2724 of file channel.c.

2725{
2727}
int ast_raw_answer_with_stream_topology(struct ast_channel *chan, struct ast_stream_topology *topology)
Answer a channel passing in a stream topology.
Definition channel.c:2672

References ast_raw_answer_with_stream_topology(), and NULL.

Referenced by __ast_answer(), answer_trunk_chan(), app_control_answer(), pbx_builtin_answer(), refer_incoming_invite_request(), and wait_for_answer().

◆ ast_raw_answer_with_stream_topology()

int ast_raw_answer_with_stream_topology ( struct ast_channel chan,
struct ast_stream_topology topology 
)

Answer a channel passing in a stream topology.

Since
18.0.0
Parameters
chanchannel to answer
topologythe peer's stream topology

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.
The topology is usually that of the peer channel and may be NULL.
Return values
0on success
non-zeroon failure

Definition at line 2672 of file channel.c.

2673{
2674 int res = 0;
2675 SCOPE_TRACE(1, "%s\n", ast_channel_name(chan));
2676
2677 ast_channel_lock(chan);
2678
2679 /* You can't answer an outbound call */
2681 ast_channel_unlock(chan);
2682 return 0;
2683 }
2684
2685 /* Stop if we're a zombie or need a soft hangup */
2687 ast_channel_unlock(chan);
2688 return -1;
2689 }
2690
2691 /*
2692 * Mark when incoming channel answered so we can know how
2693 * long the channel has been up.
2694 */
2696
2697 ast_channel_unlock(chan);
2698
2699 switch (ast_channel_state(chan)) {
2700 case AST_STATE_RINGING:
2701 case AST_STATE_RING:
2702 ast_channel_lock(chan);
2703 if (ast_channel_tech(chan)->answer_with_stream_topology) {
2704 res = ast_channel_tech(chan)->answer_with_stream_topology(chan, topology);
2705
2706 } else if (ast_channel_tech(chan)->answer) {
2707 res = ast_channel_tech(chan)->answer(chan);
2708 }
2710 ast_channel_unlock(chan);
2711 break;
2712 case AST_STATE_UP:
2713 /* Fall through */
2714 default:
2715 ast_debug(2, "Skipping answer, since channel state on %s is %s\n", ast_channel_name(chan), ast_state2str(ast_channel_state(chan)));
2716 break;
2717 }
2718
2719 ast_indicate(chan, -1);
2720
2721 return res;
2722}
static int answer(void *data)
Definition chan_pjsip.c:687
int ast_setstate(struct ast_channel *chan, enum ast_channel_state state)
Change the state of a channel.
Definition channel.c:7460
const char * ast_state2str(enum ast_channel_state state)
Gives the string form of a given channel state.
Definition channel.c:637
static void set_channel_answer_time(struct ast_channel *chan)
Definition channel.c:2661
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition channel.c:4332
int(*const answer)(struct ast_channel *chan)
Answer the channel.
Definition channel.h:727
int(*const answer_with_stream_topology)(struct ast_channel *chan, struct ast_stream_topology *topology)
Answer the channel with topology.
Definition channel.h:740

References answer(), ast_channel_tech::answer, ast_channel_tech::answer_with_stream_topology, ast_channel_flags(), ast_channel_lock, ast_channel_name(), ast_channel_unlock, ast_check_hangup(), ast_debug, AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, ast_indicate(), ast_setstate(), ast_state2str(), AST_STATE_RING, AST_STATE_RINGING, AST_STATE_UP, ast_test_flag, SCOPE_TRACE, and set_channel_answer_time().

Referenced by ast_raw_answer(), and pre_bridge_setup().

◆ ast_read()

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.
Note
This function will filter frames received from the channel so that only frames from the default stream for each media type are returned. All other media frames from other streams will be absorbed internally and a NULL frame returned instead.

Definition at line 4312 of file channel.c.

4313{
4314 return __ast_read(chan, 0, 1);
4315}
static struct ast_frame * __ast_read(struct ast_channel *chan, int dropaudio, int dropnondefault)
Definition channel.c:3575

References __ast_read().

Referenced by __adsi_transmit_messages(), __analog_ss_thread(), __ast_answer(), __ast_play_and_record(), __ast_request_and_dial(), adsi_careful_send(), analog_ss_thread(), ast_recvtext(), AST_TEST_DEFINE(), ast_tonepair(), ast_transfer_protocol(), ast_waitfordigit_full(), async_agi_read_frame(), audiosocket_run(), autoservice_run(), background_detect_exec(), channel_spy(), conf_flush(), conf_run(), dial_exec_full(), dial_trunk(), dictate_exec(), disa_exec(), disable_t38(), do_broadcast(), do_waiting(), echo_exec(), eivr_comm(), generic_fax_exec(), handle_recordfile(), handle_speechrecognize(), isAnsweringMachine(), jack_exec(), measurenoise(), moh_channel_thread(), monitor_dial(), mp3_exec(), read_from_chan(), read_mf_digits(), read_sf_digits(), receive_dtmf_digits(), receivefax_t38_init(), record_exec(), recordthread(), run_agi(), safe_sleep_conditional(), scan_exec(), send_waveform_to_channel(), sendfax_t38_init(), speech_background(), stasis_app_exec(), wait_exec(), wait_for_answer(), wait_for_answer(), wait_for_hangup(), wait_for_signal_or_hangup(), wait_for_winner(), waitforring_exec(), and waitstream_core().

◆ ast_read_noaudio()

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

4323{
4324 return __ast_read(chan, 1, 1);
4325}

References __ast_read().

Referenced by ast_control_tone(), and conf_run().

◆ ast_read_stream()

struct ast_frame * ast_read_stream ( struct ast_channel chan)

Reads a frame, but does not filter to just the default streams.

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
This function will not perform any filtering and will return media frames from all streams on the channel. To determine which stream a frame originated from the stream_num on it can be examined.

Definition at line 4317 of file channel.c.

4318{
4319 return __ast_read(chan, 0, 0);
4320}

References __ast_read().

Referenced by AST_TEST_DEFINE(), bridge_handle_trip(), read_from_chan(), and stream_echo_perform().

◆ ast_read_stream_noaudio()

struct ast_frame * ast_read_stream_noaudio ( struct ast_channel chan)

Reads a frame, but does not filter to just the default streams, 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
This function will not perform any filtering and will return media frames from all streams on the channel. To determine which stream a frame originated from the stream_num on it can be examined.
Audio is replaced with AST_FRAME_NULL to avoid transcode when the resulting audio is not necessary.

Definition at line 4327 of file channel.c.

4328{
4329 return __ast_read(chan, 1, 0);
4330}

References __ast_read().

Referenced by bridge_handle_trip().

◆ ast_readstring()

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
Examples
app_skel.c.

Definition at line 6615 of file channel.c.

6616{
6617 return ast_readstring_full(c, s, len, timeout, ftimeout, enders, -1, -1);
6618}
int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int ftimeout, char *enders, int audiofd, int ctrlfd)
Definition channel.c:6620

References ast_readstring_full(), c, and len().

Referenced by __adsi_transmit_messages(), adsi_begin_download(), adsi_get_cpeinfo(), adsi_load_session(), app_exec(), ast_app_getdata_terminator(), dialout(), do_directory(), forward_message(), privacy_exec(), vm_authenticate(), vm_newuser_setup(), and vm_options().

◆ ast_readstring_full()

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

6621{
6622 int pos = 0; /* index in the buffer where we accumulate digits */
6623 int to = ftimeout;
6624
6625 struct ast_silence_generator *silgen = NULL;
6626
6627 /* Stop if we're a zombie or need a soft hangup */
6629 return -1;
6630 if (!len)
6631 return -1;
6632 for (;;) {
6633 int d;
6634 if (ast_channel_stream(c)) {
6635 d = ast_waitstream_full(c, AST_DIGIT_ANY, audiofd, ctrlfd);
6637 if (!silgen && ast_opt_transmit_silence)
6639 usleep(1000);
6640 if (!d)
6641 d = ast_waitfordigit_full(c, to, NULL, audiofd, ctrlfd);
6642 } else {
6643 if (!silgen && ast_opt_transmit_silence)
6645 d = ast_waitfordigit_full(c, to, NULL, audiofd, ctrlfd);
6646 }
6647 if (d < 0) {
6649 return AST_GETDATA_FAILED;
6650 }
6651 if (d == 0) {
6652 s[pos] = '\0';
6654 return AST_GETDATA_TIMEOUT;
6655 }
6656 if (d == 1) {
6657 s[pos] = '\0';
6660 }
6661 if (strchr(enders, d) && (pos == 0)) {
6662 s[pos] = '\0';
6665 }
6666 if (!strchr(enders, d)) {
6667 s[pos++] = d;
6668 }
6669 if (strchr(enders, d) || (pos >= len)) {
6670 s[pos] = '\0';
6672 return AST_GETDATA_COMPLETE;
6673 }
6674 to = timeout;
6675 }
6676 /* Never reached */
6677 return 0;
6678}
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
Definition channel.c:8270
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:8316
int ast_waitfordigit_full(struct ast_channel *c, int timeout_ms, const char *breakon, int audiofd, int cmdfd)
Wait for a digit Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to mon...
Definition channel.c:3278
int ast_waitstream_full(struct ast_channel *c, const char *breakon, int audiofd, int monfd)
Definition file.c:1883
int ast_stopstream(struct ast_channel *c)
Stops a stream.
Definition file.c:223
#define AST_DIGIT_ANY
Definition file.h:48
@ AST_GETDATA_FAILED
@ AST_GETDATA_INTERRUPTED
@ AST_GETDATA_COMPLETE
@ AST_GETDATA_TIMEOUT
@ AST_GETDATA_EMPTY_END_TERMINATED
#define ast_opt_transmit_silence
Definition options.h:134
static struct test_val d

References ast_channel_flags(), ast_channel_start_silence_generator(), ast_channel_stop_silence_generator(), ast_channel_stream(), 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(), c, d, len(), and NULL.

Referenced by ast_app_getdata_full(), and ast_readstring().

◆ ast_recvchar()

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

4764{
4765 int c;
4766 char *buf = ast_recvtext(chan, timeout);
4767 if (buf == NULL)
4768 return -1; /* error or timeout */
4769 c = *(unsigned char *)buf;
4770 ast_free(buf);
4771 return c;
4772}
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:4774

References ast_free, ast_recvtext(), buf, c, and NULL.

Referenced by handle_recvchar().

◆ ast_recvtext()

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

4775{
4776 int res;
4777 char *buf = NULL;
4778 struct timeval start = ast_tvnow();
4779 int ms;
4780
4781 while ((ms = ast_remaining_ms(start, timeout))) {
4782 struct ast_frame *f;
4783
4784 if (ast_check_hangup(chan)) {
4785 break;
4786 }
4787 res = ast_waitfor(chan, ms);
4788 if (res <= 0) {/* timeout or error */
4789 break;
4790 }
4791 f = ast_read(chan);
4792 if (f == NULL) {
4793 break; /* no frame */
4794 }
4796 ast_frfree(f);
4797 break;
4798 } else if (f->frametype == AST_FRAME_TEXT) { /* what we want */
4799 buf = ast_strndup((char *) f->data.ptr, f->datalen); /* dup and break */
4800 ast_frfree(f);
4801 break;
4802 }
4803 ast_frfree(f);
4804 }
4805 return buf;
4806}
#define ast_strndup(str, len)
A wrapper for strndup()
Definition astmm.h:256

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(), buf, ast_frame::data, ast_frame::datalen, ast_frame::frametype, ast_frame_subclass::integer, NULL, ast_frame::ptr, and ast_frame::subclass.

Referenced by ast_recvchar(), handle_recvtext(), and recvtext_exec().

◆ ast_redirecting_build_data()

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

9375{
9376 int32_t value;
9377 size_t pos = 0;
9378 int res;
9379
9380 static const struct ast_party_id_ies orig_ies = {
9382 .name.char_set = AST_REDIRECTING_ORIG_NAME_CHAR_SET,
9383 .name.presentation = AST_REDIRECTING_ORIG_NAME_PRESENTATION,
9384 .name.valid = AST_REDIRECTING_ORIG_NAME_VALID,
9385
9386 .number.str = AST_REDIRECTING_ORIG_NUMBER,
9387 .number.plan = AST_REDIRECTING_ORIG_NUMBER_PLAN,
9388 .number.presentation = AST_REDIRECTING_ORIG_NUMBER_PRESENTATION,
9389 .number.valid = AST_REDIRECTING_ORIG_NUMBER_VALID,
9390
9391 .subaddress.str = AST_REDIRECTING_ORIG_SUBADDRESS,
9392 .subaddress.type = AST_REDIRECTING_ORIG_SUBADDRESS_TYPE,
9393 .subaddress.odd_even_indicator = AST_REDIRECTING_ORIG_SUBADDRESS_ODD_EVEN,
9394 .subaddress.valid = AST_REDIRECTING_ORIG_SUBADDRESS_VALID,
9395
9397 .combined_presentation = 0,/* Not sent. */
9398 };
9399 static const struct ast_party_id_ies from_ies = {
9401 .name.char_set = AST_REDIRECTING_FROM_NAME_CHAR_SET,
9402 .name.presentation = AST_REDIRECTING_FROM_NAME_PRESENTATION,
9403 .name.valid = AST_REDIRECTING_FROM_NAME_VALID,
9404
9405 .number.str = AST_REDIRECTING_FROM_NUMBER,
9406 .number.plan = AST_REDIRECTING_FROM_NUMBER_PLAN,
9407 .number.presentation = AST_REDIRECTING_FROM_NUMBER_PRESENTATION,
9408 .number.valid = AST_REDIRECTING_FROM_NUMBER_VALID,
9409
9410 .subaddress.str = AST_REDIRECTING_FROM_SUBADDRESS,
9411 .subaddress.type = AST_REDIRECTING_FROM_SUBADDRESS_TYPE,
9412 .subaddress.odd_even_indicator = AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN,
9413 .subaddress.valid = AST_REDIRECTING_FROM_SUBADDRESS_VALID,
9414
9416 .combined_presentation = AST_REDIRECTING_FROM_ID_PRESENTATION,
9417 };
9418 static const struct ast_party_id_ies to_ies = {
9420 .name.char_set = AST_REDIRECTING_TO_NAME_CHAR_SET,
9421 .name.presentation = AST_REDIRECTING_TO_NAME_PRESENTATION,
9422 .name.valid = AST_REDIRECTING_TO_NAME_VALID,
9423
9424 .number.str = AST_REDIRECTING_TO_NUMBER,
9425 .number.plan = AST_REDIRECTING_TO_NUMBER_PLAN,
9426 .number.presentation = AST_REDIRECTING_TO_NUMBER_PRESENTATION,
9427 .number.valid = AST_REDIRECTING_TO_NUMBER_VALID,
9428
9429 .subaddress.str = AST_REDIRECTING_TO_SUBADDRESS,
9430 .subaddress.type = AST_REDIRECTING_TO_SUBADDRESS_TYPE,
9431 .subaddress.odd_even_indicator = AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN,
9432 .subaddress.valid = AST_REDIRECTING_TO_SUBADDRESS_VALID,
9433
9435 .combined_presentation = AST_REDIRECTING_TO_ID_PRESENTATION,
9436 };
9437 static const struct ast_party_id_ies priv_orig_ies = {
9442
9445 .number.presentation = AST_REDIRECTING_PRIV_ORIG_NUMBER_PRESENTATION,
9447
9448 .subaddress.str = AST_REDIRECTING_PRIV_ORIG_SUBADDRESS,
9450 .subaddress.odd_even_indicator = AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_ODD_EVEN,
9452
9454 .combined_presentation = 0,/* Not sent. */
9455 };
9456 static const struct ast_party_id_ies priv_from_ies = {
9461
9464 .number.presentation = AST_REDIRECTING_PRIV_FROM_NUMBER_PRESENTATION,
9466
9467 .subaddress.str = AST_REDIRECTING_PRIV_FROM_SUBADDRESS,
9469 .subaddress.odd_even_indicator = AST_REDIRECTING_PRIV_FROM_SUBADDRESS_ODD_EVEN,
9471
9473 .combined_presentation = 0,/* Not sent. */
9474 };
9475 static const struct ast_party_id_ies priv_to_ies = {
9478 .name.presentation = AST_REDIRECTING_PRIV_TO_NAME_PRESENTATION,
9480
9481 .number.str = AST_REDIRECTING_PRIV_TO_NUMBER,
9483 .number.presentation = AST_REDIRECTING_PRIV_TO_NUMBER_PRESENTATION,
9485
9486 .subaddress.str = AST_REDIRECTING_PRIV_TO_SUBADDRESS,
9487 .subaddress.type = AST_REDIRECTING_PRIV_TO_SUBADDRESS_TYPE,
9488 .subaddress.odd_even_indicator = AST_REDIRECTING_PRIV_TO_SUBADDRESS_ODD_EVEN,
9489 .subaddress.valid = AST_REDIRECTING_PRIV_TO_SUBADDRESS_VALID,
9490
9492 .combined_presentation = 0,/* Not sent. */
9493 };
9494 static const struct ast_party_redirecting_reason_ies reason_ies = {
9497 };
9498
9499 static const struct ast_party_redirecting_reason_ies orig_reason_ies = {
9502 };
9503
9504 /* Redirecting frame version */
9505 if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
9506 ast_log(LOG_WARNING, "No space left for redirecting frame version\n");
9507 return -1;
9508 }
9509 data[pos++] = AST_REDIRECTING_VERSION;
9510 data[pos++] = 1;
9511 data[pos++] = 2;/* Version 1 did not have a version ie */
9512
9513 res = party_id_build_data(data + pos, datalen - pos, &redirecting->orig,
9514 "redirecting-orig", &orig_ies, update ? &update->orig : NULL);
9515 if (res < 0) {
9516 return -1;
9517 }
9518 pos += res;
9519
9520 res = party_id_build_data(data + pos, datalen - pos, &redirecting->from,
9521 "redirecting-from", &from_ies, update ? &update->from : NULL);
9522 if (res < 0) {
9523 return -1;
9524 }
9525 pos += res;
9526
9527 res = party_id_build_data(data + pos, datalen - pos, &redirecting->to,
9528 "redirecting-to", &to_ies, update ? &update->to : NULL);
9529 if (res < 0) {
9530 return -1;
9531 }
9532 pos += res;
9533
9534 res = party_id_build_data(data + pos, datalen - pos, &redirecting->priv_orig,
9535 "redirecting-priv-orig", &priv_orig_ies, update ? &update->priv_orig : NULL);
9536 if (res < 0) {
9537 return -1;
9538 }
9539 pos += res;
9540
9541 res = party_id_build_data(data + pos, datalen - pos, &redirecting->priv_from,
9542 "redirecting-priv-from", &priv_from_ies, update ? &update->priv_from : NULL);
9543 if (res < 0) {
9544 return -1;
9545 }
9546 pos += res;
9547
9548 res = party_id_build_data(data + pos, datalen - pos, &redirecting->priv_to,
9549 "redirecting-priv-to", &priv_to_ies, update ? &update->priv_to : NULL);
9550 if (res < 0) {
9551 return -1;
9552 }
9553 pos += res;
9554
9555 /* Redirecting reason */
9556 res = redirecting_reason_build_data(data + pos, datalen - pos, &redirecting->reason,
9557 "redirecting-reason", &reason_ies);
9558 if (res < 0) {
9559 return -1;
9560 }
9561 pos += res;
9562
9563 /* Redirecting original reason */
9564 res = redirecting_reason_build_data(data + pos, datalen - pos, &redirecting->orig_reason,
9565 "redirecting-orig-reason", &orig_reason_ies);
9566 if (res < 0) {
9567 return -1;
9568 }
9569 pos += res;
9570
9571 /* Redirecting count */
9572 if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) {
9573 ast_log(LOG_WARNING, "No space left for redirecting count\n");
9574 return -1;
9575 }
9576 data[pos++] = AST_REDIRECTING_COUNT;
9577 data[pos++] = sizeof(value);
9578 value = htonl(redirecting->count);
9579 memcpy(data + pos, &value, sizeof(value));
9580 pos += sizeof(value);
9581
9582 return pos;
9583}
@ AST_REDIRECTING_FROM_NAME_PRESENTATION
Definition channel.c:9271
@ AST_REDIRECTING_TO_NAME
Definition channel.c:9249
@ AST_REDIRECTING_VERSION
Definition channel.c:9264
@ AST_REDIRECTING_PRIV_FROM_NAME_VALID
Definition channel.c:9311
@ AST_REDIRECTING_PRIV_FROM_SUBADDRESS_ODD_EVEN
Definition channel.c:9316
@ AST_REDIRECTING_TO_TAG
Definition channel.c:9263
@ AST_REDIRECTING_FROM_NUMBER_PLAN
Definition channel.c:9246
@ AST_REDIRECTING_PRIV_TO_NAME_VALID
Definition channel.c:9298
@ AST_REDIRECTING_ORIG_TAG
Definition channel.c:9291
@ AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_ODD_EVEN
Definition channel.c:9329
@ AST_REDIRECTING_REASON_CODE
Definition channel.c:9252
@ AST_REDIRECTING_PRIV_TO_NUMBER_VALID
Definition channel.c:9295
@ AST_REDIRECTING_PRIV_TO_NUMBER_PRESENTATION
Definition channel.c:9296
@ AST_REDIRECTING_ORIG_REASON_CODE
Definition channel.c:9292
@ AST_REDIRECTING_TO_NAME_PRESENTATION
Definition channel.c:9276
@ AST_REDIRECTING_PRIV_TO_NAME
Definition channel.c:9297
@ AST_REDIRECTING_PRIV_ORIG_NAME_VALID
Definition channel.c:9324
@ AST_REDIRECTING_ORIG_NUMBER_VALID
Definition channel.c:9280
@ AST_REDIRECTING_FROM_NUMBER_PRESENTATION
Definition channel.c:9273
@ AST_REDIRECTING_ORIG_SUBADDRESS_VALID
Definition channel.c:9290
@ AST_REDIRECTING_FROM_NUMBER_VALID
Definition channel.c:9272
@ AST_REDIRECTING_TO_NAME_VALID
Definition channel.c:9274
@ AST_REDIRECTING_PRIV_FROM_NAME
Definition channel.c:9310
@ AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN
Definition channel.c:9260
@ AST_REDIRECTING_ORIG_SUBADDRESS_ODD_EVEN
Definition channel.c:9289
@ AST_REDIRECTING_PRIV_FROM_SUBADDRESS_TYPE
Definition channel.c:9315
@ AST_REDIRECTING_PRIV_TO_SUBADDRESS_VALID
Definition channel.c:9304
@ AST_REDIRECTING_PRIV_TO_SUBADDRESS_ODD_EVEN
Definition channel.c:9303
@ AST_REDIRECTING_ORIG_NAME_CHAR_SET
Definition channel.c:9285
@ AST_REDIRECTING_PRIV_FROM_SUBADDRESS
Definition channel.c:9314
@ AST_REDIRECTING_TO_NUMBER_PLAN
Definition channel.c:9250
@ AST_REDIRECTING_PRIV_TO_NUMBER
Definition channel.c:9293
@ AST_REDIRECTING_PRIV_FROM_NUMBER_VALID
Definition channel.c:9308
@ AST_REDIRECTING_ORIG_NAME
Definition channel.c:9283
@ AST_REDIRECTING_ORIG_SUBADDRESS
Definition channel.c:9287
@ AST_REDIRECTING_FROM_TAG
Definition channel.c:9262
@ AST_REDIRECTING_PRIV_ORIG_NUMBER_PLAN
Definition channel.c:9321
@ AST_REDIRECTING_TO_NUMBER
Definition channel.c:9248
@ AST_REDIRECTING_ORIG_SUBADDRESS_TYPE
Definition channel.c:9288
@ AST_REDIRECTING_FROM_NAME_CHAR_SET
Definition channel.c:9270
@ AST_REDIRECTING_PRIV_FROM_TAG
Definition channel.c:9318
@ AST_REDIRECTING_FROM_ID_PRESENTATION
Definition channel.c:9247
@ AST_REDIRECTING_PRIV_FROM_NUMBER
Definition channel.c:9306
@ AST_REDIRECTING_PRIV_TO_NUMBER_PLAN
Definition channel.c:9294
@ AST_REDIRECTING_TO_NUMBER_VALID
Definition channel.c:9277
@ AST_REDIRECTING_FROM_SUBADDRESS_VALID
Definition channel.c:9257
@ AST_REDIRECTING_FROM_NAME_VALID
Definition channel.c:9269
@ AST_REDIRECTING_PRIV_TO_NAME_CHAR_SET
Definition channel.c:9299
@ AST_REDIRECTING_PRIV_ORIG_TAG
Definition channel.c:9331
@ AST_REDIRECTING_FROM_SUBADDRESS_TYPE
Definition channel.c:9255
@ AST_REDIRECTING_PRIV_TO_TAG
Definition channel.c:9305
@ AST_REDIRECTING_COUNT
Definition channel.c:9253
@ AST_REDIRECTING_FROM_SUBADDRESS
Definition channel.c:9254
@ AST_REDIRECTING_PRIV_ORIG_NAME_CHAR_SET
Definition channel.c:9325
@ AST_REDIRECTING_ORIG_NAME_VALID
Definition channel.c:9284
@ AST_REDIRECTING_TO_ID_PRESENTATION
Definition channel.c:9251
@ AST_REDIRECTING_PRIV_FROM_NUMBER_PLAN
Definition channel.c:9307
@ AST_REDIRECTING_PRIV_TO_NAME_PRESENTATION
Definition channel.c:9300
@ AST_REDIRECTING_PRIV_FROM_NUMBER_PRESENTATION
Definition channel.c:9309
@ AST_REDIRECTING_PRIV_FROM_NAME_PRESENTATION
Definition channel.c:9313
@ AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_TYPE
Definition channel.c:9328
@ AST_REDIRECTING_ORIG_REASON_STR
Definition channel.c:9333
@ AST_REDIRECTING_ORIG_NAME_PRESENTATION
Definition channel.c:9286
@ AST_REDIRECTING_PRIV_FROM_NAME_CHAR_SET
Definition channel.c:9312
@ AST_REDIRECTING_ORIG_NUMBER
Definition channel.c:9279
@ AST_REDIRECTING_PRIV_ORIG_NAME
Definition channel.c:9323
@ AST_REDIRECTING_PRIV_TO_SUBADDRESS_TYPE
Definition channel.c:9302
@ AST_REDIRECTING_PRIV_ORIG_NUMBER_VALID
Definition channel.c:9320
@ AST_REDIRECTING_PRIV_ORIG_NUMBER_PRESENTATION
Definition channel.c:9322
@ AST_REDIRECTING_TO_SUBADDRESS_VALID
Definition channel.c:9261
@ AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_VALID
Definition channel.c:9330
@ AST_REDIRECTING_TO_SUBADDRESS_TYPE
Definition channel.c:9259
@ AST_REDIRECTING_REASON_STR
Definition channel.c:9332
@ AST_REDIRECTING_FROM_NAME
Definition channel.c:9245
@ AST_REDIRECTING_PRIV_ORIG_NUMBER
Definition channel.c:9319
@ AST_REDIRECTING_PRIV_FROM_SUBADDRESS_VALID
Definition channel.c:9317
@ AST_REDIRECTING_ORIG_NUMBER_PRESENTATION
Definition channel.c:9282
@ AST_REDIRECTING_PRIV_TO_SUBADDRESS
Definition channel.c:9301
@ AST_REDIRECTING_PRIV_ORIG_NAME_PRESENTATION
Definition channel.c:9326
@ AST_REDIRECTING_TO_NUMBER_PRESENTATION
Definition channel.c:9278
@ AST_REDIRECTING_FROM_NUMBER
Definition channel.c:9244
@ AST_REDIRECTING_ORIG_NUMBER_PLAN
Definition channel.c:9281
@ AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN
Definition channel.c:9256
@ AST_REDIRECTING_PRIV_ORIG_SUBADDRESS
Definition channel.c:9327
@ AST_REDIRECTING_TO_SUBADDRESS
Definition channel.c:9258
@ AST_REDIRECTING_TO_NAME_CHAR_SET
Definition channel.c:9275
static int redirecting_reason_build_data(unsigned char *data, size_t datalen, const struct ast_party_redirecting_reason *reason, const char *label, const struct ast_party_redirecting_reason_ies *ies)
Definition channel.c:9341

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_ORIG_NAME, AST_REDIRECTING_ORIG_NAME_CHAR_SET, AST_REDIRECTING_ORIG_NAME_PRESENTATION, AST_REDIRECTING_ORIG_NAME_VALID, AST_REDIRECTING_ORIG_NUMBER, AST_REDIRECTING_ORIG_NUMBER_PLAN, AST_REDIRECTING_ORIG_NUMBER_PRESENTATION, AST_REDIRECTING_ORIG_NUMBER_VALID, AST_REDIRECTING_ORIG_REASON_CODE, AST_REDIRECTING_ORIG_REASON_STR, AST_REDIRECTING_ORIG_SUBADDRESS, AST_REDIRECTING_ORIG_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_ORIG_SUBADDRESS_TYPE, AST_REDIRECTING_ORIG_SUBADDRESS_VALID, AST_REDIRECTING_ORIG_TAG, AST_REDIRECTING_PRIV_FROM_NAME, AST_REDIRECTING_PRIV_FROM_NAME_CHAR_SET, AST_REDIRECTING_PRIV_FROM_NAME_PRESENTATION, AST_REDIRECTING_PRIV_FROM_NAME_VALID, AST_REDIRECTING_PRIV_FROM_NUMBER, AST_REDIRECTING_PRIV_FROM_NUMBER_PLAN, AST_REDIRECTING_PRIV_FROM_NUMBER_PRESENTATION, AST_REDIRECTING_PRIV_FROM_NUMBER_VALID, AST_REDIRECTING_PRIV_FROM_SUBADDRESS, AST_REDIRECTING_PRIV_FROM_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_PRIV_FROM_SUBADDRESS_TYPE, AST_REDIRECTING_PRIV_FROM_SUBADDRESS_VALID, AST_REDIRECTING_PRIV_FROM_TAG, AST_REDIRECTING_PRIV_ORIG_NAME, AST_REDIRECTING_PRIV_ORIG_NAME_CHAR_SET, AST_REDIRECTING_PRIV_ORIG_NAME_PRESENTATION, AST_REDIRECTING_PRIV_ORIG_NAME_VALID, AST_REDIRECTING_PRIV_ORIG_NUMBER, AST_REDIRECTING_PRIV_ORIG_NUMBER_PLAN, AST_REDIRECTING_PRIV_ORIG_NUMBER_PRESENTATION, AST_REDIRECTING_PRIV_ORIG_NUMBER_VALID, AST_REDIRECTING_PRIV_ORIG_SUBADDRESS, AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_TYPE, AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_VALID, AST_REDIRECTING_PRIV_ORIG_TAG, AST_REDIRECTING_PRIV_TO_NAME, AST_REDIRECTING_PRIV_TO_NAME_CHAR_SET, AST_REDIRECTING_PRIV_TO_NAME_PRESENTATION, AST_REDIRECTING_PRIV_TO_NAME_VALID, AST_REDIRECTING_PRIV_TO_NUMBER, AST_REDIRECTING_PRIV_TO_NUMBER_PLAN, AST_REDIRECTING_PRIV_TO_NUMBER_PRESENTATION, AST_REDIRECTING_PRIV_TO_NUMBER_VALID, AST_REDIRECTING_PRIV_TO_SUBADDRESS, AST_REDIRECTING_PRIV_TO_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_PRIV_TO_SUBADDRESS_TYPE, AST_REDIRECTING_PRIV_TO_SUBADDRESS_VALID, AST_REDIRECTING_PRIV_TO_TAG, AST_REDIRECTING_REASON_CODE, AST_REDIRECTING_REASON_STR, 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_reason_ies::code, ast_party_redirecting::count, ast_party_redirecting::from, LOG_WARNING, ast_party_id_ies::name, NULL, ast_party_redirecting::orig, ast_party_redirecting::orig_reason, party_id_build_data(), ast_party_redirecting::priv_from, ast_party_redirecting::priv_orig, ast_party_redirecting::priv_to, ast_party_redirecting::reason, redirecting_reason_build_data(), ast_party_name_ies::str, ast_party_redirecting::to, update(), and value.

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

◆ ast_redirecting_parse_data()

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

9586{
9587 size_t pos;
9588 unsigned char ie_len;
9589 unsigned char ie_id;
9590 int32_t value;
9591 int frame_version = 1;
9592 int from_combined_presentation = 0;
9593 int got_from_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
9594 int to_combined_presentation = 0;
9595 int got_to_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
9596
9597 for (pos = 0; pos < datalen; pos += ie_len) {
9598 if (datalen < pos + sizeof(ie_id) + sizeof(ie_len)) {
9599 ast_log(LOG_WARNING, "Invalid redirecting update\n");
9600 return -1;
9601 }
9602 ie_id = data[pos++];
9603 ie_len = data[pos++];
9604 if (datalen < pos + ie_len) {
9605 ast_log(LOG_WARNING, "Invalid redirecting update\n");
9606 return -1;
9607 }
9608
9609 switch (ie_id) {
9610/* Redirecting frame version */
9612 if (ie_len != 1) {
9613 ast_log(LOG_WARNING, "Invalid redirecting frame version (%u)\n",
9614 (unsigned) ie_len);
9615 break;
9616 }
9617 frame_version = data[pos];
9618 break;
9619/* Redirecting-orig party id name */
9621 ast_free(redirecting->orig.name.str);
9622 redirecting->orig.name.str = ast_malloc(ie_len + 1);
9623 if (redirecting->orig.name.str) {
9624 memcpy(redirecting->orig.name.str, data + pos, ie_len);
9625 redirecting->orig.name.str[ie_len] = 0;
9626 }
9627 break;
9629 if (ie_len != 1) {
9630 ast_log(LOG_WARNING, "Invalid redirecting-orig name char set (%u)\n",
9631 (unsigned) ie_len);
9632 break;
9633 }
9634 redirecting->orig.name.char_set = data[pos];
9635 break;
9637 if (ie_len != 1) {
9638 ast_log(LOG_WARNING, "Invalid redirecting-orig name presentation (%u)\n",
9639 (unsigned) ie_len);
9640 break;
9641 }
9642 redirecting->orig.name.presentation = data[pos];
9643 break;
9645 if (ie_len != 1) {
9646 ast_log(LOG_WARNING, "Invalid redirecting-orig name valid (%u)\n",
9647 (unsigned) ie_len);
9648 break;
9649 }
9650 redirecting->orig.name.valid = data[pos];
9651 break;
9652/* Redirecting-orig party id number */
9654 ast_free(redirecting->orig.number.str);
9655 redirecting->orig.number.str = ast_malloc(ie_len + 1);
9656 if (redirecting->orig.number.str) {
9657 memcpy(redirecting->orig.number.str, data + pos, ie_len);
9658 redirecting->orig.number.str[ie_len] = 0;
9659 }
9660 break;
9662 if (ie_len != 1) {
9663 ast_log(LOG_WARNING, "Invalid redirecting-orig numbering plan (%u)\n",
9664 (unsigned) ie_len);
9665 break;
9666 }
9667 redirecting->orig.number.plan = data[pos];
9668 break;
9670 if (ie_len != 1) {
9671 ast_log(LOG_WARNING, "Invalid redirecting-orig number presentation (%u)\n",
9672 (unsigned) ie_len);
9673 break;
9674 }
9675 redirecting->orig.number.presentation = data[pos];
9676 break;
9678 if (ie_len != 1) {
9679 ast_log(LOG_WARNING, "Invalid redirecting-orig number valid (%u)\n",
9680 (unsigned) ie_len);
9681 break;
9682 }
9683 redirecting->orig.number.valid = data[pos];
9684 break;
9685/* Redirecting-orig party id subaddress */
9687 ast_free(redirecting->orig.subaddress.str);
9688 redirecting->orig.subaddress.str = ast_malloc(ie_len + 1);
9689 if (redirecting->orig.subaddress.str) {
9690 memcpy(redirecting->orig.subaddress.str, data + pos, ie_len);
9691 redirecting->orig.subaddress.str[ie_len] = 0;
9692 }
9693 break;
9695 if (ie_len != 1) {
9696 ast_log(LOG_WARNING, "Invalid redirecting-orig type of subaddress (%u)\n",
9697 (unsigned) ie_len);
9698 break;
9699 }
9700 redirecting->orig.subaddress.type = data[pos];
9701 break;
9703 if (ie_len != 1) {
9705 "Invalid redirecting-orig subaddress odd-even indicator (%u)\n",
9706 (unsigned) ie_len);
9707 break;
9708 }
9709 redirecting->orig.subaddress.odd_even_indicator = data[pos];
9710 break;
9712 if (ie_len != 1) {
9713 ast_log(LOG_WARNING, "Invalid redirecting-orig subaddress valid (%u)\n",
9714 (unsigned) ie_len);
9715 break;
9716 }
9717 redirecting->orig.subaddress.valid = data[pos];
9718 break;
9719/* Redirecting-orig party id tag */
9721 ast_free(redirecting->orig.tag);
9722 redirecting->orig.tag = ast_malloc(ie_len + 1);
9723 if (redirecting->orig.tag) {
9724 memcpy(redirecting->orig.tag, data + pos, ie_len);
9725 redirecting->orig.tag[ie_len] = 0;
9726 }
9727 break;
9728/* Redirecting-from party id name */
9730 ast_free(redirecting->from.name.str);
9731 redirecting->from.name.str = ast_malloc(ie_len + 1);
9732 if (redirecting->from.name.str) {
9733 memcpy(redirecting->from.name.str, data + pos, ie_len);
9734 redirecting->from.name.str[ie_len] = 0;
9735 }
9736 break;
9738 if (ie_len != 1) {
9739 ast_log(LOG_WARNING, "Invalid redirecting-from name char set (%u)\n",
9740 (unsigned) ie_len);
9741 break;
9742 }
9743 redirecting->from.name.char_set = data[pos];
9744 break;
9746 if (ie_len != 1) {
9747 ast_log(LOG_WARNING, "Invalid redirecting-from name presentation (%u)\n",
9748 (unsigned) ie_len);
9749 break;
9750 }
9751 redirecting->from.name.presentation = data[pos];
9752 break;
9754 if (ie_len != 1) {
9755 ast_log(LOG_WARNING, "Invalid redirecting-from name valid (%u)\n",
9756 (unsigned) ie_len);
9757 break;
9758 }
9759 redirecting->from.name.valid = data[pos];
9760 break;
9761/* Redirecting-from party id number */
9763 ast_free(redirecting->from.number.str);
9764 redirecting->from.number.str = ast_malloc(ie_len + 1);
9765 if (redirecting->from.number.str) {
9766 memcpy(redirecting->from.number.str, data + pos, ie_len);
9767 redirecting->from.number.str[ie_len] = 0;
9768 }
9769 break;
9771 if (ie_len != 1) {
9772 ast_log(LOG_WARNING, "Invalid redirecting-from numbering plan (%u)\n",
9773 (unsigned) ie_len);
9774 break;
9775 }
9776 redirecting->from.number.plan = data[pos];
9777 break;
9779 if (ie_len != 1) {
9780 ast_log(LOG_WARNING, "Invalid redirecting-from number presentation (%u)\n",
9781 (unsigned) ie_len);
9782 break;
9783 }
9784 redirecting->from.number.presentation = data[pos];
9785 break;
9787 if (ie_len != 1) {
9788 ast_log(LOG_WARNING, "Invalid redirecting-from number valid (%u)\n",
9789 (unsigned) ie_len);
9790 break;
9791 }
9792 redirecting->from.number.valid = data[pos];
9793 break;
9794/* Redirecting-from party id combined presentation */
9796 if (ie_len != 1) {
9797 ast_log(LOG_WARNING, "Invalid redirecting-from combined presentation (%u)\n",
9798 (unsigned) ie_len);
9799 break;
9800 }
9801 from_combined_presentation = data[pos];
9802 got_from_combined_presentation = 1;
9803 break;
9804/* Redirecting-from party id subaddress */
9806 ast_free(redirecting->from.subaddress.str);
9807 redirecting->from.subaddress.str = ast_malloc(ie_len + 1);
9808 if (redirecting->from.subaddress.str) {
9809 memcpy(redirecting->from.subaddress.str, data + pos, ie_len);
9810 redirecting->from.subaddress.str[ie_len] = 0;
9811 }
9812 break;
9814 if (ie_len != 1) {
9815 ast_log(LOG_WARNING, "Invalid redirecting-from type of subaddress (%u)\n",
9816 (unsigned) ie_len);
9817 break;
9818 }
9819 redirecting->from.subaddress.type = data[pos];
9820 break;
9822 if (ie_len != 1) {
9824 "Invalid redirecting-from subaddress odd-even indicator (%u)\n",
9825 (unsigned) ie_len);
9826 break;
9827 }
9828 redirecting->from.subaddress.odd_even_indicator = data[pos];
9829 break;
9831 if (ie_len != 1) {
9832 ast_log(LOG_WARNING, "Invalid redirecting-from subaddress valid (%u)\n",
9833 (unsigned) ie_len);
9834 break;
9835 }
9836 redirecting->from.subaddress.valid = data[pos];
9837 break;
9838/* Redirecting-from party id tag */
9840 ast_free(redirecting->from.tag);
9841 redirecting->from.tag = ast_malloc(ie_len + 1);
9842 if (redirecting->from.tag) {
9843 memcpy(redirecting->from.tag, data + pos, ie_len);
9844 redirecting->from.tag[ie_len] = 0;
9845 }
9846 break;
9847/* Redirecting-to party id name */
9849 ast_free(redirecting->to.name.str);
9850 redirecting->to.name.str = ast_malloc(ie_len + 1);
9851 if (redirecting->to.name.str) {
9852 memcpy(redirecting->to.name.str, data + pos, ie_len);
9853 redirecting->to.name.str[ie_len] = 0;
9854 }
9855 break;
9857 if (ie_len != 1) {
9858 ast_log(LOG_WARNING, "Invalid redirecting-to name char set (%u)\n",
9859 (unsigned) ie_len);
9860 break;
9861 }
9862 redirecting->to.name.char_set = data[pos];
9863 break;
9865 if (ie_len != 1) {
9866 ast_log(LOG_WARNING, "Invalid redirecting-to name presentation (%u)\n",
9867 (unsigned) ie_len);
9868 break;
9869 }
9870 redirecting->to.name.presentation = data[pos];
9871 break;
9873 if (ie_len != 1) {
9874 ast_log(LOG_WARNING, "Invalid redirecting-to name valid (%u)\n",
9875 (unsigned) ie_len);
9876 break;
9877 }
9878 redirecting->to.name.valid = data[pos];
9879 break;
9880/* Redirecting-to party id number */
9882 ast_free(redirecting->to.number.str);
9883 redirecting->to.number.str = ast_malloc(ie_len + 1);
9884 if (redirecting->to.number.str) {
9885 memcpy(redirecting->to.number.str, data + pos, ie_len);
9886 redirecting->to.number.str[ie_len] = 0;
9887 }
9888 break;
9890 if (ie_len != 1) {
9891 ast_log(LOG_WARNING, "Invalid redirecting-to numbering plan (%u)\n",
9892 (unsigned) ie_len);
9893 break;
9894 }
9895 redirecting->to.number.plan = data[pos];
9896 break;
9898 if (ie_len != 1) {
9899 ast_log(LOG_WARNING, "Invalid redirecting-to number presentation (%u)\n",
9900 (unsigned) ie_len);
9901 break;
9902 }
9903 redirecting->to.number.presentation = data[pos];
9904 break;
9906 if (ie_len != 1) {
9907 ast_log(LOG_WARNING, "Invalid redirecting-to number valid (%u)\n",
9908 (unsigned) ie_len);
9909 break;
9910 }
9911 redirecting->to.number.valid = data[pos];
9912 break;
9913/* Redirecting-to party id combined presentation */
9915 if (ie_len != 1) {
9916 ast_log(LOG_WARNING, "Invalid redirecting-to combined presentation (%u)\n",
9917 (unsigned) ie_len);
9918 break;
9919 }
9920 to_combined_presentation = data[pos];
9921 got_to_combined_presentation = 1;
9922 break;
9923/* Redirecting-to party id subaddress */
9925 ast_free(redirecting->to.subaddress.str);
9926 redirecting->to.subaddress.str = ast_malloc(ie_len + 1);
9927 if (redirecting->to.subaddress.str) {
9928 memcpy(redirecting->to.subaddress.str, data + pos, ie_len);
9929 redirecting->to.subaddress.str[ie_len] = 0;
9930 }
9931 break;
9933 if (ie_len != 1) {
9934 ast_log(LOG_WARNING, "Invalid redirecting-to type of subaddress (%u)\n",
9935 (unsigned) ie_len);
9936 break;
9937 }
9938 redirecting->to.subaddress.type = data[pos];
9939 break;
9941 if (ie_len != 1) {
9943 "Invalid redirecting-to subaddress odd-even indicator (%u)\n",
9944 (unsigned) ie_len);
9945 break;
9946 }
9947 redirecting->to.subaddress.odd_even_indicator = data[pos];
9948 break;
9950 if (ie_len != 1) {
9951 ast_log(LOG_WARNING, "Invalid redirecting-to subaddress valid (%u)\n",
9952 (unsigned) ie_len);
9953 break;
9954 }
9955 redirecting->to.subaddress.valid = data[pos];
9956 break;
9957/* Redirecting-to party id tag */
9959 ast_free(redirecting->to.tag);
9960 redirecting->to.tag = ast_malloc(ie_len + 1);
9961 if (redirecting->to.tag) {
9962 memcpy(redirecting->to.tag, data + pos, ie_len);
9963 redirecting->to.tag[ie_len] = 0;
9964 }
9965 break;
9966/* Private redirecting-orig party id name */
9968 ast_free(redirecting->priv_orig.name.str);
9969 redirecting->priv_orig.name.str = ast_malloc(ie_len + 1);
9970 if (redirecting->priv_orig.name.str) {
9971 memcpy(redirecting->priv_orig.name.str, data + pos, ie_len);
9972 redirecting->priv_orig.name.str[ie_len] = 0;
9973 }
9974 break;
9976 if (ie_len != 1) {
9977 ast_log(LOG_WARNING, "Invalid private redirecting-orig name char set (%u)\n",
9978 (unsigned) ie_len);
9979 break;
9980 }
9981 redirecting->priv_orig.name.char_set = data[pos];
9982 break;
9984 if (ie_len != 1) {
9985 ast_log(LOG_WARNING, "Invalid private redirecting-orig name presentation (%u)\n",
9986 (unsigned) ie_len);
9987 break;
9988 }
9989 redirecting->priv_orig.name.presentation = data[pos];
9990 break;
9992 if (ie_len != 1) {
9993 ast_log(LOG_WARNING, "Invalid private redirecting-orig name valid (%u)\n",
9994 (unsigned) ie_len);
9995 break;
9996 }
9997 redirecting->priv_orig.name.valid = data[pos];
9998 break;
9999/* Private redirecting-orig party id number */
10001 ast_free(redirecting->priv_orig.number.str);
10002 redirecting->priv_orig.number.str = ast_malloc(ie_len + 1);
10003 if (redirecting->priv_orig.number.str) {
10004 memcpy(redirecting->priv_orig.number.str, data + pos, ie_len);
10005 redirecting->priv_orig.number.str[ie_len] = 0;
10006 }
10007 break;
10009 if (ie_len != 1) {
10010 ast_log(LOG_WARNING, "Invalid private redirecting-orig numbering plan (%u)\n",
10011 (unsigned) ie_len);
10012 break;
10013 }
10014 redirecting->priv_orig.number.plan = data[pos];
10015 break;
10017 if (ie_len != 1) {
10018 ast_log(LOG_WARNING, "Invalid private redirecting-orig number presentation (%u)\n",
10019 (unsigned) ie_len);
10020 break;
10021 }
10022 redirecting->priv_orig.number.presentation = data[pos];
10023 break;
10025 if (ie_len != 1) {
10026 ast_log(LOG_WARNING, "Invalid private redirecting-orig number valid (%u)\n",
10027 (unsigned) ie_len);
10028 break;
10029 }
10030 redirecting->priv_orig.number.valid = data[pos];
10031 break;
10032/* Private redirecting-orig party id subaddress */
10034 ast_free(redirecting->priv_orig.subaddress.str);
10035 redirecting->priv_orig.subaddress.str = ast_malloc(ie_len + 1);
10036 if (redirecting->priv_orig.subaddress.str) {
10037 memcpy(redirecting->priv_orig.subaddress.str, data + pos, ie_len);
10038 redirecting->priv_orig.subaddress.str[ie_len] = 0;
10039 }
10040 break;
10042 if (ie_len != 1) {
10043 ast_log(LOG_WARNING, "Invalid private redirecting-orig type of subaddress (%u)\n",
10044 (unsigned) ie_len);
10045 break;
10046 }
10047 redirecting->priv_orig.subaddress.type = data[pos];
10048 break;
10050 if (ie_len != 1) {
10052 "Invalid private redirecting-orig subaddress odd-even indicator (%u)\n",
10053 (unsigned) ie_len);
10054 break;
10055 }
10056 redirecting->priv_orig.subaddress.odd_even_indicator = data[pos];
10057 break;
10059 if (ie_len != 1) {
10060 ast_log(LOG_WARNING, "Invalid private redirecting-orig subaddress valid (%u)\n",
10061 (unsigned) ie_len);
10062 break;
10063 }
10064 redirecting->priv_orig.subaddress.valid = data[pos];
10065 break;
10066/* Private redirecting-orig party id tag */
10068 ast_free(redirecting->priv_orig.tag);
10069 redirecting->priv_orig.tag = ast_malloc(ie_len + 1);
10070 if (redirecting->priv_orig.tag) {
10071 memcpy(redirecting->priv_orig.tag, data + pos, ie_len);
10072 redirecting->priv_orig.tag[ie_len] = 0;
10073 }
10074 break;
10075/* Private redirecting-from party id name */
10077 ast_free(redirecting->priv_from.name.str);
10078 redirecting->priv_from.name.str = ast_malloc(ie_len + 1);
10079 if (redirecting->priv_from.name.str) {
10080 memcpy(redirecting->priv_from.name.str, data + pos, ie_len);
10081 redirecting->priv_from.name.str[ie_len] = 0;
10082 }
10083 break;
10085 if (ie_len != 1) {
10086 ast_log(LOG_WARNING, "Invalid private redirecting-from name char set (%u)\n",
10087 (unsigned) ie_len);
10088 break;
10089 }
10090 redirecting->priv_from.name.char_set = data[pos];
10091 break;
10093 if (ie_len != 1) {
10094 ast_log(LOG_WARNING, "Invalid private redirecting-from name presentation (%u)\n",
10095 (unsigned) ie_len);
10096 break;
10097 }
10098 redirecting->priv_from.name.presentation = data[pos];
10099 break;
10101 if (ie_len != 1) {
10102 ast_log(LOG_WARNING, "Invalid private redirecting-from name valid (%u)\n",
10103 (unsigned) ie_len);
10104 break;
10105 }
10106 redirecting->priv_from.name.valid = data[pos];
10107 break;
10108/* Private redirecting-from party id number */
10110 ast_free(redirecting->priv_from.number.str);
10111 redirecting->priv_from.number.str = ast_malloc(ie_len + 1);
10112 if (redirecting->priv_from.number.str) {
10113 memcpy(redirecting->priv_from.number.str, data + pos, ie_len);
10114 redirecting->priv_from.number.str[ie_len] = 0;
10115 }
10116 break;
10118 if (ie_len != 1) {
10119 ast_log(LOG_WARNING, "Invalid private redirecting-from numbering plan (%u)\n",
10120 (unsigned) ie_len);
10121 break;
10122 }
10123 redirecting->priv_from.number.plan = data[pos];
10124 break;
10126 if (ie_len != 1) {
10127 ast_log(LOG_WARNING, "Invalid private redirecting-from number presentation (%u)\n",
10128 (unsigned) ie_len);
10129 break;
10130 }
10131 redirecting->priv_from.number.presentation = data[pos];
10132 break;
10134 if (ie_len != 1) {
10135 ast_log(LOG_WARNING, "Invalid private redirecting-from number valid (%u)\n",
10136 (unsigned) ie_len);
10137 break;
10138 }
10139 redirecting->priv_from.number.valid = data[pos];
10140 break;
10141/* Private redirecting-from party id subaddress */
10143 ast_free(redirecting->priv_from.subaddress.str);
10144 redirecting->priv_from.subaddress.str = ast_malloc(ie_len + 1);
10145 if (redirecting->priv_from.subaddress.str) {
10146 memcpy(redirecting->priv_from.subaddress.str, data + pos, ie_len);
10147 redirecting->priv_from.subaddress.str[ie_len] = 0;
10148 }
10149 break;
10151 if (ie_len != 1) {
10152 ast_log(LOG_WARNING, "Invalid private redirecting-from type of subaddress (%u)\n",
10153 (unsigned) ie_len);
10154 break;
10155 }
10156 redirecting->priv_from.subaddress.type = data[pos];
10157 break;
10159 if (ie_len != 1) {
10161 "Invalid private redirecting-from subaddress odd-even indicator (%u)\n",
10162 (unsigned) ie_len);
10163 break;
10164 }
10165 redirecting->priv_from.subaddress.odd_even_indicator = data[pos];
10166 break;
10168 if (ie_len != 1) {
10169 ast_log(LOG_WARNING, "Invalid private redirecting-from subaddress valid (%u)\n",
10170 (unsigned) ie_len);
10171 break;
10172 }
10173 redirecting->priv_from.subaddress.valid = data[pos];
10174 break;
10175/* Private redirecting-from party id tag */
10177 ast_free(redirecting->priv_from.tag);
10178 redirecting->priv_from.tag = ast_malloc(ie_len + 1);
10179 if (redirecting->priv_from.tag) {
10180 memcpy(redirecting->priv_from.tag, data + pos, ie_len);
10181 redirecting->priv_from.tag[ie_len] = 0;
10182 }
10183 break;
10184/* Private redirecting-to party id name */
10186 ast_free(redirecting->priv_to.name.str);
10187 redirecting->priv_to.name.str = ast_malloc(ie_len + 1);
10188 if (redirecting->priv_to.name.str) {
10189 memcpy(redirecting->priv_to.name.str, data + pos, ie_len);
10190 redirecting->priv_to.name.str[ie_len] = 0;
10191 }
10192 break;
10194 if (ie_len != 1) {
10195 ast_log(LOG_WARNING, "Invalid private redirecting-to name char set (%u)\n",
10196 (unsigned) ie_len);
10197 break;
10198 }
10199 redirecting->priv_to.name.char_set = data[pos];
10200 break;
10202 if (ie_len != 1) {
10203 ast_log(LOG_WARNING, "Invalid private redirecting-to name presentation (%u)\n",
10204 (unsigned) ie_len);
10205 break;
10206 }
10207 redirecting->priv_to.name.presentation = data[pos];
10208 break;
10210 if (ie_len != 1) {
10211 ast_log(LOG_WARNING, "Invalid private redirecting-to name valid (%u)\n",
10212 (unsigned) ie_len);
10213 break;
10214 }
10215 redirecting->priv_to.name.valid = data[pos];
10216 break;
10217/* Private redirecting-to party id number */
10219 ast_free(redirecting->priv_to.number.str);
10220 redirecting->priv_to.number.str = ast_malloc(ie_len + 1);
10221 if (redirecting->priv_to.number.str) {
10222 memcpy(redirecting->priv_to.number.str, data + pos, ie_len);
10223 redirecting->priv_to.number.str[ie_len] = 0;
10224 }
10225 break;
10227 if (ie_len != 1) {
10228 ast_log(LOG_WARNING, "Invalid private redirecting-to numbering plan (%u)\n",
10229 (unsigned) ie_len);
10230 break;
10231 }
10232 redirecting->priv_to.number.plan = data[pos];
10233 break;
10235 if (ie_len != 1) {
10236 ast_log(LOG_WARNING, "Invalid private redirecting-to number presentation (%u)\n",
10237 (unsigned) ie_len);
10238 break;
10239 }
10240 redirecting->priv_to.number.presentation = data[pos];
10241 break;
10243 if (ie_len != 1) {
10244 ast_log(LOG_WARNING, "Invalid private redirecting-to number valid (%u)\n",
10245 (unsigned) ie_len);
10246 break;
10247 }
10248 redirecting->priv_to.number.valid = data[pos];
10249 break;
10250/* Private redirecting-to party id subaddress */
10252 ast_free(redirecting->priv_to.subaddress.str);
10253 redirecting->priv_to.subaddress.str = ast_malloc(ie_len + 1);
10254 if (redirecting->priv_to.subaddress.str) {
10255 memcpy(redirecting->priv_to.subaddress.str, data + pos, ie_len);
10256 redirecting->priv_to.subaddress.str[ie_len] = 0;
10257 }
10258 break;
10260 if (ie_len != 1) {
10261 ast_log(LOG_WARNING, "Invalid private redirecting-to type of subaddress (%u)\n",
10262 (unsigned) ie_len);
10263 break;
10264 }
10265 redirecting->priv_to.subaddress.type = data[pos];
10266 break;
10268 if (ie_len != 1) {
10270 "Invalid private redirecting-to subaddress odd-even indicator (%u)\n",
10271 (unsigned) ie_len);
10272 break;
10273 }
10274 redirecting->priv_to.subaddress.odd_even_indicator = data[pos];
10275 break;
10277 if (ie_len != 1) {
10278 ast_log(LOG_WARNING, "Invalid private redirecting-to subaddress valid (%u)\n",
10279 (unsigned) ie_len);
10280 break;
10281 }
10282 redirecting->priv_to.subaddress.valid = data[pos];
10283 break;
10284/* Private redirecting-to party id tag */
10286 ast_free(redirecting->priv_to.tag);
10287 redirecting->priv_to.tag = ast_malloc(ie_len + 1);
10288 if (redirecting->priv_to.tag) {
10289 memcpy(redirecting->priv_to.tag, data + pos, ie_len);
10290 redirecting->priv_to.tag[ie_len] = 0;
10291 }
10292 break;
10293/* Redirecting reason code */
10295 if (ie_len != sizeof(value)) {
10296 ast_log(LOG_WARNING, "Invalid redirecting reason (%u)\n",
10297 (unsigned) ie_len);
10298 break;
10299 }
10300 memcpy(&value, data + pos, sizeof(value));
10301 redirecting->reason.code = ntohl(value);
10302 break;
10303/* Redirecting reason string */
10305 ast_free(redirecting->reason.str);
10306 redirecting->reason.str = ast_malloc(ie_len + 1);
10307 if (redirecting->reason.str) {
10308 memcpy(redirecting->reason.str, data + pos, ie_len);
10309 redirecting->reason.str[ie_len] = 0;
10310 }
10311 break;
10312/* Redirecting orig-reason code */
10314 if (ie_len != sizeof(value)) {
10315 ast_log(LOG_WARNING, "Invalid redirecting original reason (%u)\n",
10316 (unsigned) ie_len);
10317 break;
10318 }
10319 memcpy(&value, data + pos, sizeof(value));
10320 redirecting->orig_reason.code = ntohl(value);
10321 break;
10322/* Redirecting orig-reason string */
10324 ast_free(redirecting->orig_reason.str);
10325 redirecting->orig_reason.str = ast_malloc(ie_len + 1);
10326 if (redirecting->orig_reason.str) {
10327 memcpy(redirecting->orig_reason.str, data + pos, ie_len);
10328 redirecting->orig_reason.str[ie_len] = 0;
10329 }
10330 break;
10331/* Redirecting count */
10333 if (ie_len != sizeof(value)) {
10334 ast_log(LOG_WARNING, "Invalid redirecting count (%u)\n",
10335 (unsigned) ie_len);
10336 break;
10337 }
10338 memcpy(&value, data + pos, sizeof(value));
10339 redirecting->count = ntohl(value);
10340 break;
10341/* Redirecting unknown element */
10342 default:
10343 ast_debug(1, "Unknown redirecting element: %u (%u)\n",
10344 (unsigned) ie_id, (unsigned) ie_len);
10345 break;
10346 }
10347 }
10348
10349 switch (frame_version) {
10350 case 1:
10351 /*
10352 * The other end is an earlier version that we need to adjust
10353 * for compatibility.
10354 *
10355 * The earlier version did not have the orig party id or
10356 * orig_reason value.
10357 */
10358 redirecting->from.name.valid = 1;
10360 redirecting->from.number.valid = 1;
10361 if (got_from_combined_presentation) {
10362 redirecting->from.name.presentation = from_combined_presentation;
10363 redirecting->from.number.presentation = from_combined_presentation;
10364 }
10365
10366 redirecting->to.name.valid = 1;
10368 redirecting->to.number.valid = 1;
10369 if (got_to_combined_presentation) {
10370 redirecting->to.name.presentation = to_combined_presentation;
10371 redirecting->to.number.presentation = to_combined_presentation;
10372 }
10373 break;
10374 case 2:
10375 /* The other end is at the same level as we are. */
10376 break;
10377 default:
10378 /*
10379 * The other end is newer than we are.
10380 * We need to assume that they are compatible with us.
10381 */
10382 ast_debug(1, "Redirecting frame has newer version: %u\n",
10383 (unsigned) frame_version);
10384 break;
10385 }
10386
10387 return 0;
10388}

References ast_debug, 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_ORIG_NAME, AST_REDIRECTING_ORIG_NAME_CHAR_SET, AST_REDIRECTING_ORIG_NAME_PRESENTATION, AST_REDIRECTING_ORIG_NAME_VALID, AST_REDIRECTING_ORIG_NUMBER, AST_REDIRECTING_ORIG_NUMBER_PLAN, AST_REDIRECTING_ORIG_NUMBER_PRESENTATION, AST_REDIRECTING_ORIG_NUMBER_VALID, AST_REDIRECTING_ORIG_REASON_CODE, AST_REDIRECTING_ORIG_REASON_STR, AST_REDIRECTING_ORIG_SUBADDRESS, AST_REDIRECTING_ORIG_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_ORIG_SUBADDRESS_TYPE, AST_REDIRECTING_ORIG_SUBADDRESS_VALID, AST_REDIRECTING_ORIG_TAG, AST_REDIRECTING_PRIV_FROM_NAME, AST_REDIRECTING_PRIV_FROM_NAME_CHAR_SET, AST_REDIRECTING_PRIV_FROM_NAME_PRESENTATION, AST_REDIRECTING_PRIV_FROM_NAME_VALID, AST_REDIRECTING_PRIV_FROM_NUMBER, AST_REDIRECTING_PRIV_FROM_NUMBER_PLAN, AST_REDIRECTING_PRIV_FROM_NUMBER_PRESENTATION, AST_REDIRECTING_PRIV_FROM_NUMBER_VALID, AST_REDIRECTING_PRIV_FROM_SUBADDRESS, AST_REDIRECTING_PRIV_FROM_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_PRIV_FROM_SUBADDRESS_TYPE, AST_REDIRECTING_PRIV_FROM_SUBADDRESS_VALID, AST_REDIRECTING_PRIV_FROM_TAG, AST_REDIRECTING_PRIV_ORIG_NAME, AST_REDIRECTING_PRIV_ORIG_NAME_CHAR_SET, AST_REDIRECTING_PRIV_ORIG_NAME_PRESENTATION, AST_REDIRECTING_PRIV_ORIG_NAME_VALID, AST_REDIRECTING_PRIV_ORIG_NUMBER, AST_REDIRECTING_PRIV_ORIG_NUMBER_PLAN, AST_REDIRECTING_PRIV_ORIG_NUMBER_PRESENTATION, AST_REDIRECTING_PRIV_ORIG_NUMBER_VALID, AST_REDIRECTING_PRIV_ORIG_SUBADDRESS, AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_TYPE, AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_VALID, AST_REDIRECTING_PRIV_ORIG_TAG, AST_REDIRECTING_PRIV_TO_NAME, AST_REDIRECTING_PRIV_TO_NAME_CHAR_SET, AST_REDIRECTING_PRIV_TO_NAME_PRESENTATION, AST_REDIRECTING_PRIV_TO_NAME_VALID, AST_REDIRECTING_PRIV_TO_NUMBER, AST_REDIRECTING_PRIV_TO_NUMBER_PLAN, AST_REDIRECTING_PRIV_TO_NUMBER_PRESENTATION, AST_REDIRECTING_PRIV_TO_NUMBER_VALID, AST_REDIRECTING_PRIV_TO_SUBADDRESS, AST_REDIRECTING_PRIV_TO_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_PRIV_TO_SUBADDRESS_TYPE, AST_REDIRECTING_PRIV_TO_SUBADDRESS_VALID, AST_REDIRECTING_PRIV_TO_TAG, AST_REDIRECTING_REASON_CODE, AST_REDIRECTING_REASON_STR, 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_reason::code, ast_party_redirecting::count, ast_party_redirecting::from, LOG_WARNING, ast_party_id::name, ast_party_id::number, ast_party_subaddress::odd_even_indicator, ast_party_redirecting::orig, ast_party_redirecting::orig_reason, ast_party_number::plan, ast_party_name::presentation, ast_party_number::presentation, ast_party_redirecting::priv_from, ast_party_redirecting::priv_orig, ast_party_redirecting::priv_to, ast_party_redirecting::reason, ast_party_name::str, ast_party_number::str, ast_party_subaddress::str, ast_party_redirecting_reason::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_sub(), and indicate_redirecting().

◆ ast_ref_namedgroups()

struct ast_namedgroups * ast_ref_namedgroups ( struct ast_namedgroups *  groups)

Definition at line 7812 of file channel.c.

7813{
7814 if (groups) {
7815 ao2_ref(groups, 1);
7816 }
7817 return groups;
7818}

References ao2_ref.

Referenced by ast_channel_named_callgroups_set(), ast_channel_named_pickupgroups_set(), and mkintf().

◆ ast_request()

struct ast_channel * ast_request ( const char *  type,
struct ast_format_cap request_cap,
const struct ast_assigned_ids assignedids,
const struct ast_channel requestor,
const char *  addr,
int *  cause 
)

Requests a channel.

Parameters
typetype of channel to request
request_capFormat capabilities for requested channel
assignedidsUnique ID to create channel with
requestorchannel asking for data
addrdestination of the call
causeCause of failure

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

Return values
NULLfailure
non-NULLchannel on success

Definition at line 6411 of file channel.c.

6412{
6413 return request_channel(type, request_cap, NULL, assignedids, requestor, addr, cause);
6414}
static struct ast_channel * request_channel(const char *type, struct ast_format_cap *request_cap, struct ast_stream_topology *topology, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
Definition channel.c:6276

References NULL, request_channel(), and type.

Referenced by __ast_request_and_dial(), alloc_playback_chan(), ast_ari_channels_create(), ast_call_forward(), attended_transfer_bridge(), begin_dial_prerun(), blind_transfer_bridge(), build_conf(), chanavail_exec(), conf_run(), conf_start_record(), dial_transfer(), findmeexec(), meetme_menu_admin_extended(), park_local_transfer(), prepare_bridge_media_channel(), prepare_bridge_moh_channel(), retransfer_enter(), ring_entry(), and wait_for_answer().

◆ ast_request_and_dial()

struct ast_channel * ast_request_and_dial ( const char *  type,
struct ast_format_cap cap,
const struct ast_assigned_ids assignedids,
const struct ast_channel requestor,
const char *  addr,
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
capformat capabilities for requested channel
assignedidsUnique Id to assign to channel
requestorchannel asking for data
addrdestination of the call
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 6231 of file channel.c.

6232{
6233 return __ast_request_and_dial(type, cap, assignedids, requestor, addr, timeout, outstate, cidnum, cidname, NULL);
6234}
struct ast_channel * __ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int timeout, int *outstate, const char *cid_num, const char *cid_name, struct outgoing_helper *oh)
Request a channel of a given type, with data as optional information used by the low level module and...
Definition channel.c:6033

References __ast_request_and_dial(), NULL, and type.

Referenced by generic_recall().

◆ ast_request_with_stream_topology()

struct ast_channel * ast_request_with_stream_topology ( const char *  type,
struct ast_stream_topology topology,
const struct ast_assigned_ids assignedids,
const struct ast_channel requestor,
const char *  addr,
int *  cause 
)

Requests a channel (specifying stream topology)

Parameters
typetype of channel to request
topologyStream topology for requested channel
assignedidsUnique ID to create channel with
requestorchannel asking for data
addrdestination of the call
causeCause of failure

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

Return values
NULLfailure
non-NULLchannel on success

Definition at line 6416 of file channel.c.

6417{
6418 return request_channel(type, NULL, topology, assignedids, requestor, addr, cause);
6419}

References NULL, request_channel(), and type.

Referenced by dial_exec_full(), and do_forward().

◆ ast_safe_sleep()

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

1562{
1563 return safe_sleep_conditional(chan, ms, NULL, NULL, 1);
1564}
static int safe_sleep_conditional(struct ast_channel *chan, int timeout_ms, int(*cond)(void *), void *data, unsigned int generate_silence)
Wait, look for hangups and condition arg.
Definition channel.c:1485

References NULL, and safe_sleep_conditional().

Referenced by __analog_ss_thread(), adsi_transmit_message_full(), alarmreceiver_exec(), analog_ss_thread(), ast_senddigit(), ast_senddigit_mf(), conf_run(), dictate_exec(), disa_exec(), dtmf_no_bridge(), dtmf_stream(), flash_exec(), mf_stream(), milliwatt_exec(), old_milliwatt_exec(), pbx_builtin_wait(), play_moh_exec(), playtone(), privacy_exec(), send_tone_burst(), sf_stream(), testclient_exec(), testserver_exec(), try_calling(), waitforcond_exec(), waituntil_exec(), and zapateller_exec().

◆ ast_safe_sleep_conditional()

int ast_safe_sleep_conditional ( struct ast_channel chan,
int  ms,
int(*)(void *)  cond,
void *  data 
)

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

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.

Definition at line 1555 of file channel.c.

1556{
1557 return safe_sleep_conditional(chan, timeout_ms, cond, data, 1);
1558}

References cond, ast_frame::data, and safe_sleep_conditional().

◆ ast_safe_sleep_without_silence()

int ast_safe_sleep_without_silence ( struct ast_channel chan,
int  ms 
)

Wait for a specified amount of time, looking for hangups, and do not generate silence.

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.
Note
Unlike ast_safe_sleep this will not generate silence if Asterisk is configured to do so.

Definition at line 1566 of file channel.c.

1567{
1568 return safe_sleep_conditional(chan, ms, NULL, NULL, 0);
1569}

References NULL, and safe_sleep_conditional().

Referenced by wait_for_hangup().

◆ ast_senddigit()

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
Precondition
This must only be called by the channel's media handler thread.
Returns
0 on success, -1 on failure

Definition at line 5031 of file channel.c.

5032{
5033 if (duration < AST_DEFAULT_EMULATE_DTMF_DURATION) {
5035 }
5036 if (ast_channel_tech(chan)->send_digit_begin) {
5038 ast_safe_sleep(chan, duration);
5039 }
5040
5041 return ast_senddigit_end(chan, digit, duration);
5042}
int ast_senddigit_begin(struct ast_channel *chan, char digit)
Send a DTMF digit to a channel.
Definition channel.c:4931
#define AST_DEFAULT_EMULATE_DTMF_DURATION
Definition channel.c:106
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait, look for hangups.
Definition channel.c:1561

References AST_DEFAULT_EMULATE_DTMF_DURATION, ast_safe_sleep(), ast_senddigit_begin(), ast_senddigit_end(), and digit.

Referenced by dial_exec_full(), and dtmf_stream().

◆ ast_senddigit_begin()

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

4932{
4933 /* Device does not support DTMF tones, lets fake
4934 * it by doing our own generation. */
4935 static const char * const dtmf_tones[] = {
4936 "941+1336", /* 0 */
4937 "697+1209", /* 1 */
4938 "697+1336", /* 2 */
4939 "697+1477", /* 3 */
4940 "770+1209", /* 4 */
4941 "770+1336", /* 5 */
4942 "770+1477", /* 6 */
4943 "852+1209", /* 7 */
4944 "852+1336", /* 8 */
4945 "852+1477", /* 9 */
4946 "697+1633", /* A */
4947 "770+1633", /* B */
4948 "852+1633", /* C */
4949 "941+1633", /* D */
4950 "941+1209", /* * */
4951 "941+1477" /* # */
4952 };
4953
4954 if (!ast_channel_tech(chan)->send_digit_begin)
4955 return 0;
4956
4957 ast_channel_lock(chan);
4960 ast_channel_unlock(chan);
4961
4962 if (!ast_channel_tech(chan)->send_digit_begin(chan, digit))
4963 return 0;
4964
4965 if (digit >= '0' && digit <='9')
4966 ast_playtones_start(chan, 0, dtmf_tones[digit-'0'], 0);
4967 else if (digit >= 'A' && digit <= 'D')
4968 ast_playtones_start(chan, 0, dtmf_tones[digit-'A'+10], 0);
4969 else if (digit == '*')
4970 ast_playtones_start(chan, 0, dtmf_tones[14], 0);
4971 else if (digit == '#')
4972 ast_playtones_start(chan, 0, dtmf_tones[15], 0);
4973 else {
4974 /* not handled */
4975 ast_debug(1, "Unable to generate DTMF tone '%c' for '%s'\n", digit, ast_channel_name(chan));
4976 }
4977
4978 return 0;
4979}
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.

References ast_channel_lock, ast_channel_name(), ast_channel_sending_dtmf_digit_set(), ast_channel_sending_dtmf_tv_set(), ast_channel_unlock, ast_debug, ast_playtones_start(), ast_tvnow(), and digit.

Referenced by ast_senddigit(), ast_senddigit_external(), and ast_write_stream().

◆ ast_senddigit_end()

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

4982{
4983 int res = -1;
4984
4985 if (ast_channel_tech(chan)->send_digit_end)
4986 res = ast_channel_tech(chan)->send_digit_end(chan, digit, duration);
4987
4988 ast_channel_lock(chan);
4991 }
4992 ast_channel_unlock(chan);
4993
4994 if (res && ast_channel_generator(chan))
4995 ast_playtones_stop(chan);
4996
4997 return 0;
4998}
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
int(*const send_digit_end)(struct ast_channel *chan, char digit, unsigned int duration)
Stop sending a literal DTMF digit.
Definition channel.h:710

References ast_channel_generator(), ast_channel_lock, ast_channel_sending_dtmf_digit(), ast_channel_sending_dtmf_digit_set(), ast_channel_unlock, ast_playtones_stop(), digit, and ast_channel_tech::send_digit_end.

Referenced by ast_channel_end_dtmf(), ast_senddigit(), ast_senddigit_external(), and ast_write_stream().

◆ ast_senddigit_external()

int ast_senddigit_external ( struct ast_channel chan,
char  digit,
unsigned int  duration 
)

Send a DTMF digit to a channel from an external thread.

Parameters
chanchannel to act upon
digitthe DTMF digit to send, encoded in ASCII
durationthe duration of the digit ending in ms
Precondition
This must only be called by threads that are not the channel's media handler thread.
Returns
0 on success, -1 on failure

Definition at line 5044 of file channel.c.

5045{
5046 if (duration < AST_DEFAULT_EMULATE_DTMF_DURATION) {
5048 }
5049 if (ast_channel_tech(chan)->send_digit_begin) {
5051 usleep(duration * 1000);
5052 }
5053
5054 return ast_senddigit_end(chan, digit, duration);
5055}

References AST_DEFAULT_EMULATE_DTMF_DURATION, ast_senddigit_begin(), ast_senddigit_end(), and digit.

Referenced by dtmf_stream(), and manager_play_dtmf().

◆ ast_senddigit_mf()

int ast_senddigit_mf ( struct ast_channel chan,
char  digit,
unsigned int  duration,
unsigned int  durationkp,
unsigned int  durationst,
int  is_external 
)

Send an MF digit to a channel.

Parameters
chanchannel to act upon
digitthe MF digit to send, encoded in ASCII
durationthe duration of a numeric digit ending in ms
durationkpthe duration of a KP digit ending in ms
durationstthe duration of a ST, STP, ST2P, or ST3P digit ending in ms
is_external1 if called by a thread that is not the channel's media handler thread, 0 if called by the channel's media handler thread.
Returns
0 on success, -1 on failure

Definition at line 5009 of file channel.c.

5011{
5012 if (duration < DEFAULT_EMULATE_MF_DURATION) {
5013 duration = DEFAULT_EMULATE_MF_DURATION;
5014 }
5015 if (ast_channel_tech(chan)->send_digit_begin) {
5016 if (digit == '*') {
5017 duration = durationkp;
5018 } else if (digit == '#' || digit == 'A' || digit == 'B' || digit == 'C') {
5019 duration = durationst;
5020 }
5022 if (is_external) {
5023 usleep(duration * 1000);
5024 } else {
5025 ast_safe_sleep(chan, duration);
5026 }
5027 }
5028 return ast_senddigit_mf_end(chan);
5029}
int ast_senddigit_mf_begin(struct ast_channel *chan, char digit)
Send an MF digit to a channel.
Definition channel.c:4892
int ast_senddigit_mf_end(struct ast_channel *chan)
End sending an MF digit to a channel.
Definition channel.c:5000
#define DEFAULT_EMULATE_MF_DURATION
Definition channel.c:110

References ast_safe_sleep(), ast_senddigit_mf_begin(), ast_senddigit_mf_end(), DEFAULT_EMULATE_MF_DURATION, and digit.

Referenced by mf_stream().

◆ ast_senddigit_mf_begin()

int ast_senddigit_mf_begin ( struct ast_channel chan,
char  digit 
)

Send an MF digit to a channel.

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

Definition at line 4892 of file channel.c.

4893{
4894 static const char * const mf_tones[] = {
4895 "1300+1500", /* 0 */
4896 "700+900", /* 1 */
4897 "700+1100", /* 2 */
4898 "900+1100", /* 3 */
4899 "700+1300", /* 4 */
4900 "900+1300", /* 5 */
4901 "1100+1300", /* 6 */
4902 "700+1500", /* 7 */
4903 "900+1500", /* 8 */
4904 "1100+1500", /* 9 */
4905 "1100+1700", /* * (KP) */
4906 "1500+1700", /* # (ST) */
4907 "900+1700", /* A (STP) */
4908 "1300+1700", /* B (ST2P) */
4909 "700+1700" /* C (ST3P) */
4910 };
4911
4912 if (digit >= '0' && digit <='9') {
4913 ast_playtones_start(chan, 0, mf_tones[digit-'0'], 0);
4914 } else if (digit == '*') {
4915 ast_playtones_start(chan, 0, mf_tones[10], 0);
4916 } else if (digit == '#') {
4917 ast_playtones_start(chan, 0, mf_tones[11], 0);
4918 } else if (digit == 'A') {
4919 ast_playtones_start(chan, 0, mf_tones[12], 0);
4920 } else if (digit == 'B') {
4921 ast_playtones_start(chan, 0, mf_tones[13], 0);
4922 } else if (digit == 'C') {
4923 ast_playtones_start(chan, 0, mf_tones[14], 0);
4924 } else {
4925 /* not handled */
4926 ast_log(LOG_WARNING, "Unable to generate MF tone '%c' for '%s'\n", digit, ast_channel_name(chan));
4927 }
4928 return 0;
4929}
static const float mf_tones[]
Definition dsp.c:332

References ast_channel_name(), ast_log, ast_playtones_start(), digit, LOG_WARNING, and mf_tones.

Referenced by ast_senddigit_mf().

◆ ast_senddigit_mf_end()

int ast_senddigit_mf_end ( struct ast_channel chan)

End sending an MF digit to a channel.

Parameters
chanchannel to act upon
Returns
Returns 0 on success, -1 on failure

Definition at line 5000 of file channel.c.

5001{
5002 if (ast_channel_generator(chan)) {
5003 ast_playtones_stop(chan);
5004 return 0;
5005 }
5006 return -1;
5007}

References ast_channel_generator(), and ast_playtones_stop().

Referenced by ast_senddigit_mf(), mf_stream(), and sf_stream().

◆ ast_sendtext()

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

4867{
4868 struct ast_msg_data *msg;
4869 int rc;
4870 struct ast_msg_data_attribute attrs[] =
4871 {
4872 {
4874 .value = (char *)text,
4875 }
4876 };
4877
4878 if (ast_strlen_zero(text)) {
4879 return 0;
4880 }
4881
4883 if (!msg) {
4884 return -1;
4885 }
4886 rc = ast_sendtext_data(chan, msg);
4887 ast_free(msg);
4888
4889 return rc;
4890}
int ast_sendtext_data(struct ast_channel *chan, struct ast_msg_data *msg)
Sends text to a channel in an ast_msg_data structure wrapper with ast_sendtext as fallback.
Definition channel.c:4808
struct ast_msg_data * ast_msg_data_alloc(enum ast_msg_data_source_type source, struct ast_msg_data_attribute attributes[], size_t count)
Allocates an ast_msg_data structure.
@ AST_MSG_DATA_ATTR_BODY
Definition message.h:458
@ AST_MSG_DATA_SOURCE_TYPE_UNKNOWN
Definition message.h:447
enum ast_msg_data_attribute_type type
Definition message.h:463

References ARRAY_LEN, ast_free, ast_msg_data_alloc(), AST_MSG_DATA_ATTR_BODY, AST_MSG_DATA_SOURCE_TYPE_UNKNOWN, ast_sendtext_data(), ast_strlen_zero(), text, and ast_msg_data_attribute::type.

Referenced by __ast_read(), handle_sendtext(), sendtext_exec(), and sendtext_safe().

◆ ast_sendtext_data()

int ast_sendtext_data ( struct ast_channel chan,
struct ast_msg_data msg 
)

Sends text to a channel in an ast_msg_data structure wrapper with ast_sendtext as fallback.

Since
13.22.0
15.5.0
Parameters
chanchannel to act upon
msgast_msg_data structure

Write text to a display on a channel. If the channel driver doesn't support the send_text_data callback. then the original send_text callback will be used if available.

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

Definition at line 4808 of file channel.c.

4809{
4810 int res = 0;
4811 const char *body = ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_BODY);
4812 const char *content_type = ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_CONTENT_TYPE);
4813
4814 ast_channel_lock(chan);
4815 /* Stop if we're a zombie or need a soft hangup */
4817 ast_channel_unlock(chan);
4818 return -1;
4819 }
4820
4821 CHECK_BLOCKING(chan);
4822 if (ast_channel_tech(chan)->write_text
4823 && (ast_strlen_zero(content_type) || ast_begins_with(content_type, "text/"))
4825 struct ast_frame f;
4826 /* T.140 payload does not include the null byte terminator */
4827 size_t body_len = strlen(body);
4828
4829 /* Process as T.140 text (moved here from ast_sendtext() */
4830 memset(&f, 0, sizeof(f));
4831 f.src = "DIALPLAN";
4832 f.subclass.format = ast_format_t140;
4833 f.frametype = AST_FRAME_TEXT;
4834 f.datalen = body_len;
4835 f.mallocd = AST_MALLOCD_DATA;
4836 f.data.ptr = ast_strdup(body);
4837 if (f.data.ptr) {
4838 res = ast_channel_tech(chan)->write_text(chan, &f);
4839 } else {
4840 res = -1;
4841 }
4842 ast_frfree(&f);
4843 } else if ((ast_channel_tech(chan)->properties & AST_CHAN_TP_SEND_TEXT_DATA)
4844 && ast_channel_tech(chan)->send_text_data) {
4845 /* Send enhanced message to a channel driver that supports it */
4846 ast_debug(1, "Sending TEXT_DATA from '%s' to %s:%s %s\n",
4849 ast_channel_name(chan), body);
4850 res = ast_channel_tech(chan)->send_text_data(chan, msg);
4851 } else if (ast_channel_tech(chan)->send_text
4852 && (ast_strlen_zero(content_type) || ast_begins_with(content_type, "text/"))) {
4853 /* Send the body of an enhanced message to a channel driver that supports only a char str */
4854 ast_debug(1, "Sending TEXT to %s: %s\n", ast_channel_name(chan), body);
4855 res = ast_channel_tech(chan)->send_text(chan, body);
4856 } else {
4857 ast_debug(1, "Channel technology does not support sending content type '%s' on channel '%s'\n",
4858 S_OR(content_type, "text/plain"), ast_channel_name(chan));
4859 res = -1;
4860 }
4862 ast_channel_unlock(chan);
4863 return res;
4864}
static void send_text(unsigned char pos, unsigned char inverse, struct unistimsession *pte, const char *text)
#define CHECK_BLOCKING(c)
Set the blocking indication on the channel.
Definition channel.h:2938
@ AST_MEDIA_TYPE_TEXT
Definition codec.h:35
struct ast_format * ast_format_t140
Built-in cached t140 format.
int ast_format_cap_has_type(const struct ast_format_cap *cap, enum ast_media_type type)
Find out if the capabilities structure has any formats of a specific type.
Definition format_cap.c:613
const char * ast_msg_data_get_attribute(struct ast_msg_data *msg, enum ast_msg_data_attribute_type attribute_type)
Get attribute from ast_msg_data.
@ AST_MSG_DATA_ATTR_TO
Definition message.h:455
@ AST_MSG_DATA_ATTR_FROM
Definition message.h:456
@ AST_MSG_DATA_ATTR_CONTENT_TYPE
Definition message.h:457
#define AST_MALLOCD_DATA
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
Checks whether a string begins with another.
Definition strings.h:97
int(*const send_text)(struct ast_channel *chan, const char *text)
Display or transmit text.
Definition channel.h:776
int(*const write_text)(struct ast_channel *chan, struct ast_frame *frame)
Write a text frame, in standard format.
Definition channel.h:809
int(*const send_text_data)(struct ast_channel *chan, struct ast_msg_data *data)
Display or transmit text with data.
Definition channel.h:864

References ast_begins_with(), AST_CHAN_TP_SEND_TEXT_DATA, ast_channel_flags(), ast_channel_lock, ast_channel_name(), ast_channel_nativeformats(), ast_channel_unlock, ast_check_hangup(), ast_clear_flag, ast_debug, AST_FLAG_BLOCKING, AST_FLAG_ZOMBIE, ast_format_cap_has_type(), ast_format_t140, AST_FRAME_TEXT, ast_frfree, AST_MALLOCD_DATA, AST_MEDIA_TYPE_TEXT, AST_MSG_DATA_ATTR_BODY, AST_MSG_DATA_ATTR_CONTENT_TYPE, AST_MSG_DATA_ATTR_FROM, AST_MSG_DATA_ATTR_TO, ast_msg_data_get_attribute(), ast_strdup, ast_strlen_zero(), ast_test_flag, CHECK_BLOCKING, ast_frame::data, ast_frame::datalen, ast_frame_subclass::format, ast_frame::frametype, ast_frame::mallocd, ast_frame::ptr, S_OR, send_text(), ast_channel_tech::send_text, ast_channel_tech::send_text_data, ast_frame::src, ast_frame::subclass, and ast_channel_tech::write_text.

Referenced by __ast_read(), ast_sendtext(), bridge_channel_handle_write(), and sendtext_exec().

◆ ast_set_callerid()

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

7409{
7410 ast_channel_lock(chan);
7411
7412 if (cid_num) {
7413 ast_channel_caller(chan)->id.number.valid = 1;
7414 ast_free(ast_channel_caller(chan)->id.number.str);
7415 ast_channel_caller(chan)->id.number.str = ast_strdup(cid_num);
7416 }
7417 if (cid_name) {
7418 ast_channel_caller(chan)->id.name.valid = 1;
7419 ast_free(ast_channel_caller(chan)->id.name.str);
7420 ast_channel_caller(chan)->id.name.str = ast_strdup(cid_name);
7421 }
7422 if (cid_ani) {
7424 ast_free(ast_channel_caller(chan)->ani.number.str);
7425 ast_channel_caller(chan)->ani.number.str = ast_strdup(cid_ani);
7426 }
7427
7429
7430 ast_channel_unlock(chan);
7431}
Number structure.

References ast_party_caller::ani, ast_channel_caller(), ast_channel_lock, ast_channel_publish_snapshot(), ast_channel_unlock, ast_free, ast_strdup, ast_party_caller::id, name, ast_party_id::name, ast_party_id::number, 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(), ari_channels_handle_originate_with_id(), disa_exec(), handle_setcallerid(), pbx_outgoing_attempt(), privacy_exec(), ring_entry(), and socket_process_helper().

◆ ast_set_hangupsource()

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

2533{
2535
2536 ast_channel_lock(chan);
2537 if (force || ast_strlen_zero(ast_channel_hangupsource(chan))) {
2538 ast_channel_hangupsource_set(chan, source);
2539 }
2540 ast_channel_unlock(chan);
2541
2542 if (bridge) {
2543 ast_channel_lock(bridge);
2544 if (force || ast_strlen_zero(ast_channel_hangupsource(bridge))) {
2545 ast_channel_hangupsource_set(bridge, source);
2546 }
2547 ast_channel_unlock(bridge);
2548 }
2549}
struct ast_channel * ast_channel_bridge_peer(struct ast_channel *chan)
Get the channel's bridge peer only if the bridge is two-party.
Definition channel.c:10674
#define ast_channel_cleanup(c)
Cleanup a channel reference.
Definition channel.h:3036

References ast_channel_bridge_peer(), ast_channel_cleanup, ast_channel_hangupsource(), ast_channel_lock, ast_channel_unlock, ast_strlen_zero(), and RAII_VAR.

Referenced by __dahdi_exception(), analog_exception(), call(), chan_pjsip_session_end(), func_channel_write_real(), handle_hangup(), pbx_builtin_hangup(), session_inv_on_media_update(), and set_hangup_source_and_cause().

◆ ast_set_party_id_all()

void ast_set_party_id_all ( struct ast_set_party_id update_id)

Set the update marker to update all information of a corresponding party id.

Since
11.0
Parameters
update_idThe update marker for a corresponding party id.

Definition at line 1737 of file channel.c.

1738{
1739 update_id->name = 1;
1740 update_id->number = 1;
1741 update_id->subaddress = 1;
1742}
unsigned char subaddress
Definition channel.h:369
unsigned char number
Definition channel.h:367
unsigned char name
Definition channel.h:365

References ast_set_party_id::name, ast_set_party_id::number, and ast_set_party_id::subaddress.

Referenced by set_redirecting().

◆ ast_set_read_format()

int ast_set_read_format ( struct ast_channel chan,
struct ast_format format 
)

Sets read format on channel chan.

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

Definition at line 5819 of file channel.c.

5820{
5822 int res;
5823
5824 ast_assert(format != NULL);
5825
5826 if (!cap) {
5827 return -1;
5828 }
5829 ast_format_cap_append(cap, format, 0);
5830
5831 res = set_format(chan, cap, 0, 0);
5832
5833 ao2_cleanup(cap);
5834 return res;
5835}
static int set_format(struct ast_channel *chan, struct ast_format_cap *cap_set, const int direction, int interleaved_stereo)
Definition channel.c:5650
@ AST_FORMAT_CAP_FLAG_DEFAULT
Definition format_cap.h:38
#define ast_format_cap_append(cap, format, framing)
Add format capability to capabilities structure.
Definition format_cap.h:99
#define ast_format_cap_alloc(flags)
Allocate a new ast_format_cap structure.
Definition format_cap.h:49

References ao2_cleanup, ast_assert, ast_format_cap_alloc, ast_format_cap_append, AST_FORMAT_CAP_FLAG_DEFAULT, NULL, and set_format().

Referenced by __ast_play_and_record(), adsi_transmit_message_full(), alarmreceiver_exec(), ast_bridge_channel_restore_formats(), ast_channel_make_compatible_helper(), audiosocket_exec(), background_detect_exec(), build_conf(), channel_do_masquerade(), conf_run(), dictate_exec(), do_waiting(), eagi_exec(), fax_detect_framehook(), fax_gateway_framehook(), generic_fax_exec(), handle_recordfile(), handle_speechrecognize(), holding_bridge_join(), isAnsweringMachine(), jack_exec(), jingle_interpret_content(), jingle_read(), measurenoise(), meetme_menu_admin_extended(), old_milliwatt_exec(), ooh323_new(), ooh323_rtp_read(), ooh323_set_read_format(), ooh323_set_write_format(), record_exec(), set_caps(), set_read_to_slin(), socket_process_helper(), speech_background(), and unistim_rtp_read().

◆ ast_set_read_format_from_cap()

int ast_set_read_format_from_cap ( struct ast_channel chan,
struct ast_format_cap formats 
)

Sets read format on channel chan from capabilities Set read format for channel to whichever component of "format" is best.

Parameters
chanchannel to change
formatsnew formats to pick from for reading
Returns
Returns 0 on success, -1 on failure

Definition at line 5837 of file channel.c.

5838{
5839 return set_format(chan, cap, 0, 0);
5840}

References set_format().

◆ ast_set_read_format_path()

int ast_set_read_format_path ( struct ast_channel chan,
struct ast_format raw_format,
struct ast_format core_format 
)

Set specific read path on channel.

Since
13.4.0
Parameters
chanChannel to setup read path.
raw_formatFormat to expect from the channel driver.
core_formatWhat the core wants to read.
Precondition
chan is locked
Return values
0on success.
-1on error.

Definition at line 5545 of file channel.c.

5546{
5547 struct ast_trans_pvt *trans_old;
5548 struct ast_trans_pvt *trans_new;
5549
5552 /* Nothing to setup */
5553 return 0;
5554 }
5555
5556 ast_debug(1, "Channel %s setting read format path: %s -> %s\n",
5557 ast_channel_name(chan),
5558 ast_format_get_name(raw_format),
5559 ast_format_get_name(core_format));
5560
5561 /* Setup new translation path. */
5562 if (ast_format_cmp(raw_format, core_format) != AST_FORMAT_CMP_EQUAL) {
5563 trans_new = ast_translator_build_path(core_format, raw_format);
5564 if (!trans_new) {
5565 return -1;
5566 }
5567 } else {
5568 /* No translation needed. */
5569 trans_new = NULL;
5570 }
5571 trans_old = ast_channel_readtrans(chan);
5572 if (trans_old) {
5573 ast_translator_free_path(trans_old);
5574 }
5575 ast_channel_readtrans_set(chan, trans_new);
5576 ast_channel_set_rawreadformat(chan, raw_format);
5577 ast_channel_set_readformat(chan, core_format);
5578 return 0;
5579}
enum ast_format_cmp_res ast_format_cmp(const struct ast_format *format1, const struct ast_format *format2)
Compare two formats.
Definition format.c:201
@ AST_FORMAT_CMP_EQUAL
Definition format.h:36
const char * ast_format_get_name(const struct ast_format *format)
Get the name associated with a format.
Definition format.c:334
void ast_translator_free_path(struct ast_trans_pvt *tr)
Frees a translator path Frees the given translator path structure.
Definition translate.c:533
struct ast_trans_pvt * ast_translator_build_path(struct ast_format *dest, struct ast_format *source)
Builds a translator path Build a path (possibly NULL) from source to dest.
Definition translate.c:543

References ast_channel_name(), ast_channel_rawreadformat(), ast_channel_readformat(), ast_channel_readtrans(), ast_channel_readtrans_set(), ast_channel_set_rawreadformat(), ast_channel_set_readformat(), ast_debug, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_get_name(), ast_translator_build_path(), ast_translator_free_path(), and NULL.

Referenced by __ast_read(), chan_pjsip_read_stream(), set_softmix_bridge_data(), and softmix_bridge_write_voice().

◆ ast_set_variables()

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
Precondition
chan is locked

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

Definition at line 8221 of file channel.c.

8222{
8223 struct ast_variable *cur;
8224
8225 for (cur = vars; cur; cur = cur->next) {
8226 pbx_builtin_setvar_helper(chan, cur->name, cur->value);
8227 }
8228}
struct ast_variable * next

References ast_variable::name, ast_variable::next, pbx_builtin_setvar_helper(), and ast_variable::value.

Referenced by __ast_request_and_dial(), ari_channels_handle_originate_with_id(), ast_ari_channels_create(), ast_call_forward(), ast_pbx_outgoing_exten_predial(), and pbx_outgoing_attempt().

◆ ast_set_write_format()

int ast_set_write_format ( struct ast_channel chan,
struct ast_format format 
)

Sets write format on channel chan.

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

Definition at line 5860 of file channel.c.

5861{
5863 int res;
5864
5865 ast_assert(format != NULL);
5866
5867 if (!cap) {
5868 return -1;
5869 }
5870 ast_format_cap_append(cap, format, 0);
5871
5872 res = set_format(chan, cap, 1, 0);
5873
5874 ao2_cleanup(cap);
5875 return res;
5876}

References ao2_cleanup, ast_assert, ast_format_cap_alloc, ast_format_cap_append, AST_FORMAT_CAP_FLAG_DEFAULT, NULL, and set_format().

Referenced by adsi_transmit_message_full(), alarmreceiver_exec(), ast_bridge_channel_restore_formats(), ast_channel_make_compatible_helper(), ast_channel_start_silence_generator(), ast_channel_stop_silence_generator(), ast_stopstream(), ast_write_stream(), audiosocket_exec(), broadcast_exec(), build_conf(), channel_do_masquerade(), chanspy_exec(), conf_run(), dahdiscan_exec(), extenspy_exec(), fax_gateway_framehook(), generic_fax_exec(), handle_participant_join(), jack_exec(), jingle_interpret_content(), jingle_read(), linear_alloc(), linear_release(), meetme_menu_admin_extended(), moh_alloc(), moh_files_release(), moh_files_write_format_change(), moh_release(), mp3_exec(), old_milliwatt_exec(), ooh323_new(), ooh323_rtp_read(), ooh323_set_write_format(), ooh323_write(), participant_reaction_announcer_join(), playtones_alloc(), playtones_release(), send_waveform_to_channel(), set_caps(), set_softmix_bridge_data(), socket_process_helper(), tonepair_alloc(), tonepair_release(), and unistim_rtp_read().

◆ ast_set_write_format_from_cap()

int ast_set_write_format_from_cap ( struct ast_channel chan,
struct ast_format_cap formats 
)

Sets write format on channel chan Set write format for channel to whichever component of "format" is best.

Parameters
chanchannel to change
formatsnew formats to pick from for writing
Returns
Returns 0 on success, -1 on failure

Definition at line 5878 of file channel.c.

5879{
5880 return set_format(chan, cap, 1, 0);
5881}

References set_format().

Referenced by openstream_internal().

◆ ast_set_write_format_interleaved_stereo()

int ast_set_write_format_interleaved_stereo ( struct ast_channel chan,
struct ast_format format 
)

Sets write format for a channel. All internal data will than be handled in an interleaved format. (needed by binaural opus)

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

Definition at line 5842 of file channel.c.

5843{
5845 int res;
5846
5847 ast_assert(format != NULL);
5848
5849 if (!cap) {
5850 return -1;
5851 }
5852 ast_format_cap_append(cap, format, 0);
5853
5854 res = set_format(chan, cap, 1, 1);
5855
5856 ao2_cleanup(cap);
5857 return res;
5858}

References ao2_cleanup, ast_assert, ast_format_cap_alloc, ast_format_cap_append, AST_FORMAT_CAP_FLAG_DEFAULT, NULL, and set_format().

Referenced by set_softmix_bridge_data(), and softmix_bridge_unsuspend().

◆ ast_set_write_format_path()

int ast_set_write_format_path ( struct ast_channel chan,
struct ast_format core_format,
struct ast_format raw_format 
)

Set specific write path on channel.

Since
13.13.0
Parameters
chanChannel to setup write path.
core_formatWhat the core wants to write.
raw_formatRaw write format.
Precondition
chan is locked
Return values
0on success.
-1on error.

Definition at line 5581 of file channel.c.

5582{
5583 struct ast_trans_pvt *trans_old;
5584 struct ast_trans_pvt *trans_new;
5585
5588 /* Nothing to setup */
5589 return 0;
5590 }
5591
5592 ast_debug(1, "Channel %s setting write format path: %s -> %s\n",
5593 ast_channel_name(chan),
5594 ast_format_get_name(core_format),
5595 ast_format_get_name(raw_format));
5596
5597 /* Setup new translation path. */
5598 if (ast_format_cmp(raw_format, core_format) != AST_FORMAT_CMP_EQUAL) {
5599 trans_new = ast_translator_build_path(raw_format, core_format);
5600 if (!trans_new) {
5601 return -1;
5602 }
5603 } else {
5604 /* No translation needed. */
5605 trans_new = NULL;
5606 }
5607 trans_old = ast_channel_writetrans(chan);
5608 if (trans_old) {
5609 ast_translator_free_path(trans_old);
5610 }
5611 ast_channel_writetrans_set(chan, trans_new);
5612 ast_channel_set_rawwriteformat(chan, raw_format);
5613 ast_channel_set_writeformat(chan, core_format);
5614 return 0;
5615}

References ast_channel_name(), ast_channel_rawwriteformat(), ast_channel_set_rawwriteformat(), ast_channel_set_writeformat(), ast_channel_writeformat(), ast_channel_writetrans(), ast_channel_writetrans_set(), ast_debug, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_get_name(), ast_translator_build_path(), ast_translator_free_path(), and NULL.

Referenced by chan_pjsip_read_stream().

◆ ast_settimeout()

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, accommodates new timing methods

Definition at line 3218 of file channel.c.

3219{
3220 return ast_settimeout_full(c, rate, func, data, 0);
3221}
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:3223

References ast_settimeout_full(), c, and ast_channel::data.

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

◆ ast_settimeout_full()

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

3224{
3225 int res;
3226 unsigned int real_rate = rate, max_rate;
3228
3230
3231 if (ast_channel_timingfd(c) == -1) {
3233 return -1;
3234 }
3235
3236 if (!func) {
3237 rate = 0;
3238 data = NULL;
3239 }
3240
3241 if (rate && rate > (max_rate = ast_timer_get_max_rate(timer))) {
3242 real_rate = max_rate;
3243 }
3244
3245 ast_debug(3, "Scheduling timer at (%u requested / %u actual) timer ticks per second\n", rate, real_rate);
3246
3247 res = ast_timer_set_rate(timer, real_rate);
3248
3251 }
3252
3255
3256 if (data && is_ao2_obj) {
3257 ao2_ref(data, 1);
3259 } else {
3261 }
3262
3263 if (func == NULL && rate == 0 && ast_channel_fdno(c) == AST_TIMING_FD) {
3264 /* Clearing the timing func and setting the rate to 0
3265 * means that we don't want to be reading from the timingfd
3266 * any more. Setting c->fdno to -1 means we won't have any
3267 * errant reads from the timingfd, meaning we won't potentially
3268 * miss any important frames.
3269 */
3271 }
3272
3274
3275 return res;
3276}
#define AST_TIMING_FD
Definition channel.h:203
void * data
Definition timing.c:55
unsigned int ast_timer_get_max_rate(const struct ast_timer *handle)
Get maximum rate supported for a timer.
Definition timing.c:191

References ao2_ref, ast_channel_fdno(), ast_channel_fdno_set(), ast_channel_flags(), ast_channel_lock, ast_channel_timer(), ast_channel_timingdata(), ast_channel_timingdata_set(), ast_channel_timingfd(), ast_channel_timingfunc_set(), 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, c, ast_timer::data, NULL, and timer.

Referenced by ast_readaudio_callback(), and ast_settimeout().

◆ ast_softhangup()

int ast_softhangup ( struct ast_channel chan,
int  cause 
)

Softly hangup up a channel.

Parameters
chanchannel to be soft-hung-up
causean 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.

Warning
The channel passed to this function must NOT be locked. ast_softhangup() calls ast_rtp_instance_set_stats_vars() to set RTP QOS variables. If this channel is in a bridge, ast_rtp_instance_set_stats_vars() will attempt to lock the bridge peer as well as this channel. This can cause a lock inversion if we already have this channel locked and another thread tries to set bridge variables on the peer because it will have locked the peer first, then this channel. For this reason, we must NOT have the channel locked when we call ast_softhangup().
Returns
Returns 0 regardless

Softly hangup up a channel.

Definition at line 2462 of file channel.c.

2463{
2464 RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
2465 int res;
2466 int tech_cause = 0;
2467 struct ast_rtp_glue *glue;
2468 struct ast_rtp_instance *rtp = NULL;
2469 const struct ast_channel_tech *tech;
2470
2471 /*
2472 * Only hold the channel lock long enough to get the rtp instance.
2473 * glue->get_rtp_info() will bump the refcount on it.
2474 */
2475 ast_channel_lock(chan);
2476 tech = ast_channel_tech(chan);
2477 glue = ast_rtp_instance_get_glue(tech->type);
2478 if (glue) {
2479 glue->get_rtp_info(chan, &rtp);
2480 }
2481 ast_channel_unlock(chan);
2482
2483 /*
2484 * If this channel is in a bridge, ast_rtp_instance_set_stats_vars() will
2485 * attempt to lock the bridge peer as well as this channel. This can cause
2486 * a lock inversion if we already have this channel locked and another
2487 * thread tries to set bridge variables on the peer because it will have
2488 * locked the peer first, then this channel. For this reason, we must
2489 * NOT have the channel locked when we call ast_rtp_instance_set_stats_vars().
2490 * This should be safe since glue->get_rtp_info() will have bumped the
2491 * refcount on the rtp instance so it can't go away while the channel
2492 * is unlocked.
2493 */
2494 if (rtp) {
2496 ao2_ref(rtp, -1);
2497 }
2498
2499 /*
2500 * Now it's safe to lock the channel again.
2501 */
2502 ast_channel_lock(chan);
2503
2504 res = ast_softhangup_nolock(chan, cause);
2505 blob = ast_json_pack("{s: i, s: b}",
2506 "cause", cause,
2507 "soft", 1);
2508
2509 tech_cause = ast_channel_tech_hangupcause(chan);
2510 if (tech_cause) {
2511 ast_json_object_set(blob, "tech_cause", ast_json_integer_create(tech_cause));
2512 }
2513
2515 ast_channel_unlock(chan);
2516
2517 return res;
2518}
void ast_rtp_instance_set_stats_vars(struct ast_channel *chan, struct ast_rtp_instance *instance)
Set standard statistics from an RTP instance on a channel.
struct ast_rtp_glue * ast_rtp_instance_get_glue(const char *type)
Get the RTP glue that binds a channel to the RTP engine.
enum ast_rtp_glue_result(* get_rtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance)
Callback for retrieving the RTP instance carrying audio.
Definition rtp_engine.h:787

References ao2_ref, ast_channel_hangup_request_type(), ast_channel_lock, ast_channel_publish_blob(), ast_channel_tech_hangupcause(), ast_channel_unlock, ast_json_integer_create(), ast_json_object_set(), ast_json_pack(), ast_json_unref(), ast_rtp_instance_get_glue(), ast_rtp_instance_set_stats_vars(), ast_softhangup_nolock(), ast_rtp_glue::get_rtp_info, NULL, RAII_VAR, and ast_channel_tech::type.

Referenced by __analog_handle_event(), __ast_module_user_hangup_all(), __ast_pbx_run(), __unload_module(), after_bridge_move_channel(), after_bridge_move_channel_fail(), agent_logoff_request(), agents_sweep(), analog_attempt_transfer(), ast_ari_channels_hangup(), ast_bridge_transfer_attended(), ast_channel_softhangup_cb(), ast_dial_join(), attempt_transfer(), blond_nonfinal_exit(), bridge_channel_attended_transfer(), cc_generic_agent_stop_ringing(), channel_hangup_matches(), conf_free(), dahdi_handle_event(), handle_hangup(), handle_softhangup(), hangup_channel(), retransfer_exit(), rtp_check_timeout(), sla_handle_hold_event(), softhangup_exec(), stasis_app_bridge_moh_stop(), and unload_module().

◆ ast_softhangup_all()

void ast_softhangup_all ( void  )

Soft hangup all active channels.

Since
13.3.0

Definition at line 494 of file channel.c.

495{
497}
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.
Definition channel.c:1336
static int ast_channel_softhangup_cb(void *obj, void *arg, void *data, int flags)
Definition channel.c:485

References ast_channel_callback(), ast_channel_softhangup_cb(), and NULL.

Referenced by can_safely_quit().

◆ ast_softhangup_nolock()

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
causean AST_SOFTHANGUP_* reason code

Softly hangup up a channel (no channel lock)

Definition at line 2449 of file channel.c.

2450{
2451 ast_debug(1, "Soft-Hanging (%#04x) up channel '%s'\n", (unsigned)cause, ast_channel_name(chan));
2452 /* Inform channel driver that we need to be hung up, if it cares */
2455 /* Interrupt any poll call or such */
2457 pthread_kill(ast_channel_blocker(chan), SIGURG);
2458 return 0;
2459}

References ast_channel_blocker(), ast_channel_flags(), ast_channel_name(), ast_channel_softhangup_internal_flag_add(), ast_debug, AST_FLAG_BLOCKING, ast_null_frame, ast_queue_frame(), and ast_test_flag.

Referenced by __analog_handle_event(), app_control_dial(), ast_async_goto(), ast_bridge_join(), ast_channel_softhangup_withcause_locked(), ast_pbx_h_exten_run(), ast_pbx_hangup_handler_run(), ast_softhangup(), attempt_transfer(), dahdi_softhangup_all(), do_monitor(), gosub_run(), internal_bridge_after_cb(), jingle_indicate(), and pbx_builtin_hangup().

◆ ast_state2str()

const char * ast_state2str ( enum ast_channel_state  state)

Gives the string form of a given channel state.

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

Definition at line 637 of file channel.c.

638{
639 char *buf;
640
641 switch (state) {
642 case AST_STATE_DOWN:
643 return "Down";
645 return "Rsrvd";
647 return "OffHook";
649 return "Dialing";
650 case AST_STATE_RING:
651 return "Ring";
653 return "Ringing";
654 case AST_STATE_UP:
655 return "Up";
656 case AST_STATE_BUSY:
657 return "Busy";
659 return "Dialing Offhook";
661 return "Pre-ring";
662 case AST_STATE_MUTE:
663 return "Mute";
664 default:
665 if (!(buf = ast_threadstorage_get(&state2str_threadbuf, STATE2STR_BUFSIZE)))
666 return "Unknown";
667 snprintf(buf, STATE2STR_BUFSIZE, "Unknown (%u)", state);
668 return buf;
669 }
670}
#define STATE2STR_BUFSIZE
Definition channel.c:102
@ AST_STATE_MUTE
@ AST_STATE_DIALING_OFFHOOK
@ AST_STATE_PRERING
@ AST_STATE_OFFHOOK
@ AST_STATE_BUSY
@ AST_STATE_DIALING
@ AST_STATE_RESERVED
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.

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

Referenced by ast_channel_snapshot_to_json(), ast_manager_build_channel_state_string_prefix(), ast_raw_answer_with_stream_topology(), cli_channel_print_body(), func_channel_read(), handle_chanlist(), handle_showchan(), and serialize_showchan().

◆ ast_str2cause()

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

627{
628 int x;
629
630 for (x = 0; x < ARRAY_LEN(causes); x++)
631 if (!strncasecmp(causes[x].name, name, strlen(causes[x].name)))
632 return causes[x].cause;
633
634 return -1;
635}

References ARRAY_LEN, causes, and name.

Referenced by dial_exec_full(), and pbx_builtin_hangup().

◆ ast_tonepair()

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

7675{
7676 int res;
7677
7678 if ((res = ast_tonepair_start(chan, freq1, freq2, duration, vol)))
7679 return res;
7680
7681 /* Give us some wiggle room */
7682 while (ast_channel_generatordata(chan) && ast_waitfor(chan, 100) >= 0) {
7683 struct ast_frame *f = ast_read(chan);
7684 if (f)
7685 ast_frfree(f);
7686 else
7687 return -1;
7688 }
7689 return 0;
7690}
int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
Definition channel.c:7656

References ast_channel_generatordata(), ast_frfree, ast_read(), ast_tonepair_start(), ast_waitfor(), tonepair_def::duration, tonepair_def::freq1, tonepair_def::freq2, and tonepair_def::vol.

Referenced by zapateller_exec().

◆ ast_tonepair_start()

int ast_tonepair_start ( struct ast_channel chan,
int  freq1,
int  freq2,
int  duration,
int  vol 
)

Start a tone going

Definition at line 7656 of file channel.c.

7657{
7658 struct tonepair_def d = { 0, };
7659
7660 d.freq1 = freq1;
7661 d.freq2 = freq2;
7662 d.duration = duration;
7663 d.vol = (vol < 1) ? 8192 : vol; /* force invalid to 8192 */
7664 if (ast_activate_generator(chan, &tonepair, &d))
7665 return -1;
7666 return 0;
7667}
static struct ast_generator tonepair
Definition channel.c:7650

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

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

◆ ast_tonepair_stop()

void ast_tonepair_stop ( struct ast_channel chan)

Stop a tone from playing

Definition at line 7669 of file channel.c.

7670{
7672}
void ast_deactivate_generator(struct ast_channel *chan)
Definition channel.c:2926

References ast_deactivate_generator().

Referenced by sendnoise().

◆ ast_transfer()

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

6543{
6544 int protocol;
6545 return ast_transfer_protocol(chan, dest, &protocol);
6546}
int ast_transfer_protocol(struct ast_channel *chan, char *dest, int *protocol)
Transfer a call to dest, if the channel supports transfer.
Definition channel.c:6555

References ast_transfer_protocol().

Referenced by app_control_redirect().

◆ ast_transfer_protocol()

int ast_transfer_protocol ( struct ast_channel chan,
char *  dest,
int *  protocol 
)

Transfer a channel (if supported) receieve protocol result.

Return values
-1on error
0if not supported
1if supported and requested
Parameters
chanchannel to transfer
destdestination extension to transfer to
protocolprotocol is the protocol result SIP example, 0=success, 3xx-6xx is SIP error code

Transfer a channel (if supported) receieve protocol result.

Called by:

  • app_transfer
  • the manager interface

Definition at line 6555 of file channel.c.

6556{
6557 int res = -1;
6558
6559 if (protocol) {
6560 *protocol = 0;
6561 }
6562
6563 /* Stop if we're a zombie or need a soft hangup */
6564 ast_channel_lock(chan);
6566 if (ast_channel_tech(chan)->transfer) {
6567 res = ast_channel_tech(chan)->transfer(chan, dest);
6568 if (!res)
6569 res = 1;
6570 } else
6571 res = 0;
6572 }
6573 ast_channel_unlock(chan);
6574
6575 if (res <= 0) {
6576 return res;
6577 }
6578
6579 for (;;) {
6580 struct ast_frame *fr;
6581
6582 res = ast_waitfor(chan, -1);
6583
6584 if (res < 0 || !(fr = ast_read(chan))) {
6585 res = -1;
6586 break;
6587 }
6588
6591
6592 if (*message == AST_TRANSFER_SUCCESS) {
6593 res = 1;
6594 } else {
6595 res = -1;
6596 /* Message can contain a protocol specific code
6597 AST_TRANSFER_SUCCESS indicates success
6598 Else, failure. Protocol will be set to the failure reason.
6599 SIP example, 0 is success, else error code 3xx-6xx */
6600 if (protocol) {
6601 *protocol = *message;
6602 }
6603 }
6604
6605 ast_frfree(fr);
6606 break;
6607 }
6608
6609 ast_frfree(fr);
6610 }
6611
6612 return res;
6613}
static int transfer(void *data)
@ AST_TRANSFER_SUCCESS
@ AST_CONTROL_TRANSFER
int(*const transfer)(struct ast_channel *chan, const char *newdest)
Blind transfer other side (see app_transfer.c and ast_transfer()
Definition channel.h:803

References ast_channel_flags(), 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, transfer(), and ast_channel_tech::transfer.

Referenced by ast_transfer(), and transfer_exec().

◆ ast_transfercapability2str()

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

674{
675 switch (transfercapability) {
677 return "SPEECH";
679 return "DIGITAL";
681 return "RESTRICTED_DIGITAL";
683 return "3K1AUDIO";
685 return "DIGITAL_W_TONES";
687 return "VIDEO";
688 default:
689 return "UNKNOWN";
690 }
691}
#define AST_TRANS_CAP_RESTRICTED_DIGITAL
Definition transcap.h:37
#define AST_TRANS_CAP_DIGITAL
Definition transcap.h:36
#define AST_TRANS_CAP_DIGITAL_W_TONES
Definition transcap.h:40
#define AST_TRANS_CAP_SPEECH
Definition transcap.h:35
#define AST_TRANS_CAP_3_1K_AUDIO
Definition transcap.h:38
#define AST_TRANS_CAP_VIDEO
Definition transcap.h:41

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.

◆ ast_undestroyed_channels()

int ast_undestroyed_channels ( void  )
Returns
the number of channels not yet destroyed

Definition at line 505 of file channel.c.

506{
508}
static int chancount
Definition channel.c:97
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
Definition lock.h:764

References ast_atomic_fetchadd_int(), and chancount.

Referenced by wait_for_channels_to_die().

◆ ast_unref_namedgroups()

struct ast_namedgroups * ast_unref_namedgroups ( struct ast_namedgroups *  groups)

◆ ast_waitfor()

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

3201{
3202 if (ms < 0) {
3203 do {
3204 ms = 100000;
3205 ast_waitfor_nandfds(&c, 1, NULL, 0, NULL, NULL, &ms);
3206 } while (!ms);
3207 } else {
3208 ast_waitfor_nandfds(&c, 1, NULL, 0, NULL, NULL, &ms);
3209 }
3210 return ms;
3211}
struct ast_channel * ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds, int nfds, int *exception, int *outfd, int *ms)
Wait for x amount of time on a file descriptor to have input.
Definition channel.c:3026

References ast_waitfor_nandfds(), c, and NULL.

Referenced by __adsi_transmit_messages(), __analog_ss_thread(), __ast_answer(), __ast_play_and_record(), __ast_request_and_dial(), adsi_careful_send(), analog_ss_thread(), ast_control_tone(), ast_recvtext(), ast_tonepair(), ast_transfer_protocol(), background_detect_exec(), channel_spy(), conf_flush(), dial_trunk(), dictate_exec(), disa_exec(), disable_t38(), do_broadcast(), do_waiting(), echo_exec(), handle_recordfile(), handle_speechrecognize(), isAnsweringMachine(), jack_exec(), launch_asyncagi(), measurenoise(), moh_channel_thread(), mp3_exec(), read_mf_digits(), read_sf_digits(), receive_dtmf_digits(), receivefax_t38_init(), record_exec(), recordthread(), safe_sleep_conditional(), scan_exec(), send_waveform_to_channel(), sendfax_t38_init(), speech_background(), stasis_app_exec(), stream_echo_perform(), wait_exec(), wait_for_hangup(), waitforring_exec(), and waitstream_core().

◆ ast_waitfor_n()

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

3196{
3197 return ast_waitfor_nandfds(c, n, NULL, 0, NULL, NULL, ms);
3198}

References ast_waitfor_nandfds(), c, and NULL.

Referenced by autoservice_run(), dial_exec_full(), monitor_dial(), wait_for_answer(), wait_for_answer(), and wait_for_winner().

◆ ast_waitfor_n_fd()

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

3019{
3020 int winner = -1;
3021 ast_waitfor_nandfds(NULL, 0, fds, n, exception, &winner, ms);
3022 return winner;
3023}

References ast_waitfor_nandfds(), and NULL.

Referenced by dundi_lookup_internal(), dundi_precache_internal(), rfcomm_wait(), and softmix_mixing_loop().

◆ ast_waitfor_nandfds()

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
can 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
msOn invocation, max wait time. Upon returning, how long the wait actually was (in/out parameter).

Big momma function here. Wait for activity on any of the n channels, or any of the nfds file descriptors. -1 can be passed as the ms timeout to wait forever, 0 to return instantly if theres no activity immediantely available.

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

3028{
3029 struct timeval start = { 0 , 0 };
3030 struct pollfd *pfds = NULL;
3031 int res;
3032 long rms;
3033 int x, y, max;
3034 int sz = nfds;
3035 struct timeval now = { 0, 0 };
3036 struct timeval whentohangup = { 0, 0 }, diff;
3037 struct ast_channel *winner = NULL;
3038 struct fdmap {
3039 int chan;
3040 int fdno;
3041 } *fdmap = NULL;
3042
3043 if (outfd) {
3044 *outfd = -99999;
3045 }
3046 if (exception) {
3047 *exception = 0;
3048 }
3049
3050 for (x = 0; x < n; x++) {
3051 ast_channel_lock(c[x]);
3053 if (ast_tvzero(whentohangup))
3054 now = ast_tvnow();
3055 diff = ast_tvsub(*ast_channel_whentohangup(c[x]), now);
3056 if (diff.tv_sec < 0 || ast_tvzero(diff)) {
3057 ast_test_suite_event_notify("HANGUP_TIME", "Channel: %s", ast_channel_name(c[x]));
3058 /* Should already be hungup */
3061 return c[x];
3062 }
3063 if (ast_tvzero(whentohangup) || ast_tvcmp(diff, whentohangup) < 0)
3064 whentohangup = diff;
3065 }
3066 sz += ast_channel_fd_count(c[x]);
3068 }
3069
3070 if (!sz) {
3071 return NULL;
3072 }
3073
3074 pfds = ast_alloca(sizeof(*pfds) * sz);
3075 fdmap = ast_alloca(sizeof(*fdmap) * sz);
3076
3077 /* Wait full interval */
3078 rms = *ms;
3079 /* INT_MAX, not LONG_MAX, because it matters on 64-bit */
3080 if (!ast_tvzero(whentohangup) && whentohangup.tv_sec < INT_MAX / 1000) {
3081 rms = whentohangup.tv_sec * 1000 + whentohangup.tv_usec / 1000; /* timeout in milliseconds */
3082 if (*ms >= 0 && *ms < rms) { /* original *ms still smaller */
3083 rms = *ms;
3084 }
3085 } else if (!ast_tvzero(whentohangup) && rms < 0) {
3086 /* Tiny corner case... call would need to last >24 days */
3087 rms = INT_MAX;
3088 }
3089 /*
3090 * Build the pollfd array, putting the channels' fds first,
3091 * followed by individual fds. Order is important because
3092 * individual fd's must have priority over channel fds.
3093 */
3094 max = 0;
3095 for (x = 0; x < n; x++) {
3096 ast_channel_lock(c[x]);
3097 for (y = 0; y < ast_channel_fd_count(c[x]); y++) {
3098 fdmap[max].fdno = y; /* fd y is linked to this pfds */
3099 fdmap[max].chan = x; /* channel x is linked to this pfds */
3100 max += ast_add_fd(&pfds[max], ast_channel_fd(c[x], y));
3101 }
3102 CHECK_BLOCKING(c[x]);
3104 }
3105 /* Add the individual fds */
3106 for (x = 0; x < nfds; x++) {
3107 fdmap[max].chan = -1;
3108 max += ast_add_fd(&pfds[max], fds[x]);
3109 }
3110
3111 if (*ms > 0) {
3112 start = ast_tvnow();
3113 }
3114
3115 if (sizeof(int) == 4) { /* XXX fix timeout > 600000 on linux x86-32 */
3116 do {
3117 int kbrms = rms;
3118 if (kbrms > 600000) {
3119 kbrms = 600000;
3120 }
3121 res = ast_poll(pfds, max, kbrms);
3122 if (!res) {
3123 rms -= kbrms;
3124 }
3125 } while (!res && (rms > 0));
3126 } else {
3127 res = ast_poll(pfds, max, rms);
3128 }
3129 for (x = 0; x < n; x++) {
3130 ast_channel_lock(c[x]);
3133 }
3134 if (res < 0) { /* Simulate a timeout if we were interrupted */
3135 if (errno != EINTR) {
3136 *ms = -1;
3137 }
3138 return NULL;
3139 }
3140 if (!ast_tvzero(whentohangup)) { /* if we have a timeout, check who expired */
3141 now = ast_tvnow();
3142 for (x = 0; x < n; x++) {
3144 ast_test_suite_event_notify("HANGUP_TIME", "Channel: %s", ast_channel_name(c[x]));
3146 if (winner == NULL) {
3147 winner = c[x];
3148 }
3149 }
3150 }
3151 }
3152 if (res == 0) { /* no fd ready, reset timeout and done */
3153 *ms = 0; /* XXX use 0 since we may not have an exact timeout. */
3154 return winner;
3155 }
3156 /*
3157 * Then check if any channel or fd has a pending event.
3158 * Remember to check channels first and fds last, as they
3159 * must have priority on setting 'winner'
3160 */
3161 for (x = 0; x < max; x++) {
3162 res = pfds[x].revents;
3163 if (res == 0) {
3164 continue;
3165 }
3166 if (fdmap[x].chan >= 0) { /* this is a channel */
3167 winner = c[fdmap[x].chan]; /* override previous winners */
3168 ast_channel_lock(winner);
3169 if (res & POLLPRI) {
3171 } else {
3173 }
3174 ast_channel_fdno_set(winner, fdmap[x].fdno);
3175 ast_channel_unlock(winner);
3176 } else { /* this is an fd */
3177 if (outfd) {
3178 *outfd = pfds[x].fd;
3179 }
3180 if (exception) {
3181 *exception = (res & POLLPRI) ? -1 : 0;
3182 }
3183 winner = NULL;
3184 }
3185 }
3186 if (*ms > 0) {
3187 *ms -= ast_tvdiff_ms(ast_tvnow(), start);
3188 if (*ms < 0) {
3189 *ms = 0;
3190 }
3191 }
3192 return winner;
3193}
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition astmm.h:288
#define max(a, b)
Definition f2c.h:198
#define ast_poll(a, b, c)
Definition poll-compat.h:88
int ast_tvcmp(struct timeval _a, struct timeval _b)
Compress two struct timeval instances returning -1, 0, 1 if the first arg is smaller,...
Definition time.h:137
struct timeval ast_tvsub(struct timeval a, struct timeval b)
Returns the difference of two timevals a - b.
Definition extconf.c:2295

References ast_add_fd(), ast_alloca, ast_channel_fd(), ast_channel_fd_count(), ast_channel_fdno_set(), ast_channel_flags(), ast_channel_lock, ast_channel_name(), ast_channel_softhangup_internal_flag_add(), ast_channel_unlock, ast_channel_whentohangup(), ast_clear_flag, AST_FLAG_BLOCKING, AST_FLAG_EXCEPTION, ast_poll, ast_set_flag, AST_SOFTHANGUP_TIMEOUT, ast_test_suite_event_notify, ast_tvcmp(), ast_tvdiff_ms(), ast_tvnow(), ast_tvsub(), ast_tvzero(), c, CHECK_BLOCKING, errno, max, and NULL.

Referenced by ast_waitfor(), ast_waitfor_n(), ast_waitfor_n_fd(), ast_waitfordigit_full(), audiosocket_run(), bridge_channel_wait(), conf_run(), eivr_comm(), generic_fax_exec(), run_agi(), wait_for_signal_or_hangup(), and waitstream_core().

◆ ast_waitfordigit()

int ast_waitfordigit ( struct ast_channel c,
int  ms 
)

◆ ast_waitfordigit_full()

int ast_waitfordigit_full ( struct ast_channel c,
int  ms,
const char *  breakon,
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).
breakonstring of DTMF digits to break upon or NULL for any.
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 3278 of file channel.c.

3279{
3280 struct timeval start = ast_tvnow();
3281 int ms;
3282
3283 /* Stop if we're a zombie or need a soft hangup */
3285 return -1;
3286
3287 /* Only look for the end of DTMF, don't bother with the beginning and don't emulate things */
3289
3290 /* Wait for a digit, no more than timeout_ms milliseconds total.
3291 * Or, wait indefinitely if timeout_ms is <0.
3292 */
3293 while ((ms = ast_remaining_ms(start, timeout_ms))) {
3294 struct ast_channel *rchan;
3295 int outfd = -1;
3296
3297 errno = 0;
3298 /* While ast_waitfor_nandfds tries to help by reducing the timeout by how much was waited,
3299 * it is unhelpful if it waited less than a millisecond.
3300 */
3301 rchan = ast_waitfor_nandfds(&c, 1, &cmdfd, (cmdfd > -1) ? 1 : 0, NULL, &outfd, &ms);
3302
3303 if (!rchan && outfd < 0 && ms) {
3304 if (errno == 0 || errno == EINTR)
3305 continue;
3306 ast_log(LOG_WARNING, "Wait failed (%s)\n", strerror(errno));
3308 return -1;
3309 } else if (outfd > -1) {
3310 /* The FD we were watching has something waiting */
3311 ast_log(LOG_WARNING, "The FD we were waiting for has something waiting. Waitfordigit returning numeric 1\n");
3313 return 1;
3314 } else if (rchan) {
3315 int res;
3316 struct ast_frame *f = ast_read(c);
3317
3318 if (!f) {
3320
3321 return -1;
3322 }
3323
3324 switch (f->frametype) {
3326 break;
3327 case AST_FRAME_DTMF_END:
3328 res = f->subclass.integer;
3329 if (!breakon || strchr(breakon, res)) {
3330 ast_frfree(f);
3332 return res;
3333 }
3334 break;
3335 case AST_FRAME_CONTROL:
3336 switch (f->subclass.integer) {
3337 case AST_CONTROL_HANGUP:
3338 ast_frfree(f);
3340 return -1;
3346 /* Fall-through and treat as if it were a DTMF signal. Items
3347 * that perform stream control will handle this. */
3348 res = f->subclass.integer;
3349 ast_frfree(f);
3351 return res;
3355 case AST_CONTROL_ANSWER:
3361 case AST_CONTROL_HOLD:
3362 case AST_CONTROL_UNHOLD:
3363 case AST_CONTROL_FLASH:
3364 case -1:
3365 /* Unimportant */
3366 break;
3367 default:
3368 ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", f->subclass.integer);
3369 break;
3370 }
3371 break;
3372 case AST_FRAME_VOICE:
3373 /* Write audio if appropriate */
3374 if (audiofd > -1) {
3375 if (write(audiofd, f->data.ptr, f->datalen) < 0) {
3376 ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
3377 }
3378 }
3379 default:
3380 /* Ignore */
3381 break;
3382 }
3383 ast_frfree(f);
3384 }
3385 }
3386
3388
3389 return 0; /* Time is up */
3390}
@ AST_CONTROL_STREAM_RESTART
@ AST_CONTROL_STREAM_SUSPEND
@ AST_CONTROL_STREAM_REVERSE
@ AST_CONTROL_STREAM_STOP
@ AST_CONTROL_STREAM_FORWARD
@ AST_CONTROL_FLASH
@ AST_CONTROL_UPDATE_RTP_PEER

References ast_channel_clear_flag(), ast_channel_flags(), ast_channel_set_flag(), ast_check_hangup(), AST_CONTROL_ANSWER, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_FLASH, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_PROGRESS, AST_CONTROL_PVT_CAUSE_CODE, AST_CONTROL_REDIRECTING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_CONTROL_STREAM_FORWARD, AST_CONTROL_STREAM_RESTART, AST_CONTROL_STREAM_REVERSE, AST_CONTROL_STREAM_STOP, AST_CONTROL_STREAM_SUSPEND, 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_test_flag, ast_tvnow(), ast_waitfor_nandfds(), c, ast_frame::data, ast_frame::datalen, errno, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, NULL, ast_frame::ptr, and ast_frame::subclass.

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

◆ ast_write()

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.

Definition at line 5201 of file channel.c.

5202{
5203 return ast_write_stream(chan, -1, fr);
5204}
int ast_write_stream(struct ast_channel *chan, int stream_num, struct ast_frame *fr)
Write a frame to a stream This function writes the given frame to the indicated stream on the channel...
Definition channel.c:5206

References ast_write_stream().

Referenced by adsi_careful_send(), ast_prod(), ast_readaudio_callback(), ast_readvideo_callback(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), ast_write_video(), audiosocket_run(), conf_queue_dtmf(), conf_run(), dictate_exec(), echo_exec(), fax_gateway_detect_v21(), gen_generate(), generic_fax_exec(), handle_jack_audio(), jb_get_and_deliver(), linear_generator(), manager_send_flash(), milliwatt_generate(), moh_files_generator(), moh_generate(), mp3_exec(), playtones_generator(), send_waveform_to_channel(), silence_generator_generate(), sms_generate(), spandsp_fax_gw_t30_gen(), spy_generate(), spy_generate(), t38_tx_packet_handler(), tonepair_generator(), and wait_for_answer().

◆ ast_write_stream()

int ast_write_stream ( struct ast_channel chan,
int  stream_num,
struct ast_frame frame 
)

Write a frame to a stream This function writes the given frame to the indicated stream on the channel.

Parameters
chandestination channel of the frame
stream_numdestination stream on the channel
frameframe that will be written
Returns
It returns 0 on success, -1 on failure.
Note
If -1 is provided as the stream number and a media frame is provided the function will write to the default stream of the type of media.

Definition at line 5206 of file channel.c.

5207{
5208 struct ast_stream *stream = NULL, *default_stream = NULL;
5209 int res = -1;
5210 struct ast_frame *f = NULL;
5211 int count = 0;
5212 int hooked = 0;
5213
5214 /*Deadlock avoidance*/
5215 while(ast_channel_trylock(chan)) {
5216 /*cannot goto done since the channel is not locked*/
5217 if(count++ > 10) {
5218 ast_debug(1, "Deadlock avoided for write to channel '%s'\n", ast_channel_name(chan));
5219 return 0;
5220 }
5221 usleep(1);
5222 }
5223
5224 /* Stop if we're a zombie or need a soft hangup */
5226 goto done;
5227 }
5228
5229 if (stream_num >= 0) {
5230 /* If we were told to write to an explicit stream then allow this frame through, no matter
5231 * if the type is expected or not (a framehook could change)
5232 */
5234 goto done;
5235 }
5237 default_stream = ast_channel_get_default_stream(chan, ast_stream_get_type(stream));
5238 } else if (fr->frametype == AST_FRAME_VOICE || fr->frametype == AST_FRAME_VIDEO || fr->frametype == AST_FRAME_MODEM) {
5239 /* If we haven't been told of a stream then we need to figure out which once we need */
5241
5242 /* Some frame types have a fixed media type */
5243 if (fr->frametype == AST_FRAME_VOICE || fr->frametype == AST_FRAME_VIDEO) {
5244 type = ast_format_get_type(fr->subclass.format);
5245 } else if (fr->frametype == AST_FRAME_MODEM) {
5247 }
5248
5249 /* No stream was specified, so use the default one */
5250 stream = default_stream = ast_channel_get_default_stream(chan, type);
5251 }
5252
5253 /* Perform the framehook write event here. After the frame enters the framehook list
5254 * there is no telling what will happen, how awesome is that!!! */
5255 if ((stream == default_stream) && !(fr = ast_framehook_list_write_event(ast_channel_framehooks(chan), fr))) {
5256 res = 0;
5257 goto done;
5258 }
5259
5260 if (ast_channel_generatordata(chan) && (fr->frametype != AST_FRAME_RTCP) && (!fr->src || strcasecmp(fr->src, "ast_prod"))) {
5263 } else {
5264 if (fr->frametype == AST_FRAME_DTMF_END) {
5265 /* There is a generator running while we're in the middle of a digit.
5266 * It's probably inband DTMF, so go ahead and pass it so it can
5267 * stop the generator */
5268 ast_channel_unlock(chan);
5269 res = ast_senddigit_end(chan, fr->subclass.integer, fr->len);
5270 ast_channel_lock(chan);
5271 } else if (fr->frametype == AST_FRAME_CONTROL
5272 && fr->subclass.integer == AST_CONTROL_UNHOLD) {
5273 /*
5274 * This is a side case where Echo is basically being called
5275 * and the person put themselves on hold and took themselves
5276 * off hold.
5277 */
5278 indicate_data_internal(chan, fr->subclass.integer, fr->data.ptr,
5279 fr->datalen);
5280 }
5281 res = 0; /* XXX explain, why 0 ? */
5282 goto done;
5283 }
5284 }
5285 /* High bit prints debugging */
5286 if (ast_channel_fout(chan) & DEBUGCHAN_FLAG)
5287 ast_frame_dump(ast_channel_name(chan), fr, ">>");
5288 switch (fr->frametype) {
5289 case AST_FRAME_CONTROL:
5290 indicate_data_internal(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
5291 res = 0;
5292 break;
5294 if (ast_channel_audiohooks(chan)) {
5295 struct ast_frame *old_frame = fr;
5297 if (old_frame != fr)
5298 f = fr;
5299 }
5300 send_dtmf_begin_event(chan, DTMF_SENT, fr->subclass.integer);
5301 ast_channel_unlock(chan);
5302 res = ast_senddigit_begin(chan, fr->subclass.integer);
5303 ast_channel_lock(chan);
5304 break;
5305 case AST_FRAME_DTMF_END:
5306 if (ast_channel_audiohooks(chan)) {
5307 struct ast_frame *new_frame = fr;
5308
5310 if (new_frame != fr) {
5311 ast_frfree(new_frame);
5312 }
5313 }
5314 send_dtmf_end_event(chan, DTMF_SENT, fr->subclass.integer, fr->len);
5315 ast_channel_unlock(chan);
5316 res = ast_senddigit_end(chan, fr->subclass.integer, fr->len);
5317 ast_channel_lock(chan);
5318 break;
5319 case AST_FRAME_TEXT:
5320 CHECK_BLOCKING(chan);
5321 if (ast_format_cmp(fr->subclass.format, ast_format_t140) == AST_FORMAT_CMP_EQUAL) {
5322 res = (ast_channel_tech(chan)->write_text == NULL) ? 0 :
5323 ast_channel_tech(chan)->write_text(chan, fr);
5324 } else {
5325 res = (ast_channel_tech(chan)->send_text == NULL) ? 0 :
5326 ast_channel_tech(chan)->send_text(chan, (char *) fr->data.ptr);
5327 }
5329 break;
5330 case AST_FRAME_HTML:
5331 CHECK_BLOCKING(chan);
5332 res = (ast_channel_tech(chan)->send_html == NULL) ? 0 :
5333 ast_channel_tech(chan)->send_html(chan, fr->subclass.integer, (char *) fr->data.ptr, fr->datalen);
5335 break;
5336 case AST_FRAME_VIDEO:
5337 /* XXX Handle translation of video codecs one day XXX */
5338 CHECK_BLOCKING(chan);
5339 if (ast_channel_tech(chan)->write_stream) {
5340 if (stream) {
5341 res = ast_channel_tech(chan)->write_stream(chan, ast_stream_get_position(stream), fr);
5342 } else {
5343 res = 0;
5344 }
5345 } else if ((stream == default_stream) && ast_channel_tech(chan)->write_video) {
5346 res = ast_channel_tech(chan)->write_video(chan, fr);
5347 } else {
5348 res = 0;
5349 }
5351 break;
5352 case AST_FRAME_MODEM:
5353 CHECK_BLOCKING(chan);
5354 res = tech_write(chan, stream, default_stream, fr);
5356 break;
5357 case AST_FRAME_VOICE:
5359 apply_plc(chan, fr);
5360 }
5361
5362 f = fr;
5363
5364 /*
5365 * Send frame to audiohooks if present, if frametype is linear (else, later as per
5366 * previous behavior)
5367 */
5368 if ((stream == default_stream) && ast_channel_audiohooks(chan)) {
5369 if (ast_format_cache_is_slinear(fr->subclass.format)) {
5370 hooked = 1;
5372 }
5373 }
5374
5375 /* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */
5376 if ((stream == default_stream) && ast_format_cmp(fr->subclass.format, ast_channel_rawwriteformat(chan)) != AST_FORMAT_CMP_EQUAL) {
5377 if (ast_format_cmp(ast_channel_writeformat(chan), fr->subclass.format) != AST_FORMAT_CMP_EQUAL) {
5378 struct ast_str *codec_buf = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
5379
5380 /*
5381 * We are not setup to write this frame. Things may have changed
5382 * on the peer side of the world and we try to adjust the format to
5383 * make it compatible again. However, bad things can happen if we
5384 * cannot setup a new translation path. Problems range from no
5385 * audio, one-way audio, to garbled audio. The best we can do is
5386 * request the call to hangup since we could not make it compatible.
5387 *
5388 * Being continuously spammed by this message likely indicates a
5389 * problem with the peer because it cannot make up its mind about
5390 * which format to use.
5391 */
5392 ast_debug(1, "Channel %s changing write format from %s to %s, native formats %s\n",
5393 ast_channel_name(chan),
5395 ast_format_get_name(fr->subclass.format),
5397 if (ast_set_write_format(chan, fr->subclass.format)) {
5398 /* Could not handle the new write format. Induce a hangup. */
5399 break;
5400 }
5401 }
5402
5403 if (ast_channel_writetrans(chan)) {
5404 struct ast_frame *trans_frame = ast_translate(ast_channel_writetrans(chan), f, 0);
5405 if (trans_frame != f && f != fr) {
5406 /*
5407 * If translate gives us a new frame and so did the audio
5408 * hook then we need to free the one from the audio hook.
5409 */
5410 ast_frfree(f);
5411 }
5412 f = trans_frame;
5413 }
5414 }
5415
5416 if (!f) {
5417 res = 0;
5418 break;
5419 }
5420
5421 if ((stream == default_stream) && ast_channel_audiohooks(chan) && !hooked) {
5422 struct ast_frame *prev = NULL, *new_frame, *cur, *dup;
5423 int freeoldlist = 0;
5424
5425 if (f != fr) {
5426 freeoldlist = 1;
5427 }
5428
5429 /* Since ast_audiohook_write may return a new frame, and the cur frame is
5430 * an item in a list of frames, create a new list adding each cur frame back to it
5431 * regardless if the cur frame changes or not. */
5432 for (cur = f; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
5434
5435 /* if this frame is different than cur, preserve the end of the list,
5436 * free the old frames, and set cur to be the new frame */
5437 if (new_frame != cur) {
5438
5439 /* doing an ast_frisolate here seems silly, but we are not guaranteed the new_frame
5440 * isn't part of local storage, meaning if ast_audiohook_write is called multiple
5441 * times it may override the previous frame we got from it unless we dup it */
5442 if ((dup = ast_frisolate(new_frame))) {
5444 if (freeoldlist) {
5446 ast_frfree(cur);
5447 }
5448 if (new_frame != dup) {
5449 ast_frfree(new_frame);
5450 }
5451 cur = dup;
5452 }
5453 }
5454
5455 /* now, regardless if cur is new or not, add it to the new list,
5456 * if the new list has not started, cur will become the first item. */
5457 if (prev) {
5458 AST_LIST_NEXT(prev, frame_list) = cur;
5459 } else {
5460 f = cur; /* set f to be the beginning of our new list */
5461 }
5462 prev = cur;
5463 }
5464 }
5465
5466 /* the translator on chan->writetrans may have returned multiple frames
5467 from the single frame we passed in; if so, feed each one of them to the
5468 channel, freeing each one after it has been written */
5469 CHECK_BLOCKING(chan);
5470 if ((f != fr) && AST_LIST_NEXT(f, frame_list)) {
5471 struct ast_frame *cur, *next = NULL;
5472 unsigned int skip = 0;
5473
5474 cur = f;
5475 while (cur) {
5478 if (!skip) {
5479 res = tech_write(chan, stream, default_stream, cur);
5480 if (res < 0) {
5482 skip = 1;
5483 } else if (next) {
5484 /* don't do this for the last frame in the list,
5485 as the code outside the loop will do it once
5486 */
5488 }
5489 }
5490 ast_frfree(cur);
5491 cur = next;
5492 }
5493
5494 /* reset f so the code below doesn't attempt to free it */
5495 f = NULL;
5496 } else {
5497 res = tech_write(chan, stream, default_stream, f);
5498 }
5500 break;
5501 case AST_FRAME_NULL:
5502 case AST_FRAME_IAX:
5503 /* Ignore these */
5504 res = 0;
5505 break;
5506 case AST_FRAME_RTCP:
5507 /* RTCP information is on a per-stream basis and only available on multistream capable channels */
5508 CHECK_BLOCKING(chan);
5509 if (ast_channel_tech(chan)->write_stream && stream) {
5510 res = ast_channel_tech(chan)->write_stream(chan, ast_stream_get_position(stream), fr);
5511 } else {
5512 res = 0;
5513 }
5515 break;
5516 default:
5517 /* At this point, fr is the incoming frame and f is NULL. Channels do
5518 * not expect to get NULL as a frame pointer and will segfault. Hence,
5519 * we output the original frame passed in. */
5520 CHECK_BLOCKING(chan);
5521 res = ast_channel_tech(chan)->write(chan, fr);
5523 break;
5524 }
5525
5526 if (f && f != fr)
5527 ast_frfree(f);
5528
5529 /* Consider a write failure to force a soft hangup */
5530 if (res < 0) {
5532 } else {
5534 }
5535done:
5537 /* The list gets recreated if audiohooks are added again later */
5540 }
5541 ast_channel_unlock(chan);
5542 return res;
5543}
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:1116
@ AST_AUDIOHOOK_DIRECTION_WRITE
Definition audiohook.h:50
void ast_audiohook_detach_list(struct ast_audiohook_list *audiohook_list)
Detach audiohooks from list and destroy said list.
Definition audiohook.c:602
static void send_dtmf_begin_event(struct ast_channel *chan, enum DtmfDirection direction, const char digit)
Definition channel.c:3409
@ DTMF_SENT
Definition channel.c:3394
static void send_dtmf_end_event(struct ast_channel *chan, enum DtmfDirection direction, const char digit, long duration_ms)
Definition channel.c:3424
static int tech_write(struct ast_channel *chan, struct ast_stream *stream, struct ast_stream *default_stream, struct ast_frame *frame)
Definition channel.c:5189
static void apply_plc(struct ast_channel *chan, struct ast_frame *frame)
Definition channel.c:5163
#define DEBUGCHAN_FLAG
Definition channel.h:877
#define FRAMECOUNT_INC(x)
Definition channel.h:880
@ AST_MEDIA_TYPE_UNKNOWN
Definition codec.h:31
@ AST_MEDIA_TYPE_IMAGE
Definition codec.h:34
enum ast_media_type ast_format_get_type(const struct ast_format *format)
Get the media type of a format.
Definition format.c:354
int ast_format_cache_is_slinear(struct ast_format *format)
Determines if a format is one of the cached slin formats.
#define AST_FORMAT_CAP_NAMES_LEN
Definition format_cap.h:324
static void write_stream(struct ogg_vorbis_desc *s, FILE *f)
Write out any pending encoded data.
void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
Definition main/frame.c:731
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
INT32 integer
Definition lpc10.h:80
#define ast_opt_generic_plc
Definition options.h:144
int ast_stream_get_position(const struct ast_stream *stream)
Get the position of the stream in the topology.
Definition stream.c:500
struct ast_stream * ast_stream_topology_get_stream(const struct ast_stream_topology *topology, unsigned int position)
Get a specific stream from the topology.
Definition stream.c:791
int ast_stream_topology_get_count(const struct ast_stream_topology *topology)
Get the number of streams in a topology.
Definition stream.c:768
enum ast_media_type ast_stream_get_type(const struct ast_stream *stream)
Get the media type of a stream.
Definition stream.c:316
#define ast_str_alloca(init_len)
Definition strings.h:848
int(*const write)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format (see frame.h)
Definition channel.h:770
int(*const write_video)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format.
Definition channel.h:806
struct ast_frame * next
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:623

References apply_plc(), ast_audiohook_detach_list(), AST_AUDIOHOOK_DIRECTION_WRITE, ast_audiohook_write_list(), ast_audiohook_write_list_empty(), ast_channel_audiohooks(), ast_channel_audiohooks_set(), ast_channel_flags(), ast_channel_fout(), ast_channel_fout_set(), ast_channel_framehooks(), ast_channel_generatordata(), ast_channel_get_default_stream(), ast_channel_get_stream_topology(), ast_channel_lock, ast_channel_name(), ast_channel_nativeformats(), ast_channel_rawwriteformat(), ast_channel_softhangup_internal_flag_add(), ast_channel_trylock, ast_channel_unlock, ast_channel_writeformat(), ast_channel_writetrans(), ast_check_hangup(), ast_clear_flag, AST_CONTROL_UNHOLD, ast_deactivate_generator(), ast_debug, AST_FLAG_BLOCKING, AST_FLAG_WRITE_INT, AST_FLAG_ZOMBIE, ast_format_cache_is_slinear(), ast_format_cap_get_names(), AST_FORMAT_CAP_NAMES_LEN, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_get_name(), ast_format_get_type(), ast_format_slin, 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_RTCP, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_framehook_list_write_event(), ast_frfree, ast_frisolate, AST_LIST_NEXT, AST_MEDIA_TYPE_IMAGE, AST_MEDIA_TYPE_UNKNOWN, ast_opt_generic_plc, ast_senddigit_begin(), ast_senddigit_end(), ast_set_write_format(), AST_SOFTHANGUP_DEV, ast_str_alloca, ast_stream_get_position(), ast_stream_get_type(), ast_stream_topology_get_count(), ast_stream_topology_get_stream(), ast_test_flag, ast_translate(), CHECK_BLOCKING, ast_frame::data, ast_frame::datalen, DEBUGCHAN_FLAG, done, DTMF_SENT, ast_frame_subclass::format, FRAMECOUNT_INC, ast_frame::frametype, indicate_data_internal(), ast_frame_subclass::integer, ast_frame::len, ast_frame::next, NULL, ast_frame::ptr, send_dtmf_begin_event(), send_dtmf_end_event(), ast_channel_tech::send_html, ast_channel_tech::send_text, ast_frame::src, ast_frame::stream_num, ast_frame::subclass, tech_write(), type, ast_channel_tech::write, write_stream(), ast_channel_tech::write_stream, ast_channel_tech::write_text, and ast_channel_tech::write_video.

Referenced by AST_TEST_DEFINE(), AST_TEST_DEFINE(), ast_write(), bridge_channel_handle_write(), and stream_echo_write().

◆ ast_write_text()

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.

◆ ast_write_video()

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

5075{
5076 int res;
5077 if (!ast_channel_tech(chan)->write_video)
5078 return 0;
5079 res = ast_write(chan, fr);
5080 if (!res)
5081 res = 1;
5082 return res;
5083}

References ast_write().

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [1/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( accountcode  )

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [2/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( call_forward  )

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [3/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( dialcontext  )

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [4/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( hangupsource  )

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [5/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( language  )

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [6/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( latest_musicclass  )

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [7/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( linkedid  )

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [8/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( musicclass  )

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [9/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( name  )

The following string fields result in channel snapshot creation and should have the channel locked when called:

  • language
  • accountcode
  • peeraccount
  • linkedid

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [10/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( parkinglot  )

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [11/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( peeraccount  )

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [12/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( uniqueid  )

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [13/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( userfield  )

◆ internal_channel_set_current_storage_driver()

int internal_channel_set_current_storage_driver ( const char *  driver_name)

Definition at line 8085 of file channel.c.

8086{
8087 if (ast_fully_booted) {
8088 ast_log(LOG_ERROR, "Cannot change channel storage driver after Asterisk has started\n");
8089 return -1;
8090 }
8093 return 0;
8094 }
8096 "Invalid channel storage backend '%s' specified. Attempting to use default '%s'.\n",
8097 driver_name, AST_CHANNELSTORAGE_DEFAULT_TYPE);
8100 return 0;
8101 }
8102 ast_log(LOG_ERROR, "Unable to find default channel storage backend '%s'.\n",
8104 return -1;
8105}
const struct ast_channelstorage_driver * ast_channelstorage_get_driver(const char *driver_name)
#define AST_CHANNELSTORAGE_DEFAULT_TYPE
#define ast_fully_booted
Definition options.h:127

References AST_CHANNELSTORAGE_DEFAULT_TYPE, ast_channelstorage_get_driver(), ast_fully_booted, ast_log, current_channel_storage_driver, LOG_ERROR, and LOG_WARNING.

Referenced by ast_channel_open_storage(), and load_asterisk_conf().

Variable Documentation

◆ ast_kill_tech

const struct ast_channel_tech ast_kill_tech
extern

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

435 {
436 .type = "Kill",
437 .description = "Kill channel (should not see this)",
438 .read = kill_read,
439 .exception = kill_exception,
440 .write = kill_write,
441 .fixup = kill_fixup,
442 .hangup = kill_hangup,
443};
static int kill_write(struct ast_channel *chan, struct ast_frame *frame)
Definition channel.c:408
static struct ast_frame * kill_exception(struct ast_channel *chan)
Definition channel.c:402
static struct ast_frame * kill_read(struct ast_channel *chan)
Definition channel.c:396
static int kill_hangup(struct ast_channel *chan)
Definition channel.c:420
static int kill_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
Definition channel.c:414

◆ ast_stream_topology_changed_external

const char ast_stream_topology_changed_external[] = "external"
static

Set as the change source reason when a channel stream topology has been changed externally as a result of the remote side renegotiating.

Definition at line 223 of file channel.h.

Referenced by ast_channel_stream_topology_changed_externally().

◆ global_fin

unsigned long global_fin
extern

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

Referenced by __ast_channel_alloc_ap(), and handle_core_set_debug_channel().

◆ global_fout

unsigned long global_fout

Definition at line 886 of file channel.h.

Referenced by handle_core_set_debug_channel().