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

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

5057 : 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 2982 of file channel.h.

◆ ast_channel_lock_both

#define ast_channel_lock_both (   chan1,
  chan2 
)

Lock two channels.

Definition at line 2989 of file channel.h.

2989 { \
2990 ast_channel_lock(chan1); \
2991 while (ast_channel_trylock(chan2)) { \
2992 ast_channel_unlock(chan1); \
2993 sched_yield(); \
2994 ast_channel_lock(chan1); \
2995 } \
2996 } while (0)
#define ast_channel_trylock(chan)
Definition channel.h:2984

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

◆ ast_channel_trylock

#define ast_channel_trylock (   chan)    ao2_trylock(chan)

Definition at line 2984 of file channel.h.

◆ ast_channel_unlock

#define ast_channel_unlock (   chan)    ao2_unlock(chan)

Definition at line 2983 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 3018 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 4820 of file channel.h.

◆ AST_MUTE_DIRECTION_WRITE

#define AST_MUTE_DIRECTION_WRITE   (1 << 1)

Definition at line 4821 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 2931 of file channel.h.

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

◆ 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 4124 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 4901 of file channel.h.

4901 {
4902 /* Unable to determine what error occurred. */
4904 /* Channel with this ID already exists */
4906};

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

4117 {
4120};

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

2669{
2670 int res = 0;
2671 enum ast_channel_state old_state;
2672 SCOPE_TRACE(1, "%s\n", ast_channel_name(chan));
2673
2674 old_state = ast_channel_state(chan);
2675 if ((res = ast_raw_answer(chan))) {
2676 return res;
2677 }
2678
2679 switch (old_state) {
2680 case AST_STATE_RINGING:
2681 case AST_STATE_RING:
2682 /* wait for media to start flowing, but don't wait any longer
2683 * than 'delay' or 500 milliseconds, whichever is longer
2684 */
2685 do {
2687 struct ast_frame *cur;
2688 struct ast_frame *new_frame;
2689 int timeout_ms = MAX(delay, 500);
2690 unsigned int done = 0;
2691 struct timeval start;
2692
2694
2695 start = ast_tvnow();
2696 for (;;) {
2697 int ms = ast_remaining_ms(start, timeout_ms);
2698 ms = ast_waitfor(chan, ms);
2699 if (ms < 0) {
2700 ast_log(LOG_WARNING, "Error condition occurred when polling channel %s for a voice frame: %s\n", ast_channel_name(chan), strerror(errno));
2701 res = -1;
2702 break;
2703 }
2704 if (ms == 0) {
2705 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));
2706 break;
2707 }
2708 cur = ast_read(chan);
2709 if (!cur || ((cur->frametype == AST_FRAME_CONTROL) &&
2710 (cur->subclass.integer == AST_CONTROL_HANGUP))) {
2711 if (cur) {
2712 ast_frfree(cur);
2713 }
2714 res = -1;
2715 ast_debug(2, "Hangup of channel %s detected in answer routine\n", ast_channel_name(chan));
2716 break;
2717 }
2718
2719 if ((new_frame = ast_frisolate(cur)) != cur) {
2720 ast_frfree(cur);
2721 }
2722
2724
2725 /* if a specific delay period was requested, continue
2726 * until that delay has passed. don't stop just because
2727 * incoming media has arrived.
2728 */
2729 if (delay) {
2730 continue;
2731 }
2732
2733 switch (new_frame->frametype) {
2734 /* all of these frametypes qualify as 'media' */
2735 case AST_FRAME_VOICE:
2736 case AST_FRAME_VIDEO:
2737 case AST_FRAME_TEXT:
2740 case AST_FRAME_DTMF_END:
2741 case AST_FRAME_IMAGE:
2742 case AST_FRAME_HTML:
2743 case AST_FRAME_MODEM:
2744 case AST_FRAME_RTCP:
2745 done = 1;
2746 break;
2747 case AST_FRAME_CONTROL:
2748 case AST_FRAME_IAX:
2751 case AST_FRAME_NULL:
2752 case AST_FRAME_CNG:
2753 break;
2754 }
2755
2756 if (done) {
2757 break;
2758 }
2759 }
2760
2761 ast_channel_lock(chan);
2762 while ((cur = AST_LIST_REMOVE_HEAD(&frames, frame_list))) {
2763 if (res == 0) {
2764 ast_queue_frame_head(chan, cur);
2765 }
2766 ast_frfree(cur);
2767 }
2768 ast_channel_unlock(chan);
2769 } while (0);
2770 break;
2771 default:
2772 break;
2773 }
2774
2775 return res;
2776}
#define ast_log
Definition astobj2.c:42
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition channel.c:4225
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:1175
int ast_waitfor(struct ast_channel *c, int ms)
Wait for input on a channel.
Definition channel.c:3134
int ast_raw_answer(struct ast_channel *chan)
Answer a channel.
Definition channel.c:2663
#define ast_channel_lock(chan)
Definition channel.h:2982
#define ast_channel_unlock(chan)
Definition channel.h:2983
@ 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:2317
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:251

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

973{
974 va_list ap;
975 struct ast_channel *result;
976
977 va_start(ap, name_fmt);
978 result = __ast_channel_alloc_ap(needqueue, state, cid_num, cid_name, acctcode, exten, context,
979 assignedids, requestor, amaflag, endpoint, NULL, file, line, function, name_fmt, ap);
980 va_end(ap);
981
982 return result;
983}
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:745

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

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

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

1007{
1008 struct ast_channel *tmp;
1009 struct varshead *headp;
1010
1012 file, line, function);
1013 if (!tmp) {
1014 /* Dummy channel structure allocation failure. */
1015 return NULL;
1016 }
1017
1020
1021 /*
1022 * Init file descriptors to unopened state just in case
1023 * autoservice is called on the channel or something tries to
1024 * read a frame from it.
1025 */
1026 ast_channel_timingfd_set(tmp, -1);
1029
1031
1033
1034 headp = ast_channel_varshead(tmp);
1036
1037 return tmp;
1038}
static void ast_dummy_channel_destructor(void *obj)
Free a dummy channel structure.
Definition channel.c:2305
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 5946 of file channel.c.

5947{
5948 int dummy_outstate;
5949 int cause = 0;
5950 struct ast_channel *chan;
5951 int res = 0;
5952 int last_subclass = 0;
5954
5955 if (outstate)
5956 *outstate = 0;
5957 else
5958 outstate = &dummy_outstate; /* make outstate always a valid pointer */
5959
5960 chan = ast_request(type, cap, assignedids, requestor, addr, &cause);
5961 if (!chan) {
5962 ast_log(LOG_NOTICE, "Unable to request channel %s/%s\n", type, addr);
5963 handle_cause(cause, outstate);
5964 return NULL;
5965 }
5966
5967 if (oh) {
5968 if (oh->vars) {
5969 ast_channel_lock(chan);
5970 ast_set_variables(chan, oh->vars);
5971 ast_channel_unlock(chan);
5972 }
5973 if (!ast_strlen_zero(oh->cid_num) && !ast_strlen_zero(oh->cid_name)) {
5974 /*
5975 * Use the oh values instead of the function parameters for the
5976 * outgoing CallerID.
5977 */
5978 cid_num = oh->cid_num;
5979 cid_name = oh->cid_name;
5980 }
5981 if (oh->parent_channel) {
5982 /* Safely inherit variables and datastores from the parent channel. */
5988 ast_channel_unlock(chan);
5989 }
5990 if (!ast_strlen_zero(oh->account)) {
5991 ast_channel_lock(chan);
5993 ast_channel_accountcode_set(chan, oh->account);
5994 ast_channel_peeraccount_set(chan, oh->account);
5996 ast_channel_unlock(chan);
5997 }
5998 }
5999
6000 /*
6001 * It seems strange to set the CallerID on an outgoing call leg
6002 * to whom we are calling, but this function's callers are doing
6003 * various Originate methods. This call leg goes to the local
6004 * user. Once the local user answers, the dialplan needs to be
6005 * able to access the CallerID from the CALLERID function as if
6006 * the local user had placed this call.
6007 */
6008 ast_set_callerid(chan, cid_num, cid_name, cid_num);
6009
6010 ast_channel_lock(chan);
6012 ast_channel_unlock(chan);
6014 if (cid_num) {
6015 connected.id.number.valid = 1;
6016 connected.id.number.str = (char *) cid_num;
6018 }
6019 if (cid_name) {
6020 connected.id.name.valid = 1;
6021 connected.id.name.str = (char *) cid_name;
6023 }
6025 if (requestor) {
6026 ast_channel_lock_both(chan, (struct ast_channel *) requestor);
6028 ast_channel_unlock(chan);
6029 ast_channel_unlock((struct ast_channel *) requestor);
6030 }
6031
6032 if (ast_call(chan, addr, 0)) { /* ast_call failed... */
6033 ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, addr);
6034 } else {
6035 struct timeval start = ast_tvnow();
6036 res = 1; /* mark success in case chan->_state is already AST_STATE_UP */
6037 while (timeout && ast_channel_state(chan) != AST_STATE_UP) {
6038 struct ast_frame *f;
6039 int ms = ast_remaining_ms(start, timeout);
6040
6041 res = ast_waitfor(chan, ms);
6042 if (res == 0) { /* timeout, treat it like ringing */
6043 *outstate = AST_CONTROL_RINGING;
6044 break;
6045 }
6046 if (res < 0) /* error or done */
6047 break;
6049 if (!(chan = ast_call_forward(NULL, chan, NULL, cap, oh, outstate))) {
6050 return NULL;
6051 }
6052 continue;
6053 }
6054
6055 f = ast_read(chan);
6056 if (!f) {
6057 *outstate = AST_CONTROL_HANGUP;
6058 res = 0;
6059 break;
6060 }
6061 if (f->frametype == AST_FRAME_CONTROL) {
6062 switch (f->subclass.integer) {
6063 case AST_CONTROL_RINGING: /* record but keep going */
6064 *outstate = f->subclass.integer;
6065 break;
6066
6067 case AST_CONTROL_BUSY:
6068 *outstate = f->subclass.integer;
6069 timeout = 0;
6070 break;
6071
6073 *outstate = AST_CONTROL_CONGESTION;
6074 timeout = 0;
6075 break;
6076
6078 *outstate = f->subclass.integer;
6079 timeout = 0;
6080 break;
6081
6082 case AST_CONTROL_ANSWER:
6083 *outstate = f->subclass.integer;
6084 timeout = 0; /* trick to force exit from the while() */
6085 break;
6086
6089 break;
6090
6092 if (oh && oh->connect_on_early_media) {
6093 *outstate = f->subclass.integer;
6094 timeout = 0; /* trick to force exit from the while() */
6095 break;
6096 }
6097 /* Fallthrough */
6098 /* Ignore these */
6100 case AST_CONTROL_HOLD:
6101 case AST_CONTROL_UNHOLD:
6107 case AST_CONTROL_CC:
6108 case -1: /* Ignore -- just stopping indications */
6109 break;
6110
6111 default:
6112 ast_log(LOG_NOTICE, "Don't know what to do with control frame %d\n", f->subclass.integer);
6113 }
6114 last_subclass = f->subclass.integer;
6115 }
6116 ast_frfree(f);
6117 }
6118 }
6119
6120 /* Final fixups */
6121 if (oh) {
6122 if (!ast_strlen_zero(oh->context))
6124 if (!ast_strlen_zero(oh->exten))
6125 ast_channel_exten_set(chan, oh->exten);
6126 if (oh->priority)
6128 }
6129 if (ast_channel_state(chan) == AST_STATE_UP)
6130 *outstate = AST_CONTROL_ANSWER;
6131
6132 if (res <= 0) {
6133 ast_channel_lock(chan);
6134 if (AST_CONTROL_RINGING == last_subclass) {
6136 }
6137 ast_channel_unlock(chan);
6138 ast_hangup(chan);
6139 chan = NULL;
6140 }
6141 return chan;
6142}
#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:6431
static void handle_cause(int cause, int *outstate)
Definition channel.c:5819
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:5868
void ast_hangup(struct ast_channel *chan)
Hangup a channel.
Definition channel.c:2513
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:8327
void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars)
adds a list of channel variables to a channel
Definition channel.c:8134
int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to)
Inherit datastores from a parent to a child.
Definition channel.c:2340
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:6404
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:7321
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:6746
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:4315
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:2013
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:6324
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition channel.h:2989
@ 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:70

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

2924{
2925 int res = 0;
2926 void *generatordata = NULL;
2927
2928 ast_channel_lock(chan);
2929 if (ast_channel_generatordata(chan)) {
2930 struct ast_generator *generator_old = ast_channel_generator(chan);
2931
2932 if (generator_old && generator_old->release) {
2933 generator_old->release(chan, ast_channel_generatordata(chan));
2934 }
2935 }
2936 if (gen->alloc && !(generatordata = gen->alloc(chan, params))) {
2937 res = -1;
2938 }
2939 ast_channel_generatordata_set(chan, generatordata);
2940 if (!res) {
2941 ast_settimeout(chan, 50, generator_force, chan);
2943 }
2944 ast_channel_unlock(chan);
2945
2946 ast_prod(chan);
2947
2948 return res;
2949}
int ast_prod(struct ast_channel *chan)
Send empty audio to prime a channel driver.
Definition channel.c:4970
static int generator_force(const void *data)
Definition channel.c:2888
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:3152
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 499 of file channel.c.

500{
502}
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)
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 2879 of file channel.h.

2880{
2881 pfd->fd = fd;
2882 pfd->events = POLLIN | POLLPRI;
2883 return fd >= 0;
2884}

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

2779{
2780 SCOPE_TRACE(1, "%s\n", ast_channel_name(chan));
2781 return __ast_answer(chan, 0);
2782}
int __ast_answer(struct ast_channel *chan, unsigned int delay)
Answer a channel, with a selectable delay before returning.
Definition channel.c:2668

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

2785{
2786 if (ast_channel_state(chan) == AST_STATE_UP) {
2787 /* Already answered */
2788 return 0;
2789 }
2790 return ast_answer(chan);
2791}
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition channel.c:2778

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 ast_channel * chan
Definition autoservice.c:55
struct asent::@328 list

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:3284
#define ast_pthread_create_background(a, b, c, d)
Definition utils.h:629

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:1175
#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::@327 deferred_frames
#define ast_clear_flag(p, flag)
Definition utils.h:77

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

6432{
6433 /* Place an outgoing call, but don't wait any longer than timeout ms before returning.
6434 If the remote end does not answer within the timeout, then do NOT hang up, but
6435 return anyway. */
6436 int res = -1;
6437 /* Stop if we're a zombie or need a soft hangup */
6438 ast_channel_lock(chan);
6440 if (ast_channel_tech(chan)->call)
6441 res = ast_channel_tech(chan)->call(chan, addr, timeout);
6443 }
6444 ast_channel_unlock(chan);
6445 return res;
6446}
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:445
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 5868 of file channel.c.

5869{
5870 char tmpchan[256];
5871 char forwarder[AST_CHANNEL_NAME];
5872 struct ast_channel *new_chan = NULL;
5873 char *data, *type;
5874 int cause = 0;
5875 int res;
5876
5877 /* gather data and request the new forward channel */
5878 ast_copy_string(tmpchan, ast_channel_call_forward(orig), sizeof(tmpchan));
5879 ast_copy_string(forwarder, ast_channel_name(orig), sizeof(forwarder));
5880 if ((data = strchr(tmpchan, '/'))) {
5881 *data++ = '\0';
5882 type = tmpchan;
5883 } else {
5884 const char *forward_context;
5885 ast_channel_lock(orig);
5886 forward_context = pbx_builtin_getvar_helper(orig, "FORWARD_CONTEXT");
5887 snprintf(tmpchan, sizeof(tmpchan), "%s@%s", ast_channel_call_forward(orig), S_OR(forward_context, ast_channel_context(orig)));
5888 ast_channel_unlock(orig);
5889 data = tmpchan;
5890 type = "Local";
5891 }
5892 if (!(new_chan = ast_request(type, cap, NULL, orig, data, &cause))) {
5893 ast_log(LOG_NOTICE, "Unable to create channel for call forward to '%s/%s' (cause = %d)\n", type, data, cause);
5894 handle_cause(cause, outstate);
5895 ast_hangup(orig);
5896 return NULL;
5897 }
5898
5899 /* Copy/inherit important information into new channel */
5900 if (oh) {
5901 if (oh->vars) {
5902 ast_channel_lock(new_chan);
5903 ast_set_variables(new_chan, oh->vars);
5904 ast_channel_unlock(new_chan);
5905 }
5906 if (oh->parent_channel) {
5907 call_forward_inherit(new_chan, oh->parent_channel, orig);
5908 }
5909 if (!ast_strlen_zero(oh->account)) {
5910 ast_channel_lock(new_chan);
5912 ast_channel_accountcode_set(new_chan, oh->account);
5913 ast_channel_peeraccount_set(new_chan, oh->account);
5915 ast_channel_unlock(new_chan);
5916 }
5917 } else if (caller) { /* no outgoing helper so use caller if available */
5918 call_forward_inherit(new_chan, caller, orig);
5919 }
5920
5921 ast_channel_lock_both(orig, new_chan);
5923 pbx_builtin_setvar_helper(new_chan, "FORWARDERNAME", forwarder);
5927 ast_channel_unlock(new_chan);
5928 ast_channel_unlock(orig);
5929
5930 /* call new channel */
5931 res = ast_call(new_chan, data, 0);
5932 if (timeout) {
5933 *timeout = res;
5934 }
5935 if (res) {
5936 ast_log(LOG_NOTICE, "Unable to call forward to channel %s/%s\n", type, (char *)data);
5937 ast_hangup(orig);
5938 ast_hangup(new_chan);
5939 return NULL;
5940 }
5941 ast_hangup(orig);
5942
5943 return new_chan;
5944}
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:1999
static void call_forward_inherit(struct ast_channel *new_chan, struct ast_channel *parent, struct ast_channel *orig)
Definition channel.c:5840
void ast_channel_set_flag(struct ast_channel *chan, unsigned int flag)
Set a flag on a channel.
Definition channel.c:11046
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:2103
#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 612 of file channel.c.

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

References ARRAY_LEN, causes, and causes_map::desc.

Referenced by 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 6734 of file channel.c.

6735{
6736 /* We must re-link, as the hash value will change here. */
6738 ast_channel_lock(chan);
6740 __ast_change_name_nolink(chan, newname);
6742 ast_channel_unlock(chan);
6744}
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:6712
#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 639 of file channel_internal_api.c.

640{
641 return chan->adsicpe;
642}
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 983 of file channel_internal_api.c.

984{
985 return ast_alertpipe_writable(chan->alertpipe);
986}
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 968 of file channel_internal_api.c.

969{
970 return ast_alertpipe_write(chan->alertpipe);
971}
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 4342 of file channel.c.

4343{
4344 switch (flag) {
4345 case AST_AMA_OMIT:
4346 return "OMIT";
4347 case AST_AMA_BILLING:
4348 return "BILLING";
4350 return "DOCUMENTATION";
4351 default:
4352 return "Unknown";
4353 }
4354}

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(), 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 844 of file channel_internal_api.c.

845{
846 return chan->answertime;
847}
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 849 of file channel_internal_api.c.

850{
851 chan->answertime = *value;
852}

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 451 of file channel_internal_api.c.

452{
453 chan->audiohooks = value;
454}

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 730 of file channel_internal_api.c.

731{
732 return &chan->autochans;
733}
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 1071 of file channel_internal_api.c.

1072{
1073 return chan->blocker;
1074}
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 1075 of file channel_internal_api.c.

1076{
1077 chan->blocker = value;
1078}

References ast_channel::blocker, and value.

◆ ast_channel_blocker_tid()

int ast_channel_blocker_tid ( const struct ast_channel chan)

Definition at line 1080 of file channel_internal_api.c.

1081{
1082 return chan->blocker_tid;
1083}

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 1084 of file channel_internal_api.c.

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

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

10584{
10585 struct ast_channel *peer;
10586 struct ast_bridge *bridge;
10587
10588 /* Get the bridge the channel is in. */
10589 ast_channel_lock(chan);
10590 bridge = ast_channel_get_bridge(chan);
10591 ast_channel_unlock(chan);
10592 if (!bridge) {
10593 return NULL;
10594 }
10595
10596 peer = ast_bridge_peer(bridge, chan);
10597 ao2_ref(bridge, -1);
10598 return peer;
10599}
#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:10553

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

1319{
1321 return NULL;
1322 }
1323 if (!cb_fn) {
1324 ast_log(LOG_ERROR, "callback function must be provided\n");
1325 return NULL;
1326 }
1327 return CHANNELSTORAGE_API(current_channel_storage_instance, callback, cb_fn, arg, data, ao2_flags);
1328}
static struct ast_channel * callback(struct ast_channelstorage_instance *driver, ao2_callback_data_fn *cb_fn, void *arg, void *data, int ao2_flags)
#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 746 of file channel_internal_api.c.

747{
748 return &chan->caller;
749}

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(), 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 936 of file channel_internal_api.c.

937{
938 chan->callgroup = value;
939}

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 926 of file channel_internal_api.c.

927{
928 chan->callid = 0;
929}

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 655 of file channel_internal_api.c.

656{
657 char call_identifier_from[AST_CALLID_BUFFER_LENGTH];
658 char call_identifier_to[AST_CALLID_BUFFER_LENGTH];
659 call_identifier_from[0] = '\0';
660 ast_callid_strnprint(call_identifier_to, sizeof(call_identifier_to), callid);
661 if (chan->callid) {
662 ast_callid_strnprint(call_identifier_from, sizeof(call_identifier_from), chan->callid);
663 ast_debug(3, "Channel Call ID changing from %s to %s\n", call_identifier_from, call_identifier_to);
664 }
665
666 chan->callid = callid;
667
668 ast_test_suite_event_notify("CallIDChange",
669 "State: CallIDChange\r\n"
670 "Channel: %s\r\n"
671 "CallID: %s\r\n"
672 "PriorCallID: %s",
673 ast_channel_name(chan),
674 call_identifier_to,
675 call_identifier_from);
676}
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.

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

Definition at line 10470 of file channel.c.

10472{
10473 struct ast_cc_config_params *cc_params;
10474 struct ast_datastore *cc_datastore;
10475
10476 if (!(cc_params = ast_cc_config_params_init())) {
10477 return -1;
10478 }
10479
10480 if (!(cc_datastore = ast_datastore_alloc(&cc_channel_datastore_info, NULL))) {
10482 return -1;
10483 }
10484
10485 if (base_params) {
10486 ast_cc_copy_config_params(cc_params, base_params);
10487 }
10488 cc_datastore->data = cc_params;
10489 ast_channel_datastore_add(chan, cc_datastore);
10490 return 0;
10491}
#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:698
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:860
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition channel.c:2357
static const struct ast_datastore_info cc_channel_datastore_info
Definition channel.c:10464
#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 455 of file channel_internal_api.c.

456{
457 return chan->cdr;
458}
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 459 of file channel_internal_api.c.

460{
461 chan->cdr = value;
462}

References ast_channel::cdr, and value.

Referenced by ast_channel_destructor(), ast_dummy_channel_destructor(), custom_log(), manager_log(), and write_cdr().

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

11054{
11055 ast_channel_lock(chan);
11057 ast_channel_unlock(chan);
11058}

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

2405{
2406 ast_channel_lock(chan);
2407
2409
2411 struct ast_frame *fr;
2412
2413 /* If we have completely cleared the softhangup flag,
2414 * then we need to fully abort the hangup process. This requires
2415 * pulling the END_OF_Q frame out of the channel frame queue if it
2416 * still happens to be there. */
2417
2418 fr = AST_LIST_LAST(ast_channel_readq(chan));
2419 if (fr && fr->frametype == AST_FRAME_CONTROL &&
2422 ast_frfree(fr);
2423 }
2424 }
2425
2426 ast_channel_unlock(chan);
2427}
@ 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 523 of file channel.c.

524{
525 struct timeval whentohangup;
526
528 return ast_tvzero(offset) ? 0 : -1;
529
530 if (ast_tvzero(offset))
531 return 1;
532
533 whentohangup = ast_tvadd(offset, ast_tvnow());
534
535 return ast_tvdiff_ms(whentohangup, *ast_channel_whentohangup(chan));
536}
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 758 of file channel_internal_api.c.

759{
760 return ast_party_id_merge(&chan->connected.id, &chan->connected.priv);
761}
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 754 of file channel_internal_api.c.

755{
756 return &chan->connected_indicated;
757}
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 10357 of file channel.c.

10358{
10359 const char *sub;
10360 const char *sub_args;
10361 int retval;
10362
10363 ast_channel_lock(sub_chan);
10364 sub = pbx_builtin_getvar_helper(sub_chan, "CONNECTED_LINE_SEND_SUB");
10365 sub = ast_strdupa(S_OR(sub, ""));
10366 sub_args = pbx_builtin_getvar_helper(sub_chan, "CONNECTED_LINE_SEND_SUB_ARGS");
10367 sub_args = ast_strdupa(S_OR(sub_args, ""));
10368
10369 if (ast_strlen_zero(sub)) {
10370 ast_channel_unlock(sub_chan);
10371 return -1;
10372 }
10373
10374 if (is_frame) {
10375 const struct ast_frame *frame = connected_info;
10376
10378 } else {
10379 const struct ast_party_connected_line *connected = connected_info;
10380
10382 }
10383 ast_channel_unlock(sub_chan);
10384
10386 retval = ast_app_run_sub(autoservice_chan, sub_chan, sub, sub_args, 0);
10388 if (!retval) {
10389 struct ast_party_connected_line saved_connected;
10390
10391 ast_party_connected_line_init(&saved_connected);
10392 ast_channel_lock(sub_chan);
10393 ast_party_connected_line_copy(&saved_connected, ast_channel_connected(sub_chan));
10394 ast_channel_unlock(sub_chan);
10395 ast_channel_update_connected_line(sub_chan, &saved_connected, NULL);
10396 ast_party_connected_line_free(&saved_connected);
10397 }
10398
10399 return retval;
10400}
#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:2040
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:9112
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:8804
static void channel_set_intercept_mode(int in_intercept_mode)
Definition channel.c:10341
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
Definition channel.c:1990
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 2357 of file channel.c.

2358{
2359 int res = 0;
2360
2361 AST_LIST_INSERT_HEAD(ast_channel_datastores(chan), datastore, entry);
2362
2363 return res;
2364}

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_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(), 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_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 2371 of file channel.c.

2372{
2373 struct ast_datastore *datastore = NULL;
2374
2375 if (info == NULL)
2376 return NULL;
2377
2379 if (datastore->info != info) {
2380 continue;
2381 }
2382
2383 if (uid == NULL) {
2384 /* matched by type only */
2385 break;
2386 }
2387
2388 if ((datastore->uid != NULL) && !strcasecmp(uid, datastore->uid)) {
2389 /* Matched by type AND uid */
2390 break;
2391 }
2392 }
2393
2394 return datastore;
2395}
const struct ast_datastore_info * info
Definition datastore.h:67
const char * uid
Definition datastore.h:65
struct ast_datastore::@227 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_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(), 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(), 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(), 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_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_channel_is_internal(), stasis_app_channel_is_stasis_end_published(), stop_mixmonitor_full(), t38_attach_framehook(), talk_detect_audiohook_cb(), unlock_read(), 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 2340 of file channel.c.

2341{
2342 struct ast_datastore *datastore = NULL, *datastore2;
2343
2345 if (datastore->inheritance > 0) {
2346 datastore2 = ast_datastore_alloc(datastore->info, datastore->uid);
2347 if (datastore2) {
2348 datastore2->data = datastore->info->duplicate ? datastore->info->duplicate(datastore->data) : NULL;
2349 datastore2->inheritance = datastore->inheritance == DATASTORE_INHERIT_FOREVER ? DATASTORE_INHERIT_FOREVER : datastore->inheritance - 1;
2351 }
2352 }
2353 }
2354 return 0;
2355}
#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 1296 of file channel.c.

1297{
1298 int pre = 0;
1299
1300 if (chan) {
1301 ast_channel_lock(chan);
1304 ast_channel_unlock(chan);
1305 }
1306 return pre;
1307}

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 1194 of file channel_internal_api.c.

1195{
1196 struct ast_control_pvt_cause_code *ao2_cause_code;
1197 char *arg = ast_strdupa(cause_code->chan_name);
1198
1200
1201 ao2_cause_code = ao2_alloc(datalen, NULL);
1202 if (ao2_cause_code) {
1203 memcpy(ao2_cause_code, cause_code, datalen);
1204 ao2_link(chan->dialed_causes, ao2_cause_code);
1205 ao2_ref(ao2_cause_code, -1);
1206 return 0;
1207 }
1208
1209 return -1;
1210}
#define ao2_link(container, obj)
Add an object to a container.
Definition astobj2.h:1532
#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
@ OBJ_NODATA
Definition astobj2.h:1044
@ OBJ_MULTIPLE
Definition astobj2.h:1049
@ OBJ_UNLINK
Definition astobj2.h:1039
#define ao2_alloc(data_size, destructor_fn)
Definition astobj2.h:409
static int remove_dialstatus_cb(void *obj, void *arg, int flags)
struct ao2_container * dialed_causes

References ao2_alloc, ao2_callback, ao2_link, ao2_ref, ast_strdupa, ast_control_pvt_cause_code::chan_name, ast_channel::dialed_causes, NULL, OBJ_MULTIPLE, OBJ_NODATA, OBJ_UNLINK, and remove_dialstatus_cb().

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 1133 of file channel_internal_api.c.

1134{
1135 struct ast_str *chanlist = ast_str_create(128);
1136
1137 if (!chanlist) {
1138 return NULL;
1139 }
1140
1142
1143 return chanlist;
1144}
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 1212 of file channel_internal_api.c.

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 1146 of file channel_internal_api.c.

1147{
1148 struct ao2_iterator causes;
1149 struct ast_control_pvt_cause_code *cause_code;
1150
1152 while ((cause_code = ao2_iterator_next(&causes))) {
1153 if (strcmp(cause_code->chan_name, chan_name)) {
1154 ao2_ref(cause_code, -1);
1155 continue;
1156 }
1157 if (!cause_code->cause_extended) {
1159 return cause_code;
1160 }
1161 ao2_ref(cause_code, -1);
1162 }
1164
1165 return NULL;
1166}
#define ao2_iterator_next(iter)
Definition astobj2.h:1911
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.

References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_control_pvt_cause_code::cause_extended, causes, ast_control_pvt_cause_code::chan_name, ast_channel::dialed_causes, and NULL.

Referenced by hangupcause_read().

◆ ast_channel_dialed_causes_find_multiple()

struct ao2_iterator * ast_channel_dialed_causes_find_multiple ( const struct ast_channel chan,
const char *  chan_name 
)

Retrieve a ref-counted cause code information structure iterator.

Since
20.17.0, 22.8.0, 23.1.0

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 ao2_iterator object containing the desired information

Definition at line 1168 of file channel_internal_api.c.

1169{
1170 struct ao2_iterator *causes;
1171 struct ast_control_pvt_cause_code *cause_code;
1172
1174 while ((cause_code = ao2_iterator_next(causes))) {
1175 ao2_ref(cause_code, -1);
1176 }
1178
1180}
#define ao2_find(container, arg, flags)
Definition astobj2.h:1736
@ OBJ_SEARCH_KEY
The arg parameter is a search key, but is not an object.
Definition astobj2.h:1101

References ao2_find, ao2_iterator_destroy(), ao2_iterator_next, ao2_ref, causes, ast_control_pvt_cause_code::chan_name, ast_channel::dialed_causes, OBJ_MULTIPLE, and OBJ_SEARCH_KEY.

Referenced by hangupcause_read().

◆ 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 782 of file channel_internal_api.c.

783{
784 return &chan->dtmf_tv;
785}
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 822 of file channel_internal_api.c.

823{
824 chan->dtmf_tv = *value;
825}

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 738 of file channel_internal_api.c.

739{
740 return &chan->dtmff;
741}
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 794 of file channel_internal_api.c.

795{
796 chan->dtmff = *value;
797}

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

7400{
7401 /* Make sure we can early bridge, if not error out */
7402 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)))
7403 return -1;
7404
7405 return ast_channel_tech(c0)->early_bridge(c0, c1);
7406}
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 372 of file channel_internal_api.c.

373{
374 return chan->emulate_dtmf_duration;
375}
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 376 of file channel_internal_api.c.

377{
379}

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

10889{
10890 int dead;
10891 long duration;
10892
10893 ast_channel_lock(chan);
10896 & ~AST_SOFTHANGUP_ASYNCGOTO);
10897 ast_channel_unlock(chan);
10898 if (dead) {
10899 /* Channel is a zombie or a real hangup. */
10900 return;
10901 }
10902
10903 duration = ast_tvdiff_ms(ast_tvnow(), start);
10904 if (duration < option_dtmfminduration) {
10905 duration = option_dtmfminduration;
10906 }
10907 ast_senddigit_end(chan, digit, duration);
10908 ast_log(LOG_DTMF, "DTMF end '%c' simulated on %s due to %s, duration %ld ms\n",
10909 digit, ast_channel_name(chan), why, duration);
10910}
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition channel.c:4894
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 1611 of file channel_internal_api.c.

1612{
1613 return chan->endpoint;
1614}

References ast_channel::endpoint.

◆ ast_channel_endpoint_set()

void ast_channel_endpoint_set ( struct ast_channel chan,
struct ast_endpoint endpoint 
)

Definition at line 1616 of file channel_internal_api.c.

1617{
1618 if (chan->endpoint) {
1620 ao2_ref(chan->endpoint, -1);
1621 }
1622
1623 chan->endpoint = ao2_bump(endpoint);
1624
1625 if (chan->endpoint) {
1627 }
1628}
#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 10980 of file channel.c.

10981{
10983}
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)

◆ 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 1044 of file channel_internal_api.c.

1045{
1046 return (which >= AST_VECTOR_SIZE(&chan->fds)) ? -1 : AST_VECTOR_GET(&chan->fds, which);
1047}
#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 1058 of file channel_internal_api.c.

1059{
1060 int pos = AST_EXTENDED_FDS;
1061
1062 while (ast_channel_fd_isset(chan, pos)) {
1063 pos += 1;
1064 }
1065
1066 AST_VECTOR_REPLACE(&chan->fds, pos, value);
1067
1068 return pos;
1069}
#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 1053 of file channel_internal_api.c.

1054{
1055 return AST_VECTOR_SIZE(&chan->fds);
1056}

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 1048 of file channel_internal_api.c.

1049{
1050 return ast_channel_fd(chan, which) > -1;
1051}
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 10970 of file channel.c.

10971{
10972 return channel_feature_hooks_set_full(chan, features, 0);
10973}
static int channel_feature_hooks_set_full(struct ast_channel *chan, struct ast_bridge_features *features, int replace)
Definition channel.c:10933

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

10923{
10924 struct ast_datastore *datastore;
10925
10927 if (!datastore) {
10928 return NULL;
10929 }
10930 return datastore->data;
10931}
static const struct ast_datastore_info bridge_features_info
Definition channel.c:10917
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:2371

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

10976{
10977 return channel_feature_hooks_set_full(chan, features, 1);
10978}

References channel_feature_hooks_set_full().

◆ ast_channel_fin()

unsigned int ast_channel_fin ( const struct ast_channel chan)

Definition at line 380 of file channel_internal_api.c.

381{
382 return chan->fin;
383}
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 384 of file channel_internal_api.c.

385{
386 chan->fin = value;
387}

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 1118 of file channel_internal_api.c.

1119{
1120 return &chan->flags;
1121}
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_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(), 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(), 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(), tonepair_alloc(), and waitstream_core().

◆ 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 1458 of file channel_internal_api.c.

1460{
1461 ast_assert(chan != NULL);
1462 ast_assert(endpoint != NULL);
1463
1464 chan->endpoint_forward =
1466 ast_endpoint_topic(endpoint));
1467 if (!chan->endpoint_forward) {
1468 return -1;
1469 }
1470
1471 return 0;
1472}
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:776

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 388 of file channel_internal_api.c.

389{
390 return chan->fout;
391}
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 392 of file channel_internal_api.c.

393{
394 chan->fout = value;
395}

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 567 of file channel_internal_api.c.

568{
569 chan->framehooks = value;
570}

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 575 of file channel_internal_api.c.

576{
577 chan->generator = value;
578}

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

7949{
7950 return channel_get_external_vars(&ari_vars, chan);
7951}
static struct varshead * channel_get_external_vars(struct external_vars *channelvars, struct ast_channel *chan)
Definition channel.c:7896
static struct external_vars ari_vars
Definition channel.c:7792

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

10554{
10555 struct ast_bridge *bridge;
10556
10557 bridge = ast_channel_internal_bridge(chan);
10558 if (bridge) {
10559 ao2_ref(bridge, +1);
10560 }
10561 return bridge;
10562}

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

10602{
10603 struct ast_bridge_channel *bridge_channel;
10604
10605 bridge_channel = ast_channel_internal_bridge_channel(chan);
10606 if (bridge_channel) {
10607 ao2_ref(bridge_channel, +1);
10608 }
10609 return bridge_channel;
10610}

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

1412{
1414 return NULL;
1415 }
1416 if (ast_strlen_zero(exten) || ast_strlen_zero(context)) {
1417 ast_log(LOG_ERROR, "exten and context must be provided\n");
1418 return NULL;
1419 }
1421}
static struct ast_channel * get_by_exten(struct ast_channelstorage_instance *driver, const char *exten, const char *context)

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

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

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(), 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 1381 of file channel.c.

1382{
1384 return NULL;
1385 }
1386 if (ast_strlen_zero(name)) {
1387 ast_log(LOG_ERROR, "name must be provided\n");
1388 return NULL;
1389 }
1390
1391 return CHANNELSTORAGE_API(current_channel_storage_instance, get_by_name_prefix_or_uniqueid, name, name_len);
1392}

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

1424{
1426 return NULL;
1427 }
1428 if (ast_strlen_zero(uniqueid)) {
1429 ast_log(LOG_ERROR, "uniqueid must be provided\n");
1430 return NULL;
1431 }
1433}
static struct ast_channel * get_by_uniqueid(struct ast_channelstorage_instance *driver, const char *uniqueid)

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

10533{
10534 int len = size;
10535 char *slash;
10536
10538 return 0;
10539 }
10540
10542 if ((slash = strchr(agent_type, '/'))) {
10543 *slash = '\0';
10544 }
10545 return 0;
10546}
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:7429
#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.

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

Definition at line 10493 of file channel.c.

10494{
10495 struct ast_datastore *cc_datastore;
10496
10497 if (!(cc_datastore = ast_channel_datastore_find(chan, &cc_channel_datastore_info, NULL))) {
10498 /* If we can't find the datastore, it almost definitely means that the channel type being
10499 * used has not had its driver modified to parse CC config parameters. The best action
10500 * to take here is to create the parameters on the spot with the defaults set.
10501 */
10502 if (ast_channel_cc_params_init(chan, NULL)) {
10503 return NULL;
10504 }
10505 if (!(cc_datastore = ast_channel_datastore_find(chan, &cc_channel_datastore_info, NULL))) {
10506 /* Should be impossible */
10507 return NULL;
10508 }
10509 }
10510
10511 ast_assert(cc_datastore->data != NULL);
10512 return cc_datastore->data;
10513}
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:10470

References ast_assert, 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 7992 of file channel.c.

7993{
7996}
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 1566 of file channel_internal_api.c.

1568{
1569 ast_assert(chan != NULL);
1571
1572 return chan->default_streams[type];
1573}
@ 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 10515 of file channel.c.

10516{
10517 int len = name_buffer_length;
10518 char *dash;
10519 if (!ast_channel_queryoption(chan, AST_OPTION_DEVICE_NAME, device_name, &len, 0)) {
10520 return 0;
10521 }
10522
10523 /* Dang. Do it the old-fashioned way */
10524 ast_copy_string(device_name, ast_channel_name(chan), name_buffer_length);
10525 if ((dash = strrchr(device_name, '-'))) {
10526 *dash = '\0';
10527 }
10528
10529 return 0;
10530}
#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 2803 of file channel.c.

2804{
2805 return (ast_channel_get_duration_ms(chan) / 1000);
2806}
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:2793

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

2794{
2795 ast_assert(NULL != chan);
2796
2798 return 0;
2799 }
2801}

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

Referenced by ast_channel_get_duration(), and end_bridge_callback().

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

10353{
10354 return ast_threadstorage_get_ptr(&in_intercept_routine) ? 1 : 0;
10355}
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 7943 of file channel.c.

7944{
7945 return channel_get_external_vars(&ami_vars, chan);
7946}
static struct external_vars ami_vars
Definition channel.c:7791

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 530 of file channel_internal_api.c.

531{
533}
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 2910 of file channel.h.

2911{
2913 int datalen = sizeof(state);
2914
2916
2917 return state;
2918}

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

2819{
2820 return (ast_channel_get_up_time_ms(chan) / 1000);
2821}
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:2808

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

2809{
2810 ast_assert(NULL != chan);
2811
2813 return 0;
2814 }
2816}

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

7872{
7873 RAII_VAR(struct varshead *, ret, NULL, ao2_cleanup);
7874 struct ast_var_t *cv;
7875
7876 ret = ao2_alloc(sizeof(*ret), varshead_dtor);
7877
7878 if (!ret) {
7879 return NULL;
7880 }
7881
7884
7885 if (!var) {
7886 return NULL;
7887 }
7888
7890 }
7891
7892 ao2_ref(ret, +1);
7893 return ret;
7894}
#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:7861
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::@224 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:978

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

4316{
4317 char causevar[256];
4318
4319 if (ast_channel_dialed_causes_add(chan, cause_code, datalen)) {
4320 ast_log(LOG_WARNING, "Unable to store hangup cause for %s on %s\n", cause_code->chan_name, ast_channel_name(chan));
4321 }
4322
4323 if (cause_code->emulate_sip_cause) {
4324 snprintf(causevar, sizeof(causevar), "HASH(SIP_CAUSE,%s)", cause_code->chan_name);
4325 ast_func_write(chan, causevar, cause_code->code);
4326 }
4327}
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(), rfc3326_use_reason_header(), 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 7820 of file channel.c.

7821{
7823}
static int channel_has_external_vars(struct external_vars *channelvars)
Definition channel.c:7804

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

2491{
2494}
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 2496 of file channel.c.

2497{
2500}
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 7815 of file channel.c.

7816{
7818}

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 352 of file channel_internal_api.c.

353{
354 chan->hold_state = value;
355}

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

6747{
6748 struct ast_var_t *current;
6749 struct ast_var_t *newvar;
6750 const char *varname;
6751 int vartype;
6752
6754 varname = ast_var_full_name(current);
6755 if (!varname) {
6756 continue;
6757 }
6758
6759 vartype = 0;
6760 if (varname[0] == '_') {
6761 vartype = 1;
6762 if (varname[1] == '_') {
6763 vartype = 2;
6764 }
6765 }
6766
6767 switch (vartype) {
6768 case 1:
6769 newvar = ast_var_assign(&varname[1], ast_var_value(current));
6770 break;
6771 case 2:
6772 newvar = ast_var_assign(varname, ast_var_value(current));
6773 break;
6774 default:
6775 continue;
6776 }
6777 if (newvar) {
6778 ast_debug(1, "Inheriting variable %s from %s to %s.\n",
6779 ast_var_full_name(newvar), ast_channel_name(parent),
6780 ast_channel_name(child));
6783 ast_var_value(newvar));
6784 }
6785 }
6786}
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 396 of file channel_internal_api.c.

397{
398 return chan->insmpl;
399}
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 400 of file channel_internal_api.c.

401{
402 chan->insmpl = value;
403}

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 973 of file channel_internal_api.c.

974{
975 return ast_alertpipe_flush(chan->alertpipe);
976}
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 978 of file channel_internal_api.c.

979{
980 return ast_alertpipe_read(chan->alertpipe);
981}
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 988 of file channel_internal_api.c.

989{
990 return ast_alertpipe_readable(chan->alertpipe);
991}
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 1008 of file channel_internal_api.c.

1009{
1010 return ast_alertpipe_readfd(chan->alertpipe);
1011}
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 993 of file channel_internal_api.c.

994{
996}
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 998 of file channel_internal_api.c.

999{
1001}
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 1003 of file channel_internal_api.c.

1004{
1005 return ast_alertpipe_init(chan->alertpipe);
1006}
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 1013 of file channel_internal_api.c.

1014{
1015 ast_alertpipe_swap(chan1->alertpipe, chan2->alertpipe);
1016}
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 1098 of file channel_internal_api.c.

1099{
1100 return chan->bridge;
1101}
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 1335 of file channel_internal_api.c.

1336{
1337 if (dest->linkedid.creation_time == source->linkedid.creation_time
1339 && !strcmp(dest->linkedid.unique_id, source->linkedid.unique_id)) {
1340 return;
1341 }
1342 dest->linkedid = source->linkedid;
1345}
@ 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 1032 of file channel_internal_api.c.

1033{
1034 if (which >= AST_VECTOR_SIZE(&chan->fds)) {
1035 return;
1036 }
1037
1038 AST_VECTOR_REPLACE(&chan->fds, which, -1);
1039}

References AST_VECTOR_REPLACE, and AST_VECTOR_SIZE.

Referenced by handle_negotiated_sdp().

◆ ast_channel_internal_fd_clear_all()

void ast_channel_internal_fd_clear_all ( struct ast_channel chan)

Definition at line 1040 of file channel_internal_api.c.

1041{
1043}
#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 1019 of file channel_internal_api.c.

1020{
1021 int pos;
1022
1023 /* This ensures that if the vector has to grow with unused positions they will be
1024 * initialized to -1.
1025 */
1026 for (pos = AST_VECTOR_SIZE(&chan->fds); pos < which; pos++) {
1027 AST_VECTOR_REPLACE(&chan->fds, pos, -1);
1028 }
1029
1030 AST_VECTOR_REPLACE(&chan->fds, which, value);
1031}

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 1318 of file channel_internal_api.c.

1319{
1320 ast_assert(a->linkedid.creation_time != 0);
1321 ast_assert(b->linkedid.creation_time != 0);
1322
1323 if (a->linkedid.creation_time < b->linkedid.creation_time) {
1324 return a;
1325 }
1326 if (b->linkedid.creation_time < a->linkedid.creation_time) {
1327 return b;
1328 }
1329 if (a->linkedid.creation_unique < b->linkedid.creation_unique) {
1330 return a;
1331 }
1332 return b;
1333}

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 1412 of file channel_internal_api.c.

1413{
1414 ast_copy_string(chan->uniqueid.unique_id, uniqueid, sizeof(chan->uniqueid.unique_id));
1415 ast_copy_string(chan->linkedid.unique_id, linkedid, sizeof(chan->linkedid.unique_id));
1416}

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 1385 of file channel_internal_api.c.

1386{
1387 struct stasis_forward *temp;
1388
1389 temp = a->endpoint_forward;
1390 a->endpoint_forward = b->endpoint_forward;
1391 b->endpoint_forward = temp;
1392}
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 1403 of file channel_internal_api.c.

1404{
1405 struct ast_endpoint *endpoint;
1406
1407 endpoint = a->endpoint;
1408 a->endpoint = b->endpoint;
1409 b->endpoint = endpoint;
1410}

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 1394 of file channel_internal_api.c.

1395{
1396 struct ast_channel_snapshot *snapshot;
1397
1398 snapshot = a->snapshot;
1399 a->snapshot = b->snapshot;
1400 b->snapshot = snapshot;
1401}

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 1371 of file channel_internal_api.c.

1372{
1373 struct stasis_topic *topic;
1374 struct stasis_forward *forward;
1375
1376 topic = a->topic;
1377 a->topic = b->topic;
1378 b->topic = topic;
1379
1380 forward = a->channel_forward;
1381 a->channel_forward = b->channel_forward;
1382 b->channel_forward = forward;
1383}

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 1347 of file channel_internal_api.c.

1348{
1349 struct ast_channel_id temp;
1350
1351 /* This operation is used as part of masquerading and so does not invalidate the peer
1352 * segment. This is due to the masquerade process invalidating all segments.
1353 */
1354
1355 /*
1356 * Since unique ids can be a key in the channel storage backend,
1357 * ensure that neither channel is linked in or the keys will be
1358 * invalid.
1359 */
1360 ast_assert(!a->linked_in_container && !b->linked_in_container);
1361
1362 temp = a->uniqueid;
1363 a->uniqueid = b->uniqueid;
1364 b->uniqueid = temp;
1365
1366 temp = a->linkedid;
1367 a->linkedid = b->linkedid;
1368 b->linkedid = temp;
1369}
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 10564 of file channel.c.

10565{
10566 return ast_channel_internal_bridge(chan) != NULL;
10567}

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

10570{
10571 int hangup_flags = ast_channel_softhangup_internal_flag(chan);
10572 int hangup_test = hangup_flags & AST_SOFTHANGUP_ASYNCGOTO;
10573 int unbridge = ast_channel_unbridged(chan);
10574
10575 /* This function should only return true if either the unbridged flag or
10576 * the ASYNCGOTO soft hangup flag is set and when no other soft hangup
10577 * flags are set. Any other soft hangup flags being set should make it
10578 * return false.
10579 */
10580 return ((hangup_test || unbridge) && (hangup_test == hangup_flags));
10581}

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 1590 of file channel_internal_api.c.

1591{
1592 return (chan && chan->tech && chan->tech->read_stream && chan->tech->write_stream);
1593}
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 904 of file channel_internal_api.c.

905{
906 int res;
907
908 ast_channel_lock(chan);
910 ast_channel_unlock(chan);
911 return res;
912}
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 899 of file channel_internal_api.c.

900{
901 return chan->is_t38_active;
902}

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

1362{
1364 return NULL;
1365 }
1367}
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(), handle_show_hangup_all(), and handle_softhangup().

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

1339{
1341 return NULL;
1342 }
1343 if (ast_strlen_zero(exten) || ast_strlen_zero(context)) {
1344 ast_log(LOG_ERROR, "exten and context must be provided\n");
1345 return NULL;
1346 }
1348}
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 1349 of file channel.c.

1350{
1352 return NULL;
1353 }
1354 if (ast_strlen_zero(name)) {
1355 ast_log(LOG_ERROR, "name must be provided\n");
1356 return NULL;
1357 }
1359}
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 1330 of file channel.c.

1331{
1333 return NULL;
1334 }
1336}
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(), handle_softhangup(), 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 1369 of file channel.c.

1370{
1372 return NULL;
1373 }
1375}
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(), handle_softhangup(), 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 798 of file channel_internal_api.c.

799{
800 chan->jb = *value;
801}

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

6691{
6692 /*
6693 * Set up translation from the peer to the chan first in case we
6694 * need to hear any in-band tones and the other direction fails.
6695 */
6696 if (ast_channel_make_compatible_helper(peer, chan)) {
6697 return -1;
6698 }
6699
6700 /* Set up translation from the chan to the peer */
6701 if (ast_channel_make_compatible_helper(chan, peer)) {
6702 return -1;
6703 }
6704
6705 return 0;
6706}
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:6611

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 463 of file channel_internal_api.c.

464{
465 return chan->masq;
466}
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 467 of file channel_internal_api.c.

468{
469 chan->masq = value;
470}

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 471 of file channel_internal_api.c.

472{
473 return chan->masqr;
474}
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 475 of file channel_internal_api.c.

476{
477 chan->masqr = value;
478}

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

10686{
10687 RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
10689
10690 if (dest == source) {
10691 ast_log(LOG_WARNING, "Can't move channel '%s' into itself!\n",
10692 ast_channel_name(dest));
10693 return -1;
10694 }
10695
10696 ast_channel_lock_both(dest, source);
10697
10700 /* Zombies! Run! */
10702 "Can't move channel. One or both is dead (%s <-- %s)\n",
10703 ast_channel_name(dest), ast_channel_name(source));
10704 ast_channel_unlock(source);
10705 ast_channel_unlock(dest);
10706 return -1;
10707 }
10708
10709 ast_channel_masq_set(dest, source);
10710 ast_channel_masqr_set(source, dest);
10711
10712 blob = ast_json_pack("{s: s}",
10713 "newchanneluniqueid", ast_channel_uniqueid(dest));
10715
10716 ast_channel_unlock(dest);
10717 ast_channel_unlock(source);
10718
10719 channel_do_masquerade(dest, source);
10720 return 0;
10721}
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:6832
static ast_mutex_t channel_move_lock
Definition channel.c:10683
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 424 of file channel_internal_api.c.

425{
426 chan->music_state = value;
427}

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(), _dahdi_get_index(), 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(), 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_response_read_header(), func_response_read_headers(), 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_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(), 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(), read_thread_handler(), 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_hold_intercept(), remove_scrambler(), remove_talk_detect(), request_withdraw_caller_from_queue(), resetcdr_exec(), revert_fax_buffers(), rfc3326_use_reason_header(), ring_entry(), rqm_exec(), rtp_check_timeout(), run_agi(), say_number_full(), say_position(), scan_exec(), 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_instance_translator(), 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(), 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_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_send_dtmf_text(), webchan_write(), 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 6814 of file channel.c.

6815{
6816 char *dash;
6817
6818 /* Truncate after the dash */
6819 dash = strrchr(channel_name, '-');
6820 if (dash) {
6821 *dash = '\0';
6822 }
6823}

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 948 of file channel_internal_api.c.

949{
950 return chan->named_callgroups;
951}
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 957 of file channel_internal_api.c.

958{
959 return chan->named_pickupgroups;
960}
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 535 of file channel_internal_api.c.

537{
538 SCOPE_ENTER(2, "%s: %sFormats: %s\n", S_OR(ast_channel_name(chan), "<initializing>"),
539 S_COR(ast_channel_is_multistream(chan), "Multistream", ""),
541
542 ast_assert(chan != NULL);
543
545
546 /* If chan->stream_topology is NULL, the channel is being destroyed
547 * and topology is destroyed.
548 */
549 if (!chan->stream_topology) {
550 SCOPE_EXIT_RTN("Channel is being initialized or destroyed\n");
551 }
552
553 if (!ast_channel_is_multistream(chan) || !value) {
554 struct ast_stream_topology *new_topology;
555
558 SCOPE_EXIT_RTN("New %stopology set\n", value ? "" : "empty ");
559 }
560 SCOPE_EXIT_RTN("Set native formats but not topology\n");
561}
#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 702 of file channel_internal_api.c.

703{
704 return chan->oldwriteformat;
705}
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 404 of file channel_internal_api.c.

405{
406 return chan->outsmpl;
407}
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 408 of file channel_internal_api.c.

409{
410 chan->outsmpl = value;
411}

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 944 of file channel_internal_api.c.

945{
946 chan->pickupgroup = value;
947}

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

7430{
7431 int res;
7432
7433 ast_channel_lock(chan);
7434 if (!ast_channel_tech(chan)->queryoption) {
7435 errno = ENOSYS;
7436 ast_channel_unlock(chan);
7437 return -1;
7438 }
7439
7440 if (block)
7441 ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n");
7442
7443 res = ast_channel_tech(chan)->queryoption(chan, option, data, datalen);
7444 ast_channel_unlock(chan);
7445
7446 return res;
7447}
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 9125 of file channel.c.

9126{
9127 unsigned char data[1024]; /* This should be large enough */
9128 size_t datalen;
9129
9130 datalen = ast_connected_line_build_data(data, sizeof(data), connected, update);
9131 if (datalen == (size_t) -1) {
9132 return;
9133 }
9134
9136}
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:1277
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:8716

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

10317{
10318 unsigned char data[1024]; /* This should be large enough */
10319 size_t datalen;
10320
10321 datalen = ast_redirecting_build_data(data, sizeof(data), redirecting, update);
10322 if (datalen == (size_t) -1) {
10323 return;
10324 }
10325
10326 ast_queue_control_data(chan, AST_CONTROL_REDIRECTING, data, datalen);
10327}
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:9287

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 615 of file channel_internal_api.c.

616{
617 chan->readtrans = value;
618}

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

5797{
5798 switch (reason) /* the following appear to be the only ones actually returned by request_and_dial */
5799 {
5800 case 0:
5801 return "Call Failure (not BUSY, and not NO_ANSWER, maybe Circuit busy or down?)";
5802 case AST_CONTROL_HANGUP:
5803 return "Hangup";
5804 case AST_CONTROL_RING:
5805 return "Local Ring";
5807 return "Remote end Ringing";
5808 case AST_CONTROL_ANSWER:
5809 return "Remote end has Answered";
5810 case AST_CONTROL_BUSY:
5811 return "Remote end is Busy";
5813 return "Congestion (circuits busy)";
5814 default:
5815 return "Unknown Reason!!";
5816 }
5817}

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 774 of file channel_internal_api.c.

775{
777}
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 770 of file channel_internal_api.c.

771{
773}
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 778 of file channel_internal_api.c.

779{
780 return ast_party_id_merge(&chan->redirecting.to, &chan->redirecting.priv_to);
781}
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 10402 of file channel.c.

10403{
10404 const char *sub;
10405 const char *sub_args;
10406 int retval;
10407
10408 ast_channel_lock(sub_chan);
10409 sub = pbx_builtin_getvar_helper(sub_chan, "REDIRECTING_SEND_SUB");
10410 sub = ast_strdupa(S_OR(sub, ""));
10411 sub_args = pbx_builtin_getvar_helper(sub_chan, "REDIRECTING_SEND_SUB_ARGS");
10412 sub_args = ast_strdupa(S_OR(sub_args, ""));
10413
10414 if (ast_strlen_zero(sub)) {
10415 ast_channel_unlock(sub_chan);
10416 return -1;
10417 }
10418
10419 if (is_frame) {
10420 const struct ast_frame *frame = redirecting_info;
10421
10423 } else {
10424 const struct ast_party_redirecting *redirecting = redirecting_info;
10425
10427 }
10428 ast_channel_unlock(sub_chan);
10429
10431 retval = ast_app_run_sub(autoservice_chan, sub_chan, sub, sub_args, 0);
10433 if (!retval) {
10434 struct ast_party_redirecting saved_redirecting;
10435
10436 ast_party_redirecting_init(&saved_redirecting);
10437 ast_channel_lock(sub_chan);
10438 ast_party_redirecting_copy(&saved_redirecting, ast_channel_redirecting(sub_chan));
10439 ast_channel_unlock(sub_chan);
10440 ast_channel_update_redirecting(sub_chan, &saved_redirecting, NULL);
10441 ast_party_redirecting_free(&saved_redirecting);
10442 }
10443
10444 return retval;
10445}
void ast_party_redirecting_init(struct ast_party_redirecting *init)
Initialize the given redirecting structure.
Definition channel.c:2090
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:10303
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:9498
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition channel.c:2147

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

540{
541 struct chanlist *chan;
542
544
546 if (!strcasecmp(tech->type, chan->tech->type)) {
547 ast_log(LOG_WARNING, "Already have a handler for type '%s'\n", tech->type);
549 return -1;
550 }
551 }
552
553 if (!(chan = ast_calloc(1, sizeof(*chan)))) {
555 return -1;
556 }
557 chan->tech = tech;
559
560 ast_debug(5, "Registered handler for '%s' (%s)\n", chan->tech->type, chan->tech->description);
561
562 ast_verb(5, "Registered channel type '%s' (%s)\n", chan->tech->type, chan->tech->description);
563
565
566 return 0;
567}
#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:124
struct chanlist::@352 list
struct ast_channel * chan
Definition app_dial.c:806
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 1552 of file channel.c.

1553{
1554 /* Safe, even if already unlinked. */
1555 ast_channel_unlink(chan);
1556 return ast_channel_unref(chan);
1557}
void ast_channel_unlink(struct ast_channel *chan)
Remove a channel from the global channels container.
Definition channel.c:10548
#define ast_channel_unref(c)
Decrease channel reference count.
Definition channel.h:3018

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

6405{
6406 channel_req_accountcodes(chan, requestor, relationship, 0);
6407}
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:6346

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

6410{
6411 channel_req_accountcodes(chan, requestor, relationship, 1);
6412}

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

10987{
10988 int res;
10989
10990 ast_assert(chan != NULL);
10991 ast_assert(topology != NULL);
10992
10993 ast_channel_lock(chan);
10995 ast_channel_unlock(chan);
10996 return -1;
10997 }
10998
11000 ast_debug(2, "%s: Topologies already match. Current: %s Requested: %s\n",
11001 ast_channel_name(chan),
11003 ast_str_tmp(256, ast_stream_topology_to_str(topology, &STR_TMP)));
11004 ast_channel_unlock(chan);
11005 return 0;
11006 }
11007
11009
11010 res = ast_channel_tech(chan)->indicate(chan, AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE, topology, sizeof(topology));
11011 ast_channel_unlock(chan);
11012 return res;
11013}
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 316 of file channel_internal_api.c.

317{
318 return chan->rings;
319}

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 591 of file channel_internal_api.c.

592{
593 chan->sched = value;
594}

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

6599{
6600 if (ast_channel_tech(chan)->send_html)
6601 return ast_channel_tech(chan)->send_html(chan, subclass, data, datalen);
6602 return -1;
6603}
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 6605 of file channel.c.

6606{
6607 return ast_channel_sendhtml(chan, AST_HTML_URL, url, strlen(url) + 1);
6608}
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:6598
#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 7852 of file channel.c.

7853{
7854 channel_set_external_vars(&ari_vars, varc, vars);
7855}
static void channel_set_external_vars(struct external_vars *channelvars, size_t varc, char **vars)
Definition channel.c:7825

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

7347{
7348 if (ast_channel_caller(chan) == caller) {
7349 /* Don't set to self */
7350 return;
7351 }
7352
7353 ast_channel_lock(chan);
7356 ast_channel_unlock(chan);
7357}
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:1975

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

7360{
7361 if (ast_channel_caller(chan) == caller) {
7362 /* Don't set to self */
7363 return;
7364 }
7365
7366 ast_channel_lock(chan);
7370 ast_channel_unlock(chan);
7371}

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

8328{
8329 if (ast_channel_connected(chan) == connected) {
8330 /* Don't set to self */
8331 return;
8332 }
8333
8334 ast_channel_lock(chan);
8338 ast_channel_unlock(chan);
8339}
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:2022

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

11047{
11048 ast_channel_lock(chan);
11050 ast_channel_unlock(chan);
11051}

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 919 of file channel_internal_api.c.

920{
921 ast_channel_lock(chan);
922 ast_channel_set_is_t38_active_nolock(chan, is_t38_active);
923 ast_channel_unlock(chan);
924}
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 914 of file channel_internal_api.c.

915{
916 chan->is_t38_active = !!is_t38_active;
917}

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

7848{
7849 channel_set_external_vars(&ami_vars, varc, vars);
7850}

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 682 of file channel_internal_api.c.

683{
684 ao2_replace(chan->oldwriteformat, format);
685}

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

9139{
9140 if (ast_channel_redirecting(chan) == redirecting) {
9141 /* Don't set to self */
9142 return;
9143 }
9144
9145 ast_channel_lock(chan);
9149 ast_channel_unlock(chan);
9150}
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:2134

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 1538 of file channel_internal_api.c.

1540{
1541 struct ast_stream_topology *new_topology;
1542 SCOPE_ENTER(1, "%s: %s\n", ast_channel_name(chan),
1543 ast_str_tmp(256, ast_stream_topology_to_str(topology, &STR_TMP)));
1544
1545 ast_assert(chan != NULL);
1546
1547 /* A non-MULTISTREAM channel can't manipulate topology directly */
1549
1550 /* Unless the channel is being destroyed, we always want a topology on
1551 * it even if its empty.
1552 */
1553 if (!topology) {
1554 new_topology = ast_stream_topology_alloc();
1555 } else {
1556 new_topology = topology;
1557 }
1558
1559 if (new_topology) {
1560 ast_channel_internal_set_stream_topology(chan, new_topology);
1561 }
1562
1563 SCOPE_EXIT_RTN_VALUE(new_topology, "Used %s topology\n", topology ? "provided" : "empty");
1564}
#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 892 of file channel_internal_api.c.

893{
894 ast_channel_lock(chan);
896 ast_channel_unlock(chan);
897}
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 886 of file channel_internal_api.c.

887{
888 chan->unbridged = !!value;
890}
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:1170
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 7409 of file channel.c.

7410{
7411 int res;
7412
7413 ast_channel_lock(chan);
7414 if (!ast_channel_tech(chan)->setoption) {
7415 errno = ENOSYS;
7416 ast_channel_unlock(chan);
7417 return -1;
7418 }
7419
7420 if (block)
7421 ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n");
7422
7423 res = ast_channel_tech(chan)->setoption(chan, option, data, datalen);
7424 ast_channel_unlock(chan);
7425
7426 return res;
7427}
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 510 of file channel.c.

511{
512 if (ast_tvzero(offset)) {
513 ast_channel_whentohangup_set(chan, &offset);
514 } else {
515 struct timeval tv = ast_tvadd(offset, ast_tvnow());
517 }
519 return;
520}
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:1170

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 1595 of file channel_internal_api.c.

1596{
1597 return chan->snapshot;
1598}
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 1600 of file channel_internal_api.c.

1601{
1602 ao2_cleanup(chan->snapshot);
1603 chan->snapshot = ao2_bump(snapshot);
1604}

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 867 of file channel_internal_api.c.

868{
869 chan ->softhangup &= ~value;
870}

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 859 of file channel_internal_api.c.

860{
861 chan->softhangup = value;
862}

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

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

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

8184{
8186
8187 if (!(state = ast_calloc(1, sizeof(*state)))) {
8188 return NULL;
8189 }
8190
8191 state->old_write_format = ao2_bump(ast_channel_writeformat(chan));
8192
8193 if (ast_set_write_format(chan, ast_format_slin) < 0) {
8194 ast_log(LOG_ERROR, "Could not set write format to SLINEAR\n");
8195 ast_free(state);
8196 return NULL;
8197 }
8198
8200
8201 ast_debug(1, "Started silence generator on '%s'\n", ast_channel_name(chan));
8202
8203 return state;
8204}
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
Definition channel.c:2923
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
Definition channel.c:5773
static struct ast_generator silence_generator
Definition channel.c:8173
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 647 of file channel_internal_api.c.

648{
649 return chan->state;
650}

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

8230{
8231 if (!state) {
8232 return;
8233 }
8234
8235 if (deactivate_silence_generator(chan)) {
8236 ast_debug(1, "Stopped silence generator on '%s'\n", ast_channel_name(chan));
8237 if (ast_set_write_format(chan, state->old_write_format) < 0) {
8238 ast_log(LOG_ERROR, "Could not return write format to its original state\n");
8239 }
8240 }
8241 ao2_cleanup(state->old_write_format);
8242 ast_free(state);
8243}
static int deactivate_silence_generator(struct ast_channel *chan)
Definition channel.c:8206

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

11016{
11017 ast_assert(chan != NULL);
11018 ast_assert(topology != NULL);
11019
11021 return -1;
11022 }
11023
11024 return ast_channel_tech(chan)->indicate(chan, AST_CONTROL_STREAM_TOPOLOGY_CHANGED, topology, sizeof(topology));
11025}
@ 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 11027 of file channel.c.

11028{
11029 int res;
11031
11032 ast_assert(chan != NULL);
11033
11034 if (!ast_channel_is_multistream(chan)) {
11035 return -1;
11036 }
11037
11038 ast_channel_lock(chan);
11040 res = ast_queue_frame(chan, &f);
11041 ast_channel_unlock(chan);
11042
11043 return res;
11044}
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 324 of file channel_internal_api.c.

325{
326 return chan->streamid;
327}

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 328 of file channel_internal_api.c.

329{
330 chan->streamid = value;
331}

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

4330{
4331 if (!strcasecmp(flag, "default"))
4332 return DEFAULT_AMA_FLAGS;
4333 if (!strcasecmp(flag, "omit"))
4334 return AST_AMA_OMIT;
4335 if (!strcasecmp(flag, "billing"))
4336 return AST_AMA_BILLING;
4337 if (!strcasecmp(flag, "documentation"))
4338 return AST_AMA_DOCUMENTATION;
4339 return AST_AMA_NONE;
4340}
#define DEFAULT_AMA_FLAGS
Definition channel.c:111

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

6594{
6595 return (ast_channel_tech(chan)->send_html) ? 1 : 0;
6596}

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

10797{
10798 struct suppress_data *suppress;
10799 const struct ast_datastore_info *datastore_info = NULL;
10800 struct ast_datastore *datastore = NULL;
10801 struct ast_framehook_interface interface = {
10803 .event_cb = suppress_framehook_event_cb,
10804 .destroy_cb = suppress_framehook_destroy_cb,
10805 .chan_fixup_cb = suppress_framehook_fixup_cb,
10806 };
10807 int framehook_id;
10808
10809 if (!(datastore_info = suppress_get_datastore_information(frametype))) {
10810 ast_log(LOG_WARNING, "Attempted to suppress an unsupported frame type (%u).\n", frametype);
10811 return -1;
10812 }
10813
10814 if ((datastore = ast_channel_datastore_find(chan, datastore_info, NULL))) {
10815 suppress = datastore->data;
10816 suppress->direction |= direction;
10817 return 0;
10818 }
10819
10820 if (!(suppress = ao2_alloc(sizeof(*suppress), NULL))) {
10821 ast_log(LOG_WARNING, "Failed to allocate data while attempting to suppress a stream.\n");
10822 return -1;
10823 }
10824
10825 suppress->frametype = frametype;
10826 suppress->direction |= direction;
10827
10828 interface.data = suppress;
10829
10830 framehook_id = ast_framehook_attach(chan, &interface);
10831 if (framehook_id < 0) {
10832 /* Hook attach failed. Get rid of the evidence. */
10833 ast_log(LOG_WARNING, "Failed to attach framehook while attempting to suppress a stream.\n");
10834 ao2_ref(suppress, -1);
10835 return -1;
10836 }
10837
10838 /* One ref for the framehook */
10839 ao2_ref(suppress, +1);
10840
10841 suppress->framehook_id = framehook_id;
10842
10843 if (!(datastore = ast_datastore_alloc(datastore_info, NULL))) {
10844 ast_log(LOG_WARNING, "Failed to allocate datastore while attempting to suppress a stream.\n");
10845 ast_framehook_detach(chan, framehook_id);
10846 ao2_ref(suppress, -1);
10847 return -1;
10848 }
10849
10850 /* the ref provided by the allocation is taken by the datastore */
10851 datastore->data = suppress;
10852
10853 ast_channel_datastore_add(chan, datastore);
10854
10855 return 0;
10856}
static void suppress_framehook_fixup_cb(void *data, int framehook_id, struct ast_channel *old_chan, struct ast_channel *new_chan)
Definition channel.c:10744
static const struct ast_datastore_info * suppress_get_datastore_information(enum ast_frame_type frametype)
Definition channel.c:10786
static void suppress_framehook_destroy_cb(void *data)
Definition channel.c:10733
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:10751
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:10739
unsigned int direction
Definition channel.c:10740

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 627 of file channel_internal_api.c.

628{
629 return chan->tech;
630}

References ast_channel::tech.

◆ ast_channel_tech_pvt()

void * ast_channel_tech_pvt ( const struct ast_channel chan)

Definition at line 428 of file channel_internal_api.c.

429{
430 return chan->tech_pvt;
431}

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 599 of file channel_internal_api.c.

600{
601 chan->timer = value;
602}

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 439 of file channel_internal_api.c.

440{
441 return chan->timingdata;
442}

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 443 of file channel_internal_api.c.

444{
445 chan->timingdata = value;
446}

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 336 of file channel_internal_api.c.

337{
338 chan->timingfd = value;
339}

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 1093 of file channel_internal_api.c.

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

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 1449 of file channel_internal_api.c.

1450{
1451 if (!chan) {
1452 return ast_channel_topic_all();
1453 }
1454
1455 return chan->topic;
1456}
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 877 of file channel_internal_api.c.

878{
879 int res;
880 ast_channel_lock(chan);
882 ast_channel_unlock(chan);
883 return res;
884}
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 872 of file channel_internal_api.c.

873{
874 return chan->unbridged;
875}

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

1311{
1312 if (chan) {
1314 }
1315}
void ast_channel_clear_flag(struct ast_channel *chan, unsigned int flag)
Clear a flag on a channel.
Definition channel.c:11053

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(), 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(), 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_control_find_by_channel(), stasis_app_control_get_channel_id(), stasis_app_control_snoop(), stasis_app_exec(), stasis_app_subscribe_channel(), 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 10548 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 570 of file channel.c.

571{
572 struct chanlist *chan;
573
574 ast_debug(5, "Unregistering channel type '%s'\n", tech->type);
575
577
579 if (chan->tech == tech) {
581 ast_free(chan);
582 ast_verb(5, "Unregistered channel type '%s'\n", tech->type);
583 break;
584 }
585 }
587
589}
#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 10858 of file channel.c.

10859{
10860 const struct ast_datastore_info *datastore_info = NULL;
10861 struct ast_datastore *datastore = NULL;
10862 struct suppress_data *suppress;
10863
10864 if (!(datastore_info = suppress_get_datastore_information(frametype))) {
10865 ast_log(LOG_WARNING, "Attempted to unsuppress an unsupported frame type (%u).\n", frametype);
10866 return -1;
10867 }
10868
10869 if (!(datastore = ast_channel_datastore_find(chan, datastore_info, NULL))) {
10870 /* Nothing to do! */
10871 return 0;
10872 }
10873
10874 suppress = datastore->data;
10875
10876 suppress->direction &= ~(direction);
10877
10878 if (suppress->direction == 0) {
10879 /* Nothing left to suppress. Bye! */
10880 ast_framehook_detach(chan, suppress->framehook_id);
10881 ast_channel_datastore_remove(chan, datastore);
10882 ast_datastore_free(datastore);
10883 }
10884
10885 return 0;
10886}
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
Definition channel.c:2366
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 9112 of file channel.c.

9113{
9114 unsigned char data[1024]; /* This should be large enough */
9115 size_t datalen;
9116
9117 datalen = ast_connected_line_build_data(data, sizeof(data), connected, update);
9118 if (datalen == (size_t) -1) {
9119 return;
9120 }
9121
9122 ast_indicate_data(chan, AST_CONTROL_CONNECTED_LINE, data, datalen);
9123}
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:4623

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

10304{
10305 unsigned char data[1024]; /* This should be large enough */
10306 size_t datalen;
10307
10308 datalen = ast_redirecting_build_data(data, sizeof(data), redirecting, update);
10309 if (datalen == (size_t) -1) {
10310 return;
10311 }
10312
10313 ast_indicate_data(chan, AST_CONTROL_REDIRECTING, data, datalen);
10314}

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 830 of file channel_internal_api.c.

831{
832 chan->varshead = *value;
833}

References value, and ast_channel::varshead.

◆ ast_channel_visible_indication()

int ast_channel_visible_indication ( const struct ast_channel chan)

Definition at line 340 of file channel_internal_api.c.

341{
342 return chan->visible_indication;
343}

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 344 of file channel_internal_api.c.

345{
347}

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 487 of file channel_internal_api.c.

488{
489 return chan->vstream;
490}
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 491 of file channel_internal_api.c.

492{
493 chan->vstream = value;
494}

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 356 of file channel_internal_api.c.

357{
358 return chan->vstreamid;
359}

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 360 of file channel_internal_api.c.

361{
362 chan->vstreamid = value;
363}

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 826 of file channel_internal_api.c.

827{
828 chan->whentohangup = *value;
829}

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 623 of file channel_internal_api.c.

624{
625 chan->writetrans = value;
626}

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

10613{
10614 struct ast_channel *yanked_chan;
10615 struct {
10616 char *accountcode;
10617 char *exten;
10618 char *context;
10619 char *name;
10620 int amaflags;
10621 int priority;
10622 struct ast_format *readformat;
10623 struct ast_format *writeformat;
10624 } my_vars = { 0, };
10625
10626 ast_channel_lock(yankee);
10627 my_vars.accountcode = ast_strdupa(ast_channel_accountcode(yankee));
10628 my_vars.exten = ast_strdupa(ast_channel_exten(yankee));
10629 my_vars.context = ast_strdupa(ast_channel_context(yankee));
10630 my_vars.name = ast_strdupa(ast_channel_name(yankee));
10631 my_vars.amaflags = ast_channel_amaflags(yankee);
10632 my_vars.priority = ast_channel_priority(yankee);
10633 /* The priority as returned by ast_channel_yank is where the channel
10634 * should go if the dialplan is executed on it. If the channel is
10635 * already executing dialplan then the priority currently set is
10636 * where it is currently. We increment it so it becomes where it should
10637 * execute.
10638 */
10640 my_vars.priority++;
10641 }
10642 my_vars.writeformat = ao2_bump(ast_channel_writeformat(yankee));
10643 my_vars.readformat = ao2_bump(ast_channel_readformat(yankee));
10644 ast_channel_unlock(yankee);
10645
10646 /* Do not hold any channel locks while calling channel_alloc() since the function
10647 * locks the channel container when linking the new channel in. */
10648 if (!(yanked_chan = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, my_vars.accountcode,
10649 my_vars.exten, my_vars.context, NULL, yankee, my_vars.amaflags,
10650 "Surrogate/%s", my_vars.name))) {
10651 ao2_cleanup(my_vars.writeformat);
10652 ao2_cleanup(my_vars.readformat);
10653 return NULL;
10654 }
10655
10656 /* Make formats okay */
10657 ast_channel_set_readformat(yanked_chan, my_vars.readformat);
10658 ast_channel_set_writeformat(yanked_chan, my_vars.writeformat);
10659 ao2_cleanup(my_vars.readformat);
10660 ao2_cleanup(my_vars.writeformat);
10661 ast_channel_priority_set(yanked_chan, my_vars.priority);
10662
10663 ast_channel_unlock(yanked_chan);
10664
10665 if (ast_channel_move(yanked_chan, yankee)) {
10666 ast_hangup(yanked_chan);
10667 return NULL;
10668 }
10669
10670 return yanked_chan;
10671}
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:10685
#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 607 of file channel_internal_api.c.

608{
609 chan->zone = value;
610}

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

189{
190 struct chanlist *cl;
191 struct ast_variable *var = NULL, *prev = NULL;
192
194 AST_RWLIST_TRAVERSE(&backends, cl, list) {
195 if (prev) {
196 if ((prev->next = ast_variable_new(cl->tech->type, cl->tech->description, "")))
197 prev = prev->next;
198 } else {
199 var = ast_variable_new(cl->tech->type, cl->tech->description, "");
200 prev = var;
201 }
202 }
204
205 return var;
206}
#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 445 of file channel.c.

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

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

8717{
8718 int32_t value;
8719 size_t pos = 0;
8720 int res;
8721
8722 static const struct ast_party_id_ies ies = {
8724 .name.char_set = AST_CONNECTED_LINE_NAME_CHAR_SET,
8725 .name.presentation = AST_CONNECTED_LINE_NAME_PRESENTATION,
8726 .name.valid = AST_CONNECTED_LINE_NAME_VALID,
8727
8728 .number.str = AST_CONNECTED_LINE_NUMBER,
8729 .number.plan = AST_CONNECTED_LINE_NUMBER_PLAN,
8730 .number.presentation = AST_CONNECTED_LINE_NUMBER_PRESENTATION,
8731 .number.valid = AST_CONNECTED_LINE_NUMBER_VALID,
8732
8733 .subaddress.str = AST_CONNECTED_LINE_SUBADDRESS,
8734 .subaddress.type = AST_CONNECTED_LINE_SUBADDRESS_TYPE,
8735 .subaddress.odd_even_indicator = AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN,
8736 .subaddress.valid = AST_CONNECTED_LINE_SUBADDRESS_VALID,
8737
8739 .combined_presentation = AST_CONNECTED_LINE_ID_PRESENTATION,
8740 };
8741
8742 static const struct ast_party_id_ies priv_ies = {
8745 .name.presentation = AST_CONNECTED_LINE_PRIV_NAME_PRESENTATION,
8747
8748 .number.str = AST_CONNECTED_LINE_PRIV_NUMBER,
8750 .number.presentation = AST_CONNECTED_LINE_PRIV_NUMBER_PRESENTATION,
8752
8753 .subaddress.str = AST_CONNECTED_LINE_PRIV_SUBADDRESS,
8754 .subaddress.type = AST_CONNECTED_LINE_PRIV_SUBADDRESS_TYPE,
8755 .subaddress.odd_even_indicator = AST_CONNECTED_LINE_PRIV_SUBADDRESS_ODD_EVEN,
8756 .subaddress.valid = AST_CONNECTED_LINE_PRIV_SUBADDRESS_VALID,
8757
8759 .combined_presentation = 0,/* Not sent. */
8760 };
8761
8762 /*
8763 * The size of integer values must be fixed in case the frame is
8764 * shipped to another machine.
8765 */
8766
8767 /* Connected line frame version */
8768 if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8769 ast_log(LOG_WARNING, "No space left for connected line frame version\n");
8770 return -1;
8771 }
8772 data[pos++] = AST_CONNECTED_LINE_VERSION;
8773 data[pos++] = 1;
8774 data[pos++] = 2;/* Version 1 did not have a version ie */
8775
8776 res = party_id_build_data(data + pos, datalen - pos, &connected->id,
8777 "connected line", &ies, update ? &update->id : NULL);
8778 if (res < 0) {
8779 return -1;
8780 }
8781 pos += res;
8782
8783 res = party_id_build_data(data + pos, datalen - pos, &connected->priv,
8784 "connected line priv", &priv_ies, update ? &update->priv : NULL);
8785 if (res < 0) {
8786 return -1;
8787 }
8788 pos += res;
8789
8790 /* Connected line source */
8791 if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) {
8792 ast_log(LOG_WARNING, "No space left for connected line source\n");
8793 return -1;
8794 }
8795 data[pos++] = AST_CONNECTED_LINE_SOURCE;
8796 data[pos++] = sizeof(value);
8797 value = htonl(connected->source);
8798 memcpy(data + pos, &value, sizeof(value));
8799 pos += sizeof(value);
8800
8801 return pos;
8802}
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:8596
@ AST_CONNECTED_LINE_NUMBER_VALID
Definition channel.c:8699
@ AST_CONNECTED_LINE_SOURCE
Definition channel.c:8685
@ AST_CONNECTED_LINE_PRIV_SUBADDRESS_VALID
Definition channel.c:8712
@ AST_CONNECTED_LINE_PRIV_SUBADDRESS_ODD_EVEN
Definition channel.c:8711
@ AST_CONNECTED_LINE_PRIV_NAME_VALID
Definition channel.c:8706
@ AST_CONNECTED_LINE_PRIV_SUBADDRESS_TYPE
Definition channel.c:8710
@ AST_CONNECTED_LINE_PRIV_NUMBER_PRESENTATION
Definition channel.c:8704
@ AST_CONNECTED_LINE_NAME_CHAR_SET
Definition channel.c:8697
@ AST_CONNECTED_LINE_SUBADDRESS_VALID
Definition channel.c:8689
@ AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN
Definition channel.c:8688
@ AST_CONNECTED_LINE_SUBADDRESS
Definition channel.c:8686
@ AST_CONNECTED_LINE_PRIV_NUMBER_PLAN
Definition channel.c:8702
@ AST_CONNECTED_LINE_NUMBER
Definition channel.c:8681
@ AST_CONNECTED_LINE_ID_PRESENTATION
Definition channel.c:8684
@ AST_CONNECTED_LINE_PRIV_NAME_PRESENTATION
Definition channel.c:8708
@ AST_CONNECTED_LINE_PRIV_NAME
Definition channel.c:8705
@ AST_CONNECTED_LINE_TAG
Definition channel.c:8690
@ AST_CONNECTED_LINE_PRIV_NUMBER_VALID
Definition channel.c:8703
@ AST_CONNECTED_LINE_NUMBER_PRESENTATION
Definition channel.c:8700
@ AST_CONNECTED_LINE_PRIV_NAME_CHAR_SET
Definition channel.c:8707
@ AST_CONNECTED_LINE_NAME
Definition channel.c:8682
@ AST_CONNECTED_LINE_NAME_PRESENTATION
Definition channel.c:8698
@ AST_CONNECTED_LINE_SUBADDRESS_TYPE
Definition channel.c:8687
@ AST_CONNECTED_LINE_PRIV_SUBADDRESS
Definition channel.c:8709
@ AST_CONNECTED_LINE_PRIV_TAG
Definition channel.c:8713
@ AST_CONNECTED_LINE_NAME_VALID
Definition channel.c:8696
@ AST_CONNECTED_LINE_PRIV_NUMBER
Definition channel.c:8701
@ AST_CONNECTED_LINE_NUMBER_PLAN
Definition channel.c:8683
@ AST_CONNECTED_LINE_VERSION
Definition channel.c:8691
struct ast_party_name_ies name
Subscriber name ies.
Definition channel.c:8567
int str
Subscriber name ie.
Definition channel.c:8344

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

8313{
8314 ast_party_id_copy(&dest->id, &src->id);
8315 ast_party_id_copy(&dest->ani, &src->ani);
8316 dest->ani2 = src->ani2;
8317}
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:1733
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 8319 of file channel.c.

8320{
8321 ast_party_id_copy(&dest->id, &src->id);
8322 ast_party_id_copy(&dest->ani, &src->ani);
8323
8324 dest->ani2 = src->ani2;
8325}

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

8805{
8806 size_t pos;
8807 unsigned char ie_len;
8808 unsigned char ie_id;
8809 int32_t value;
8810 int frame_version = 1;
8811 int combined_presentation = 0;
8812 int got_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
8813
8814 for (pos = 0; pos < datalen; pos += ie_len) {
8815 if (datalen < pos + sizeof(ie_id) + sizeof(ie_len)) {
8816 ast_log(LOG_WARNING, "Invalid connected line update\n");
8817 return -1;
8818 }
8819 ie_id = data[pos++];
8820 ie_len = data[pos++];
8821 if (datalen < pos + ie_len) {
8822 ast_log(LOG_WARNING, "Invalid connected line update\n");
8823 return -1;
8824 }
8825
8826 switch (ie_id) {
8827/* Connected line party frame version */
8829 if (ie_len != 1) {
8830 ast_log(LOG_WARNING, "Invalid connected line frame version (%u)\n",
8831 (unsigned) ie_len);
8832 break;
8833 }
8834 frame_version = data[pos];
8835 break;
8836/* Connected line party id name */
8838 ast_free(connected->id.name.str);
8839 connected->id.name.str = ast_malloc(ie_len + 1);
8840 if (connected->id.name.str) {
8841 memcpy(connected->id.name.str, data + pos, ie_len);
8842 connected->id.name.str[ie_len] = 0;
8843 }
8844 break;
8846 if (ie_len != 1) {
8847 ast_log(LOG_WARNING, "Invalid connected line name char set (%u)\n",
8848 (unsigned) ie_len);
8849 break;
8850 }
8851 connected->id.name.char_set = data[pos];
8852 break;
8854 if (ie_len != 1) {
8855 ast_log(LOG_WARNING, "Invalid connected line name presentation (%u)\n",
8856 (unsigned) ie_len);
8857 break;
8858 }
8859 connected->id.name.presentation = data[pos];
8860 break;
8862 if (ie_len != 1) {
8863 ast_log(LOG_WARNING, "Invalid connected line name valid (%u)\n",
8864 (unsigned) ie_len);
8865 break;
8866 }
8867 connected->id.name.valid = data[pos];
8868 break;
8869/* Connected line party id number */
8871 ast_free(connected->id.number.str);
8872 connected->id.number.str = ast_malloc(ie_len + 1);
8873 if (connected->id.number.str) {
8874 memcpy(connected->id.number.str, data + pos, ie_len);
8875 connected->id.number.str[ie_len] = 0;
8876 }
8877 break;
8879 if (ie_len != 1) {
8880 ast_log(LOG_WARNING, "Invalid connected line numbering plan (%u)\n",
8881 (unsigned) ie_len);
8882 break;
8883 }
8884 connected->id.number.plan = data[pos];
8885 break;
8887 if (ie_len != 1) {
8888 ast_log(LOG_WARNING, "Invalid connected line number presentation (%u)\n",
8889 (unsigned) ie_len);
8890 break;
8891 }
8892 connected->id.number.presentation = data[pos];
8893 break;
8895 if (ie_len != 1) {
8896 ast_log(LOG_WARNING, "Invalid connected line number valid (%u)\n",
8897 (unsigned) ie_len);
8898 break;
8899 }
8900 connected->id.number.valid = data[pos];
8901 break;
8902/* Connected line party id subaddress */
8904 ast_free(connected->id.subaddress.str);
8905 connected->id.subaddress.str = ast_malloc(ie_len + 1);
8906 if (connected->id.subaddress.str) {
8907 memcpy(connected->id.subaddress.str, data + pos, ie_len);
8908 connected->id.subaddress.str[ie_len] = 0;
8909 }
8910 break;
8912 if (ie_len != 1) {
8913 ast_log(LOG_WARNING, "Invalid connected line type of subaddress (%u)\n",
8914 (unsigned) ie_len);
8915 break;
8916 }
8917 connected->id.subaddress.type = data[pos];
8918 break;
8920 if (ie_len != 1) {
8922 "Invalid connected line subaddress odd-even indicator (%u)\n",
8923 (unsigned) ie_len);
8924 break;
8925 }
8926 connected->id.subaddress.odd_even_indicator = data[pos];
8927 break;
8929 if (ie_len != 1) {
8930 ast_log(LOG_WARNING, "Invalid connected line subaddress valid (%u)\n",
8931 (unsigned) ie_len);
8932 break;
8933 }
8934 connected->id.subaddress.valid = data[pos];
8935 break;
8936/* Connected line party tag */
8938 ast_free(connected->id.tag);
8939 connected->id.tag = ast_malloc(ie_len + 1);
8940 if (connected->id.tag) {
8941 memcpy(connected->id.tag, data + pos, ie_len);
8942 connected->id.tag[ie_len] = 0;
8943 }
8944 break;
8945/* Connected line party id combined presentation */
8947 if (ie_len != 1) {
8948 ast_log(LOG_WARNING, "Invalid connected line combined presentation (%u)\n",
8949 (unsigned) ie_len);
8950 break;
8951 }
8952 combined_presentation = data[pos];
8953 got_combined_presentation = 1;
8954 break;
8955/* Private connected line party id name */
8957 ast_free(connected->priv.name.str);
8958 connected->priv.name.str = ast_malloc(ie_len + 1);
8959 if (connected->priv.name.str) {
8960 memcpy(connected->priv.name.str, data + pos, ie_len);
8961 connected->priv.name.str[ie_len] = 0;
8962 }
8963 break;
8965 if (ie_len != 1) {
8966 ast_log(LOG_WARNING, "Invalid connected line private name char set (%u)\n",
8967 (unsigned) ie_len);
8968 break;
8969 }
8970 connected->priv.name.char_set = data[pos];
8971 break;
8973 if (ie_len != 1) {
8974 ast_log(LOG_WARNING, "Invalid connected line private name presentation (%u)\n",
8975 (unsigned) ie_len);
8976 break;
8977 }
8978 connected->priv.name.presentation = data[pos];
8979 break;
8981 if (ie_len != 1) {
8982 ast_log(LOG_WARNING, "Invalid connected line private name valid (%u)\n",
8983 (unsigned) ie_len);
8984 break;
8985 }
8986 connected->priv.name.valid = data[pos];
8987 break;
8988/* Private connected line party id number */
8990 ast_free(connected->priv.number.str);
8991 connected->priv.number.str = ast_malloc(ie_len + 1);
8992 if (connected->priv.number.str) {
8993 memcpy(connected->priv.number.str, data + pos, ie_len);
8994 connected->priv.number.str[ie_len] = 0;
8995 }
8996 break;
8998 if (ie_len != 1) {
8999 ast_log(LOG_WARNING, "Invalid connected line private numbering plan (%u)\n",
9000 (unsigned) ie_len);
9001 break;
9002 }
9003 connected->priv.number.plan = data[pos];
9004 break;
9006 if (ie_len != 1) {
9007 ast_log(LOG_WARNING, "Invalid connected line private number presentation (%u)\n",
9008 (unsigned) ie_len);
9009 break;
9010 }
9011 connected->priv.number.presentation = data[pos];
9012 break;
9014 if (ie_len != 1) {
9015 ast_log(LOG_WARNING, "Invalid connected line private number valid (%u)\n",
9016 (unsigned) ie_len);
9017 break;
9018 }
9019 connected->priv.number.valid = data[pos];
9020 break;
9021/* Private connected line party id subaddress */
9023 ast_free(connected->priv.subaddress.str);
9024 connected->priv.subaddress.str = ast_malloc(ie_len + 1);
9025 if (connected->priv.subaddress.str) {
9026 memcpy(connected->priv.subaddress.str, data + pos, ie_len);
9027 connected->priv.subaddress.str[ie_len] = 0;
9028 }
9029 break;
9031 if (ie_len != 1) {
9032 ast_log(LOG_WARNING, "Invalid connected line private type of subaddress (%u)\n",
9033 (unsigned) ie_len);
9034 break;
9035 }
9036 connected->priv.subaddress.type = data[pos];
9037 break;
9039 if (ie_len != 1) {
9041 "Invalid connected line private subaddress odd-even indicator (%u)\n",
9042 (unsigned) ie_len);
9043 break;
9044 }
9045 connected->priv.subaddress.odd_even_indicator = data[pos];
9046 break;
9048 if (ie_len != 1) {
9049 ast_log(LOG_WARNING, "Invalid connected line private subaddress valid (%u)\n",
9050 (unsigned) ie_len);
9051 break;
9052 }
9053 connected->priv.subaddress.valid = data[pos];
9054 break;
9055/* Private connected line party tag */
9057 ast_free(connected->priv.tag);
9058 connected->priv.tag = ast_malloc(ie_len + 1);
9059 if (connected->priv.tag) {
9060 memcpy(connected->priv.tag, data + pos, ie_len);
9061 connected->priv.tag[ie_len] = 0;
9062 }
9063 break;
9064/* Connected line party source */
9066 if (ie_len != sizeof(value)) {
9067 ast_log(LOG_WARNING, "Invalid connected line source (%u)\n",
9068 (unsigned) ie_len);
9069 break;
9070 }
9071 memcpy(&value, data + pos, sizeof(value));
9072 connected->source = ntohl(value);
9073 break;
9074/* Connected line party unknown element */
9075 default:
9076 ast_debug(1, "Unknown connected line element: %u (%u)\n",
9077 (unsigned) ie_id, (unsigned) ie_len);
9078 break;
9079 }
9080 }
9081
9082 switch (frame_version) {
9083 case 1:
9084 /*
9085 * The other end is an earlier version that we need to adjust
9086 * for compatibility.
9087 */
9088 connected->id.name.valid = 1;
9089 connected->id.name.char_set = AST_PARTY_CHAR_SET_ISO8859_1;
9090 connected->id.number.valid = 1;
9091 if (got_combined_presentation) {
9092 connected->id.name.presentation = combined_presentation;
9093 connected->id.number.presentation = combined_presentation;
9094 }
9095 break;
9096 case 2:
9097 /* The other end is at the same level as we are. */
9098 break;
9099 default:
9100 /*
9101 * The other end is newer than we are.
9102 * We need to assume that they are compatible with us.
9103 */
9104 ast_debug(1, "Connected line frame has newer version: %u\n",
9105 (unsigned) frame_version);
9106 break;
9107 }
9108
9109 return 0;
9110}
#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 2865 of file channel.c.

2866{
2867 ast_channel_lock(chan);
2870 /* if in the middle of dtmf emulation keep 50 tick per sec timer on rolling */
2872 }
2873 ast_channel_unlock(chan);
2874}
static void deactivate_generator_nolock(struct ast_channel *chan)
Definition channel.c:2850
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:2828
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_timer_set_rate(), deactivate_generator_nolock(), and should_trigger_dtmf_emulating().

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

2888{
2889 int x;
2890 int dummy = 0;
2891
2892 if (fd < 0)
2893 return 0;
2894 if (!start)
2895 start = &dummy;
2896 for (x = *start; x < maximum; x++)
2897 if (pfds[x].fd == fd) {
2898 if (x == *start)
2899 (*start)++;
2900 return pfds[x].revents;
2901 }
2902 return 0;
2903}

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

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

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

7606{
7607 char *piece;
7608 char *c;
7609 int start=0, finish=0, x;
7610 ast_group_t group = 0;
7611
7612 if (ast_strlen_zero(s))
7613 return 0;
7614
7615 c = ast_strdupa(s);
7616
7617 while ((piece = strsep(&c, ","))) {
7618 if (sscanf(piece, "%30d-%30d", &start, &finish) == 2) {
7619 /* Range */
7620 } else if (sscanf(piece, "%30d", &start)) {
7621 /* Just one */
7622 finish = start;
7623 } else {
7624 ast_log(LOG_ERROR, "Syntax error parsing group configuration '%s' at '%s'. Ignoring.\n", s, piece);
7625 continue;
7626 }
7627 for (x = start; x <= finish; x++) {
7628 if ((x > 63) || (x < 0)) {
7629 ast_log(LOG_WARNING, "Ignoring invalid group %d (maximum group is 63)\n", x);
7630 } else
7631 group |= ((ast_group_t) 1 << x);
7632 }
7633 }
7634 return group;
7635}
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 7662 of file channel.c.

7663{
7664 struct ao2_container *namedgroups;
7665 char *piece;
7666 char *c;
7667
7668 if (!s) {
7669 return NULL;
7670 }
7671
7672 /*! \brief Remove leading and trailing whitespace */
7674 if (ast_strlen_zero(c)) {
7675 return NULL;
7676 }
7677
7680 if (!namedgroups) {
7681 return NULL;
7682 }
7683
7684 while ((piece = strsep(&c, ","))) {
7685 struct namedgroup_member *member;
7686 size_t len;
7687
7688 /* remove leading/trailing whitespace */
7689 piece = ast_strip(piece);
7690
7691 len = strlen(piece);
7692 if (!len) {
7693 continue;
7694 }
7695
7697 if (!member) {
7698 ao2_ref(namedgroups, -1);
7699 return NULL;
7700 }
7701 strcpy(member->name, piece);/* Safe */
7702 member->hash = ast_str_hash(member->name);
7703
7704 /* every group name may exist only once, delete duplicates */
7705 ao2_find(namedgroups, member, OBJ_POINTER | OBJ_UNLINK | OBJ_NODATA);
7706 ao2_link(namedgroups, member);
7707 ao2_ref(member, -1);
7708 }
7709
7710 if (!ao2_container_count(namedgroups)) {
7711 /* There were no group names specified. */
7712 ao2_ref(namedgroups, -1);
7713 namedgroups = NULL;
7714 }
7715
7716 return (struct ast_namedgroups *) namedgroups;
7717}
#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:7646
static int namedgroup_hash_cb(const void *obj, const int flags)
Hashing function used for named group container.
Definition channel.c:7655
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:7638

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

2514{
2515 /* Be NULL safe for RAII_VAR() usage. */
2516 if (!chan) {
2517 return;
2518 }
2519
2520 ast_debug(1, "Channel %p '%s' hanging up. Refs: %d\n", chan, ast_channel_name(chan),
2521 ao2_ref(chan, 0));
2522
2524
2525 ast_channel_lock(chan);
2526
2527 while (ast_channel_masq(chan) || ast_channel_masqr(chan)) {
2529 }
2530
2531 /* Mark as a zombie so a masquerade cannot be setup on this channel. */
2533
2534 ast_channel_unlock(chan);
2535
2536 /*
2537 * XXX if running the hangup handlers here causes problems
2538 * because the handlers take too long to execute, we could move
2539 * the meat of this function into another thread. A thread
2540 * where channels go to die.
2541 *
2542 * If this is done, ast_autoservice_chan_hangup_peer() will no
2543 * longer be needed.
2544 */
2546 ast_channel_unlink(chan);
2547 ast_channel_lock(chan);
2548
2549 destroy_hooks(chan);
2550
2551 free_translation(chan);
2552 /* Close audio stream */
2553 if (ast_channel_stream(chan)) {
2556 }
2557 /* Close video stream */
2558 if (ast_channel_vstream(chan)) {
2561 }
2562 if (ast_channel_sched(chan)) {
2565 }
2566
2567 if (ast_channel_generatordata(chan)) { /* Clear any tone stuff remaining */
2568 if (ast_channel_generator(chan) && ast_channel_generator(chan)->release) {
2570 }
2571 }
2574
2576 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",
2578 ast_channel_blockproc(chan));
2579 ast_assert(0);
2580 }
2581
2582 if (ast_channel_tech(chan)->hangup) {
2583 ast_channel_tech(chan)->hangup(chan);
2584 }
2585
2586 ast_channel_unlock(chan);
2587
2588 ast_cc_offer(chan);
2589
2590 ast_channel_unref(chan);
2591}
int ast_cc_offer(struct ast_channel *caller_chan)
Offer CC to a caller.
Definition ccss.c:3722
static int hangup(void *data)
static void destroy_hooks(struct ast_channel *chan)
Definition channel.c:2502
static void free_translation(struct ast_channel *clonechan)
Definition channel.c:2459
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 4245 of file channel.c.

4246{
4247 return ast_indicate_data(chan, condition, NULL, 0);
4248}

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

4624{
4625 int res;
4626 /* this frame is used by framehooks. if it is set, we must free it at the end of this function */
4627 struct ast_frame *awesome_frame = NULL;
4628
4629 ast_channel_lock(chan);
4630
4631 /* Don't bother if the channel is about to go away, anyway. */
4634 && _condition != AST_CONTROL_MASQUERADE_NOTIFY) {
4635 res = -1;
4636 goto indicate_cleanup;
4637 }
4638
4640 /* Do framehooks now, do it, go, go now */
4641 struct ast_frame frame = {
4643 .subclass.integer = _condition,
4644 .data.ptr = (void *) data, /* this cast from const is only okay because we do the ast_frdup below */
4645 .datalen = datalen
4646 };
4647
4648 /* we have now committed to freeing this frame */
4649 awesome_frame = ast_frdup(&frame);
4650
4651 /* who knows what we will get back! the anticipation is killing me. */
4653 awesome_frame);
4654 if (!awesome_frame
4655 || awesome_frame->frametype != AST_FRAME_CONTROL) {
4656 res = 0;
4657 goto indicate_cleanup;
4658 }
4659
4660 _condition = awesome_frame->subclass.integer;
4661 data = awesome_frame->data.ptr;
4662 datalen = awesome_frame->datalen;
4663 }
4664
4665 res = indicate_data_internal(chan, _condition, data, datalen);
4666
4667indicate_cleanup:
4668 ast_channel_unlock(chan);
4669 if (awesome_frame) {
4670 ast_frfree(awesome_frame);
4671 }
4672
4673 return res;
4674}
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:10569
static int indicate_data_internal(struct ast_channel *chan, int _condition, const void *data, size_t datalen)
Definition channel.c:4439
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 1435 of file channel.c.

1436{
1437 /* Do not add a default entry in this switch statement. Each new
1438 * frame type should be addressed directly as to whether it should
1439 * be queued up or not.
1440 */
1441 switch (frame->frametype) {
1444 case AST_FRAME_CONTROL:
1445 case AST_FRAME_TEXT:
1447 case AST_FRAME_IMAGE:
1448 case AST_FRAME_HTML:
1449 return 1;
1450
1451 case AST_FRAME_DTMF_END:
1453 case AST_FRAME_VOICE:
1454 case AST_FRAME_VIDEO:
1455 case AST_FRAME_NULL:
1456 case AST_FRAME_IAX:
1457 case AST_FRAME_CNG:
1458 case AST_FRAME_MODEM:
1459 case AST_FRAME_RTCP:
1460 return 0;
1461 }
1462 return 0;
1463}

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

8110{
8111 void *match;
8112 struct ao2_container *group_a = (struct ao2_container *) a;
8113 struct ao2_container *group_b = (struct ao2_container *) b;
8114
8115 if (!a || !b) {
8116 return 0;
8117 }
8118
8119 /*
8120 * Do groups a and b intersect? Since a and b are hash tables,
8121 * the average time complexity is:
8122 * O(a.count <= b.count ? a.count : b.count)
8123 */
8124 if (ao2_container_count(group_b) < ao2_container_count(group_a)) {
8125 /* Traverse over the smaller group. */
8126 SWAP(group_a, group_b);
8127 }
8128 match = ao2_callback(group_a, 0, namedgroup_match, group_b);
8130
8131 return match != NULL;
8132}
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:2388
static int namedgroup_match(void *obj, void *arg, int flags)
Definition channel.c:8099
#define SWAP(a, b)
Definition utils.h:253

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

1955{
1956 if (dest == src) {
1957 /* Don't copy to self */
1958 return;
1959 }
1960
1961 ast_party_id_copy(&dest->id, &src->id);
1962 ast_party_id_copy(&dest->ani, &src->ani);
1963 ast_party_id_copy(&dest->priv, &src->priv);
1964 dest->ani2 = src->ani2;
1965}
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 1983 of file channel.c.

1984{
1985 ast_party_id_free(&doomed->id);
1986 ast_party_id_free(&doomed->ani);
1987 ast_party_id_free(&doomed->priv);
1988}
void ast_party_id_free(struct ast_party_id *doomed)
Destroy the party id contents.
Definition channel.c:1779

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

1947{
1948 ast_party_id_init(&init->id);
1949 ast_party_id_init(&init->ani);
1950 ast_party_id_init(&init->priv);
1951 init->ani2 = 0;
1952}
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition channel.c:1725

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

1976{
1977 ast_party_id_set(&dest->id, &src->id, update ? &update->id : NULL);
1978 ast_party_id_set(&dest->ani, &src->ani, update ? &update->ani : NULL);
1979 ast_party_id_set(&dest->priv, &src->priv, update ? &update->priv : NULL);
1980 dest->ani2 = src->ani2;
1981}
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:1756

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

1968{
1969 ast_party_id_set_init(&init->id, &guide->id);
1970 ast_party_id_set_init(&init->ani, &guide->ani);
1971 ast_party_id_set_init(&init->priv, &guide->priv);
1972 init->ani2 = guide->ani2;
1973}
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:1748

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

2032{
2033 connected->id = caller->id;
2034 connected->ani = caller->ani;
2035 connected->priv = caller->priv;
2036 connected->ani2 = caller->ani2;
2038}
@ 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 1999 of file channel.c.

2000{
2001 if (dest == src) {
2002 /* Don't copy to self */
2003 return;
2004 }
2005
2006 ast_party_id_copy(&dest->id, &src->id);
2007 ast_party_id_copy(&dest->ani, &src->ani);
2008 ast_party_id_copy(&dest->priv, &src->priv);
2009 dest->ani2 = src->ani2;
2010 dest->source = src->source;
2011}
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 2022 of file channel.c.

2023{
2024 ast_party_id_set(&dest->id, &src->id, update ? &update->id : NULL);
2025 ast_party_id_set(&dest->ani, &src->ani, update ? &update->ani : NULL);
2026 ast_party_id_set(&dest->priv, &src->priv, update ? &update->priv : NULL);
2027 dest->ani2 = src->ani2;
2028 dest->source = src->source;
2029}

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

2014{
2015 ast_party_id_set_init(&init->id, &guide->id);
2016 ast_party_id_set_init(&init->ani, &guide->ani);
2017 ast_party_id_set_init(&init->priv, &guide->priv);
2018 init->ani2 = guide->ani2;
2019 init->source = guide->source;
2020}

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

1905{
1906 if (dest == src) {
1907 /* Don't copy to self */
1908 return;
1909 }
1910
1911 ast_free(dest->number.str);
1912 dest->number.str = ast_strdup(src->number.str);
1913 dest->number.plan = src->number.plan;
1916}
#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:1673
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::@221 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 1939 of file channel.c.

1940{
1941 ast_free(doomed->number.str);
1942 doomed->number.str = NULL;
1944}
void ast_party_subaddress_free(struct ast_party_subaddress *doomed)
Destroy the party subaddress contents.
Definition channel.c:1712

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

1897{
1898 init->number.str = NULL;
1899 init->number.plan = 0;/* Unknown */
1901 init->transit_network_select = 0;
1902}
void ast_party_subaddress_init(struct ast_party_subaddress *init)
Initialize the given subaddress structure.
Definition channel.c:1665

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

1927{
1928 if (src->number.str && src->number.str != dest->number.str) {
1929 ast_free(dest->number.str);
1930 dest->number.str = ast_strdup(src->number.str);
1931 }
1932 dest->number.plan = src->number.plan;
1933
1935
1937}
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:1695

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

1919{
1920 init->number.str = NULL;
1921 init->number.plan = guide->number.plan;
1924}
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:1687

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

1734{
1735 if (dest == src) {
1736 /* Don't copy to self */
1737 return;
1738 }
1739
1740 ast_party_name_copy(&dest->name, &src->name);
1741 ast_party_number_copy(&dest->number, &src->number);
1743
1744 ast_free(dest->tag);
1745 dest->tag = ast_strdup(src->tag);
1746}
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:1620
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:1567
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 1779 of file channel.c.

1780{
1781 ast_party_name_free(&doomed->name);
1782 ast_party_number_free(&doomed->number);
1784
1785 ast_free(doomed->tag);
1786 doomed->tag = NULL;
1787}
void ast_party_name_free(struct ast_party_name *doomed)
Destroy the party name contents.
Definition channel.c:1606
void ast_party_number_free(struct ast_party_number *doomed)
Destroy the party number contents.
Definition channel.c:1659

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

1726{
1727 ast_party_name_init(&init->name);
1730 init->tag = NULL;
1731}
void ast_party_name_init(struct ast_party_name *init)
Initialize the given name structure.
Definition channel.c:1559
void ast_party_number_init(struct ast_party_number *init)
Initialize the given number structure.
Definition channel.c:1612

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

1858{
1859 id->name.valid = 0;
1860 id->number.valid = 0;
1861 id->subaddress.valid = 0;
1862}

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

1871{
1872 struct ast_party_id merged;
1873
1874 merged = *base;
1875 if (overlay->name.valid) {
1876 merged.name = overlay->name;
1877 }
1878 if (overlay->number.valid) {
1879 merged.number = overlay->number;
1880 }
1881 if (overlay->subaddress.valid) {
1882 merged.subaddress = overlay->subaddress;
1883 }
1884 /* Note the actual structure is returned and not a pointer to it! */
1885 return merged;
1886}
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 1888 of file channel.c.

1889{
1890 struct ast_party_id merged;
1891
1892 merged = ast_party_id_merge(base, overlay);
1893 ast_party_id_copy(dest, &merged);
1894}
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:1870

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

1790{
1791 int number_priority;
1792 int number_value;
1793 int number_screening;
1794 int name_priority;
1795 int name_value;
1796
1797 /* Determine name presentation priority. */
1798 if (!id->name.valid) {
1799 name_value = AST_PRES_UNAVAILABLE;
1800 name_priority = 3;
1801 } else {
1802 name_value = id->name.presentation & AST_PRES_RESTRICTION;
1803 switch (name_value) {
1805 name_priority = 0;
1806 break;
1807 case AST_PRES_ALLOWED:
1808 name_priority = 1;
1809 break;
1811 name_priority = 2;
1812 break;
1813 default:
1814 name_value = AST_PRES_UNAVAILABLE;
1815 name_priority = 3;
1816 break;
1817 }
1818 }
1819
1820 /* Determine number presentation priority. */
1821 if (!id->number.valid) {
1822 number_screening = AST_PRES_USER_NUMBER_UNSCREENED;
1823 number_value = AST_PRES_UNAVAILABLE;
1824 number_priority = 3;
1825 } else {
1826 number_screening = id->number.presentation & AST_PRES_NUMBER_TYPE;
1827 number_value = id->number.presentation & AST_PRES_RESTRICTION;
1828 switch (number_value) {
1830 number_priority = 0;
1831 break;
1832 case AST_PRES_ALLOWED:
1833 number_priority = 1;
1834 break;
1836 number_priority = 2;
1837 break;
1838 default:
1839 number_screening = AST_PRES_USER_NUMBER_UNSCREENED;
1840 number_value = AST_PRES_UNAVAILABLE;
1841 number_priority = 3;
1842 break;
1843 }
1844 }
1845
1846 /* Select the wining presentation value. */
1847 if (name_priority < number_priority) {
1848 number_value = name_value;
1849 }
1850 if (number_value == AST_PRES_UNAVAILABLE) {
1852 }
1853
1854 return number_value | number_screening;
1855}
enum queue_result id
Definition app_queue.c:1767
#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 1864 of file channel.c.

1865{
1868}

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

1757{
1758 if (dest == src) {
1759 /* Don't set to self */
1760 return;
1761 }
1762
1763 if (!update || update->name) {
1764 ast_party_name_set(&dest->name, &src->name);
1765 }
1766 if (!update || update->number) {
1767 ast_party_number_set(&dest->number, &src->number);
1768 }
1769 if (!update || update->subaddress) {
1771 }
1772
1773 if (src->tag && src->tag != dest->tag) {
1774 ast_free(dest->tag);
1775 dest->tag = ast_strdup(src->tag);
1776 }
1777}
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:1642
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:1589

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

1749{
1750 ast_party_name_set_init(&init->name, &guide->name);
1751 ast_party_number_set_init(&init->number, &guide->number);
1753 init->tag = NULL;
1754}
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:1581
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:1634

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

1568{
1569 if (dest == src) {
1570 /* Don't copy to self */
1571 return;
1572 }
1573
1574 ast_free(dest->str);
1575 dest->str = ast_strdup(src->str);
1576 dest->char_set = src->char_set;
1577 dest->presentation = src->presentation;
1578 dest->valid = src->valid;
1579}
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 1606 of file channel.c.

1607{
1608 ast_free(doomed->str);
1609 doomed->str = NULL;
1610}

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

1560{
1561 init->str = NULL;
1564 init->valid = 0;
1565}

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

1590{
1591 if (dest == src) {
1592 /* Don't set to self */
1593 return;
1594 }
1595
1596 if (src->str && src->str != dest->str) {
1597 ast_free(dest->str);
1598 dest->str = ast_strdup(src->str);
1599 }
1600
1601 dest->char_set = src->char_set;
1602 dest->presentation = src->presentation;
1603 dest->valid = src->valid;
1604}

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

1582{
1583 init->str = NULL;
1584 init->char_set = guide->char_set;
1585 init->presentation = guide->presentation;
1586 init->valid = guide->valid;
1587}

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

1621{
1622 if (dest == src) {
1623 /* Don't copy to self */
1624 return;
1625 }
1626
1627 ast_free(dest->str);
1628 dest->str = ast_strdup(src->str);
1629 dest->plan = src->plan;
1630 dest->presentation = src->presentation;
1631 dest->valid = src->valid;
1632}
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 1659 of file channel.c.

1660{
1661 ast_free(doomed->str);
1662 doomed->str = NULL;
1663}

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

1613{
1614 init->str = NULL;
1615 init->plan = 0;/* Unknown */
1617 init->valid = 0;
1618}

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

1643{
1644 if (dest == src) {
1645 /* Don't set to self */
1646 return;
1647 }
1648
1649 if (src->str && src->str != dest->str) {
1650 ast_free(dest->str);
1651 dest->str = ast_strdup(src->str);
1652 }
1653
1654 dest->plan = src->plan;
1655 dest->presentation = src->presentation;
1656 dest->valid = src->valid;
1657}

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

1635{
1636 init->str = NULL;
1637 init->plan = guide->plan;
1638 init->presentation = guide->presentation;
1639 init->valid = guide->valid;
1640}

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

2104{
2105 if (dest == src) {
2106 /* Don't copy to self */
2107 return;
2108 }
2109
2110 ast_party_id_copy(&dest->orig, &src->orig);
2111 ast_party_id_copy(&dest->from, &src->from);
2112 ast_party_id_copy(&dest->to, &src->to);
2113 ast_party_id_copy(&dest->priv_orig, &src->priv_orig);
2114 ast_party_id_copy(&dest->priv_from, &src->priv_from);
2115 ast_party_id_copy(&dest->priv_to, &src->priv_to);
2118 dest->count = src->count;
2119}
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:2053
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 2090 of file channel.c.

2091{
2092 ast_party_id_init(&init->orig);
2093 ast_party_id_init(&init->from);
2094 ast_party_id_init(&init->to);
2097 ast_party_id_init(&init->priv_to);
2100 init->count = 0;
2101}
void ast_party_redirecting_reason_init(struct ast_party_redirecting_reason *init)
Initialize the given redirecting reason structure.
Definition channel.c:2047

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

2054{
2055 if (dest == src) {
2056 return;
2057 }
2058
2059 ast_free(dest->str);
2060 dest->str = ast_strdup(src->str);
2061 dest->code = src->code;
2062}
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 2084 of file channel.c.

2085{
2086 ast_free(doomed->str);
2087}

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

2048{
2049 init->str = NULL;
2051}
@ 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 2070 of file channel.c.

2071{
2072 if (dest == src) {
2073 return;
2074 }
2075
2076 if (src->str && src->str != dest->str) {
2077 ast_free(dest->str);
2078 dest->str = ast_strdup(src->str);
2079 }
2080
2081 dest->code = src->code;
2082}

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

2065{
2066 init->str = NULL;
2067 init->code = guide->code;
2068}

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

2135{
2136 ast_party_id_set(&dest->orig, &src->orig, update ? &update->orig : NULL);
2137 ast_party_id_set(&dest->from, &src->from, update ? &update->from : NULL);
2138 ast_party_id_set(&dest->to, &src->to, update ? &update->to : NULL);
2139 ast_party_id_set(&dest->priv_orig, &src->priv_orig, update ? &update->priv_orig : NULL);
2140 ast_party_id_set(&dest->priv_from, &src->priv_from, update ? &update->priv_from : NULL);
2141 ast_party_id_set(&dest->priv_to, &src->priv_to, update ? &update->priv_to : NULL);
2144 dest->count = src->count;
2145}
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:2070

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

2122{
2123 ast_party_id_set_init(&init->orig, &guide->orig);
2124 ast_party_id_set_init(&init->from, &guide->from);
2125 ast_party_id_set_init(&init->to, &guide->to);
2126 ast_party_id_set_init(&init->priv_orig, &guide->priv_orig);
2127 ast_party_id_set_init(&init->priv_from, &guide->priv_from);
2128 ast_party_id_set_init(&init->priv_to, &guide->priv_to);
2131 init->count = guide->count;
2132}
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:2064

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

1674{
1675 if (dest == src) {
1676 /* Don't copy to self */
1677 return;
1678 }
1679
1680 ast_free(dest->str);
1681 dest->str = ast_strdup(src->str);
1682 dest->type = src->type;
1684 dest->valid = src->valid;
1685}
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 1712 of file channel.c.

1713{
1714 ast_free(doomed->str);
1715 doomed->str = NULL;
1716}

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

1666{
1667 init->str = NULL;
1668 init->type = 0;
1669 init->odd_even_indicator = 0;
1670 init->valid = 0;
1671}

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

1696{
1697 if (dest == src) {
1698 /* Don't set to self */
1699 return;
1700 }
1701
1702 if (src->str && src->str != dest->str) {
1703 ast_free(dest->str);
1704 dest->str = ast_strdup(src->str);
1705 }
1706
1707 dest->type = src->type;
1709 dest->valid = src->valid;
1710}

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

1688{
1689 init->str = NULL;
1690 init->type = guide->type;
1692 init->valid = guide->valid;
1693}

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

6415{
6416 int (*pre_call)(struct ast_channel *chan, const char *sub_args);
6417
6418 ast_channel_lock(chan);
6419 pre_call = ast_channel_tech(chan)->pre_call;
6420 if (pre_call) {
6421 int res;
6422
6423 res = pre_call(chan, sub_args);
6424 ast_channel_unlock(chan);
6425 return res;
6426 }
6427 ast_channel_unlock(chan);
6428 return ast_app_exec_sub(NULL, chan, sub_args, 0);
6429}
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 8050 of file channel.c.

8051{
8052 unsigned int i;
8053 int first = 1;
8054 char num[3];
8055
8056 buf[0] = '\0';
8057
8058 if (!group) /* Return empty string if no group */
8059 return buf;
8060
8061 for (i = 0; i <= 63; i++) { /* Max group is 63 */
8062 if (group & ((ast_group_t) 1 << i)) {
8063 if (!first) {
8064 strncat(buf, ", ", buflen - strlen(buf) - 1);
8065 } else {
8066 first = 0;
8067 }
8068 snprintf(num, sizeof(num), "%u", i);
8069 strncat(buf, num, buflen - strlen(buf) - 1);
8070 }
8071 }
8072 return buf;
8073}
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 8075 of file channel.c.

8076{
8077 struct ao2_container *grp = (struct ao2_container *) group;
8078 struct namedgroup_member *ng;
8079 int first = 1;
8080 struct ao2_iterator it;
8081
8082 if (!grp) {
8083 return ast_str_buffer(*buf);
8084 }
8085
8086 for (it = ao2_iterator_init(grp, 0); (ng = ao2_iterator_next(&it)); ao2_ref(ng, -1)) {
8087 if (!first) {
8088 ast_str_append(buf, 0, ", ");
8089 } else {
8090 first = 0;
8091 }
8092 ast_str_append(buf, 0, "%s", ng->name);
8093 }
8095
8096 return ast_str_buffer(*buf);
8097}
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 4970 of file channel.c.

4971{
4972 struct ast_frame a = { AST_FRAME_VOICE };
4973 char nothing[128];
4974
4975 /* Send an empty audio frame to get things moving */
4976 if (ast_channel_state(chan) != AST_STATE_UP) {
4977 ast_debug(3, "Prodding channel '%s'\n", ast_channel_name(chan));
4978 a.subclass.format = ast_channel_rawwriteformat(chan);
4979 a.data.ptr = nothing + AST_FRIENDLY_OFFSET;
4980 a.src = "ast_prod"; /* this better match check in ast_write */
4981 if (ast_write(chan, &a))
4982 ast_log(LOG_WARNING, "Prodding channel '%s' failed\n", ast_channel_name(chan));
4983 }
4984 return 0;
4985}
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:5114
#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 1285 of file channel.c.

1286{
1287 struct ast_frame f = {
1290 .subclass.topology = (struct ast_stream_topology *)topology,
1291 };
1292 return ast_queue_frame(chan, &f);
1293}

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

1279{
1280 struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = control, .data.ptr = (void *) data, .datalen = datalen };
1281 return ast_queue_frame(chan, &f);
1282}

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(), rfc3326_use_reason_header(), 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 1170 of file channel.c.

1171{
1172 return __ast_queue_frame(chan, fin, 0, NULL);
1173}
static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, int head, struct ast_frame *after)
Definition channel.c:1040

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

1176{
1177 return __ast_queue_frame(chan, fin, 1, NULL);
1178}

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

1182{
1183 RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
1185 int res, cause;
1186
1187 /* Yeah, let's not change a lock-critical value without locking */
1188 ast_channel_lock(chan);
1190
1191 cause = ast_channel_hangupcause(chan);
1192 if (cause) {
1193 blob = ast_json_pack("{s: i}",
1194 "cause", cause);
1195 }
1196
1198
1199 res = ast_queue_frame(chan, &f);
1200 ast_channel_unlock(chan);
1201 return res;
1202}
struct stasis_message_type * ast_channel_hangup_request_type(void)
Message type for when a hangup is requested on a channel.

References ast_channel_hangup_request_type(), ast_channel_hangupcause(), ast_channel_lock, ast_channel_publish_blob(), ast_channel_softhangup_internal_flag_add(), ast_channel_unlock, AST_CONTROL_HANGUP, AST_FRAME_CONTROL, ast_json_pack(), ast_json_unref(), ast_queue_frame(), AST_SOFTHANGUP_DEV, ast_frame_subclass::integer, NULL, 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 1205 of file channel.c.

1206{
1207 RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
1209 int res;
1210
1211 if (cause >= 0) {
1212 f.data.uint32 = cause;
1213 }
1214
1215 /* Yeah, let's not change a lock-critical value without locking */
1216 ast_channel_lock(chan);
1218 if (cause < 0) {
1220 }
1221 blob = ast_json_pack("{s: i}",
1222 "cause", cause);
1224
1225 res = ast_queue_frame(chan, &f);
1226 ast_channel_unlock(chan);
1227 return res;
1228}

References ast_channel_hangup_request_type(), ast_channel_hangupcause(), ast_channel_lock, ast_channel_publish_blob(), ast_channel_softhangup_internal_flag_add(), ast_channel_unlock, AST_CONTROL_HANGUP, AST_FRAME_CONTROL, 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(), ast_unreal_hangup(), chan_pjsip_session_end(), 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 1230 of file channel.c.

1231{
1233 struct ast_json *blob = NULL;
1234 int res;
1235
1236 if (!ast_strlen_zero(musicclass)) {
1237 f.data.ptr = (void *) musicclass;
1238 f.datalen = strlen(musicclass) + 1;
1239
1240 blob = ast_json_pack("{s: s}",
1241 "musicclass", musicclass);
1242 }
1243
1244 ast_channel_lock(chan);
1246 ast_channel_unlock(chan);
1247
1248 res = ast_queue_frame(chan, &f);
1249
1250 ast_json_unref(blob);
1251
1252 return res;
1253}
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 1255 of file channel.c.

1256{
1258 int res;
1259
1260 ast_channel_lock(chan);
1262 ast_channel_unlock(chan);
1263
1264 res = ast_queue_frame(chan, &f);
1265
1266 return res;
1267}
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 2663 of file channel.c.

2664{
2666}
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:2611

References ast_raw_answer_with_stream_topology(), and NULL.

Referenced by __ast_answer(), answer_trunk_chan(), app_control_answer(), pbx_builtin_answer(), and refer_incoming_invite_request().

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

2612{
2613 int res = 0;
2614 SCOPE_TRACE(1, "%s\n", ast_channel_name(chan));
2615
2616 ast_channel_lock(chan);
2617
2618 /* You can't answer an outbound call */
2620 ast_channel_unlock(chan);
2621 return 0;
2622 }
2623
2624 /* Stop if we're a zombie or need a soft hangup */
2626 ast_channel_unlock(chan);
2627 return -1;
2628 }
2629
2630 /*
2631 * Mark when incoming channel answered so we can know how
2632 * long the channel has been up.
2633 */
2635
2636 ast_channel_unlock(chan);
2637
2638 switch (ast_channel_state(chan)) {
2639 case AST_STATE_RINGING:
2640 case AST_STATE_RING:
2641 ast_channel_lock(chan);
2642 if (ast_channel_tech(chan)->answer_with_stream_topology) {
2643 res = ast_channel_tech(chan)->answer_with_stream_topology(chan, topology);
2644
2645 } else if (ast_channel_tech(chan)->answer) {
2646 res = ast_channel_tech(chan)->answer(chan);
2647 }
2649 ast_channel_unlock(chan);
2650 break;
2651 case AST_STATE_UP:
2652 /* Fall through */
2653 default:
2654 ast_debug(2, "Skipping answer, since channel state on %s is %s\n", ast_channel_name(chan), ast_state2str(ast_channel_state(chan)));
2655 break;
2656 }
2657
2658 ast_indicate(chan, -1);
2659
2660 return res;
2661}
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:7373
const char * ast_state2str(enum ast_channel_state state)
Gives the string form of a given channel state.
Definition channel.c:636
static void set_channel_answer_time(struct ast_channel *chan)
Definition channel.c:2600
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition channel.c:4245
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 4225 of file channel.c.

4226{
4227 return __ast_read(chan, 0, 1);
4228}
static struct ast_frame * __ast_read(struct ast_channel *chan, int dropaudio, int dropnondefault)
Definition channel.c:3508

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

4236{
4237 return __ast_read(chan, 1, 1);
4238}

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

4231{
4232 return __ast_read(chan, 0, 0);
4233}

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

4241{
4242 return __ast_read(chan, 1, 0);
4243}

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

6529{
6530 return ast_readstring_full(c, s, len, timeout, ftimeout, enders, -1, -1);
6531}
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:6533

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

6534{
6535 int pos = 0; /* index in the buffer where we accumulate digits */
6536 int to = ftimeout;
6537
6538 struct ast_silence_generator *silgen = NULL;
6539
6540 /* Stop if we're a zombie or need a soft hangup */
6542 return -1;
6543 if (!len)
6544 return -1;
6545 for (;;) {
6546 int d;
6547 if (ast_channel_stream(c)) {
6548 d = ast_waitstream_full(c, AST_DIGIT_ANY, audiofd, ctrlfd);
6550 if (!silgen && ast_opt_transmit_silence)
6552 usleep(1000);
6553 if (!d)
6554 d = ast_waitfordigit_full(c, to, NULL, audiofd, ctrlfd);
6555 } else {
6556 if (!silgen && ast_opt_transmit_silence)
6558 d = ast_waitfordigit_full(c, to, NULL, audiofd, ctrlfd);
6559 }
6560 if (d < 0) {
6562 return AST_GETDATA_FAILED;
6563 }
6564 if (d == 0) {
6565 s[pos] = '\0';
6567 return AST_GETDATA_TIMEOUT;
6568 }
6569 if (d == 1) {
6570 s[pos] = '\0';
6573 }
6574 if (strchr(enders, d) && (pos == 0)) {
6575 s[pos] = '\0';
6578 }
6579 if (!strchr(enders, d)) {
6580 s[pos++] = d;
6581 }
6582 if (strchr(enders, d) || (pos >= len)) {
6583 s[pos] = '\0';
6585 return AST_GETDATA_COMPLETE;
6586 }
6587 to = timeout;
6588 }
6589 /* Never reached */
6590 return 0;
6591}
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
Definition channel.c:8183
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:8229
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:3211
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 4676 of file channel.c.

4677{
4678 int c;
4679 char *buf = ast_recvtext(chan, timeout);
4680 if (buf == NULL)
4681 return -1; /* error or timeout */
4682 c = *(unsigned char *)buf;
4683 ast_free(buf);
4684 return c;
4685}
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:4687

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

4688{
4689 int res;
4690 char *buf = NULL;
4691 struct timeval start = ast_tvnow();
4692 int ms;
4693
4694 while ((ms = ast_remaining_ms(start, timeout))) {
4695 struct ast_frame *f;
4696
4697 if (ast_check_hangup(chan)) {
4698 break;
4699 }
4700 res = ast_waitfor(chan, ms);
4701 if (res <= 0) {/* timeout or error */
4702 break;
4703 }
4704 f = ast_read(chan);
4705 if (f == NULL) {
4706 break; /* no frame */
4707 }
4709 ast_frfree(f);
4710 break;
4711 } else if (f->frametype == AST_FRAME_TEXT) { /* what we want */
4712 buf = ast_strndup((char *) f->data.ptr, f->datalen); /* dup and break */
4713 ast_frfree(f);
4714 break;
4715 }
4716 ast_frfree(f);
4717 }
4718 return buf;
4719}
#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 9287 of file channel.c.

9288{
9289 int32_t value;
9290 size_t pos = 0;
9291 int res;
9292
9293 static const struct ast_party_id_ies orig_ies = {
9295 .name.char_set = AST_REDIRECTING_ORIG_NAME_CHAR_SET,
9296 .name.presentation = AST_REDIRECTING_ORIG_NAME_PRESENTATION,
9297 .name.valid = AST_REDIRECTING_ORIG_NAME_VALID,
9298
9299 .number.str = AST_REDIRECTING_ORIG_NUMBER,
9300 .number.plan = AST_REDIRECTING_ORIG_NUMBER_PLAN,
9301 .number.presentation = AST_REDIRECTING_ORIG_NUMBER_PRESENTATION,
9302 .number.valid = AST_REDIRECTING_ORIG_NUMBER_VALID,
9303
9304 .subaddress.str = AST_REDIRECTING_ORIG_SUBADDRESS,
9305 .subaddress.type = AST_REDIRECTING_ORIG_SUBADDRESS_TYPE,
9306 .subaddress.odd_even_indicator = AST_REDIRECTING_ORIG_SUBADDRESS_ODD_EVEN,
9307 .subaddress.valid = AST_REDIRECTING_ORIG_SUBADDRESS_VALID,
9308
9310 .combined_presentation = 0,/* Not sent. */
9311 };
9312 static const struct ast_party_id_ies from_ies = {
9314 .name.char_set = AST_REDIRECTING_FROM_NAME_CHAR_SET,
9315 .name.presentation = AST_REDIRECTING_FROM_NAME_PRESENTATION,
9316 .name.valid = AST_REDIRECTING_FROM_NAME_VALID,
9317
9318 .number.str = AST_REDIRECTING_FROM_NUMBER,
9319 .number.plan = AST_REDIRECTING_FROM_NUMBER_PLAN,
9320 .number.presentation = AST_REDIRECTING_FROM_NUMBER_PRESENTATION,
9321 .number.valid = AST_REDIRECTING_FROM_NUMBER_VALID,
9322
9323 .subaddress.str = AST_REDIRECTING_FROM_SUBADDRESS,
9324 .subaddress.type = AST_REDIRECTING_FROM_SUBADDRESS_TYPE,
9325 .subaddress.odd_even_indicator = AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN,
9326 .subaddress.valid = AST_REDIRECTING_FROM_SUBADDRESS_VALID,
9327
9329 .combined_presentation = AST_REDIRECTING_FROM_ID_PRESENTATION,
9330 };
9331 static const struct ast_party_id_ies to_ies = {
9333 .name.char_set = AST_REDIRECTING_TO_NAME_CHAR_SET,
9334 .name.presentation = AST_REDIRECTING_TO_NAME_PRESENTATION,
9335 .name.valid = AST_REDIRECTING_TO_NAME_VALID,
9336
9337 .number.str = AST_REDIRECTING_TO_NUMBER,
9338 .number.plan = AST_REDIRECTING_TO_NUMBER_PLAN,
9339 .number.presentation = AST_REDIRECTING_TO_NUMBER_PRESENTATION,
9340 .number.valid = AST_REDIRECTING_TO_NUMBER_VALID,
9341
9342 .subaddress.str = AST_REDIRECTING_TO_SUBADDRESS,
9343 .subaddress.type = AST_REDIRECTING_TO_SUBADDRESS_TYPE,
9344 .subaddress.odd_even_indicator = AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN,
9345 .subaddress.valid = AST_REDIRECTING_TO_SUBADDRESS_VALID,
9346
9348 .combined_presentation = AST_REDIRECTING_TO_ID_PRESENTATION,
9349 };
9350 static const struct ast_party_id_ies priv_orig_ies = {
9355
9358 .number.presentation = AST_REDIRECTING_PRIV_ORIG_NUMBER_PRESENTATION,
9360
9361 .subaddress.str = AST_REDIRECTING_PRIV_ORIG_SUBADDRESS,
9363 .subaddress.odd_even_indicator = AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_ODD_EVEN,
9365
9367 .combined_presentation = 0,/* Not sent. */
9368 };
9369 static const struct ast_party_id_ies priv_from_ies = {
9374
9377 .number.presentation = AST_REDIRECTING_PRIV_FROM_NUMBER_PRESENTATION,
9379
9380 .subaddress.str = AST_REDIRECTING_PRIV_FROM_SUBADDRESS,
9382 .subaddress.odd_even_indicator = AST_REDIRECTING_PRIV_FROM_SUBADDRESS_ODD_EVEN,
9384
9386 .combined_presentation = 0,/* Not sent. */
9387 };
9388 static const struct ast_party_id_ies priv_to_ies = {
9391 .name.presentation = AST_REDIRECTING_PRIV_TO_NAME_PRESENTATION,
9393
9394 .number.str = AST_REDIRECTING_PRIV_TO_NUMBER,
9396 .number.presentation = AST_REDIRECTING_PRIV_TO_NUMBER_PRESENTATION,
9398
9399 .subaddress.str = AST_REDIRECTING_PRIV_TO_SUBADDRESS,
9400 .subaddress.type = AST_REDIRECTING_PRIV_TO_SUBADDRESS_TYPE,
9401 .subaddress.odd_even_indicator = AST_REDIRECTING_PRIV_TO_SUBADDRESS_ODD_EVEN,
9402 .subaddress.valid = AST_REDIRECTING_PRIV_TO_SUBADDRESS_VALID,
9403
9405 .combined_presentation = 0,/* Not sent. */
9406 };
9407 static const struct ast_party_redirecting_reason_ies reason_ies = {
9410 };
9411
9412 static const struct ast_party_redirecting_reason_ies orig_reason_ies = {
9415 };
9416
9417 /* Redirecting frame version */
9418 if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
9419 ast_log(LOG_WARNING, "No space left for redirecting frame version\n");
9420 return -1;
9421 }
9422 data[pos++] = AST_REDIRECTING_VERSION;
9423 data[pos++] = 1;
9424 data[pos++] = 2;/* Version 1 did not have a version ie */
9425
9426 res = party_id_build_data(data + pos, datalen - pos, &redirecting->orig,
9427 "redirecting-orig", &orig_ies, update ? &update->orig : NULL);
9428 if (res < 0) {
9429 return -1;
9430 }
9431 pos += res;
9432
9433 res = party_id_build_data(data + pos, datalen - pos, &redirecting->from,
9434 "redirecting-from", &from_ies, update ? &update->from : NULL);
9435 if (res < 0) {
9436 return -1;
9437 }
9438 pos += res;
9439
9440 res = party_id_build_data(data + pos, datalen - pos, &redirecting->to,
9441 "redirecting-to", &to_ies, update ? &update->to : NULL);
9442 if (res < 0) {
9443 return -1;
9444 }
9445 pos += res;
9446
9447 res = party_id_build_data(data + pos, datalen - pos, &redirecting->priv_orig,
9448 "redirecting-priv-orig", &priv_orig_ies, update ? &update->priv_orig : NULL);
9449 if (res < 0) {
9450 return -1;
9451 }
9452 pos += res;
9453
9454 res = party_id_build_data(data + pos, datalen - pos, &redirecting->priv_from,
9455 "redirecting-priv-from", &priv_from_ies, update ? &update->priv_from : NULL);
9456 if (res < 0) {
9457 return -1;
9458 }
9459 pos += res;
9460
9461 res = party_id_build_data(data + pos, datalen - pos, &redirecting->priv_to,
9462 "redirecting-priv-to", &priv_to_ies, update ? &update->priv_to : NULL);
9463 if (res < 0) {
9464 return -1;
9465 }
9466 pos += res;
9467
9468 /* Redirecting reason */
9469 res = redirecting_reason_build_data(data + pos, datalen - pos, &redirecting->reason,
9470 "redirecting-reason", &reason_ies);
9471 if (res < 0) {
9472 return -1;
9473 }
9474 pos += res;
9475
9476 /* Redirecting original reason */
9477 res = redirecting_reason_build_data(data + pos, datalen - pos, &redirecting->orig_reason,
9478 "redirecting-orig-reason", &orig_reason_ies);
9479 if (res < 0) {
9480 return -1;
9481 }
9482 pos += res;
9483
9484 /* Redirecting count */
9485 if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) {
9486 ast_log(LOG_WARNING, "No space left for redirecting count\n");
9487 return -1;
9488 }
9489 data[pos++] = AST_REDIRECTING_COUNT;
9490 data[pos++] = sizeof(value);
9491 value = htonl(redirecting->count);
9492 memcpy(data + pos, &value, sizeof(value));
9493 pos += sizeof(value);
9494
9495 return pos;
9496}
@ AST_REDIRECTING_FROM_NAME_PRESENTATION
Definition channel.c:9184
@ AST_REDIRECTING_TO_NAME
Definition channel.c:9162
@ AST_REDIRECTING_VERSION
Definition channel.c:9177
@ AST_REDIRECTING_PRIV_FROM_NAME_VALID
Definition channel.c:9224
@ AST_REDIRECTING_PRIV_FROM_SUBADDRESS_ODD_EVEN
Definition channel.c:9229
@ AST_REDIRECTING_TO_TAG
Definition channel.c:9176
@ AST_REDIRECTING_FROM_NUMBER_PLAN
Definition channel.c:9159
@ AST_REDIRECTING_PRIV_TO_NAME_VALID
Definition channel.c:9211
@ AST_REDIRECTING_ORIG_TAG
Definition channel.c:9204
@ AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_ODD_EVEN
Definition channel.c:9242
@ AST_REDIRECTING_REASON_CODE
Definition channel.c:9165
@ AST_REDIRECTING_PRIV_TO_NUMBER_VALID
Definition channel.c:9208
@ AST_REDIRECTING_PRIV_TO_NUMBER_PRESENTATION
Definition channel.c:9209
@ AST_REDIRECTING_ORIG_REASON_CODE
Definition channel.c:9205
@ AST_REDIRECTING_TO_NAME_PRESENTATION
Definition channel.c:9189
@ AST_REDIRECTING_PRIV_TO_NAME
Definition channel.c:9210
@ AST_REDIRECTING_PRIV_ORIG_NAME_VALID
Definition channel.c:9237
@ AST_REDIRECTING_ORIG_NUMBER_VALID
Definition channel.c:9193
@ AST_REDIRECTING_FROM_NUMBER_PRESENTATION
Definition channel.c:9186
@ AST_REDIRECTING_ORIG_SUBADDRESS_VALID
Definition channel.c:9203
@ AST_REDIRECTING_FROM_NUMBER_VALID
Definition channel.c:9185
@ AST_REDIRECTING_TO_NAME_VALID
Definition channel.c:9187
@ AST_REDIRECTING_PRIV_FROM_NAME
Definition channel.c:9223
@ AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN
Definition channel.c:9173
@ AST_REDIRECTING_ORIG_SUBADDRESS_ODD_EVEN
Definition channel.c:9202
@ AST_REDIRECTING_PRIV_FROM_SUBADDRESS_TYPE
Definition channel.c:9228
@ AST_REDIRECTING_PRIV_TO_SUBADDRESS_VALID
Definition channel.c:9217
@ AST_REDIRECTING_PRIV_TO_SUBADDRESS_ODD_EVEN
Definition channel.c:9216
@ AST_REDIRECTING_ORIG_NAME_CHAR_SET
Definition channel.c:9198
@ AST_REDIRECTING_PRIV_FROM_SUBADDRESS
Definition channel.c:9227
@ AST_REDIRECTING_TO_NUMBER_PLAN
Definition channel.c:9163
@ AST_REDIRECTING_PRIV_TO_NUMBER
Definition channel.c:9206
@ AST_REDIRECTING_PRIV_FROM_NUMBER_VALID
Definition channel.c:9221
@ AST_REDIRECTING_ORIG_NAME
Definition channel.c:9196
@ AST_REDIRECTING_ORIG_SUBADDRESS
Definition channel.c:9200
@ AST_REDIRECTING_FROM_TAG
Definition channel.c:9175
@ AST_REDIRECTING_PRIV_ORIG_NUMBER_PLAN
Definition channel.c:9234
@ AST_REDIRECTING_TO_NUMBER
Definition channel.c:9161
@ AST_REDIRECTING_ORIG_SUBADDRESS_TYPE
Definition channel.c:9201
@ AST_REDIRECTING_FROM_NAME_CHAR_SET
Definition channel.c:9183
@ AST_REDIRECTING_PRIV_FROM_TAG
Definition channel.c:9231
@ AST_REDIRECTING_FROM_ID_PRESENTATION
Definition channel.c:9160
@ AST_REDIRECTING_PRIV_FROM_NUMBER
Definition channel.c:9219
@ AST_REDIRECTING_PRIV_TO_NUMBER_PLAN
Definition channel.c:9207
@ AST_REDIRECTING_TO_NUMBER_VALID
Definition channel.c:9190
@ AST_REDIRECTING_FROM_SUBADDRESS_VALID
Definition channel.c:9170
@ AST_REDIRECTING_FROM_NAME_VALID
Definition channel.c:9182
@ AST_REDIRECTING_PRIV_TO_NAME_CHAR_SET
Definition channel.c:9212
@ AST_REDIRECTING_PRIV_ORIG_TAG
Definition channel.c:9244
@ AST_REDIRECTING_FROM_SUBADDRESS_TYPE
Definition channel.c:9168
@ AST_REDIRECTING_PRIV_TO_TAG
Definition channel.c:9218
@ AST_REDIRECTING_COUNT
Definition channel.c:9166
@ AST_REDIRECTING_FROM_SUBADDRESS
Definition channel.c:9167
@ AST_REDIRECTING_PRIV_ORIG_NAME_CHAR_SET
Definition channel.c:9238
@ AST_REDIRECTING_ORIG_NAME_VALID
Definition channel.c:9197
@ AST_REDIRECTING_TO_ID_PRESENTATION
Definition channel.c:9164
@ AST_REDIRECTING_PRIV_FROM_NUMBER_PLAN
Definition channel.c:9220
@ AST_REDIRECTING_PRIV_TO_NAME_PRESENTATION
Definition channel.c:9213
@ AST_REDIRECTING_PRIV_FROM_NUMBER_PRESENTATION
Definition channel.c:9222
@ AST_REDIRECTING_PRIV_FROM_NAME_PRESENTATION
Definition channel.c:9226
@ AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_TYPE
Definition channel.c:9241
@ AST_REDIRECTING_ORIG_REASON_STR
Definition channel.c:9246
@ AST_REDIRECTING_ORIG_NAME_PRESENTATION
Definition channel.c:9199
@ AST_REDIRECTING_PRIV_FROM_NAME_CHAR_SET
Definition channel.c:9225
@ AST_REDIRECTING_ORIG_NUMBER
Definition channel.c:9192
@ AST_REDIRECTING_PRIV_ORIG_NAME
Definition channel.c:9236
@ AST_REDIRECTING_PRIV_TO_SUBADDRESS_TYPE
Definition channel.c:9215
@ AST_REDIRECTING_PRIV_ORIG_NUMBER_VALID
Definition channel.c:9233
@ AST_REDIRECTING_PRIV_ORIG_NUMBER_PRESENTATION
Definition channel.c:9235
@ AST_REDIRECTING_TO_SUBADDRESS_VALID
Definition channel.c:9174
@ AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_VALID
Definition channel.c:9243
@ AST_REDIRECTING_TO_SUBADDRESS_TYPE
Definition channel.c:9172
@ AST_REDIRECTING_REASON_STR
Definition channel.c:9245
@ AST_REDIRECTING_FROM_NAME
Definition channel.c:9158
@ AST_REDIRECTING_PRIV_ORIG_NUMBER
Definition channel.c:9232
@ AST_REDIRECTING_PRIV_FROM_SUBADDRESS_VALID
Definition channel.c:9230
@ AST_REDIRECTING_ORIG_NUMBER_PRESENTATION
Definition channel.c:9195
@ AST_REDIRECTING_PRIV_TO_SUBADDRESS
Definition channel.c:9214
@ AST_REDIRECTING_PRIV_ORIG_NAME_PRESENTATION
Definition channel.c:9239
@ AST_REDIRECTING_TO_NUMBER_PRESENTATION
Definition channel.c:9191
@ AST_REDIRECTING_FROM_NUMBER
Definition channel.c:9157
@ AST_REDIRECTING_ORIG_NUMBER_PLAN
Definition channel.c:9194
@ AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN
Definition channel.c:9169
@ AST_REDIRECTING_PRIV_ORIG_SUBADDRESS
Definition channel.c:9240
@ AST_REDIRECTING_TO_SUBADDRESS
Definition channel.c:9171
@ AST_REDIRECTING_TO_NAME_CHAR_SET
Definition channel.c:9188
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:9254

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

9499{
9500 size_t pos;
9501 unsigned char ie_len;
9502 unsigned char ie_id;
9503 int32_t value;
9504 int frame_version = 1;
9505 int from_combined_presentation = 0;
9506 int got_from_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
9507 int to_combined_presentation = 0;
9508 int got_to_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
9509
9510 for (pos = 0; pos < datalen; pos += ie_len) {
9511 if (datalen < pos + sizeof(ie_id) + sizeof(ie_len)) {
9512 ast_log(LOG_WARNING, "Invalid redirecting update\n");
9513 return -1;
9514 }
9515 ie_id = data[pos++];
9516 ie_len = data[pos++];
9517 if (datalen < pos + ie_len) {
9518 ast_log(LOG_WARNING, "Invalid redirecting update\n");
9519 return -1;
9520 }
9521
9522 switch (ie_id) {
9523/* Redirecting frame version */
9525 if (ie_len != 1) {
9526 ast_log(LOG_WARNING, "Invalid redirecting frame version (%u)\n",
9527 (unsigned) ie_len);
9528 break;
9529 }
9530 frame_version = data[pos];
9531 break;
9532/* Redirecting-orig party id name */
9534 ast_free(redirecting->orig.name.str);
9535 redirecting->orig.name.str = ast_malloc(ie_len + 1);
9536 if (redirecting->orig.name.str) {
9537 memcpy(redirecting->orig.name.str, data + pos, ie_len);
9538 redirecting->orig.name.str[ie_len] = 0;
9539 }
9540 break;
9542 if (ie_len != 1) {
9543 ast_log(LOG_WARNING, "Invalid redirecting-orig name char set (%u)\n",
9544 (unsigned) ie_len);
9545 break;
9546 }
9547 redirecting->orig.name.char_set = data[pos];
9548 break;
9550 if (ie_len != 1) {
9551 ast_log(LOG_WARNING, "Invalid redirecting-orig name presentation (%u)\n",
9552 (unsigned) ie_len);
9553 break;
9554 }
9555 redirecting->orig.name.presentation = data[pos];
9556 break;
9558 if (ie_len != 1) {
9559 ast_log(LOG_WARNING, "Invalid redirecting-orig name valid (%u)\n",
9560 (unsigned) ie_len);
9561 break;
9562 }
9563 redirecting->orig.name.valid = data[pos];
9564 break;
9565/* Redirecting-orig party id number */
9567 ast_free(redirecting->orig.number.str);
9568 redirecting->orig.number.str = ast_malloc(ie_len + 1);
9569 if (redirecting->orig.number.str) {
9570 memcpy(redirecting->orig.number.str, data + pos, ie_len);
9571 redirecting->orig.number.str[ie_len] = 0;
9572 }
9573 break;
9575 if (ie_len != 1) {
9576 ast_log(LOG_WARNING, "Invalid redirecting-orig numbering plan (%u)\n",
9577 (unsigned) ie_len);
9578 break;
9579 }
9580 redirecting->orig.number.plan = data[pos];
9581 break;
9583 if (ie_len != 1) {
9584 ast_log(LOG_WARNING, "Invalid redirecting-orig number presentation (%u)\n",
9585 (unsigned) ie_len);
9586 break;
9587 }
9588 redirecting->orig.number.presentation = data[pos];
9589 break;
9591 if (ie_len != 1) {
9592 ast_log(LOG_WARNING, "Invalid redirecting-orig number valid (%u)\n",
9593 (unsigned) ie_len);
9594 break;
9595 }
9596 redirecting->orig.number.valid = data[pos];
9597 break;
9598/* Redirecting-orig party id subaddress */
9600 ast_free(redirecting->orig.subaddress.str);
9601 redirecting->orig.subaddress.str = ast_malloc(ie_len + 1);
9602 if (redirecting->orig.subaddress.str) {
9603 memcpy(redirecting->orig.subaddress.str, data + pos, ie_len);
9604 redirecting->orig.subaddress.str[ie_len] = 0;
9605 }
9606 break;
9608 if (ie_len != 1) {
9609 ast_log(LOG_WARNING, "Invalid redirecting-orig type of subaddress (%u)\n",
9610 (unsigned) ie_len);
9611 break;
9612 }
9613 redirecting->orig.subaddress.type = data[pos];
9614 break;
9616 if (ie_len != 1) {
9618 "Invalid redirecting-orig subaddress odd-even indicator (%u)\n",
9619 (unsigned) ie_len);
9620 break;
9621 }
9622 redirecting->orig.subaddress.odd_even_indicator = data[pos];
9623 break;
9625 if (ie_len != 1) {
9626 ast_log(LOG_WARNING, "Invalid redirecting-orig subaddress valid (%u)\n",
9627 (unsigned) ie_len);
9628 break;
9629 }
9630 redirecting->orig.subaddress.valid = data[pos];
9631 break;
9632/* Redirecting-orig party id tag */
9634 ast_free(redirecting->orig.tag);
9635 redirecting->orig.tag = ast_malloc(ie_len + 1);
9636 if (redirecting->orig.tag) {
9637 memcpy(redirecting->orig.tag, data + pos, ie_len);
9638 redirecting->orig.tag[ie_len] = 0;
9639 }
9640 break;
9641/* Redirecting-from party id name */
9643 ast_free(redirecting->from.name.str);
9644 redirecting->from.name.str = ast_malloc(ie_len + 1);
9645 if (redirecting->from.name.str) {
9646 memcpy(redirecting->from.name.str, data + pos, ie_len);
9647 redirecting->from.name.str[ie_len] = 0;
9648 }
9649 break;
9651 if (ie_len != 1) {
9652 ast_log(LOG_WARNING, "Invalid redirecting-from name char set (%u)\n",
9653 (unsigned) ie_len);
9654 break;
9655 }
9656 redirecting->from.name.char_set = data[pos];
9657 break;
9659 if (ie_len != 1) {
9660 ast_log(LOG_WARNING, "Invalid redirecting-from name presentation (%u)\n",
9661 (unsigned) ie_len);
9662 break;
9663 }
9664 redirecting->from.name.presentation = data[pos];
9665 break;
9667 if (ie_len != 1) {
9668 ast_log(LOG_WARNING, "Invalid redirecting-from name valid (%u)\n",
9669 (unsigned) ie_len);
9670 break;
9671 }
9672 redirecting->from.name.valid = data[pos];
9673 break;
9674/* Redirecting-from party id number */
9676 ast_free(redirecting->from.number.str);
9677 redirecting->from.number.str = ast_malloc(ie_len + 1);
9678 if (redirecting->from.number.str) {
9679 memcpy(redirecting->from.number.str, data + pos, ie_len);
9680 redirecting->from.number.str[ie_len] = 0;
9681 }
9682 break;
9684 if (ie_len != 1) {
9685 ast_log(LOG_WARNING, "Invalid redirecting-from numbering plan (%u)\n",
9686 (unsigned) ie_len);
9687 break;
9688 }
9689 redirecting->from.number.plan = data[pos];
9690 break;
9692 if (ie_len != 1) {
9693 ast_log(LOG_WARNING, "Invalid redirecting-from number presentation (%u)\n",
9694 (unsigned) ie_len);
9695 break;
9696 }
9697 redirecting->from.number.presentation = data[pos];
9698 break;
9700 if (ie_len != 1) {
9701 ast_log(LOG_WARNING, "Invalid redirecting-from number valid (%u)\n",
9702 (unsigned) ie_len);
9703 break;
9704 }
9705 redirecting->from.number.valid = data[pos];
9706 break;
9707/* Redirecting-from party id combined presentation */
9709 if (ie_len != 1) {
9710 ast_log(LOG_WARNING, "Invalid redirecting-from combined presentation (%u)\n",
9711 (unsigned) ie_len);
9712 break;
9713 }
9714 from_combined_presentation = data[pos];
9715 got_from_combined_presentation = 1;
9716 break;
9717/* Redirecting-from party id subaddress */
9719 ast_free(redirecting->from.subaddress.str);
9720 redirecting->from.subaddress.str = ast_malloc(ie_len + 1);
9721 if (redirecting->from.subaddress.str) {
9722 memcpy(redirecting->from.subaddress.str, data + pos, ie_len);
9723 redirecting->from.subaddress.str[ie_len] = 0;
9724 }
9725 break;
9727 if (ie_len != 1) {
9728 ast_log(LOG_WARNING, "Invalid redirecting-from type of subaddress (%u)\n",
9729 (unsigned) ie_len);
9730 break;
9731 }
9732 redirecting->from.subaddress.type = data[pos];
9733 break;
9735 if (ie_len != 1) {
9737 "Invalid redirecting-from subaddress odd-even indicator (%u)\n",
9738 (unsigned) ie_len);
9739 break;
9740 }
9741 redirecting->from.subaddress.odd_even_indicator = data[pos];
9742 break;
9744 if (ie_len != 1) {
9745 ast_log(LOG_WARNING, "Invalid redirecting-from subaddress valid (%u)\n",
9746 (unsigned) ie_len);
9747 break;
9748 }
9749 redirecting->from.subaddress.valid = data[pos];
9750 break;
9751/* Redirecting-from party id tag */
9753 ast_free(redirecting->from.tag);
9754 redirecting->from.tag = ast_malloc(ie_len + 1);
9755 if (redirecting->from.tag) {
9756 memcpy(redirecting->from.tag, data + pos, ie_len);
9757 redirecting->from.tag[ie_len] = 0;
9758 }
9759 break;
9760/* Redirecting-to party id name */
9762 ast_free(redirecting->to.name.str);
9763 redirecting->to.name.str = ast_malloc(ie_len + 1);
9764 if (redirecting->to.name.str) {
9765 memcpy(redirecting->to.name.str, data + pos, ie_len);
9766 redirecting->to.name.str[ie_len] = 0;
9767 }
9768 break;
9770 if (ie_len != 1) {
9771 ast_log(LOG_WARNING, "Invalid redirecting-to name char set (%u)\n",
9772 (unsigned) ie_len);
9773 break;
9774 }
9775 redirecting->to.name.char_set = data[pos];
9776 break;
9778 if (ie_len != 1) {
9779 ast_log(LOG_WARNING, "Invalid redirecting-to name presentation (%u)\n",
9780 (unsigned) ie_len);
9781 break;
9782 }
9783 redirecting->to.name.presentation = data[pos];
9784 break;
9786 if (ie_len != 1) {
9787 ast_log(LOG_WARNING, "Invalid redirecting-to name valid (%u)\n",
9788 (unsigned) ie_len);
9789 break;
9790 }
9791 redirecting->to.name.valid = data[pos];
9792 break;
9793/* Redirecting-to party id number */
9795 ast_free(redirecting->to.number.str);
9796 redirecting->to.number.str = ast_malloc(ie_len + 1);
9797 if (redirecting->to.number.str) {
9798 memcpy(redirecting->to.number.str, data + pos, ie_len);
9799 redirecting->to.number.str[ie_len] = 0;
9800 }
9801 break;
9803 if (ie_len != 1) {
9804 ast_log(LOG_WARNING, "Invalid redirecting-to numbering plan (%u)\n",
9805 (unsigned) ie_len);
9806 break;
9807 }
9808 redirecting->to.number.plan = data[pos];
9809 break;
9811 if (ie_len != 1) {
9812 ast_log(LOG_WARNING, "Invalid redirecting-to number presentation (%u)\n",
9813 (unsigned) ie_len);
9814 break;
9815 }
9816 redirecting->to.number.presentation = data[pos];
9817 break;
9819 if (ie_len != 1) {
9820 ast_log(LOG_WARNING, "Invalid redirecting-to number valid (%u)\n",
9821 (unsigned) ie_len);
9822 break;
9823 }
9824 redirecting->to.number.valid = data[pos];
9825 break;
9826/* Redirecting-to party id combined presentation */
9828 if (ie_len != 1) {
9829 ast_log(LOG_WARNING, "Invalid redirecting-to combined presentation (%u)\n",
9830 (unsigned) ie_len);
9831 break;
9832 }
9833 to_combined_presentation = data[pos];
9834 got_to_combined_presentation = 1;
9835 break;
9836/* Redirecting-to party id subaddress */
9838 ast_free(redirecting->to.subaddress.str);
9839 redirecting->to.subaddress.str = ast_malloc(ie_len + 1);
9840 if (redirecting->to.subaddress.str) {
9841 memcpy(redirecting->to.subaddress.str, data + pos, ie_len);
9842 redirecting->to.subaddress.str[ie_len] = 0;
9843 }
9844 break;
9846 if (ie_len != 1) {
9847 ast_log(LOG_WARNING, "Invalid redirecting-to type of subaddress (%u)\n",
9848 (unsigned) ie_len);
9849 break;
9850 }
9851 redirecting->to.subaddress.type = data[pos];
9852 break;
9854 if (ie_len != 1) {
9856 "Invalid redirecting-to subaddress odd-even indicator (%u)\n",
9857 (unsigned) ie_len);
9858 break;
9859 }
9860 redirecting->to.subaddress.odd_even_indicator = data[pos];
9861 break;
9863 if (ie_len != 1) {
9864 ast_log(LOG_WARNING, "Invalid redirecting-to subaddress valid (%u)\n",
9865 (unsigned) ie_len);
9866 break;
9867 }
9868 redirecting->to.subaddress.valid = data[pos];
9869 break;
9870/* Redirecting-to party id tag */
9872 ast_free(redirecting->to.tag);
9873 redirecting->to.tag = ast_malloc(ie_len + 1);
9874 if (redirecting->to.tag) {
9875 memcpy(redirecting->to.tag, data + pos, ie_len);
9876 redirecting->to.tag[ie_len] = 0;
9877 }
9878 break;
9879/* Private redirecting-orig party id name */
9881 ast_free(redirecting->priv_orig.name.str);
9882 redirecting->priv_orig.name.str = ast_malloc(ie_len + 1);
9883 if (redirecting->priv_orig.name.str) {
9884 memcpy(redirecting->priv_orig.name.str, data + pos, ie_len);
9885 redirecting->priv_orig.name.str[ie_len] = 0;
9886 }
9887 break;
9889 if (ie_len != 1) {
9890 ast_log(LOG_WARNING, "Invalid private redirecting-orig name char set (%u)\n",
9891 (unsigned) ie_len);
9892 break;
9893 }
9894 redirecting->priv_orig.name.char_set = data[pos];
9895 break;
9897 if (ie_len != 1) {
9898 ast_log(LOG_WARNING, "Invalid private redirecting-orig name presentation (%u)\n",
9899 (unsigned) ie_len);
9900 break;
9901 }
9902 redirecting->priv_orig.name.presentation = data[pos];
9903 break;
9905 if (ie_len != 1) {
9906 ast_log(LOG_WARNING, "Invalid private redirecting-orig name valid (%u)\n",
9907 (unsigned) ie_len);
9908 break;
9909 }
9910 redirecting->priv_orig.name.valid = data[pos];
9911 break;
9912/* Private redirecting-orig party id number */
9914 ast_free(redirecting->priv_orig.number.str);
9915 redirecting->priv_orig.number.str = ast_malloc(ie_len + 1);
9916 if (redirecting->priv_orig.number.str) {
9917 memcpy(redirecting->priv_orig.number.str, data + pos, ie_len);
9918 redirecting->priv_orig.number.str[ie_len] = 0;
9919 }
9920 break;
9922 if (ie_len != 1) {
9923 ast_log(LOG_WARNING, "Invalid private redirecting-orig numbering plan (%u)\n",
9924 (unsigned) ie_len);
9925 break;
9926 }
9927 redirecting->priv_orig.number.plan = data[pos];
9928 break;
9930 if (ie_len != 1) {
9931 ast_log(LOG_WARNING, "Invalid private redirecting-orig number presentation (%u)\n",
9932 (unsigned) ie_len);
9933 break;
9934 }
9935 redirecting->priv_orig.number.presentation = data[pos];
9936 break;
9938 if (ie_len != 1) {
9939 ast_log(LOG_WARNING, "Invalid private redirecting-orig number valid (%u)\n",
9940 (unsigned) ie_len);
9941 break;
9942 }
9943 redirecting->priv_orig.number.valid = data[pos];
9944 break;
9945/* Private redirecting-orig party id subaddress */
9947 ast_free(redirecting->priv_orig.subaddress.str);
9948 redirecting->priv_orig.subaddress.str = ast_malloc(ie_len + 1);
9949 if (redirecting->priv_orig.subaddress.str) {
9950 memcpy(redirecting->priv_orig.subaddress.str, data + pos, ie_len);
9951 redirecting->priv_orig.subaddress.str[ie_len] = 0;
9952 }
9953 break;
9955 if (ie_len != 1) {
9956 ast_log(LOG_WARNING, "Invalid private redirecting-orig type of subaddress (%u)\n",
9957 (unsigned) ie_len);
9958 break;
9959 }
9960 redirecting->priv_orig.subaddress.type = data[pos];
9961 break;
9963 if (ie_len != 1) {
9965 "Invalid private redirecting-orig subaddress odd-even indicator (%u)\n",
9966 (unsigned) ie_len);
9967 break;
9968 }
9969 redirecting->priv_orig.subaddress.odd_even_indicator = data[pos];
9970 break;
9972 if (ie_len != 1) {
9973 ast_log(LOG_WARNING, "Invalid private redirecting-orig subaddress valid (%u)\n",
9974 (unsigned) ie_len);
9975 break;
9976 }
9977 redirecting->priv_orig.subaddress.valid = data[pos];
9978 break;
9979/* Private redirecting-orig party id tag */
9981 ast_free(redirecting->priv_orig.tag);
9982 redirecting->priv_orig.tag = ast_malloc(ie_len + 1);
9983 if (redirecting->priv_orig.tag) {
9984 memcpy(redirecting->priv_orig.tag, data + pos, ie_len);
9985 redirecting->priv_orig.tag[ie_len] = 0;
9986 }
9987 break;
9988/* Private redirecting-from party id name */
9990 ast_free(redirecting->priv_from.name.str);
9991 redirecting->priv_from.name.str = ast_malloc(ie_len + 1);
9992 if (redirecting->priv_from.name.str) {
9993 memcpy(redirecting->priv_from.name.str, data + pos, ie_len);
9994 redirecting->priv_from.name.str[ie_len] = 0;
9995 }
9996 break;
9998 if (ie_len != 1) {
9999 ast_log(LOG_WARNING, "Invalid private redirecting-from name char set (%u)\n",
10000 (unsigned) ie_len);
10001 break;
10002 }
10003 redirecting->priv_from.name.char_set = data[pos];
10004 break;
10006 if (ie_len != 1) {
10007 ast_log(LOG_WARNING, "Invalid private redirecting-from name presentation (%u)\n",
10008 (unsigned) ie_len);
10009 break;
10010 }
10011 redirecting->priv_from.name.presentation = data[pos];
10012 break;
10014 if (ie_len != 1) {
10015 ast_log(LOG_WARNING, "Invalid private redirecting-from name valid (%u)\n",
10016 (unsigned) ie_len);
10017 break;
10018 }
10019 redirecting->priv_from.name.valid = data[pos];
10020 break;
10021/* Private redirecting-from party id number */
10023 ast_free(redirecting->priv_from.number.str);
10024 redirecting->priv_from.number.str = ast_malloc(ie_len + 1);
10025 if (redirecting->priv_from.number.str) {
10026 memcpy(redirecting->priv_from.number.str, data + pos, ie_len);
10027 redirecting->priv_from.number.str[ie_len] = 0;
10028 }
10029 break;
10031 if (ie_len != 1) {
10032 ast_log(LOG_WARNING, "Invalid private redirecting-from numbering plan (%u)\n",
10033 (unsigned) ie_len);
10034 break;
10035 }
10036 redirecting->priv_from.number.plan = data[pos];
10037 break;
10039 if (ie_len != 1) {
10040 ast_log(LOG_WARNING, "Invalid private redirecting-from number presentation (%u)\n",
10041 (unsigned) ie_len);
10042 break;
10043 }
10044 redirecting->priv_from.number.presentation = data[pos];
10045 break;
10047 if (ie_len != 1) {
10048 ast_log(LOG_WARNING, "Invalid private redirecting-from number valid (%u)\n",
10049 (unsigned) ie_len);
10050 break;
10051 }
10052 redirecting->priv_from.number.valid = data[pos];
10053 break;
10054/* Private redirecting-from party id subaddress */
10056 ast_free(redirecting->priv_from.subaddress.str);
10057 redirecting->priv_from.subaddress.str = ast_malloc(ie_len + 1);
10058 if (redirecting->priv_from.subaddress.str) {
10059 memcpy(redirecting->priv_from.subaddress.str, data + pos, ie_len);
10060 redirecting->priv_from.subaddress.str[ie_len] = 0;
10061 }
10062 break;
10064 if (ie_len != 1) {
10065 ast_log(LOG_WARNING, "Invalid private redirecting-from type of subaddress (%u)\n",
10066 (unsigned) ie_len);
10067 break;
10068 }
10069 redirecting->priv_from.subaddress.type = data[pos];
10070 break;
10072 if (ie_len != 1) {
10074 "Invalid private redirecting-from subaddress odd-even indicator (%u)\n",
10075 (unsigned) ie_len);
10076 break;
10077 }
10078 redirecting->priv_from.subaddress.odd_even_indicator = data[pos];
10079 break;
10081 if (ie_len != 1) {
10082 ast_log(LOG_WARNING, "Invalid private redirecting-from subaddress valid (%u)\n",
10083 (unsigned) ie_len);
10084 break;
10085 }
10086 redirecting->priv_from.subaddress.valid = data[pos];
10087 break;
10088/* Private redirecting-from party id tag */
10090 ast_free(redirecting->priv_from.tag);
10091 redirecting->priv_from.tag = ast_malloc(ie_len + 1);
10092 if (redirecting->priv_from.tag) {
10093 memcpy(redirecting->priv_from.tag, data + pos, ie_len);
10094 redirecting->priv_from.tag[ie_len] = 0;
10095 }
10096 break;
10097/* Private redirecting-to party id name */
10099 ast_free(redirecting->priv_to.name.str);
10100 redirecting->priv_to.name.str = ast_malloc(ie_len + 1);
10101 if (redirecting->priv_to.name.str) {
10102 memcpy(redirecting->priv_to.name.str, data + pos, ie_len);
10103 redirecting->priv_to.name.str[ie_len] = 0;
10104 }
10105 break;
10107 if (ie_len != 1) {
10108 ast_log(LOG_WARNING, "Invalid private redirecting-to name char set (%u)\n",
10109 (unsigned) ie_len);
10110 break;
10111 }
10112 redirecting->priv_to.name.char_set = data[pos];
10113 break;
10115 if (ie_len != 1) {
10116 ast_log(LOG_WARNING, "Invalid private redirecting-to name presentation (%u)\n",
10117 (unsigned) ie_len);
10118 break;
10119 }
10120 redirecting->priv_to.name.presentation = data[pos];
10121 break;
10123 if (ie_len != 1) {
10124 ast_log(LOG_WARNING, "Invalid private redirecting-to name valid (%u)\n",
10125 (unsigned) ie_len);
10126 break;
10127 }
10128 redirecting->priv_to.name.valid = data[pos];
10129 break;
10130/* Private redirecting-to party id number */
10132 ast_free(redirecting->priv_to.number.str);
10133 redirecting->priv_to.number.str = ast_malloc(ie_len + 1);
10134 if (redirecting->priv_to.number.str) {
10135 memcpy(redirecting->priv_to.number.str, data + pos, ie_len);
10136 redirecting->priv_to.number.str[ie_len] = 0;
10137 }
10138 break;
10140 if (ie_len != 1) {
10141 ast_log(LOG_WARNING, "Invalid private redirecting-to numbering plan (%u)\n",
10142 (unsigned) ie_len);
10143 break;
10144 }
10145 redirecting->priv_to.number.plan = data[pos];
10146 break;
10148 if (ie_len != 1) {
10149 ast_log(LOG_WARNING, "Invalid private redirecting-to number presentation (%u)\n",
10150 (unsigned) ie_len);
10151 break;
10152 }
10153 redirecting->priv_to.number.presentation = data[pos];
10154 break;
10156 if (ie_len != 1) {
10157 ast_log(LOG_WARNING, "Invalid private redirecting-to number valid (%u)\n",
10158 (unsigned) ie_len);
10159 break;
10160 }
10161 redirecting->priv_to.number.valid = data[pos];
10162 break;
10163/* Private redirecting-to party id subaddress */
10165 ast_free(redirecting->priv_to.subaddress.str);
10166 redirecting->priv_to.subaddress.str = ast_malloc(ie_len + 1);
10167 if (redirecting->priv_to.subaddress.str) {
10168 memcpy(redirecting->priv_to.subaddress.str, data + pos, ie_len);
10169 redirecting->priv_to.subaddress.str[ie_len] = 0;
10170 }
10171 break;
10173 if (ie_len != 1) {
10174 ast_log(LOG_WARNING, "Invalid private redirecting-to type of subaddress (%u)\n",
10175 (unsigned) ie_len);
10176 break;
10177 }
10178 redirecting->priv_to.subaddress.type = data[pos];
10179 break;
10181 if (ie_len != 1) {
10183 "Invalid private redirecting-to subaddress odd-even indicator (%u)\n",
10184 (unsigned) ie_len);
10185 break;
10186 }
10187 redirecting->priv_to.subaddress.odd_even_indicator = data[pos];
10188 break;
10190 if (ie_len != 1) {
10191 ast_log(LOG_WARNING, "Invalid private redirecting-to subaddress valid (%u)\n",
10192 (unsigned) ie_len);
10193 break;
10194 }
10195 redirecting->priv_to.subaddress.valid = data[pos];
10196 break;
10197/* Private redirecting-to party id tag */
10199 ast_free(redirecting->priv_to.tag);
10200 redirecting->priv_to.tag = ast_malloc(ie_len + 1);
10201 if (redirecting->priv_to.tag) {
10202 memcpy(redirecting->priv_to.tag, data + pos, ie_len);
10203 redirecting->priv_to.tag[ie_len] = 0;
10204 }
10205 break;
10206/* Redirecting reason code */
10208 if (ie_len != sizeof(value)) {
10209 ast_log(LOG_WARNING, "Invalid redirecting reason (%u)\n",
10210 (unsigned) ie_len);
10211 break;
10212 }
10213 memcpy(&value, data + pos, sizeof(value));
10214 redirecting->reason.code = ntohl(value);
10215 break;
10216/* Redirecting reason string */
10218 ast_free(redirecting->reason.str);
10219 redirecting->reason.str = ast_malloc(ie_len + 1);
10220 if (redirecting->reason.str) {
10221 memcpy(redirecting->reason.str, data + pos, ie_len);
10222 redirecting->reason.str[ie_len] = 0;
10223 }
10224 break;
10225/* Redirecting orig-reason code */
10227 if (ie_len != sizeof(value)) {
10228 ast_log(LOG_WARNING, "Invalid redirecting original reason (%u)\n",
10229 (unsigned) ie_len);
10230 break;
10231 }
10232 memcpy(&value, data + pos, sizeof(value));
10233 redirecting->orig_reason.code = ntohl(value);
10234 break;
10235/* Redirecting orig-reason string */
10237 ast_free(redirecting->orig_reason.str);
10238 redirecting->orig_reason.str = ast_malloc(ie_len + 1);
10239 if (redirecting->orig_reason.str) {
10240 memcpy(redirecting->orig_reason.str, data + pos, ie_len);
10241 redirecting->orig_reason.str[ie_len] = 0;
10242 }
10243 break;
10244/* Redirecting count */
10246 if (ie_len != sizeof(value)) {
10247 ast_log(LOG_WARNING, "Invalid redirecting count (%u)\n",
10248 (unsigned) ie_len);
10249 break;
10250 }
10251 memcpy(&value, data + pos, sizeof(value));
10252 redirecting->count = ntohl(value);
10253 break;
10254/* Redirecting unknown element */
10255 default:
10256 ast_debug(1, "Unknown redirecting element: %u (%u)\n",
10257 (unsigned) ie_id, (unsigned) ie_len);
10258 break;
10259 }
10260 }
10261
10262 switch (frame_version) {
10263 case 1:
10264 /*
10265 * The other end is an earlier version that we need to adjust
10266 * for compatibility.
10267 *
10268 * The earlier version did not have the orig party id or
10269 * orig_reason value.
10270 */
10271 redirecting->from.name.valid = 1;
10273 redirecting->from.number.valid = 1;
10274 if (got_from_combined_presentation) {
10275 redirecting->from.name.presentation = from_combined_presentation;
10276 redirecting->from.number.presentation = from_combined_presentation;
10277 }
10278
10279 redirecting->to.name.valid = 1;
10281 redirecting->to.number.valid = 1;
10282 if (got_to_combined_presentation) {
10283 redirecting->to.name.presentation = to_combined_presentation;
10284 redirecting->to.number.presentation = to_combined_presentation;
10285 }
10286 break;
10287 case 2:
10288 /* The other end is at the same level as we are. */
10289 break;
10290 default:
10291 /*
10292 * The other end is newer than we are.
10293 * We need to assume that they are compatible with us.
10294 */
10295 ast_debug(1, "Redirecting frame has newer version: %u\n",
10296 (unsigned) frame_version);
10297 break;
10298 }
10299
10300 return 0;
10301}

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

7726{
7727 if (groups) {
7728 ao2_ref(groups, 1);
7729 }
7730 return groups;
7731}

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

6325{
6326 return request_channel(type, request_cap, NULL, assignedids, requestor, addr, cause);
6327}
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:6189

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

6145{
6146 return __ast_request_and_dial(type, cap, assignedids, requestor, addr, timeout, outstate, cidnum, cidname, NULL);
6147}
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:5946

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

6330{
6331 return request_channel(type, NULL, topology, assignedids, requestor, addr, cause);
6332}

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

1543{
1544 return safe_sleep_conditional(chan, ms, NULL, NULL, 1);
1545}
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:1466

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

1537{
1538 return safe_sleep_conditional(chan, timeout_ms, cond, data, 1);
1539}

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

1548{
1549 return safe_sleep_conditional(chan, ms, NULL, NULL, 0);
1550}

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

4945{
4946 if (duration < AST_DEFAULT_EMULATE_DTMF_DURATION) {
4948 }
4949 if (ast_channel_tech(chan)->send_digit_begin) {
4951 ast_safe_sleep(chan, duration);
4952 }
4953
4954 return ast_senddigit_end(chan, digit, duration);
4955}
int ast_senddigit_begin(struct ast_channel *chan, char digit)
Send a DTMF digit to a channel.
Definition channel.c:4844
#define AST_DEFAULT_EMULATE_DTMF_DURATION
Definition channel.c:105
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait, look for hangups.
Definition channel.c:1542

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

4845{
4846 /* Device does not support DTMF tones, lets fake
4847 * it by doing our own generation. */
4848 static const char * const dtmf_tones[] = {
4849 "941+1336", /* 0 */
4850 "697+1209", /* 1 */
4851 "697+1336", /* 2 */
4852 "697+1477", /* 3 */
4853 "770+1209", /* 4 */
4854 "770+1336", /* 5 */
4855 "770+1477", /* 6 */
4856 "852+1209", /* 7 */
4857 "852+1336", /* 8 */
4858 "852+1477", /* 9 */
4859 "697+1633", /* A */
4860 "770+1633", /* B */
4861 "852+1633", /* C */
4862 "941+1633", /* D */
4863 "941+1209", /* * */
4864 "941+1477" /* # */
4865 };
4866
4867 if (!ast_channel_tech(chan)->send_digit_begin)
4868 return 0;
4869
4870 ast_channel_lock(chan);
4873 ast_channel_unlock(chan);
4874
4875 if (!ast_channel_tech(chan)->send_digit_begin(chan, digit))
4876 return 0;
4877
4878 if (digit >= '0' && digit <='9')
4879 ast_playtones_start(chan, 0, dtmf_tones[digit-'0'], 0);
4880 else if (digit >= 'A' && digit <= 'D')
4881 ast_playtones_start(chan, 0, dtmf_tones[digit-'A'+10], 0);
4882 else if (digit == '*')
4883 ast_playtones_start(chan, 0, dtmf_tones[14], 0);
4884 else if (digit == '#')
4885 ast_playtones_start(chan, 0, dtmf_tones[15], 0);
4886 else {
4887 /* not handled */
4888 ast_debug(1, "Unable to generate DTMF tone '%c' for '%s'\n", digit, ast_channel_name(chan));
4889 }
4890
4891 return 0;
4892}
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 4894 of file channel.c.

4895{
4896 int res = -1;
4897
4898 if (ast_channel_tech(chan)->send_digit_end)
4899 res = ast_channel_tech(chan)->send_digit_end(chan, digit, duration);
4900
4901 ast_channel_lock(chan);
4904 }
4905 ast_channel_unlock(chan);
4906
4907 if (res && ast_channel_generator(chan))
4908 ast_playtones_stop(chan);
4909
4910 return 0;
4911}
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 4957 of file channel.c.

4958{
4959 if (duration < AST_DEFAULT_EMULATE_DTMF_DURATION) {
4961 }
4962 if (ast_channel_tech(chan)->send_digit_begin) {
4964 usleep(duration * 1000);
4965 }
4966
4967 return ast_senddigit_end(chan, digit, duration);
4968}

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

4924{
4925 if (duration < DEFAULT_EMULATE_MF_DURATION) {
4926 duration = DEFAULT_EMULATE_MF_DURATION;
4927 }
4928 if (ast_channel_tech(chan)->send_digit_begin) {
4929 if (digit == '*') {
4930 duration = durationkp;
4931 } else if (digit == '#' || digit == 'A' || digit == 'B' || digit == 'C') {
4932 duration = durationst;
4933 }
4935 if (is_external) {
4936 usleep(duration * 1000);
4937 } else {
4938 ast_safe_sleep(chan, duration);
4939 }
4940 }
4941 return ast_senddigit_mf_end(chan);
4942}
int ast_senddigit_mf_begin(struct ast_channel *chan, char digit)
Send an MF digit to a channel.
Definition channel.c:4805
int ast_senddigit_mf_end(struct ast_channel *chan)
End sending an MF digit to a channel.
Definition channel.c:4913
#define DEFAULT_EMULATE_MF_DURATION
Definition channel.c:109

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

4806{
4807 static const char * const mf_tones[] = {
4808 "1300+1500", /* 0 */
4809 "700+900", /* 1 */
4810 "700+1100", /* 2 */
4811 "900+1100", /* 3 */
4812 "700+1300", /* 4 */
4813 "900+1300", /* 5 */
4814 "1100+1300", /* 6 */
4815 "700+1500", /* 7 */
4816 "900+1500", /* 8 */
4817 "1100+1500", /* 9 */
4818 "1100+1700", /* * (KP) */
4819 "1500+1700", /* # (ST) */
4820 "900+1700", /* A (STP) */
4821 "1300+1700", /* B (ST2P) */
4822 "700+1700" /* C (ST3P) */
4823 };
4824
4825 if (digit >= '0' && digit <='9') {
4826 ast_playtones_start(chan, 0, mf_tones[digit-'0'], 0);
4827 } else if (digit == '*') {
4828 ast_playtones_start(chan, 0, mf_tones[10], 0);
4829 } else if (digit == '#') {
4830 ast_playtones_start(chan, 0, mf_tones[11], 0);
4831 } else if (digit == 'A') {
4832 ast_playtones_start(chan, 0, mf_tones[12], 0);
4833 } else if (digit == 'B') {
4834 ast_playtones_start(chan, 0, mf_tones[13], 0);
4835 } else if (digit == 'C') {
4836 ast_playtones_start(chan, 0, mf_tones[14], 0);
4837 } else {
4838 /* not handled */
4839 ast_log(LOG_WARNING, "Unable to generate MF tone '%c' for '%s'\n", digit, ast_channel_name(chan));
4840 }
4841 return 0;
4842}
static const float mf_tones[]
Definition dsp.c:325

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

4914{
4915 if (ast_channel_generator(chan)) {
4916 ast_playtones_stop(chan);
4917 return 0;
4918 }
4919 return -1;
4920}

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

4780{
4781 struct ast_msg_data *msg;
4782 int rc;
4783 struct ast_msg_data_attribute attrs[] =
4784 {
4785 {
4787 .value = (char *)text,
4788 }
4789 };
4790
4791 if (ast_strlen_zero(text)) {
4792 return 0;
4793 }
4794
4796 if (!msg) {
4797 return -1;
4798 }
4799 rc = ast_sendtext_data(chan, msg);
4800 ast_free(msg);
4801
4802 return rc;
4803}
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:4721
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 4721 of file channel.c.

4722{
4723 int res = 0;
4724 const char *body = ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_BODY);
4725 const char *content_type = ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_CONTENT_TYPE);
4726
4727 ast_channel_lock(chan);
4728 /* Stop if we're a zombie or need a soft hangup */
4730 ast_channel_unlock(chan);
4731 return -1;
4732 }
4733
4734 CHECK_BLOCKING(chan);
4735 if (ast_channel_tech(chan)->write_text
4736 && (ast_strlen_zero(content_type) || ast_begins_with(content_type, "text/"))
4738 struct ast_frame f;
4739 /* T.140 payload does not include the null byte terminator */
4740 size_t body_len = strlen(body);
4741
4742 /* Process as T.140 text (moved here from ast_sendtext() */
4743 memset(&f, 0, sizeof(f));
4744 f.src = "DIALPLAN";
4745 f.subclass.format = ast_format_t140;
4746 f.frametype = AST_FRAME_TEXT;
4747 f.datalen = body_len;
4748 f.mallocd = AST_MALLOCD_DATA;
4749 f.data.ptr = ast_strdup(body);
4750 if (f.data.ptr) {
4751 res = ast_channel_tech(chan)->write_text(chan, &f);
4752 } else {
4753 res = -1;
4754 }
4755 ast_frfree(&f);
4756 } else if ((ast_channel_tech(chan)->properties & AST_CHAN_TP_SEND_TEXT_DATA)
4757 && ast_channel_tech(chan)->send_text_data) {
4758 /* Send enhanced message to a channel driver that supports it */
4759 ast_debug(1, "Sending TEXT_DATA from '%s' to %s:%s %s\n",
4762 ast_channel_name(chan), body);
4763 res = ast_channel_tech(chan)->send_text_data(chan, msg);
4764 } else if (ast_channel_tech(chan)->send_text
4765 && (ast_strlen_zero(content_type) || ast_begins_with(content_type, "text/"))) {
4766 /* Send the body of an enhanced message to a channel driver that supports only a char str */
4767 ast_debug(1, "Sending TEXT to %s: %s\n", ast_channel_name(chan), body);
4768 res = ast_channel_tech(chan)->send_text(chan, body);
4769 } else {
4770 ast_debug(1, "Channel technology does not support sending content type '%s' on channel '%s'\n",
4771 S_OR(content_type, "text/plain"), ast_channel_name(chan));
4772 res = -1;
4773 }
4775 ast_channel_unlock(chan);
4776 return res;
4777}
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:2931
@ 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 7321 of file channel.c.

7322{
7323 ast_channel_lock(chan);
7324
7325 if (cid_num) {
7326 ast_channel_caller(chan)->id.number.valid = 1;
7327 ast_free(ast_channel_caller(chan)->id.number.str);
7328 ast_channel_caller(chan)->id.number.str = ast_strdup(cid_num);
7329 }
7330 if (cid_name) {
7331 ast_channel_caller(chan)->id.name.valid = 1;
7332 ast_free(ast_channel_caller(chan)->id.name.str);
7333 ast_channel_caller(chan)->id.name.str = ast_strdup(cid_name);
7334 }
7335 if (cid_ani) {
7337 ast_free(ast_channel_caller(chan)->ani.number.str);
7338 ast_channel_caller(chan)->ani.number.str = ast_strdup(cid_ani);
7339 }
7340
7342
7343 ast_channel_unlock(chan);
7344}
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 2471 of file channel.c.

2472{
2474
2475 ast_channel_lock(chan);
2476 if (force || ast_strlen_zero(ast_channel_hangupsource(chan))) {
2477 ast_channel_hangupsource_set(chan, source);
2478 }
2479 ast_channel_unlock(chan);
2480
2481 if (bridge) {
2482 ast_channel_lock(bridge);
2483 if (force || ast_strlen_zero(ast_channel_hangupsource(bridge))) {
2484 ast_channel_hangupsource_set(bridge, source);
2485 }
2486 ast_channel_unlock(bridge);
2487 }
2488}
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:10583
#define ast_channel_cleanup(c)
Cleanup a channel reference.
Definition channel.h:3029

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

1719{
1720 update_id->name = 1;
1721 update_id->number = 1;
1722 update_id->subaddress = 1;
1723}
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 5732 of file channel.c.

5733{
5735 int res;
5736
5737 ast_assert(format != NULL);
5738
5739 if (!cap) {
5740 return -1;
5741 }
5742 ast_format_cap_append(cap, format, 0);
5743
5744 res = set_format(chan, cap, 0, 0);
5745
5746 ao2_cleanup(cap);
5747 return res;
5748}
static int set_format(struct ast_channel *chan, struct ast_format_cap *cap_set, const int direction, int interleaved_stereo)
Definition channel.c:5563
@ 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_channel_format(), 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 5750 of file channel.c.

5751{
5752 return set_format(chan, cap, 0, 0);
5753}

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

5459{
5460 struct ast_trans_pvt *trans_old;
5461 struct ast_trans_pvt *trans_new;
5462
5465 /* Nothing to setup */
5466 return 0;
5467 }
5468
5469 ast_debug(1, "Channel %s setting read format path: %s -> %s\n",
5470 ast_channel_name(chan),
5471 ast_format_get_name(raw_format),
5472 ast_format_get_name(core_format));
5473
5474 /* Setup new translation path. */
5475 if (ast_format_cmp(raw_format, core_format) != AST_FORMAT_CMP_EQUAL) {
5476 trans_new = ast_translator_build_path(core_format, raw_format);
5477 if (!trans_new) {
5478 return -1;
5479 }
5480 } else {
5481 /* No translation needed. */
5482 trans_new = NULL;
5483 }
5484 trans_old = ast_channel_readtrans(chan);
5485 if (trans_old) {
5486 ast_translator_free_path(trans_old);
5487 }
5488 ast_channel_readtrans_set(chan, trans_new);
5489 ast_channel_set_rawreadformat(chan, raw_format);
5490 ast_channel_set_readformat(chan, core_format);
5491 return 0;
5492}
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:476
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:486

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

8135{
8136 struct ast_variable *cur;
8137
8138 for (cur = vars; cur; cur = cur->next) {
8139 pbx_builtin_setvar_helper(chan, cur->name, cur->value);
8140 }
8141}
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 5773 of file channel.c.

5774{
5776 int res;
5777
5778 ast_assert(format != NULL);
5779
5780 if (!cap) {
5781 return -1;
5782 }
5783 ast_format_cap_append(cap, format, 0);
5784
5785 res = set_format(chan, cap, 1, 0);
5786
5787 ao2_cleanup(cap);
5788 return res;
5789}

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

5792{
5793 return set_format(chan, cap, 1, 0);
5794}

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

5756{
5758 int res;
5759
5760 ast_assert(format != NULL);
5761
5762 if (!cap) {
5763 return -1;
5764 }
5765 ast_format_cap_append(cap, format, 0);
5766
5767 res = set_format(chan, cap, 1, 1);
5768
5769 ao2_cleanup(cap);
5770 return res;
5771}

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

5495{
5496 struct ast_trans_pvt *trans_old;
5497 struct ast_trans_pvt *trans_new;
5498
5501 /* Nothing to setup */
5502 return 0;
5503 }
5504
5505 ast_debug(1, "Channel %s setting write format path: %s -> %s\n",
5506 ast_channel_name(chan),
5507 ast_format_get_name(core_format),
5508 ast_format_get_name(raw_format));
5509
5510 /* Setup new translation path. */
5511 if (ast_format_cmp(raw_format, core_format) != AST_FORMAT_CMP_EQUAL) {
5512 trans_new = ast_translator_build_path(raw_format, core_format);
5513 if (!trans_new) {
5514 return -1;
5515 }
5516 } else {
5517 /* No translation needed. */
5518 trans_new = NULL;
5519 }
5520 trans_old = ast_channel_writetrans(chan);
5521 if (trans_old) {
5522 ast_translator_free_path(trans_old);
5523 }
5524 ast_channel_writetrans_set(chan, trans_new);
5525 ast_channel_set_rawwriteformat(chan, raw_format);
5526 ast_channel_set_writeformat(chan, core_format);
5527 return 0;
5528}

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

3153{
3154 return ast_settimeout_full(c, rate, func, data, 0);
3155}
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:3157

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

3158{
3159 int res;
3160 unsigned int real_rate = rate, max_rate;
3161
3163
3164 if (ast_channel_timingfd(c) == -1) {
3166 return -1;
3167 }
3168
3169 if (!func) {
3170 rate = 0;
3171 data = NULL;
3172 }
3173
3174 if (rate && rate > (max_rate = ast_timer_get_max_rate(ast_channel_timer(c)))) {
3175 real_rate = max_rate;
3176 }
3177
3178 ast_debug(3, "Scheduling timer at (%u requested / %u actual) timer ticks per second\n", rate, real_rate);
3179
3180 res = ast_timer_set_rate(ast_channel_timer(c), real_rate);
3181
3184 }
3185
3188
3189 if (data && is_ao2_obj) {
3190 ao2_ref(data, 1);
3192 } else {
3194 }
3195
3196 if (func == NULL && rate == 0 && ast_channel_fdno(c) == AST_TIMING_FD) {
3197 /* Clearing the timing func and setting the rate to 0
3198 * means that we don't want to be reading from the timingfd
3199 * any more. Setting c->fdno to -1 means we won't have any
3200 * errant reads from the timingfd, meaning we won't potentially
3201 * miss any important frames.
3202 */
3204 }
3205
3207
3208 return res;
3209}
#define AST_TIMING_FD
Definition channel.h:203
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_channel::data, and NULL.

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.

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

Softly hangup up a channel.

Definition at line 2443 of file channel.c.

2444{
2445 RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
2446 int res;
2447
2448 ast_channel_lock(chan);
2449 res = ast_softhangup_nolock(chan, cause);
2450 blob = ast_json_pack("{s: i, s: b}",
2451 "cause", cause,
2452 "soft", 1);
2454 ast_channel_unlock(chan);
2455
2456 return res;
2457}

References ast_channel_hangup_request_type(), ast_channel_lock, ast_channel_publish_blob(), ast_channel_unlock, ast_json_pack(), ast_json_unref(), ast_softhangup_nolock(), NULL, and RAII_VAR.

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(), 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 493 of file channel.c.

494{
496}
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:1317
static int ast_channel_softhangup_cb(void *obj, void *arg, void *data, int flags)
Definition channel.c:484

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

2431{
2432 ast_debug(1, "Soft-Hanging (%#04x) up channel '%s'\n", (unsigned)cause, ast_channel_name(chan));
2433 /* Inform channel driver that we need to be hung up, if it cares */
2436 /* Interrupt any poll call or such */
2438 pthread_kill(ast_channel_blocker(chan), SIGURG);
2439 return 0;
2440}

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

637{
638 char *buf;
639
640 switch (state) {
641 case AST_STATE_DOWN:
642 return "Down";
644 return "Rsrvd";
646 return "OffHook";
648 return "Dialing";
649 case AST_STATE_RING:
650 return "Ring";
652 return "Ringing";
653 case AST_STATE_UP:
654 return "Up";
655 case AST_STATE_BUSY:
656 return "Busy";
658 return "Dialing Offhook";
660 return "Pre-ring";
661 case AST_STATE_MUTE:
662 return "Mute";
663 default:
664 if (!(buf = ast_threadstorage_get(&state2str_threadbuf, STATE2STR_BUFSIZE)))
665 return "Unknown";
666 snprintf(buf, STATE2STR_BUFSIZE, "Unknown (%u)", state);
667 return buf;
668 }
669}
#define STATE2STR_BUFSIZE
Definition channel.c:101
@ 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 625 of file channel.c.

626{
627 int x;
628
629 for (x = 0; x < ARRAY_LEN(causes); x++)
630 if (!strncasecmp(causes[x].name, name, strlen(causes[x].name)))
631 return causes[x].cause;
632
633 return -1;
634}

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

7588{
7589 int res;
7590
7591 if ((res = ast_tonepair_start(chan, freq1, freq2, duration, vol)))
7592 return res;
7593
7594 /* Give us some wiggle room */
7595 while (ast_channel_generatordata(chan) && ast_waitfor(chan, 100) >= 0) {
7596 struct ast_frame *f = ast_read(chan);
7597 if (f)
7598 ast_frfree(f);
7599 else
7600 return -1;
7601 }
7602 return 0;
7603}
int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
Definition channel.c:7569

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

7570{
7571 struct tonepair_def d = { 0, };
7572
7573 d.freq1 = freq1;
7574 d.freq2 = freq2;
7575 d.duration = duration;
7576 d.vol = (vol < 1) ? 8192 : vol; /* force invalid to 8192 */
7577 if (ast_activate_generator(chan, &tonepair, &d))
7578 return -1;
7579 return 0;
7580}
static struct ast_generator tonepair
Definition channel.c:7563

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

7583{
7585}
void ast_deactivate_generator(struct ast_channel *chan)
Definition channel.c:2865

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

6456{
6457 int protocol;
6458 return ast_transfer_protocol(chan, dest, &protocol);
6459}
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:6468

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

6469{
6470 int res = -1;
6471
6472 if (protocol) {
6473 *protocol = 0;
6474 }
6475
6476 /* Stop if we're a zombie or need a soft hangup */
6477 ast_channel_lock(chan);
6479 if (ast_channel_tech(chan)->transfer) {
6480 res = ast_channel_tech(chan)->transfer(chan, dest);
6481 if (!res)
6482 res = 1;
6483 } else
6484 res = 0;
6485 }
6486 ast_channel_unlock(chan);
6487
6488 if (res <= 0) {
6489 return res;
6490 }
6491
6492 for (;;) {
6493 struct ast_frame *fr;
6494
6495 res = ast_waitfor(chan, -1);
6496
6497 if (res < 0 || !(fr = ast_read(chan))) {
6498 res = -1;
6499 break;
6500 }
6501
6504
6505 if (*message == AST_TRANSFER_SUCCESS) {
6506 res = 1;
6507 } else {
6508 res = -1;
6509 /* Message can contain a protocol specific code
6510 AST_TRANSFER_SUCCESS indicates success
6511 Else, failure. Protocol will be set to the failure reason.
6512 SIP example, 0 is success, else error code 3xx-6xx */
6513 if (protocol) {
6514 *protocol = *message;
6515 }
6516 }
6517
6518 ast_frfree(fr);
6519 break;
6520 }
6521
6522 ast_frfree(fr);
6523 }
6524
6525 return res;
6526}
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 672 of file channel.c.

673{
674 switch (transfercapability) {
676 return "SPEECH";
678 return "DIGITAL";
680 return "RESTRICTED_DIGITAL";
682 return "3K1AUDIO";
684 return "DIGITAL_W_TONES";
686 return "VIDEO";
687 default:
688 return "UNKNOWN";
689 }
690}
#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 504 of file channel.c.

505{
507}
static int chancount
Definition channel.c:96
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 3134 of file channel.c.

3135{
3136 if (ms < 0) {
3137 do {
3138 ms = 100000;
3139 ast_waitfor_nandfds(&c, 1, NULL, 0, NULL, NULL, &ms);
3140 } while (!ms);
3141 } else {
3142 ast_waitfor_nandfds(&c, 1, NULL, 0, NULL, NULL, &ms);
3143 }
3144 return ms;
3145}
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:2960

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

3130{
3131 return ast_waitfor_nandfds(c, n, NULL, 0, NULL, NULL, ms);
3132}

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

2953{
2954 int winner = -1;
2955 ast_waitfor_nandfds(NULL, 0, fds, n, exception, &winner, ms);
2956 return winner;
2957}

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

2962{
2963 struct timeval start = { 0 , 0 };
2964 struct pollfd *pfds = NULL;
2965 int res;
2966 long rms;
2967 int x, y, max;
2968 int sz = nfds;
2969 struct timeval now = { 0, 0 };
2970 struct timeval whentohangup = { 0, 0 }, diff;
2971 struct ast_channel *winner = NULL;
2972 struct fdmap {
2973 int chan;
2974 int fdno;
2975 } *fdmap = NULL;
2976
2977 if (outfd) {
2978 *outfd = -99999;
2979 }
2980 if (exception) {
2981 *exception = 0;
2982 }
2983
2984 for (x = 0; x < n; x++) {
2985 ast_channel_lock(c[x]);
2987 if (ast_tvzero(whentohangup))
2988 now = ast_tvnow();
2989 diff = ast_tvsub(*ast_channel_whentohangup(c[x]), now);
2990 if (diff.tv_sec < 0 || ast_tvzero(diff)) {
2991 ast_test_suite_event_notify("HANGUP_TIME", "Channel: %s", ast_channel_name(c[x]));
2992 /* Should already be hungup */
2995 return c[x];
2996 }
2997 if (ast_tvzero(whentohangup) || ast_tvcmp(diff, whentohangup) < 0)
2998 whentohangup = diff;
2999 }
3000 sz += ast_channel_fd_count(c[x]);
3002 }
3003
3004 if (!sz) {
3005 return NULL;
3006 }
3007
3008 pfds = ast_alloca(sizeof(*pfds) * sz);
3009 fdmap = ast_alloca(sizeof(*fdmap) * sz);
3010
3011 /* Wait full interval */
3012 rms = *ms;
3013 /* INT_MAX, not LONG_MAX, because it matters on 64-bit */
3014 if (!ast_tvzero(whentohangup) && whentohangup.tv_sec < INT_MAX / 1000) {
3015 rms = whentohangup.tv_sec * 1000 + whentohangup.tv_usec / 1000; /* timeout in milliseconds */
3016 if (*ms >= 0 && *ms < rms) { /* original *ms still smaller */
3017 rms = *ms;
3018 }
3019 } else if (!ast_tvzero(whentohangup) && rms < 0) {
3020 /* Tiny corner case... call would need to last >24 days */
3021 rms = INT_MAX;
3022 }
3023 /*
3024 * Build the pollfd array, putting the channels' fds first,
3025 * followed by individual fds. Order is important because
3026 * individual fd's must have priority over channel fds.
3027 */
3028 max = 0;
3029 for (x = 0; x < n; x++) {
3030 ast_channel_lock(c[x]);
3031 for (y = 0; y < ast_channel_fd_count(c[x]); y++) {
3032 fdmap[max].fdno = y; /* fd y is linked to this pfds */
3033 fdmap[max].chan = x; /* channel x is linked to this pfds */
3034 max += ast_add_fd(&pfds[max], ast_channel_fd(c[x], y));
3035 }
3036 CHECK_BLOCKING(c[x]);
3038 }
3039 /* Add the individual fds */
3040 for (x = 0; x < nfds; x++) {
3041 fdmap[max].chan = -1;
3042 max += ast_add_fd(&pfds[max], fds[x]);
3043 }
3044
3045 if (*ms > 0) {
3046 start = ast_tvnow();
3047 }
3048
3049 if (sizeof(int) == 4) { /* XXX fix timeout > 600000 on linux x86-32 */
3050 do {
3051 int kbrms = rms;
3052 if (kbrms > 600000) {
3053 kbrms = 600000;
3054 }
3055 res = ast_poll(pfds, max, kbrms);
3056 if (!res) {
3057 rms -= kbrms;
3058 }
3059 } while (!res && (rms > 0));
3060 } else {
3061 res = ast_poll(pfds, max, rms);
3062 }
3063 for (x = 0; x < n; x++) {
3064 ast_channel_lock(c[x]);
3067 }
3068 if (res < 0) { /* Simulate a timeout if we were interrupted */
3069 if (errno != EINTR) {
3070 *ms = -1;
3071 }
3072 return NULL;
3073 }
3074 if (!ast_tvzero(whentohangup)) { /* if we have a timeout, check who expired */
3075 now = ast_tvnow();
3076 for (x = 0; x < n; x++) {
3078 ast_test_suite_event_notify("HANGUP_TIME", "Channel: %s", ast_channel_name(c[x]));
3080 if (winner == NULL) {
3081 winner = c[x];
3082 }
3083 }
3084 }
3085 }
3086 if (res == 0) { /* no fd ready, reset timeout and done */
3087 *ms = 0; /* XXX use 0 since we may not have an exact timeout. */
3088 return winner;
3089 }
3090 /*
3091 * Then check if any channel or fd has a pending event.
3092 * Remember to check channels first and fds last, as they
3093 * must have priority on setting 'winner'
3094 */
3095 for (x = 0; x < max; x++) {
3096 res = pfds[x].revents;
3097 if (res == 0) {
3098 continue;
3099 }
3100 if (fdmap[x].chan >= 0) { /* this is a channel */
3101 winner = c[fdmap[x].chan]; /* override previous winners */
3102 ast_channel_lock(winner);
3103 if (res & POLLPRI) {
3105 } else {
3107 }
3108 ast_channel_fdno_set(winner, fdmap[x].fdno);
3109 ast_channel_unlock(winner);
3110 } else { /* this is an fd */
3111 if (outfd) {
3112 *outfd = pfds[x].fd;
3113 }
3114 if (exception) {
3115 *exception = (res & POLLPRI) ? -1 : 0;
3116 }
3117 winner = NULL;
3118 }
3119 }
3120 if (*ms > 0) {
3121 *ms -= ast_tvdiff_ms(ast_tvnow(), start);
3122 if (*ms < 0) {
3123 *ms = 0;
3124 }
3125 }
3126 return winner;
3127}
#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 3211 of file channel.c.

3212{
3213 struct timeval start = ast_tvnow();
3214 int ms;
3215
3216 /* Stop if we're a zombie or need a soft hangup */
3218 return -1;
3219
3220 /* Only look for the end of DTMF, don't bother with the beginning and don't emulate things */
3222
3223 /* Wait for a digit, no more than timeout_ms milliseconds total.
3224 * Or, wait indefinitely if timeout_ms is <0.
3225 */
3226 while ((ms = ast_remaining_ms(start, timeout_ms))) {
3227 struct ast_channel *rchan;
3228 int outfd = -1;
3229
3230 errno = 0;
3231 /* While ast_waitfor_nandfds tries to help by reducing the timeout by how much was waited,
3232 * it is unhelpful if it waited less than a millisecond.
3233 */
3234 rchan = ast_waitfor_nandfds(&c, 1, &cmdfd, (cmdfd > -1) ? 1 : 0, NULL, &outfd, &ms);
3235
3236 if (!rchan && outfd < 0 && ms) {
3237 if (errno == 0 || errno == EINTR)
3238 continue;
3239 ast_log(LOG_WARNING, "Wait failed (%s)\n", strerror(errno));
3241 return -1;
3242 } else if (outfd > -1) {
3243 /* The FD we were watching has something waiting */
3244 ast_log(LOG_WARNING, "The FD we were waiting for has something waiting. Waitfordigit returning numeric 1\n");
3246 return 1;
3247 } else if (rchan) {
3248 int res;
3249 struct ast_frame *f = ast_read(c);
3250
3251 if (!f) {
3253
3254 return -1;
3255 }
3256
3257 switch (f->frametype) {
3259 break;
3260 case AST_FRAME_DTMF_END:
3261 res = f->subclass.integer;
3262 if (!breakon || strchr(breakon, res)) {
3263 ast_frfree(f);
3265 return res;
3266 }
3267 break;
3268 case AST_FRAME_CONTROL:
3269 switch (f->subclass.integer) {
3270 case AST_CONTROL_HANGUP:
3271 ast_frfree(f);
3273 return -1;
3279 /* Fall-through and treat as if it were a DTMF signal. Items
3280 * that perform stream control will handle this. */
3281 res = f->subclass.integer;
3282 ast_frfree(f);
3284 return res;
3288 case AST_CONTROL_ANSWER:
3294 case AST_CONTROL_HOLD:
3295 case AST_CONTROL_UNHOLD:
3296 case AST_CONTROL_FLASH:
3297 case -1:
3298 /* Unimportant */
3299 break;
3300 default:
3301 ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", f->subclass.integer);
3302 break;
3303 }
3304 break;
3305 case AST_FRAME_VOICE:
3306 /* Write audio if appropriate */
3307 if (audiofd > -1) {
3308 if (write(audiofd, f->data.ptr, f->datalen) < 0) {
3309 ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
3310 }
3311 }
3312 default:
3313 /* Ignore */
3314 break;
3315 }
3316 ast_frfree(f);
3317 }
3318 }
3319
3321
3322 return 0; /* Time is up */
3323}
@ 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 5114 of file channel.c.

5115{
5116 return ast_write_stream(chan, -1, fr);
5117}
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:5119

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

5120{
5121 struct ast_stream *stream = NULL, *default_stream = NULL;
5122 int res = -1;
5123 struct ast_frame *f = NULL;
5124 int count = 0;
5125 int hooked = 0;
5126
5127 /*Deadlock avoidance*/
5128 while(ast_channel_trylock(chan)) {
5129 /*cannot goto done since the channel is not locked*/
5130 if(count++ > 10) {
5131 ast_debug(1, "Deadlock avoided for write to channel '%s'\n", ast_channel_name(chan));
5132 return 0;
5133 }
5134 usleep(1);
5135 }
5136
5137 /* Stop if we're a zombie or need a soft hangup */
5139 goto done;
5140 }
5141
5142 if (stream_num >= 0) {
5143 /* If we were told to write to an explicit stream then allow this frame through, no matter
5144 * if the type is expected or not (a framehook could change)
5145 */
5147 goto done;
5148 }
5150 default_stream = ast_channel_get_default_stream(chan, ast_stream_get_type(stream));
5151 } else if (fr->frametype == AST_FRAME_VOICE || fr->frametype == AST_FRAME_VIDEO || fr->frametype == AST_FRAME_MODEM) {
5152 /* If we haven't been told of a stream then we need to figure out which once we need */
5154
5155 /* Some frame types have a fixed media type */
5156 if (fr->frametype == AST_FRAME_VOICE || fr->frametype == AST_FRAME_VIDEO) {
5157 type = ast_format_get_type(fr->subclass.format);
5158 } else if (fr->frametype == AST_FRAME_MODEM) {
5160 }
5161
5162 /* No stream was specified, so use the default one */
5163 stream = default_stream = ast_channel_get_default_stream(chan, type);
5164 }
5165
5166 /* Perform the framehook write event here. After the frame enters the framehook list
5167 * there is no telling what will happen, how awesome is that!!! */
5168 if ((stream == default_stream) && !(fr = ast_framehook_list_write_event(ast_channel_framehooks(chan), fr))) {
5169 res = 0;
5170 goto done;
5171 }
5172
5173 if (ast_channel_generatordata(chan) && (fr->frametype != AST_FRAME_RTCP) && (!fr->src || strcasecmp(fr->src, "ast_prod"))) {
5176 } else {
5177 if (fr->frametype == AST_FRAME_DTMF_END) {
5178 /* There is a generator running while we're in the middle of a digit.
5179 * It's probably inband DTMF, so go ahead and pass it so it can
5180 * stop the generator */
5181 ast_channel_unlock(chan);
5182 res = ast_senddigit_end(chan, fr->subclass.integer, fr->len);
5183 ast_channel_lock(chan);
5184 } else if (fr->frametype == AST_FRAME_CONTROL
5185 && fr->subclass.integer == AST_CONTROL_UNHOLD) {
5186 /*
5187 * This is a side case where Echo is basically being called
5188 * and the person put themselves on hold and took themselves
5189 * off hold.
5190 */
5191 indicate_data_internal(chan, fr->subclass.integer, fr->data.ptr,
5192 fr->datalen);
5193 }
5194 res = 0; /* XXX explain, why 0 ? */
5195 goto done;
5196 }
5197 }
5198 /* High bit prints debugging */
5199 if (ast_channel_fout(chan) & DEBUGCHAN_FLAG)
5200 ast_frame_dump(ast_channel_name(chan), fr, ">>");
5201 switch (fr->frametype) {
5202 case AST_FRAME_CONTROL:
5203 indicate_data_internal(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
5204 res = 0;
5205 break;
5207 if (ast_channel_audiohooks(chan)) {
5208 struct ast_frame *old_frame = fr;
5210 if (old_frame != fr)
5211 f = fr;
5212 }
5213 send_dtmf_begin_event(chan, DTMF_SENT, fr->subclass.integer);
5214 ast_channel_unlock(chan);
5215 res = ast_senddigit_begin(chan, fr->subclass.integer);
5216 ast_channel_lock(chan);
5217 break;
5218 case AST_FRAME_DTMF_END:
5219 if (ast_channel_audiohooks(chan)) {
5220 struct ast_frame *new_frame = fr;
5221
5223 if (new_frame != fr) {
5224 ast_frfree(new_frame);
5225 }
5226 }
5227 send_dtmf_end_event(chan, DTMF_SENT, fr->subclass.integer, fr->len);
5228 ast_channel_unlock(chan);
5229 res = ast_senddigit_end(chan, fr->subclass.integer, fr->len);
5230 ast_channel_lock(chan);
5231 break;
5232 case AST_FRAME_TEXT:
5233 CHECK_BLOCKING(chan);
5234 if (ast_format_cmp(fr->subclass.format, ast_format_t140) == AST_FORMAT_CMP_EQUAL) {
5235 res = (ast_channel_tech(chan)->write_text == NULL) ? 0 :
5236 ast_channel_tech(chan)->write_text(chan, fr);
5237 } else {
5238 res = (ast_channel_tech(chan)->send_text == NULL) ? 0 :
5239 ast_channel_tech(chan)->send_text(chan, (char *) fr->data.ptr);
5240 }
5242 break;
5243 case AST_FRAME_HTML:
5244 CHECK_BLOCKING(chan);
5245 res = (ast_channel_tech(chan)->send_html == NULL) ? 0 :
5246 ast_channel_tech(chan)->send_html(chan, fr->subclass.integer, (char *) fr->data.ptr, fr->datalen);
5248 break;
5249 case AST_FRAME_VIDEO:
5250 /* XXX Handle translation of video codecs one day XXX */
5251 CHECK_BLOCKING(chan);
5252 if (ast_channel_tech(chan)->write_stream) {
5253 if (stream) {
5254 res = ast_channel_tech(chan)->write_stream(chan, ast_stream_get_position(stream), fr);
5255 } else {
5256 res = 0;
5257 }
5258 } else if ((stream == default_stream) && ast_channel_tech(chan)->write_video) {
5259 res = ast_channel_tech(chan)->write_video(chan, fr);
5260 } else {
5261 res = 0;
5262 }
5264 break;
5265 case AST_FRAME_MODEM:
5266 CHECK_BLOCKING(chan);
5267 res = tech_write(chan, stream, default_stream, fr);
5269 break;
5270 case AST_FRAME_VOICE:
5272 apply_plc(chan, fr);
5273 }
5274
5275 f = fr;
5276
5277 /*
5278 * Send frame to audiohooks if present, if frametype is linear (else, later as per
5279 * previous behavior)
5280 */
5281 if ((stream == default_stream) && ast_channel_audiohooks(chan)) {
5282 if (ast_format_cache_is_slinear(fr->subclass.format)) {
5283 hooked = 1;
5285 }
5286 }
5287
5288 /* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */
5289 if ((stream == default_stream) && ast_format_cmp(fr->subclass.format, ast_channel_rawwriteformat(chan)) != AST_FORMAT_CMP_EQUAL) {
5290 if (ast_format_cmp(ast_channel_writeformat(chan), fr->subclass.format) != AST_FORMAT_CMP_EQUAL) {
5291 struct ast_str *codec_buf = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
5292
5293 /*
5294 * We are not setup to write this frame. Things may have changed
5295 * on the peer side of the world and we try to adjust the format to
5296 * make it compatible again. However, bad things can happen if we
5297 * cannot setup a new translation path. Problems range from no
5298 * audio, one-way audio, to garbled audio. The best we can do is
5299 * request the call to hangup since we could not make it compatible.
5300 *
5301 * Being continuously spammed by this message likely indicates a
5302 * problem with the peer because it cannot make up its mind about
5303 * which format to use.
5304 */
5305 ast_debug(1, "Channel %s changing write format from %s to %s, native formats %s\n",
5306 ast_channel_name(chan),
5308 ast_format_get_name(fr->subclass.format),
5310 if (ast_set_write_format(chan, fr->subclass.format)) {
5311 /* Could not handle the new write format. Induce a hangup. */
5312 break;
5313 }
5314 }
5315
5316 if (ast_channel_writetrans(chan)) {
5317 struct ast_frame *trans_frame = ast_translate(ast_channel_writetrans(chan), f, 0);
5318 if (trans_frame != f && f != fr) {
5319 /*
5320 * If translate gives us a new frame and so did the audio
5321 * hook then we need to free the one from the audio hook.
5322 */
5323 ast_frfree(f);
5324 }
5325 f = trans_frame;
5326 }
5327 }
5328
5329 if (!f) {
5330 res = 0;
5331 break;
5332 }
5333
5334 if ((stream == default_stream) && ast_channel_audiohooks(chan) && !hooked) {
5335 struct ast_frame *prev = NULL, *new_frame, *cur, *dup;
5336 int freeoldlist = 0;
5337
5338 if (f != fr) {
5339 freeoldlist = 1;
5340 }
5341
5342 /* Since ast_audiohook_write may return a new frame, and the cur frame is
5343 * an item in a list of frames, create a new list adding each cur frame back to it
5344 * regardless if the cur frame changes or not. */
5345 for (cur = f; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
5347
5348 /* if this frame is different than cur, preserve the end of the list,
5349 * free the old frames, and set cur to be the new frame */
5350 if (new_frame != cur) {
5351
5352 /* doing an ast_frisolate here seems silly, but we are not guaranteed the new_frame
5353 * isn't part of local storage, meaning if ast_audiohook_write is called multiple
5354 * times it may override the previous frame we got from it unless we dup it */
5355 if ((dup = ast_frisolate(new_frame))) {
5357 if (freeoldlist) {
5359 ast_frfree(cur);
5360 }
5361 if (new_frame != dup) {
5362 ast_frfree(new_frame);
5363 }
5364 cur = dup;
5365 }
5366 }
5367
5368 /* now, regardless if cur is new or not, add it to the new list,
5369 * if the new list has not started, cur will become the first item. */
5370 if (prev) {
5371 AST_LIST_NEXT(prev, frame_list) = cur;
5372 } else {
5373 f = cur; /* set f to be the beginning of our new list */
5374 }
5375 prev = cur;
5376 }
5377 }
5378
5379 /* the translator on chan->writetrans may have returned multiple frames
5380 from the single frame we passed in; if so, feed each one of them to the
5381 channel, freeing each one after it has been written */
5382 CHECK_BLOCKING(chan);
5383 if ((f != fr) && AST_LIST_NEXT(f, frame_list)) {
5384 struct ast_frame *cur, *next = NULL;
5385 unsigned int skip = 0;
5386
5387 cur = f;
5388 while (cur) {
5391 if (!skip) {
5392 res = tech_write(chan, stream, default_stream, cur);
5393 if (res < 0) {
5395 skip = 1;
5396 } else if (next) {
5397 /* don't do this for the last frame in the list,
5398 as the code outside the loop will do it once
5399 */
5401 }
5402 }
5403 ast_frfree(cur);
5404 cur = next;
5405 }
5406
5407 /* reset f so the code below doesn't attempt to free it */
5408 f = NULL;
5409 } else {
5410 res = tech_write(chan, stream, default_stream, f);
5411 }
5413 break;
5414 case AST_FRAME_NULL:
5415 case AST_FRAME_IAX:
5416 /* Ignore these */
5417 res = 0;
5418 break;
5419 case AST_FRAME_RTCP:
5420 /* RTCP information is on a per-stream basis and only available on multistream capable channels */
5421 CHECK_BLOCKING(chan);
5422 if (ast_channel_tech(chan)->write_stream && stream) {
5423 res = ast_channel_tech(chan)->write_stream(chan, ast_stream_get_position(stream), fr);
5424 } else {
5425 res = 0;
5426 }
5428 break;
5429 default:
5430 /* At this point, fr is the incoming frame and f is NULL. Channels do
5431 * not expect to get NULL as a frame pointer and will segfault. Hence,
5432 * we output the original frame passed in. */
5433 CHECK_BLOCKING(chan);
5434 res = ast_channel_tech(chan)->write(chan, fr);
5436 break;
5437 }
5438
5439 if (f && f != fr)
5440 ast_frfree(f);
5441
5442 /* Consider a write failure to force a soft hangup */
5443 if (res < 0) {
5445 } else {
5447 }
5448done:
5450 /* The list gets recreated if audiohooks are added again later */
5453 }
5454 ast_channel_unlock(chan);
5455 return res;
5456}
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:3342
@ DTMF_SENT
Definition channel.c:3327
static void send_dtmf_end_event(struct ast_channel *chan, enum DtmfDirection direction, const char digit, long duration_ms)
Definition channel.c:3357
static int tech_write(struct ast_channel *chan, struct ast_stream *stream, struct ast_stream *default_stream, struct ast_frame *frame)
Definition channel.c:5102
static void apply_plc(struct ast_channel *chan, struct ast_frame *frame)
Definition channel.c:5076
#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:566

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

4988{
4989 int res;
4990 if (!ast_channel_tech(chan)->write_video)
4991 return 0;
4992 res = ast_write(chan, fr);
4993 if (!res)
4994 res = 1;
4995 return res;
4996}

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

7999{
8000 if (ast_fully_booted) {
8001 ast_log(LOG_ERROR, "Cannot change channel storage driver after Asterisk has started\n");
8002 return -1;
8003 }
8006 return 0;
8007 }
8009 "Invalid channel storage backend '%s' specified. Attempting to use default '%s'.\n",
8010 driver_name, AST_CHANNELSTORAGE_DEFAULT_TYPE);
8013 return 0;
8014 }
8015 ast_log(LOG_ERROR, "Unable to find default channel storage backend '%s'.\n",
8017 return -1;
8018}
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 434 of file channel.c.

434 {
435 .type = "Kill",
436 .description = "Kill channel (should not see this)",
437 .read = kill_read,
438 .exception = kill_exception,
439 .write = kill_write,
440 .fixup = kill_fixup,
441 .hangup = kill_hangup,
442};
static int kill_write(struct ast_channel *chan, struct ast_frame *frame)
Definition channel.c:407
static struct ast_frame * kill_exception(struct ast_channel *chan)
Definition channel.c:401
static struct ast_frame * kill_read(struct ast_channel *chan)
Definition channel.c:395
static int kill_hangup(struct ast_channel *chan)
Definition channel.c:419
static int kill_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
Definition channel.c:413

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