Asterisk - The Open Source Telephony Project  18.5.0
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_monitor
 
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. More...
 
#define AST_BRIDGE_DTMF_CHANNEL_1   (1 << 1)
 Report DTMF on channel 1. More...
 
#define AST_CHAN_WRITE_INFO_T_VERSION   1
 ast_chan_write_info_t version. Must be incremented if structure is changed More...
 
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag, ...)
 Create a channel structure. More...
 
#define ast_channel_alloc_with_endpoint(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag, endpoint, ...)
 
#define ast_channel_cleanup(c)   ({ ao2_cleanup(c); (struct ast_channel *) (NULL); })
 Cleanup a channel reference. More...
 
#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. More...
 
#define ast_channel_lock(chan)   ao2_lock(chan)
 
#define ast_channel_lock_both(chan1, chan2)
 Lock two channels. More...
 
#define AST_CHANNEL_NAME   80
 
#define ast_channel_ref(c)   ({ ao2_ref(c, +1); (c); })
 Increase channel reference count. More...
 
#define ast_channel_trylock(chan)   ao2_trylock(chan)
 
#define ast_channel_unlock(chan)   ao2_unlock(chan)
 
#define ast_channel_unref(c)   ({ ao2_ref(c, -1); (struct ast_channel *) (NULL); })
 Decrease channel reference count. More...
 
#define ast_dummy_channel_alloc()   __ast_dummy_channel_alloc(__FILE__, __LINE__, __PRETTY_FUNCTION__)
 Create a fake channel structure. More...
 
#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_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. More...
 
#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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
int ast_activate_generator (struct ast_channel *chan, struct ast_generator *gen, void *params)
 
int ast_active_channels (void)
 returns number of active/allocated channels More...
 
static int ast_add_fd (struct pollfd *pfd, int fd)
 if fd is a valid descriptor, set *pfd with the descriptor More...
 
int ast_answer (struct ast_channel *chan)
 Answer a channel. More...
 
int ast_auto_answer (struct ast_channel *chan)
 Answer a channel, if it's not already answered. More...
 
void ast_autoservice_chan_hangup_peer (struct ast_channel *chan, struct ast_channel *peer)
 Put chan into autoservice while hanging up peer. More...
 
int ast_autoservice_ignore (struct ast_channel *chan, enum ast_frame_type ftype)
 Ignore certain frame types. More...
 
int ast_autoservice_start (struct ast_channel *chan)
 Automatically service a channel for us... More...
 
int ast_autoservice_stop (struct ast_channel *chan)
 Stop servicing a channel for us... More...
 
int ast_call (struct ast_channel *chan, const char *addr, int timeout)
 Make a call. More...
 
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. More...
 
const char * ast_cause2str (int state) attribute_pure
 Gives the string form of a given cause code. More...
 
void ast_change_name (struct ast_channel *chan, const char *newname)
 Change channel name. More...
 
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. More...
 
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. More...
 
const char * ast_channel_call_forward (const struct ast_channel *chan)
 
struct ast_channelast_channel_callback (ao2_callback_data_fn *cb_fn, void *arg, void *data, int ao2_flags)
 Call a function with every active channel. More...
 
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. More...
 
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)
 
void ast_channel_clear_softhangup (struct ast_channel *chan, int flag)
 Clear a set of softhangup flags from a channel. More...
 
int ast_channel_cmpwhentohangup_tv (struct ast_channel *chan, struct timeval offset)
 Compare a offset with the settings of when to hang a channel up. More...
 
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_macro (struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *connected_info, int is_caller, int frame)
 Run a connected line interception macro and update a channel's connected line information. More...
 
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. More...
 
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. More...
 
struct ast_datastoreast_channel_datastore_find (struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
 Find a datastore on a channel. More...
 
int ast_channel_datastore_inherit (struct ast_channel *from, struct ast_channel *to)
 Inherit datastores from a parent to a child. More...
 
int ast_channel_datastore_remove (struct ast_channel *chan, struct ast_datastore *datastore)
 Remove a datastore from a channel. More...
 
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. More...
 
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. More...
 
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. More...
 
void ast_channel_dialed_causes_clear (const struct ast_channel *chan)
 Clear all cause information from the channel. More...
 
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. More...
 
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) More...
 
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. More...
 
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. More...
 
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. More...
 
int ast_channel_fd_count (const struct ast_channel *chan)
 Retrieve the number of file decriptor positions present on the channel. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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(). More...
 
struct ast_bridgeast_channel_get_bridge (const struct ast_channel *chan)
 Get the bridge associated with a channel. More...
 
struct ast_bridge_channelast_channel_get_bridge_channel (struct ast_channel *chan)
 Get a reference to the channel's bridge pointer. More...
 
int ast_channel_get_cc_agent_type (struct ast_channel *chan, char *agent_type, size_t size)
 Find the appropriate CC agent type to use given a channel. More...
 
struct ast_cc_config_paramsast_channel_get_cc_config_params (struct ast_channel *chan)
 Get the CCSS parameters from a channel. More...
 
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. More...
 
int ast_channel_get_device_name (struct ast_channel *chan, char *device_name, size_t name_buffer_length)
 Get a device name given its channel structure. More...
 
int ast_channel_get_duration (struct ast_channel *chan)
 Obtain how long the channel since the channel was created. More...
 
int64_t ast_channel_get_duration_ms (struct ast_channel *chan)
 Obtain how long it's been, in milliseconds, since the channel was created. More...
 
int ast_channel_get_intercept_mode (void)
 Am I currently running an intercept dialplan routine. More...
 
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(). More...
 
struct ast_stream_topologyast_channel_get_stream_topology (const struct ast_channel *chan)
 Retrieve the topology of streams on a channel. More...
 
void * ast_channel_get_stream_topology_change_source (struct ast_channel *chan)
 Retrieve the source that initiated the last stream topology change. More...
 
static enum ast_t38_state ast_channel_get_t38_state (struct ast_channel *chan)
 Retrieves the current T38 state of a channel. More...
 
int ast_channel_get_up_time (struct ast_channel *chan)
 Obtain how long it has been since the channel was answered. More...
 
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. More...
 
struct varsheadast_channel_get_vars (struct ast_channel *chan)
 Gets the variables for a given channel, as set using pbx_builtin_setvar_helper(). More...
 
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. More...
 
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. More...
 
int ast_channel_has_audio_frame_or_monitor (struct ast_channel *chan)
 Check if the channel has active audiohooks, active framehooks, or a monitor. More...
 
int ast_channel_has_hook_requiring_audio (struct ast_channel *chan)
 Check if the channel has any active hooks that require audio. More...
 
int ast_channel_has_manager_vars (void)
 Return whether or not any manager variables have been set. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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) More...
 
void ast_channel_internal_swap_endpoint_forward (struct ast_channel *a, struct ast_channel *b)
 Swap endpoint_forward between two channels. More...
 
void ast_channel_internal_swap_snapshots (struct ast_channel *a, struct ast_channel *b)
 Swap snapshots beteween two channels. More...
 
void ast_channel_internal_swap_topics (struct ast_channel *a, struct ast_channel *b)
 Swap topics beteween two channels. More...
 
void ast_channel_internal_swap_uniqueid_and_linkedid (struct ast_channel *a, struct ast_channel *b)
 Swap uniqueid and linkedid beteween two channels. More...
 
int ast_channel_is_bridged (const struct ast_channel *chan)
 Determine if a channel is in a bridge. More...
 
int ast_channel_is_leaving_bridge (struct ast_channel *chan)
 Determine if a channel is leaving a bridge, but not hung up. More...
 
int ast_channel_is_multistream (struct ast_channel *chan)
 Determine if a channel is multi-stream capable. More...
 
int ast_channel_is_t38_active (struct ast_channel *chan)
 This function will check if T.38 is active on the channel. More...
 
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. More...
 
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_latest_musicclass (const struct ast_channel *chan)
 
const char * ast_channel_linkedid (const struct ast_channel *chan)
 
const char * ast_channel_macrocontext (const struct ast_channel *chan)
 
void ast_channel_macrocontext_set (struct ast_channel *chan, const char *value)
 
const char * ast_channel_macroexten (const struct ast_channel *chan)
 
void ast_channel_macroexten_set (struct ast_channel *chan, const char *value)
 
int ast_channel_macropriority (const struct ast_channel *chan)
 
void ast_channel_macropriority_set (struct ast_channel *chan, int value)
 
int ast_channel_make_compatible (struct ast_channel *chan, struct ast_channel *peer)
 Make the frame formats of two channels compatible. More...
 
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)
 
struct ast_channel_monitorast_channel_monitor (const struct ast_channel *chan)
 
void ast_channel_monitor_set (struct ast_channel *chan, struct ast_channel_monitor *value)
 
int ast_channel_move (struct ast_channel *dest, struct ast_channel *source)
 Move a channel from its current location to a new location. More...
 
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_set (struct ast_channel *chan, const char *name)
 Set the channel name. More...
 
void ast_channel_name_to_dial_string (char *channel_name)
 Removes the trailing identifiers from a channel name string. More...
 
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. More...
 
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. More...
 
void ast_channel_queue_connected_line_update (struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
 Queue a connected line update frame on a channel. More...
 
void ast_channel_queue_redirecting_update (struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
 Queue a redirecting update frame on a channel. More...
 
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 More...
 
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)
 
int ast_channel_redirecting_macro (struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *redirecting_info, int is_caller, int is_frame)
 Run a redirecting interception macro and update a channel's redirecting information. More...
 
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. More...
 
int ast_channel_register (const struct ast_channel_tech *tech)
 Register a channel technology (a new channel driver) Called by a channel module to register the kind of channels it supports. More...
 
struct ast_channelast_channel_release (struct ast_channel *chan)
 Unlink and release reference to a channel. More...
 
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(). More...
 
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(). More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
void ast_channel_set_caller (struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update)
 Set the caller id information in the Asterisk channel. More...
 
void ast_channel_set_caller_event (struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update)
 Set the caller id information in the Asterisk channel and generate an AMI event if the caller id name or number changed. More...
 
void ast_channel_set_connected_line (struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
 Set the connected line information in the Asterisk channel. More...
 
void ast_channel_set_fd (struct ast_channel *chan, int which, int fd)
 
void ast_channel_set_flag (struct ast_channel *chan, unsigned int flag)
 Set a flag on a channel. More...
 
void ast_channel_set_is_t38_active (struct ast_channel *chan, int is_t38_active)
 Sets the is_t38_active flag. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
void ast_channel_setwhentohangup_tv (struct ast_channel *chan, struct timeval offset)
 Set when to hang a channel up. More...
 
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. More...
 
struct ast_silence_generatorast_channel_start_silence_generator (struct ast_channel *chan)
 Starts a silence generator on the given channel. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
int ast_channel_supports_html (struct ast_channel *channel)
 Checks for HTML support on a channel. More...
 
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. More...
 
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)
 
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. More...
 
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. More...
 
int ast_channel_unbridged_nolock (struct ast_channel *chan)
 ast_channel_unbridged variant. Use this if the channel is already locked prior to calling. More...
 
void ast_channel_undefer_dtmf (struct ast_channel *chan)
 Unset defer DTMF flag on channel. More...
 
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. More...
 
void ast_channel_unregister (const struct ast_channel_tech *tech)
 Unregister a channel technology. More...
 
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. More...
 
void ast_channel_update_connected_line (struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
 Indicate that the connected line information has changed. More...
 
void ast_channel_update_redirecting (struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
 Indicate that the redirecting id has changed. More...
 
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. More...
 
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 More...
 
int ast_check_hangup (struct ast_channel *chan)
 Check to see if a channel is needing hang up. More...
 
int ast_check_hangup_locked (struct ast_channel *chan)
 
int ast_connected_line_build_data (unsigned char *data, size_t datalen, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
 Build the connected line information data frame. More...
 
void ast_connected_line_copy_from_caller (struct ast_party_connected_line *dest, const struct ast_party_caller *src)
 Copy the caller information to the connected line information. More...
 
void ast_connected_line_copy_to_caller (struct ast_party_caller *dest, const struct ast_party_connected_line *src)
 Copy the connected line information to the caller information. More...
 
int ast_connected_line_parse_data (const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected)
 Parse connected line indication frame data. More...
 
void ast_deactivate_generator (struct ast_channel *chan)
 
static int ast_fdisset (struct pollfd *pfds, int fd, int maximum, int *start)
 Helper function for migrating select to poll. More...
 
const struct ast_channel_techast_get_channel_tech (const char *name)
 Get a channel technology structure by name. More...
 
ast_group_t ast_get_group (const char *s)
 
struct ast_namedgroups * ast_get_namedgroups (const char *s)
 Create an ast_namedgroups set with group names from comma separated string. More...
 
void ast_hangup (struct ast_channel *chan)
 Hang up a channel. More...
 
int ast_indicate (struct ast_channel *chan, int condition)
 Indicates condition of channel. More...
 
int ast_indicate_data (struct ast_channel *chan, int condition, const void *data, size_t datalen)
 Indicates condition of channel, with payload. More...
 
int ast_is_deferrable_frame (const struct ast_frame *frame)
 Should we keep this frame for later? More...
 
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. More...
 
void ast_party_caller_copy (struct ast_party_caller *dest, const struct ast_party_caller *src)
 Copy the source caller information to the destination caller. More...
 
void ast_party_caller_free (struct ast_party_caller *doomed)
 Destroy the caller party contents. More...
 
void ast_party_caller_init (struct ast_party_caller *init)
 Initialize the given caller structure. More...
 
void ast_party_caller_set (struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update)
 Set the caller information based on another caller source. More...
 
void ast_party_caller_set_init (struct ast_party_caller *init, const struct ast_party_caller *guide)
 Initialize the given caller structure using the given guide for a set update operation. More...
 
void ast_party_connected_line_collect_caller (struct ast_party_connected_line *connected, struct ast_party_caller *caller)
 Collect the caller party information into a connected line structure. More...
 
void ast_party_connected_line_copy (struct ast_party_connected_line *dest, const struct ast_party_connected_line *src)
 Copy the source connected line information to the destination connected line. More...
 
void ast_party_connected_line_free (struct ast_party_connected_line *doomed)
 Destroy the connected line information contents. More...
 
void ast_party_connected_line_init (struct ast_party_connected_line *init)
 Initialize the given connected line structure. More...
 
void ast_party_connected_line_set (struct ast_party_connected_line *dest, const struct ast_party_connected_line *src, const struct ast_set_party_connected_line *update)
 Set the connected line information based on another connected line source. More...
 
void ast_party_connected_line_set_init (struct ast_party_connected_line *init, const struct ast_party_connected_line *guide)
 Initialize the given connected line structure using the given guide for a set update operation. More...
 
void ast_party_dialed_copy (struct ast_party_dialed *dest, const struct ast_party_dialed *src)
 Copy the source dialed party information to the destination dialed party. More...
 
void ast_party_dialed_free (struct ast_party_dialed *doomed)
 Destroy the dialed party contents. More...
 
void ast_party_dialed_init (struct ast_party_dialed *init)
 Initialize the given dialed structure. More...
 
void ast_party_dialed_set (struct ast_party_dialed *dest, const struct ast_party_dialed *src)
 Set the dialed information based on another dialed source. More...
 
void ast_party_dialed_set_init (struct ast_party_dialed *init, const struct ast_party_dialed *guide)
 Initialize the given dialed structure using the given guide for a set update operation. More...
 
void ast_party_id_copy (struct ast_party_id *dest, const struct ast_party_id *src)
 Copy the source party id information to the destination party id. More...
 
void ast_party_id_free (struct ast_party_id *doomed)
 Destroy the party id contents. More...
 
void ast_party_id_init (struct ast_party_id *init)
 Initialize the given party id structure. More...
 
void ast_party_id_invalidate (struct ast_party_id *id)
 Invalidate all components of the given party id. More...
 
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. More...
 
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. More...
 
int ast_party_id_presentation (const struct ast_party_id *id)
 Determine the overall presentation value for the given party. More...
 
void ast_party_id_reset (struct ast_party_id *id)
 Destroy and initialize the given party id structure. More...
 
void ast_party_id_set (struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update)
 Set the source party id information into the destination party id. More...
 
void ast_party_id_set_init (struct ast_party_id *init, const struct ast_party_id *guide)
 Initialize the given party id structure using the given guide for a set update operation. More...
 
void ast_party_name_copy (struct ast_party_name *dest, const struct ast_party_name *src)
 Copy the source party name information to the destination party name. More...
 
void ast_party_name_free (struct ast_party_name *doomed)
 Destroy the party name contents. More...
 
void ast_party_name_init (struct ast_party_name *init)
 Initialize the given name structure. More...
 
void ast_party_name_set (struct ast_party_name *dest, const struct ast_party_name *src)
 Set the source party name information into the destination party name. More...
 
void ast_party_name_set_init (struct ast_party_name *init, const struct ast_party_name *guide)
 Initialize the given party name structure using the given guide for a set update operation. More...
 
void ast_party_number_copy (struct ast_party_number *dest, const struct ast_party_number *src)
 Copy the source party number information to the destination party number. More...
 
void ast_party_number_free (struct ast_party_number *doomed)
 Destroy the party number contents. More...
 
void ast_party_number_init (struct ast_party_number *init)
 Initialize the given number structure. More...
 
void ast_party_number_set (struct ast_party_number *dest, const struct ast_party_number *src)
 Set the source party number information into the destination party number. More...
 
void ast_party_number_set_init (struct ast_party_number *init, const struct ast_party_number *guide)
 Initialize the given party number structure using the given guide for a set update operation. More...
 
void ast_party_redirecting_copy (struct ast_party_redirecting *dest, const struct ast_party_redirecting *src)
 Copy the source redirecting information to the destination redirecting. More...
 
void ast_party_redirecting_free (struct ast_party_redirecting *doomed)
 Destroy the redirecting information contents. More...
 
void ast_party_redirecting_init (struct ast_party_redirecting *init)
 Initialize the given redirecting structure. More...
 
void ast_party_redirecting_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. More...
 
void ast_party_redirecting_reason_free (struct ast_party_redirecting_reason *doomed)
 Destroy the redirecting reason contents. More...
 
void ast_party_redirecting_reason_init (struct ast_party_redirecting_reason *init)
 Initialize the given redirecting reason structure. More...
 
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. More...
 
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. More...
 
void ast_party_redirecting_set (struct ast_party_redirecting *dest, const struct ast_party_redirecting *src, const struct ast_set_party_redirecting *update)
 Set the redirecting information based on another redirecting source. More...
 
void ast_party_redirecting_set_init (struct ast_party_redirecting *init, const struct ast_party_redirecting *guide)
 Initialize the given redirecting id structure using the given guide for a set update operation. More...
 
void ast_party_subaddress_copy (struct ast_party_subaddress *dest, const struct ast_party_subaddress *src)
 Copy the source party subaddress information to the destination party subaddress. More...
 
void ast_party_subaddress_free (struct ast_party_subaddress *doomed)
 Destroy the party subaddress contents. More...
 
void ast_party_subaddress_init (struct ast_party_subaddress *init)
 Initialize the given subaddress structure. More...
 
void ast_party_subaddress_set (struct ast_party_subaddress *dest, const struct ast_party_subaddress *src)
 Set the source party subaddress information into the destination party subaddress. More...
 
void ast_party_subaddress_set_init (struct ast_party_subaddress *init, const struct ast_party_subaddress *guide)
 Initialize the given party subaddress structure using the given guide for a set update operation. More...
 
int ast_pre_call (struct ast_channel *chan, const char *sub_args)
 Execute a Gosub call on the channel before a call is placed. More...
 
char * ast_print_group (char *buf, int buflen, ast_group_t group)
 Print call and pickup groups into buffer. More...
 
char * ast_print_namedgroups (struct ast_str **buf, struct ast_namedgroups *groups)
 Print named call groups and named pickup groups. More...
 
int ast_prod (struct ast_channel *chan)
 Send empty audio to prime a channel driver. More...
 
int ast_queue_answer (struct ast_channel *chan, const struct ast_stream_topology *topology)
 Queue an ANSWER control frame with topology. More...
 
int ast_queue_control (struct ast_channel *chan, enum ast_control_frame_type control)
 Queue a control frame without payload. More...
 
int ast_queue_control_data (struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen)
 Queue a control frame with payload. More...
 
int ast_queue_frame (struct ast_channel *chan, struct ast_frame *f)
 Queue one or more frames to a channel's frame queue. More...
 
int ast_queue_frame_head (struct ast_channel *chan, struct ast_frame *f)
 Queue one or more frames to the head of a channel's frame queue. More...
 
int ast_queue_hangup (struct ast_channel *chan)
 Queue a hangup frame. More...
 
int ast_queue_hangup_with_cause (struct ast_channel *chan, int cause)
 Queue a hangup frame with hangupcause set. More...
 
int ast_queue_hold (struct ast_channel *chan, const char *musicclass)
 Queue a hold frame. More...
 
int ast_queue_unhold (struct ast_channel *chan)
 Queue an unhold frame. More...
 
int ast_raw_answer (struct ast_channel *chan)
 Answer a channel. More...
 
int ast_raw_answer_with_stream_topology (struct ast_channel *chan, struct ast_stream_topology *topology)
 Answer a channel passing in a stream topology. More...
 
struct ast_frameast_read (struct ast_channel *chan)
 Reads a frame. More...
 
struct ast_frameast_read_noaudio (struct ast_channel *chan)
 Reads a frame, returning AST_FRAME_NULL frame if audio. More...
 
struct ast_frameast_read_stream (struct ast_channel *chan)
 Reads a frame, but does not filter to just the default streams. More...
 
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. More...
 
int ast_readstring (struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders)
 Reads multiple digits. More...
 
int ast_readstring_full (struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders, int audiofd, int ctrlfd)
 
int ast_recvchar (struct ast_channel *chan, int timeout)
 Receives a text character from a channel. More...
 
char * ast_recvtext (struct ast_channel *chan, int timeout)
 Receives a text string from a channel Read a string of text from a channel. More...
 
int ast_redirecting_build_data (unsigned char *data, size_t datalen, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
 Build the redirecting id data frame. More...
 
int ast_redirecting_parse_data (const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting)
 Parse redirecting indication frame data. More...
 
struct ast_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. More...
 
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. More...
 
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) More...
 
int ast_safe_sleep (struct ast_channel *chan, int ms)
 Wait for a specified amount of time, looking for hangups. More...
 
int ast_safe_sleep_conditional (struct ast_channel *chan, int ms, int(*cond)(void *), void *data)
 Wait for a specified amount of time, looking for hangups and a condition argument. More...
 
int ast_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. More...
 
int ast_senddigit (struct ast_channel *chan, char digit, unsigned int duration)
 Send a DTMF digit to a channel. More...
 
int ast_senddigit_begin (struct ast_channel *chan, char digit)
 Send a DTMF digit to a channel. More...
 
int ast_senddigit_end (struct ast_channel *chan, char digit, unsigned int duration)
 Send a DTMF digit to a channel. More...
 
int ast_senddigit_external (struct ast_channel *chan, char digit, unsigned int duration)
 Send a DTMF digit to a channel from an external thread. More...
 
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. More...
 
int ast_senddigit_mf_begin (struct ast_channel *chan, char digit)
 Send an MF digit to a channel. More...
 
int ast_senddigit_mf_end (struct ast_channel *chan)
 End sending an MF digit to a channel. More...
 
int ast_sendtext (struct ast_channel *chan, const char *text)
 Sends text to a channel. More...
 
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. More...
 
void ast_set_callerid (struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani)
 Set caller ID number, name and ANI and generate AMI event. More...
 
void ast_set_hangupsource (struct ast_channel *chan, const char *source, int force)
 Set the source of the hangup in this channel and it's bridge. More...
 
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. More...
 
int ast_set_read_format (struct ast_channel *chan, struct ast_format *format)
 Sets read format on channel chan. More...
 
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. More...
 
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. More...
 
void ast_set_variables (struct ast_channel *chan, struct ast_variable *vars)
 adds a list of channel variables to a channel More...
 
int ast_set_write_format (struct ast_channel *chan, struct ast_format *format)
 Sets write format on channel chan. More...
 
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. More...
 
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) More...
 
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. More...
 
int ast_settimeout (struct ast_channel *c, unsigned int rate, int(*func)(const void *data), void *data)
 Enable or disable timer ticks for a channel. More...
 
int ast_settimeout_full (struct ast_channel *c, unsigned int rate, int(*func)(const void *data), void *data, unsigned int is_ao2_obj)
 
int ast_softhangup (struct ast_channel *chan, int reason)
 Softly hangup up a channel. More...
 
void ast_softhangup_all (void)
 Soft hangup all active channels. More...
 
int ast_softhangup_nolock (struct ast_channel *chan, int reason)
 Softly hangup up a channel (no channel lock) More...
 
const char * ast_state2str (enum ast_channel_state)
 Gives the string form of a given channel state. More...
 
int ast_str2cause (const char *name) attribute_pure
 Convert the string form of a cause code to a number. More...
 
int ast_tonepair (struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
 
int ast_tonepair_start (struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
 
void ast_tonepair_stop (struct ast_channel *chan)
 
int ast_transfer (struct ast_channel *chan, char *dest)
 Transfer a channel (if supported). More...
 
int ast_transfer_protocol (struct ast_channel *chan, char *dest, int *protocol)
 Transfer a channel (if supported) receieve protocol result. More...
 
char * ast_transfercapability2str (int transfercapability) attribute_const
 Gives the string form of a given transfer capability. More...
 
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. More...
 
struct ast_channelast_waitfor_n (struct ast_channel **chan, int n, int *ms)
 Waits for input on a group of channels Wait for input on an array of channels for a given # of milliseconds. More...
 
int ast_waitfor_n_fd (int *fds, int n, int *ms, int *exception)
 Waits for input on an fd. More...
 
struct ast_channelast_waitfor_nandfds (struct ast_channel **chan, int n, int *fds, int nfds, int *exception, int *outfd, int *ms)
 Waits for activity on a group of channels. More...
 
int ast_waitfordigit (struct ast_channel *c, int ms)
 Waits for a digit. More...
 
int ast_waitfordigit_full (struct ast_channel *c, int ms, 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. More...
 
int ast_write (struct ast_channel *chan, struct ast_frame *frame)
 Write a frame to a channel This function writes the given frame to the indicated channel. More...
 
int ast_write_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. More...
 
int ast_write_text (struct ast_channel *chan, struct ast_frame *frame)
 Write text frame to a channel This function writes the given frame to the indicated channel. More...
 
int ast_write_video (struct ast_channel *chan, struct ast_frame *frame)
 Write video frame to a channel This function writes the given frame to the indicated channel. More...
 
 DECLARE_STRINGFIELD_SETTERS_FOR (name)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (language)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (musicclass)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (latest_musicclass)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (accountcode)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (peeraccount)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (userfield)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (call_forward)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (uniqueid)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (linkedid)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (parkinglot)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (hangupsource)
 
 DECLARE_STRINGFIELD_SETTERS_FOR (dialcontext)
 
struct ast_channel_iteratorast_channel_iterator_destroy (struct ast_channel_iterator *i)
 Destroy a channel iterator. More...
 
struct ast_channel_iteratorast_channel_iterator_by_exten_new (const char *exten, const char *context)
 Create a new channel iterator based on extension. More...
 
struct ast_channel_iteratorast_channel_iterator_by_name_new (const char *name, size_t name_len)
 Create a new channel iterator based on name. More...
 
struct ast_channel_iteratorast_channel_iterator_all_new (void)
 Create a new channel iterator. More...
 
struct ast_channelast_channel_iterator_next (struct ast_channel_iterator *i)
 Get the next channel for a channel iterator. More...
 
struct ast_channelast_channel_get_by_name (const char *name)
 Find a channel by name. More...
 
struct ast_channelast_channel_get_by_name_prefix (const char *name, size_t name_len)
 Find a channel by a name prefix. More...
 
struct ast_channelast_channel_get_by_exten (const char *exten, const char *context)
 Find a channel by extension and context. More...
 

Variables

const struct ast_channel_tech ast_kill_tech
 Kill the channel channel driver technology descriptor. More...
 
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. More...
 
unsigned long global_fin
 
unsigned long global_fout
 

Detailed Description

General Asterisk PBX channel definitions.

See also:

Definition in file channel.h.

Macro Definition Documentation

◆ AST_AGENT_FD

#define AST_AGENT_FD   (AST_MAX_FDS-3)

used by agents for pass through

Definition at line 203 of file channel.h.

◆ AST_ALERT_FD

#define AST_ALERT_FD   (AST_MAX_FDS-1)

used for alertpipe

Definition at line 201 of file channel.h.

Referenced by __ast_channel_alloc_ap().

◆ AST_BRIDGE_DTMF_CHANNEL_0

#define AST_BRIDGE_DTMF_CHANNEL_0   (1 << 0)

Report DTMF on channel 0.

Definition at line 2382 of file channel.h.

Referenced by iax2_key_rotate(), misdn_write(), and set_config_flags().

◆ AST_BRIDGE_DTMF_CHANNEL_1

#define AST_BRIDGE_DTMF_CHANNEL_1   (1 << 1)

Report DTMF on channel 1.

Definition at line 2384 of file channel.h.

Referenced by iax2_key_rotate(), misdn_write(), and set_config_flags().

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

Referenced by ast_unreal_setoption(), and func_channel_write().

◆ 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__)
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
#define NULL
Definition: resample.c:96
static char cid_num[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:164
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:960
static char cid_name[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:165
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116

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

Referenced by alsa_new(), ast_channel_yank(), ast_iax2_new(), ast_pbx_outgoing_exten_predial(), AST_TEST_DEFINE(), ast_unreal_new_channels(), audiosocket_request(), console_new(), create_alice_channel(), create_msg_q_chan(), dahdi_new(), do_notify(), make_channel(), mbl_new(), mgcp_new(), misdn_new(), multicast_rtp_request(), nbs_new(), ooh323_new(), oss_new(), phone_new(), rec_request(), sip_new(), skinny_new(), stasis_app_control_snoop(), test_vm_api_create_mock_channel(), unicast_rtp_request(), unistim_new(), and wait_for_digits().

◆ 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__)
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
static char cid_num[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:164
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:960
static char cid_name[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:165
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116

Definition at line 1263 of file channel.h.

Referenced by ast_iax2_new(), chan_pjsip_new(), jingle_new(), and sip_new().

◆ ast_channel_cleanup

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

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

◆ ast_channel_lock

#define ast_channel_lock (   chan)    ao2_lock(chan)

Definition at line 2945 of file channel.h.

Referenced by __after_bridge_set_goto(), __analog_handle_event(), __analog_ss_thread(), __ast_answer(), __ast_channel_alloc_ap(), __ast_pbx_run(), __ast_queue_frame(), __ast_read(), __ast_request_and_dial(), __dahdi_exception(), _if_exec(), _macro_exec(), _while_exec(), acf_cc_read(), acf_cc_write(), acf_curl_helper(), acf_faxopt_write(), acf_fetch(), acf_odbc_read(), action_add_agi_cmd(), action_atxfer(), action_bridge(), action_cancel_atxfer(), action_dialplan_exec(), action_redirect(), action_status(), action_timeout(), add_features_datastore(), add_to_agi(), after_bridge_goto_remove(), after_bridge_move_channel(), agent_bridge_channel_get_lock(), agent_lock_logged(), agent_login_channel_config(), agent_login_exec(), agent_logout(), agent_request_exec(), alloc_playback_chan(), analog_attempt_transfer(), analog_exception(), analog_ss_thread(), aoc_publish_blob(), app_control_dial(), app_control_mute(), app_control_unmute(), app_exec(), append_expected_event(), apply_negotiated_sdp_stream(), ari_channels_handle_originate_with_id(), ast_activate_generator(), ast_ari_channels_dial(), ast_ari_channels_rtpstatistics(), ast_async_goto(), ast_atomic_dec_and_test(), ast_audiohook_attach(), ast_audiohook_detach_source(), ast_audiohook_remove(), ast_audiohook_set_mute(), ast_autochan_setup(), ast_autoservice_start(), ast_autoservice_stop(), ast_bridge_add_channel(), ast_bridge_call_with_flags(), ast_bridge_channel_leave_bridge_nolock(), ast_bridge_channel_playfile(), ast_bridge_channel_restore_formats(), ast_bridge_channel_stream_map(), ast_bridge_channel_update_linkedids(), ast_bridge_depart(), ast_bridge_features_ds_get_string(), ast_bridge_features_ds_set_string(), ast_bridge_join(), ast_bridge_notify_masquerade(), ast_bridge_timelimit(), ast_bridge_transfer_acquire_bridge(), ast_bridge_transfer_attended(), ast_bridge_transfer_blind(), ast_call(), ast_call_forward(), ast_cc_agent_set_interfaces_chanvar(), ast_cc_call_init(), ast_cc_completed(), ast_cc_extension_monitor_add_dialstring(), ast_cc_get_current_core_id(), ast_cc_is_recall(), ast_cc_offer(), ast_change_name(), ast_channel_bridge_peer(), ast_channel_by_exten_cb(), ast_channel_by_name_cb(), ast_channel_by_uniqueid_cb(), ast_channel_clear_flag(), ast_channel_clear_softhangup(), ast_channel_connected_line_macro(), ast_channel_connected_line_sub(), ast_channel_defer_dtmf(), ast_channel_destructor(), ast_channel_end_dtmf(), ast_channel_is_t38_active(), ast_channel_publish_dial_forward(), ast_channel_publish_dial_internal(), ast_channel_queryoption(), ast_channel_redirecting_macro(), ast_channel_redirecting_sub(), ast_channel_request_stream_topology_change(), ast_channel_set_caller(), ast_channel_set_caller_event(), ast_channel_set_connected_line(), ast_channel_set_flag(), ast_channel_set_is_t38_active(), ast_channel_set_redirecting(), ast_channel_set_unbridged(), ast_channel_setoption(), ast_channel_softhangup_withcause_locked(), ast_channel_stream_topology_changed_externally(), ast_channel_unbridged(), ast_channel_yank(), ast_check_hangup_locked(), ast_deactivate_generator(), ast_dial_join(), ast_do_pickup(), ast_eivr_getvariable(), ast_explicit_goto(), ast_handle_cc_control_frame(), ast_hangup(), ast_ignore_cc(), ast_indicate_data(), ast_jb_create_framehook(), ast_local_setup_bridge(), ast_local_setup_masquerade(), ast_odbc_retrieve_transaction_obj(), ast_openstream_full(), ast_openvstream(), ast_pbx_h_exten_run(), ast_pbx_hangup_handler_destroy(), ast_pbx_hangup_handler_pop(), ast_pbx_hangup_handler_push(), ast_pbx_hangup_handler_run(), ast_pbx_hangup_handler_show(), ast_pickup_call(), ast_pickup_find_by_group(), ast_pre_call(), ast_queue_hangup(), ast_queue_hangup_with_cause(), ast_queue_hold(), ast_queue_unhold(), ast_raw_answer_with_stream_topology(), ast_read_generator_actions(), ast_rtp_instance_make_compatible(), ast_rtp_instance_set_stats_vars(), ast_senddigit_begin(), ast_senddigit_end(), ast_sendtext_data(), ast_set_callerid(), ast_set_cc_interfaces_chanvar(), ast_set_hangupsource(), ast_settimeout_full(), ast_setup_cc_recall_datastore(), ast_softhangup(), ast_stir_shaken_add_verification(), ast_stopstream(), ast_str_retrieve_variable(), ast_streamfile(), AST_TEST_DEFINE(), ast_transfer_protocol(), ast_unreal_channel_push_to_bridge(), ast_unreal_hangup(), ast_unreal_indicate(), ast_unreal_lock_all(), ast_unreal_queryoption(), ast_unreal_setoption(), ast_var_channel_bridge(), ast_var_channels_table(), ast_waitfor_nandfds(), ast_write_stream(), async_play_sound_ready(), async_playback_task_data_alloc(), attach_framehook(), attempt_transfer(), attended_transfer_exec(), attended_transfer_monitor_thread(), attended_transfer_properties_alloc(), auth_exec(), begin_dial_channel(), begin_dial_prerun(), bridge_channel_change_bridge(), bridge_channel_depart(), bridge_channel_feature_digit_timeout(), bridge_channel_impart_add(), bridge_channel_impart_signal(), bridge_channel_ind_thread(), bridge_channel_internal_join(), bridge_channel_internal_queue_attended_transfer(), bridge_channel_internal_queue_blind_transfer(), bridge_channel_queue_deferred_frames(), bridge_check_monitor(), bridge_exec(), bridge_impart_internal(), bridge_move(), bridge_parking_push(), bridge_reconfigured_connected_line_update(), bridge_stasis_push_peek(), bridge_stasis_queue_join_action(), bridge_timeout(), bridgeadd_exec(), calendar_event_read(), calendar_query_exec(), calendar_query_result_exec(), call_forward_inherit(), caller_id_outgoing_request(), caller_id_outgoing_response(), callerid_read(), callerid_write(), cb_events(), cc_build_payload(), cc_interfaces_datastore_init(), cdr_write(), chan_cleanup(), chan_pjsip_answer(), chan_pjsip_cng_tone_detected(), chan_pjsip_incoming_response(), chan_pjsip_indicate(), channel_do_masquerade(), channel_set_cause(), channel_set_debug(), channel_spy(), check_bridge_play_sound(), cli_channelstats_print_body(), common_exec(), conf_find_bridge_profile(), conf_find_user_profile(), conf_run(), conf_set_menu_to_user(), conf_start_moh(), connectedline_read(), connectedline_write(), control_prestart_dispatch_all(), control_swap_channel_in_bridge(), create_dynamic_lot_full(), create_msg_q_chan(), create_parked_subscription_full(), create_transaction(), crement_function_read(), dahdi_handle_dtmf(), dahdi_handle_event(), deactivate_silence_generator(), detect_read(), detect_write(), dial_bridge_after_cb(), dial_exec_full(), dialog_info_generate_body_content(), dialplan_handle_msg_cb(), disa_exec(), disable_jack_hook(), do_forward(), do_notify(), dundi_query_read(), dundi_result_read(), dynamic_dtmf_hook_trip(), enable_jack_hook(), end_bridge_callback(), enum_query_read(), enum_result_read(), eval_exten_read(), exec_odbcfinish(), expand_gosub_args(), external_media_audiosocket_tcp(), external_media_rtp_udp(), fax_detect_attach(), fax_detect_framehook(), fax_gateway_attach(), fax_gateway_detect_t38(), fax_gateway_detect_v21(), fax_gateway_framehook(), fax_gateway_indicate_t38(), fax_gateway_start(), feature_automixmonitor(), feature_automonitor(), feature_blind_transfer(), fetch_bridge_roles_datastore(), fetch_or_create_bridge_roles_datastore(), find_by_mark(), find_by_name(), find_by_uniqueid(), find_channel_by_group(), find_conf_realtime(), find_details(), find_or_create_details(), find_ringing_channel(), find_speech(), find_transaction(), frame_drop_helper(), frame_trace_helper(), func_channel_read(), func_channel_write_real(), func_channels_read(), func_confbridge_helper(), func_header_read(), func_headers_read2(), func_mixmonitor_read(), function_ooh323_read(), function_ooh323_write(), gather_softmix_stats(), generate_parked_user(), generator_force(), generator_write_format_change(), generic_fax_exec(), get_agi_cmd(), get_chan_by_ast_name(), get_cid_name(), get_device_state_causing_channels(), get_refer_info(), get_replace_channel_store(), get_transfer_parties(), gosub_exec(), gosub_run(), goto_parser(), grab_transfer(), handle_autohangup(), handle_call_forward(), handle_call_outgoing(), handle_cli_agi_add_cmd(), handle_cli_mixmonitor(), handle_exec(), handle_gosub(), handle_incoming_request(), handle_invite_replaces(), handle_negotiated_sdp(), handle_remb_set(), handle_request_bye(), handle_show_chanvar(), handle_showchan(), handle_soft_key_event_message(), handle_softhangup(), handle_stimulus_message(), hangupcause_clear_exec(), hangupcause_keys_read(), hangupcause_read(), hold(), hook_callback(), hook_off(), hook_re_enable(), hook_thread_arg_alloc(), iax2_request(), import_ch(), import_helper(), indicate_busy(), indicate_congestion(), inherit_channel_vars_from_id(), init_hook(), init_jack_data(), internal_bridge_after_cb(), is_colp_update_allowed(), jack_hook_callback(), jingle_action_session_initiate(), jingle_session_lock_full(), launch_monitor_thread(), leave_voicemail(), limits_interval_playback(), listfilter(), local_ast_moh_start(), local_ast_moh_stop(), local_call(), local_read(), local_write(), lua_get_state(), manager_bridge_kick(), manager_mixmonitor(), manager_park(), manager_park_bridged(), map_source_to_destinations(), mark_transaction_active(), meetme_menu_admin_extended(), meetme_stasis_generate_msg(), mgcp_ss(), minivm_delete_exec(), minivm_notify_exec(), misdn_answer(), misdn_update_caller_id(), mixmonitor_ds_remove_and_free(), moh_files_generator(), morsecode_exec(), msg_data_func_read(), msg_data_func_write(), msg_func_read(), msg_func_write(), msg_send_exec(), mute_channel(), my_handle_dtmf(), MYSQL_exec(), native_bridge_is_capable(), native_chan_changed(), native_rtp_bridge_framehook_attach(), native_rtp_bridge_framehook_detach(), native_rtp_bridge_stop(), native_rtp_framehook(), native_start(), notify_new_message(), ooh323_answer(), park_and_announce_app_exec(), park_app_exec(), park_common_setup(), parked_call_app_exec(), parked_call_payload_from_failure(), parked_call_payload_from_parked_user(), parked_call_retrieve_enable_features(), parker_parked_call_message_response(), parking_duration_callback(), parking_park_call(), pbx_builtin_background(), pbx_builtin_getvar_helper(), pbx_builtin_gotoiftime(), pbx_builtin_hangup(), pbx_builtin_pushvar_helper(), pbx_builtin_saycharacters(), pbx_builtin_saycharacters_case(), pbx_builtin_saydigits(), pbx_builtin_saymoney(), pbx_builtin_saynumber(), pbx_builtin_sayphonetic(), pbx_builtin_serialize_variables(), pbx_builtin_setamaflags(), pbx_builtin_setvar_helper(), pbx_exec(), pbx_outgoing_attempt(), peek_read(), phone_new(), pickup_by_exten(), pitchshift_helper(), pjsip_acf_channel_read(), pjsip_acf_dtmf_mode_read(), pjsip_acf_dtmf_mode_write(), pjsip_acf_moh_passthrough_read(), pjsip_acf_moh_passthrough_write(), play_failsound(), play_sound(), pop_exec(), pre_bridge_setup(), process_sdp(), publish_dahdichannel(), push_notify_channel(), queue_exec(), queue_publish_multi_channel_blob(), read_config(), realtime_exec(), recall_pull(), receive_ademco_event(), redirecting_read(), redirecting_write(), refer_blind_callback(), refer_incoming_invite_request(), refer_outgoing_request(), refer_progress_bridge(), reload(), remove_stasis_end_published(), retrydial_exec(), return_exec(), ring_entry(), ringing(), rtp_check_timeout(), run_agi(), safe_sleep_conditional(), save_dialstring(), sayunixtime_exec(), scramble_write(), send_direct_media_request(), send_start_msg(), sendtext_exec(), serialize_showchan(), set_bridge_peer_vars_2party(), set_bridge_peer_vars_holding(), set_bridge_peer_vars_multiparty(), set_caps(), set_config_flags(), set_ext_pri(), set_format(), set_from_header(), set_security_requirements(), set_softmix_bridge_data(), set_timeout(), set_transfer_variables_all(), setup_bridge_features_builtin(), setup_bridge_features_dynamic(), setup_mixmonitor(), setup_mixmonitor_ds(), setup_park_common_datastore(), setup_peer_after_bridge_goto(), sfu_topologies_on_join(), sfu_topologies_on_source_change(), shared_read(), shared_write(), sip_addheader(), sip_dtmfmode(), sip_hangup(), sip_new(), sip_pvt_dtor(), sip_pvt_lock_full(), sip_read(), sip_removeheader(), sipinfo_send(), skinny_locksub(), skinny_newcall(), smdi_msg_read(), smdi_msg_retrieve_read(), softhangup_exec(), softmix_bridge_stream_topology_changed(), softmix_bridge_write_voice(), speech_background(), speech_create(), speech_datastore_destroy(), speex_read(), speex_write(), srv_datastore_setup(), srv_query_read(), srv_result_read(), stackpeek_read(), start_monitor_action(), start_monitor_exec(), stasis_app_channel_is_internal(), stasis_app_channel_is_stasis_end_published(), stasis_app_channel_set_internal(), stasis_app_channel_set_stasis_end_published(), stasis_app_exec(), state_notify_build_xml(), stir_shaken_read(), stop_automonitor(), stop_mixmonitor_full(), stream_failsound(), t38_attach_framehook(), testsuite_notify_feature_success(), timeout_write(), transfer_pull(), transmit_invite(), try_calling(), try_parking(), unhold(), unistim_ss(), unreal_colp_redirect_indicate(), unreal_colp_stream_topology_request_change(), unreal_queue_frame(), update_connected_line_from_peer(), update_initial_connected_line(), userevent_exec(), vm_execmain(), volume_read(), volume_write(), wait_for_answer(), wait_for_bridged(), wait_for_empty_queue(), wait_for_initiator(), wait_for_unbridged(), wipe_park_common_datastore(), and wipe_subscription_datastore().

◆ ast_channel_lock_both

#define ast_channel_lock_both (   chan1,
  chan2 
)

◆ AST_CHANNEL_NAME

#define AST_CHANNEL_NAME   80

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

Referenced by agent_bridge_channel_get_lock(), agent_lock_logged(), agent_login_exec(), agents_sweep(), analog_attempt_transfer(), ari_channels_handle_originate_with_id(), ast_autochan_new_channel(), ast_autochan_setup(), ast_bridge_add_channel(), ast_bridge_peer_nolock(), ast_bridge_set_single_src_video_mode(), ast_bridge_update_talker_src_video_mode(), ast_local_get_peer(), ast_local_setup_bridge(), ast_local_setup_masquerade(), ast_unreal_channel_push_to_bridge(), ast_unreal_lock_all(), ast_unreal_queryoption(), ast_unreal_setoption(), async_playback_task_data_alloc(), attach_barge(), attempt_transfer(), attended_transfer_properties_alloc(), blond_nonfinal_enter(), bridge_agent_hold_push(), bridge_channel_attended_transfer(), bridge_stasis_queue_join_action(), call_pickup_incoming_request(), channel_do_masquerade(), conf_start_record(), control_create(), export_aoc_vars(), feature_attended_transfer(), find_ringing_channel(), get_device_state_causing_channels(), get_refer_info(), get_sip_pvt_from_replaces(), get_transfer_party_non_transferer_bridge(), handle_getvariablefull(), handle_invite_replaces(), handle_request_bye(), handle_request_refer(), handle_soft_key_event_message(), hangup_data_alloc(), invite_replaces(), jingle_session_lock_full(), misdn_attempt_transfer(), parking_blind_transfer_park(), pbx_outgoing_attempt(), recalling_exit(), refer_attended_alloc(), retransfer_enter(), set_dial_masquerade(), set_hangup_source_and_cause(), sip_pickup(), sip_pvt_lock_full(), sip_queue_hangup_cause(), snoop_fixup(), socket_process_helper(), stasis_app_control_snoop(), and unreal_queue_frame().

◆ ast_channel_trylock

#define ast_channel_trylock (   chan)    ao2_trylock(chan)

◆ ast_channel_unlock

#define ast_channel_unlock (   chan)    ao2_unlock(chan)

Definition at line 2946 of file channel.h.

Referenced by __after_bridge_set_goto(), __analog_handle_event(), __analog_ss_thread(), __ast_answer(), __ast_channel_alloc_ap(), __ast_pbx_run(), __ast_queue_frame(), __ast_read(), __ast_request_and_dial(), __dahdi_exception(), __sched_check_pendings(), __sip_autodestruct(), _if_exec(), _macro_exec(), _while_exec(), acf_cc_read(), acf_cc_write(), acf_curl_helper(), acf_faxopt_write(), acf_fetch(), acf_odbc_read(), action_add_agi_cmd(), action_agents(), action_atxfer(), action_bridge(), action_cancel_atxfer(), action_dialplan_exec(), action_redirect(), action_status(), action_timeout(), add_features_datastore(), add_to_agi(), after_bridge_goto_remove(), after_bridge_move_channel(), agent_bridge_channel_get_lock(), agent_function_read(), agent_handle_show_specific(), agent_lock_logged(), agent_login_channel_config(), agent_login_exec(), agent_logoff_request(), agent_logout(), agent_request_exec(), agent_show_requested(), alloc_playback_chan(), alsa_call(), alsa_new(), analog_attempt_transfer(), analog_exception(), analog_hangup(), analog_ss_thread(), aoc_publish_blob(), app_control_dial(), app_control_mute(), app_control_unmute(), app_exec(), append_expected_event(), apply_negotiated_sdp_stream(), ari_channels_handle_originate_with_id(), ast_activate_generator(), ast_ari_channels_dial(), ast_ari_channels_rtpstatistics(), ast_async_goto(), ast_atomic_dec_and_test(), ast_audiohook_attach(), ast_audiohook_detach_source(), ast_audiohook_remove(), ast_audiohook_set_mute(), ast_autochan_setup(), ast_autoservice_start(), ast_autoservice_stop(), ast_bridge_add_channel(), ast_bridge_call_with_flags(), ast_bridge_channel_leave_bridge_nolock(), ast_bridge_channel_playfile(), ast_bridge_channel_restore_formats(), ast_bridge_channel_stream_map(), ast_bridge_channel_update_linkedids(), ast_bridge_depart(), ast_bridge_features_ds_get_string(), ast_bridge_features_ds_set_string(), ast_bridge_join(), ast_bridge_notify_masquerade(), ast_bridge_timelimit(), ast_bridge_transfer_acquire_bridge(), ast_bridge_transfer_attended(), ast_bridge_transfer_blind(), ast_bridge_unreal_optimize_out(), ast_call(), ast_call_forward(), ast_cc_agent_set_interfaces_chanvar(), ast_cc_call_init(), ast_cc_completed(), ast_cc_extension_monitor_add_dialstring(), ast_cc_get_current_core_id(), ast_cc_is_recall(), ast_cc_offer(), ast_change_name(), ast_channel_bridge_peer(), ast_channel_by_exten_cb(), ast_channel_by_name_cb(), ast_channel_by_uniqueid_cb(), ast_channel_clear_flag(), ast_channel_clear_softhangup(), ast_channel_connected_line_macro(), ast_channel_connected_line_sub(), ast_channel_defer_dtmf(), ast_channel_destructor(), ast_channel_end_dtmf(), ast_channel_is_t38_active(), ast_channel_make_compatible_helper(), ast_channel_move(), ast_channel_publish_dial_forward(), ast_channel_publish_dial_internal(), ast_channel_queryoption(), ast_channel_redirecting_macro(), ast_channel_redirecting_sub(), ast_channel_request_stream_topology_change(), ast_channel_set_caller(), ast_channel_set_caller_event(), ast_channel_set_connected_line(), ast_channel_set_flag(), ast_channel_set_is_t38_active(), ast_channel_set_redirecting(), ast_channel_set_unbridged(), ast_channel_setoption(), ast_channel_softhangup_withcause_locked(), ast_channel_stream_topology_changed_externally(), ast_channel_unbridged(), ast_channel_yank(), ast_check_hangup_locked(), ast_deactivate_generator(), ast_dial_join(), ast_do_pickup(), ast_eivr_getvariable(), ast_explicit_goto(), ast_handle_cc_control_frame(), ast_hangup(), ast_iax2_new(), ast_ignore_cc(), ast_indicate_data(), ast_jb_create_framehook(), ast_local_setup_bridge(), ast_local_setup_masquerade(), ast_local_unlock_all(), ast_odbc_retrieve_transaction_obj(), ast_openstream_full(), ast_openvstream(), ast_pbx_h_exten_run(), ast_pbx_hangup_handler_destroy(), ast_pbx_hangup_handler_pop(), ast_pbx_hangup_handler_push(), ast_pbx_hangup_handler_run(), ast_pbx_hangup_handler_show(), ast_pbx_outgoing_exten_predial(), ast_pickup_call(), ast_pickup_find_by_group(), ast_pre_call(), ast_queue_hangup(), ast_queue_hangup_with_cause(), ast_queue_hold(), ast_queue_unhold(), ast_raw_answer_with_stream_topology(), ast_read_generator_actions(), ast_rtp_instance_early_bridge(), ast_rtp_instance_early_bridge_make_compatible(), ast_rtp_instance_make_compatible(), ast_rtp_instance_set_stats_vars(), ast_senddigit_begin(), ast_senddigit_end(), ast_sendtext_data(), ast_set_callerid(), ast_set_cc_interfaces_chanvar(), ast_set_hangupsource(), ast_settimeout_full(), ast_setup_cc_recall_datastore(), ast_softhangup(), ast_stir_shaken_add_verification(), ast_stopstream(), ast_str_retrieve_variable(), ast_streamfile(), AST_TEST_DEFINE(), ast_transfer_protocol(), ast_unreal_channel_push_to_bridge(), ast_unreal_hangup(), ast_unreal_indicate(), ast_unreal_lock_all(), ast_unreal_new_channels(), ast_unreal_queryoption(), ast_unreal_setoption(), ast_var_channel_bridge(), ast_var_channels_table(), ast_waitfor_nandfds(), ast_write_stream(), async_play_sound_ready(), async_playback_task_data_alloc(), attach_framehook(), attempt_transfer(), attended_transfer_bridge(), attended_transfer_exec(), attended_transfer_monitor_thread(), attended_transfer_properties_alloc(), audiosocket_request(), auth_exec(), auto_congest(), begin_dial_channel(), begin_dial_prerun(), blind_transfer_bridge(), bridge_channel_change_bridge(), bridge_channel_depart(), bridge_channel_feature_digit_timeout(), bridge_channel_impart_add(), bridge_channel_impart_signal(), bridge_channel_ind_thread(), bridge_channel_internal_join(), bridge_channel_internal_queue_attended_transfer(), bridge_channel_internal_queue_blind_transfer(), bridge_channel_queue_deferred_frames(), bridge_channel_update_accountcodes_joining(), bridge_channel_update_accountcodes_leaving(), bridge_check_monitor(), bridge_exec(), bridge_impart_internal(), bridge_move(), bridge_parking_push(), bridge_reconfigured_connected_line_update(), bridge_stasis_push_peek(), bridge_stasis_queue_join_action(), bridge_timeout(), bridgeadd_exec(), calendar_event_read(), calendar_query_exec(), calendar_query_result_exec(), call_forward_inherit(), caller_id_outgoing_request(), caller_id_outgoing_response(), callerid_read(), callerid_write(), cb_events(), cc_build_payload(), cc_interfaces_datastore_init(), cdr_write(), chan_cleanup(), chan_pjsip_answer(), chan_pjsip_cng_tone_detected(), chan_pjsip_incoming_response(), chan_pjsip_indicate(), chan_pjsip_new(), channel_do_masquerade(), channel_set_cause(), channel_set_debug(), channel_spy(), check_bridge_play_sound(), check_rtp_timeout(), cli_channelstats_print_body(), close_udptl_connection(), common_exec(), conf_find_bridge_profile(), conf_find_user_profile(), conf_run(), conf_set_menu_to_user(), conf_start_moh(), configure_local_rtp(), connectedline_read(), connectedline_write(), console_answer(), console_hangup(), console_new(), console_sendtext(), control_prestart_dispatch_all(), control_swap_channel_in_bridge(), copy_caller_data(), create_alice_channel(), create_dynamic_lot_full(), create_msg_q_chan(), create_parked_subscription_full(), create_transaction(), crement_function_read(), dahdi_handle_dtmf(), dahdi_handle_event(), dahdi_new(), dahdi_queue_frame(), dahdi_softhangup_all(), deactivate_silence_generator(), detect_read(), detect_write(), dial_bridge_after_cb(), dial_exec_full(), dial_transfer(), dialog_info_generate_body_content(), dialog_unlink_all(), dialplan_handle_msg_cb(), disa_exec(), disable_jack_hook(), do_forward(), do_monitor(), do_notify(), dundi_query_read(), dundi_result_read(), dynamic_dtmf_hook_trip(), enable_jack_hook(), end_bridge_callback(), enum_query_read(), enum_result_read(), eval_exten_read(), exec_odbcfinish(), expand_gosub_args(), external_media_audiosocket_tcp(), external_media_rtp_udp(), fast_originate(), fax_detect_attach(), fax_detect_framehook(), fax_gateway_attach(), fax_gateway_detect_t38(), fax_gateway_detect_v21(), fax_gateway_framehook(), fax_gateway_indicate_t38(), fax_gateway_start(), feature_automixmonitor(), feature_automonitor(), feature_blind_transfer(), fetch_bridge_roles_datastore(), fetch_or_create_bridge_roles_datastore(), find_by_mark(), find_by_name(), find_by_uniqueid(), find_channel_by_group(), find_conf_realtime(), find_details(), find_or_create_details(), find_ringing_channel(), find_speech(), find_transaction(), findmeexec(), frame_drop_helper(), frame_trace_helper(), func_channel_read(), func_channel_write_real(), func_channels_read(), func_confbridge_helper(), func_header_read(), func_headers_read2(), func_mixmonitor_read(), function_ooh323_read(), function_ooh323_write(), gather_softmix_stats(), generate_parked_user(), generator_force(), generator_write_format_change(), generic_fax_exec(), get_agi_cmd(), get_chan_by_ast_name(), get_cid_name(), get_device_state_causing_channels(), get_refer_info(), get_replace_channel_store(), get_transfer_parties(), gosub_exec(), gosub_run(), goto_parser(), grab_transfer(), handle_autohangup(), handle_call_forward(), handle_call_outgoing(), handle_cli_agi_add_cmd(), handle_cli_mixmonitor(), handle_exec(), handle_gosub(), handle_incoming_request(), handle_invite_replaces(), handle_negotiated_sdp(), handle_remb_set(), handle_request_bye(), handle_request_do(), handle_request_invite(), handle_request_refer(), handle_show_chanvar(), handle_showchan(), handle_soft_key_event_message(), handle_softhangup(), handle_stimulus_message(), hangupcause_clear_exec(), hangupcause_keys_read(), hangupcause_read(), hold(), hook_callback(), hook_off(), hook_re_enable(), hook_thread_arg_alloc(), iax2_destroy(), iax2_queue_frame(), iax2_queue_hangup(), iax2_queue_hold(), iax2_queue_unhold(), iax2_request(), import_ch(), import_helper(), indicate_busy(), indicate_congestion(), inherit_channel_vars_from_id(), init_hook(), init_jack_data(), internal_bridge_after_cb(), is_colp_update_allowed(), jack_hook_callback(), jingle_action_session_accept(), jingle_action_session_info(), jingle_action_session_initiate(), jingle_action_session_terminate(), jingle_interpret_content(), jingle_new(), jingle_outgoing_hook(), jingle_queue_hangup_with_cause(), jingle_session_lock_full(), launch_monitor_thread(), leave_voicemail(), limits_interval_playback(), listfilter(), local_ast_moh_start(), local_ast_moh_stop(), local_attended_transfer(), local_call(), local_read(), local_write(), lua_get_state(), make_channel(), manager_bridge_kick(), manager_mixmonitor(), manager_park(), manager_park_bridged(), map_source_to_destinations(), mark_transaction_active(), mbl_new(), mbl_queue_control(), mbl_queue_hangup(), meetme_menu_admin_extended(), meetme_stasis_generate_msg(), mgcp_new(), mgcp_pktcgate_remove(), mgcp_queue_frame(), mgcp_queue_hangup(), mgcp_ss(), minivm_delete_exec(), minivm_notify_exec(), misdn_answer(), misdn_attempt_transfer(), misdn_new(), misdn_update_caller_id(), mixmonitor_ds_remove_and_free(), moh_files_generator(), morsecode_exec(), msg_data_func_read(), msg_data_func_write(), msg_func_read(), msg_func_write(), msg_send_exec(), multicast_rtp_request(), mute_channel(), my_handle_dtmf(), MYSQL_exec(), native_bridge_is_capable(), native_chan_changed(), native_rtp_bridge_compatible(), native_rtp_bridge_framehook_attach(), native_rtp_bridge_framehook_detach(), native_rtp_bridge_join(), native_rtp_bridge_start(), native_rtp_bridge_stop(), native_rtp_framehook(), native_rtp_stream_topology_changed(), native_start(), nbs_new(), notify_new_message(), onAlerting(), onCallCleared(), onCallEstablished(), onModeChanged(), onProgress(), ooh323_answer(), ooh323_destroy(), ooh323_new(), ooh323_onReceivedDigit(), ooh323_set_read_format(), ooh323_set_write_format(), optimize_lock_peer_stack(), oss_new(), park_and_announce_app_exec(), park_app_exec(), park_common_setup(), park_local_transfer(), parked_call_app_exec(), parked_call_payload_from_failure(), parked_call_payload_from_parked_user(), parked_call_retrieve_enable_features(), parker_parked_call_message_response(), parking_duration_callback(), parking_park_call(), pbx_builtin_background(), pbx_builtin_getvar_helper(), pbx_builtin_gotoiftime(), pbx_builtin_hangup(), pbx_builtin_pushvar_helper(), pbx_builtin_saycharacters(), pbx_builtin_saycharacters_case(), pbx_builtin_saydigits(), pbx_builtin_saymoney(), pbx_builtin_saynumber(), pbx_builtin_sayphonetic(), pbx_builtin_serialize_variables(), pbx_builtin_setamaflags(), pbx_builtin_setvar_helper(), pbx_exec(), pbx_outgoing_attempt(), peek_read(), phone_new(), pickup_by_channel(), pickup_by_exten(), pickup_by_group(), pickup_by_mark(), pickup_by_part(), pitchshift_helper(), pjsip_acf_channel_read(), pjsip_acf_dtmf_mode_read(), pjsip_acf_dtmf_mode_write(), pjsip_acf_moh_passthrough_read(), pjsip_acf_moh_passthrough_write(), play_failsound(), play_sound(), pop_exec(), pre_bridge_setup(), proc_session_timer(), process_sdp(), publish_dahdichannel(), publish_local_bridge_message(), push_notify_channel(), queue_exec(), queue_publish_multi_channel_blob(), read_config(), realtime_exec(), rec_request(), recall_pull(), recalling_enter(), receive_ademco_event(), redirecting_read(), redirecting_write(), refer_blind_callback(), refer_incoming_invite_request(), refer_outgoing_request(), refer_progress_bridge(), reinvite_timeout(), release_chan(), release_chan_early(), reload(), remove_stasis_end_published(), request_channel(), retrans_pkt(), retransfer_enter(), retrydial_exec(), return_exec(), ring_entry(), ringing(), rtp_check_timeout(), run_agi(), safe_sleep_conditional(), save_dialstring(), sayunixtime_exec(), scramble_write(), send_direct_media_request(), send_provisional_keepalive_full(), send_start_msg(), sendtext_exec(), serialize_showchan(), set_bridge_peer_vars_2party(), set_bridge_peer_vars_holding(), set_bridge_peer_vars_multiparty(), set_caps(), set_config_flags(), set_ext_pri(), set_format(), set_from_header(), set_hangup_source_and_cause(), set_security_requirements(), set_softmix_bridge_data(), set_timeout(), set_transfer_variables_all(), setup_bridge_features_builtin(), setup_bridge_features_dynamic(), setup_mixmonitor(), setup_mixmonitor_ds(), setup_park_common_datastore(), setup_peer_after_bridge_goto(), setup_udptl_connection(), sfu_topologies_on_join(), sfu_topologies_on_source_change(), shared_read(), shared_write(), simple_bridge_join(), simple_bridge_stream_topology_changed(), sip_addheader(), sip_dtmfmode(), sip_hangup(), sip_new(), sip_pvt_dtor(), sip_pvt_lock_full(), sip_queue_hangup_cause(), sip_read(), sip_reinvite_retry(), sip_removeheader(), sip_request_call(), sip_t38_abort(), sipinfo_send(), skinny_new(), skinny_newcall(), skinny_unlocksub(), smdi_msg_read(), smdi_msg_retrieve_read(), socket_process_helper(), softhangup_exec(), softmix_bridge_stream_topology_changed(), softmix_bridge_write_voice(), speech_background(), speech_create(), speech_datastore_destroy(), speex_read(), speex_write(), srv_datastore_setup(), srv_query_read(), srv_result_read(), stackpeek_read(), start_monitor_action(), start_monitor_exec(), stasis_app_channel_is_internal(), stasis_app_channel_is_stasis_end_published(), stasis_app_channel_set_internal(), stasis_app_channel_set_stasis_end_published(), stasis_app_channel_unreal_set_internal(), stasis_app_control_snoop(), stasis_app_exec(), state_notify_build_xml(), stir_shaken_read(), stop_automonitor(), stop_mixmonitor_full(), stream_failsound(), t38_attach_framehook(), test_vm_api_create_mock_channel(), testsuite_notify_feature_success(), timeout_write(), transfer_pull(), transmit_invite(), try_calling(), try_parking(), try_swap_optimize_out(), unhold(), unicast_rtp_request(), unistim_new(), unistim_ss(), unreal_colp_redirect_indicate(), unreal_colp_stream_topology_request_change(), unreal_queue_frame(), update_connected_line_from_peer(), update_initial_connected_line(), userevent_exec(), vm_execmain(), volume_read(), volume_write(), wait_for_answer(), wait_for_bridged(), wait_for_digits(), wait_for_empty_queue(), wait_for_initiator(), wait_for_unbridged(), wakeup_sub(), wipe_park_common_datastore(), and wipe_subscription_datastore().

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

Referenced by __ast_channel_alloc_ap(), __ast_channel_internal_alloc(), __sched_check_pendings(), __sip_autodestruct(), acf_odbc_read(), acf_odbc_write(), action_add_agi_cmd(), action_agents(), action_aocmessage(), action_atxfer(), action_blind_transfer(), action_cancel_atxfer(), action_getvar(), action_hangup(), action_redirect(), action_sendtext(), action_setvar(), action_status(), action_timeout(), agent_bridge_channel_get_lock(), agent_function_read(), agent_handle_show_specific(), agent_lock_logged(), agent_logoff_request(), agent_logout(), agent_pvt_destructor(), agent_show_requested(), agents_sweep(), analog_attempt_transfer(), ari_channels_handle_originate_with_id(), ast_add_extension2_lockopt(), ast_async_goto_by_name(), ast_autochan_destroy(), ast_autochan_new_channel(), ast_bridge_add_channel(), ast_bridge_remove_video_src(), ast_bridge_update_talker_src_video_mode(), ast_cel_fabricate_channel_from_event(), ast_channel_release(), ast_hangup(), ast_local_unlock_all(), ast_parse_device_state(), ast_pickup_call(), ast_pickup_find_by_group(), ast_rtp_instance_set_stats_vars(), ast_str_substitute_variables_full(), AST_TEST_DEFINE(), ast_unreal_channel_push_to_bridge(), ast_unreal_hangup(), ast_unreal_indicate(), ast_unreal_lock_all(), ast_unreal_queryoption(), ast_unreal_setoption(), ast_var_channel_bridge(), ast_var_channel_types_table(), ast_var_channels_table(), asyncgoto_exec(), attach_barge(), attempt_transfer(), blond_nonfinal_enter(), blond_nonfinal_exit(), bridge_agent_hold_push(), bridge_channel_attended_transfer(), bridge_exec(), bridgeadd_exec(), call_forwarded_handler(), call_pickup_incoming_request(), change_monitor_action(), channel_do_masquerade(), cleanup_video_mode(), cli_odbc_read(), cli_odbc_write(), common_exec(), conf_start_record(), conf_stop_record(), controlplayback_manager(), custom_log(), dialog_info_generate_body_content(), dialog_unlink_all(), do_pause_or_unpause(), does_id_conflict(), external_media_audiosocket_tcp(), external_media_rtp_udp(), fast_originate(), func_channel_read(), func_channels_read(), func_mchan_read(), func_mchan_write(), get_device_state_causing_channels(), handle_bridge_kick_channel(), handle_cli_agi_add_cmd(), handle_cli_mixmonitor(), handle_core_set_debug_channel(), handle_getvariablefull(), handle_hangup(), handle_incoming_request(), handle_invite_replaces(), handle_redirect(), handle_remb_set(), handle_request_do(), handle_set_chanvar(), handle_show_chanvar(), handle_show_hangup_all(), handle_show_hangup_channel(), handle_showchan(), handle_soft_key_event_message(), handle_softhangup(), hangup_data_destroy(), import_helper(), jingle_action_session_accept(), jingle_action_session_info(), jingle_action_session_terminate(), jingle_interpret_content(), jingle_outgoing_hook(), jingle_queue_hangup_with_cause(), jingle_session_lock_full(), load_values_config(), local_call(), make_email_file(), manager_log(), manager_mixmonitor(), manager_mute_mixmonitor(), manager_mutestream(), manager_optimize_away(), manager_play_dtmf(), manager_play_mf(), manager_stop_mixmonitor(), misdn_attempt_transfer(), next_channel(), park_local_transfer(), parking_blind_transfer_park(), pbx_builtin_importvar(), pbx_outgoing_attempt(), pbx_substitute_variables_helper_full(), pickup_by_channel(), pickup_by_exten(), pickup_by_group(), pickup_by_mark(), pickup_by_part(), proc_session_timer(), publish_local_bridge_message(), push_notify_channel(), recalling_exit(), refer_incoming_invite_request(), refer_progress_bridge(), reinvite_timeout(), retrans_pkt(), retransfer_enter(), retransfer_exit(), rotate_file(), rtp_check_timeout(), send_provisional_keepalive_full(), senddtmf_exec(), sendmail(), sendmf_exec(), sendpage(), set_hangup_source_and_cause(), shared_read(), shared_write(), sip_pickup(), sip_pickup_thread(), sip_pvt_lock_full(), sip_queue_hangup_cause(), sip_reinvite_retry(), sip_t38_abort(), skinny_new(), snoop_fixup(), socket_process_helper(), softhangup_exec(), start_monitor_action(), stasis_app_channel_unreal_set_internal(), state_notify_build_xml(), stop_monitor_action(), syslog_log(), unreal_colp_redirect_indicate(), unreal_colp_stream_topology_request_change(), unreal_queue_frame(), vm_allocate_dh(), and write_cel().

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

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

◆ AST_EXTENDED_FDS

#define AST_EXTENDED_FDS   12

the start of extended file descriptor positions

Definition at line 196 of file channel.h.

Referenced by ast_channel_fd_add(), AST_TEST_DEFINE(), chan_pjsip_read_stream(), check_for_rtp_changes(), and handle_negotiated_sdp().

◆ AST_FEATURE_DTMF_MASK

#define AST_FEATURE_DTMF_MASK

◆ AST_GENERATOR_FD

#define AST_GENERATOR_FD   (AST_MAX_FDS-4)

used by generator

Definition at line 204 of file channel.h.

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

◆ AST_JITTERBUFFER_FD

#define AST_JITTERBUFFER_FD   (AST_MAX_FDS-5)

used by generator

Definition at line 205 of file channel.h.

Referenced by __ast_read(), ast_jb_create_framehook(), and hook_event_cb().

◆ AST_MAX_ACCOUNT_CODE

#define AST_MAX_ACCOUNT_CODE   80

Max length of an account code

Definition at line 171 of file channel.h.

◆ AST_MAX_CONTEXT

#define AST_MAX_CONTEXT   80

◆ AST_MAX_EXTENSION

#define AST_MAX_EXTENSION   80

Max length of an extension

Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 135 of file channel.h.

Referenced by __analog_ss_thread(), __ast_context_destroy(), add_extensions(), advanced_options(), analog_ss_thread(), ast_beep_start(), ast_devstate_changed(), ast_ivr_menu_run_internal(), ast_presence_state_changed(), blind_transfer_bridge(), build_device(), cc_extension_monitor_init(), conf_run(), device_state_notify_callbacks(), dial_exec_full(), disa_exec(), do_magic_pickup(), dundi_lookup_local(), feature_attended_transfer(), feature_blind_transfer(), find_conf_realtime(), forward_message(), function_enum(), get_destination(), handle_call_forward(), handle_request_invite(), handle_show_hint(), handle_show_hints(), handle_soft_key_event_message(), handle_stimulus_message(), iax2_exec(), load_module(), log_exec(), manager_show_dialplan_helper(), mgcp_ss(), ooh323_call(), ooh323_request(), options_on_rx_request(), park_local_transfer(), parking_duration_callback(), parking_lot_cfg_create_extensions(), pbx_substitute_variables_helper(), phone_check_exception(), presence_state_notify_callbacks(), process_dahdi(), realtime_common(), realtime_switch_common(), refer_incoming_blind_request(), retransfer_enter(), rx_data_to_ast_msg(), session_inv_on_redirected(), show_dialplan_helper(), skinny_extensionstate_cb(), sla_build_station(), sla_station_destructor(), speech_background(), state_notify_build_xml(), test_vm_api_create_mock_snapshot(), try_calling(), vm_authenticate(), and vmauthenticate().

◆ AST_MAX_FDS

#define AST_MAX_FDS   11

original maximum number of file descriptors

Definition at line 195 of file channel.h.

Referenced by __ast_channel_internal_alloc().

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

Referenced by action_originate(), and ari_channels_handle_originate_with_id().

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

◆ AST_MAX_USER_FIELD

#define AST_MAX_USER_FIELD   256

Max length of the channel user field

Definition at line 175 of file channel.h.

Referenced by ast_rtp_instance_set_stats_vars(), handle_request_bye(), sip_acf_channel_read(), sip_hangup(), and tds_log().

◆ AST_MUTE_DIRECTION_READ

#define AST_MUTE_DIRECTION_READ   (1 << 0)

◆ AST_MUTE_DIRECTION_WRITE

#define AST_MUTE_DIRECTION_WRITE   (1 << 1)

◆ AST_NUM_CHANNEL_BUCKETS

#define AST_NUM_CHANNEL_BUCKETS   1567

The number of buckets to store channels or channel information

Definition at line 156 of file channel.h.

Referenced by ast_channels_init(), ast_stasis_channels_init(), and load_module().

◆ AST_TIMING_FD

#define AST_TIMING_FD   (AST_MAX_FDS-2)

used for timingfd

Definition at line 202 of file channel.h.

Referenced by __ast_channel_alloc_ap(), __ast_read(), ast_settimeout_full(), and channel_do_masquerade().

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

Referenced by ast_sendtext_data(), ast_waitfor_nandfds(), ast_write_stream(), dahdi_read(), and phone_read().

◆ DATASTORE_INHERIT_FOREVER

#define DATASTORE_INHERIT_FOREVER   INT_MAX

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

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

◆ 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)))
Main Channel structure associated with a channel.
static snd_pcm_format_t format
Definition: chan_alsa.c:102

Definition at line 4257 of file channel.h.

◆ FRAMECOUNT_INC

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

Definition at line 861 of file channel.h.

Referenced by __ast_read(), and ast_write_stream().

◆ MAX_LANGUAGE

#define MAX_LANGUAGE   40

Max length of the language setting

Definition at line 173 of file channel.h.

Referenced by load_asterisk_conf().

◆ MAX_MUSICCLASS

#define MAX_MUSICCLASS   80

Max length of the music class setting

Definition at line 174 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 581 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 575 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 587 of file channel.h.

◆ ast_group_t

typedef unsigned long long ast_group_t

Definition at line 214 of file channel.h.

◆ ast_timing_func_t

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

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

956  {
957  /*!
958  * \brief Channels have this property if they can accept input with jitter;
959  * i.e. most VoIP channels
960  */
961  AST_CHAN_TP_WANTSJITTER = (1 << 0),
962  /*!
963  * \brief Channels have this property if they can create jitter;
964  * i.e. most VoIP channels
965  */
966  AST_CHAN_TP_CREATESJITTER = (1 << 1),
967  /*!
968  * \brief Channels with this particular technology are an implementation detail of
969  * Asterisk and should generally not be exposed or manipulated by the outside
970  * world
971  */
972  AST_CHAN_TP_INTERNAL = (1 << 2),
973  /*!
974  * \brief Channels have this property if they implement send_text_data
975  */
976  AST_CHAN_TP_SEND_TEXT_DATA = (1 << 3),
977 };
Channels have this property if they implement send_text_data.
Definition: channel.h:976
Channels have this property if they can accept input with jitter; i.e. most VoIP channels.
Definition: channel.h:961
Channels with this particular technology are an implementation detail of Asterisk and should generall...
Definition: channel.h:972
Channels have this property if they can create jitter; i.e. most VoIP channels.
Definition: channel.h:966

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

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

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

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

1117  {
1118  /*!
1119  * Soft hangup requested by device or other internal reason.
1120  * Actual hangup needed.
1121  */
1122  AST_SOFTHANGUP_DEV = (1 << 0),
1123  /*!
1124  * Used to break the normal frame flow so an async goto can be
1125  * done instead of actually hanging up.
1126  */
1127  AST_SOFTHANGUP_ASYNCGOTO = (1 << 1),
1128  /*!
1129  * Soft hangup requested by system shutdown. Actual hangup
1130  * needed.
1131  */
1132  AST_SOFTHANGUP_SHUTDOWN = (1 << 2),
1133  /*!
1134  * Used to break the normal frame flow after a timeout so an
1135  * implicit async goto can be done to the 'T' exten if it exists
1136  * instead of actually hanging up. If the exten does not exist
1137  * then actually hangup.
1138  */
1139  AST_SOFTHANGUP_TIMEOUT = (1 << 3),
1140  /*!
1141  * Soft hangup requested by application/channel-driver being
1142  * unloaded. Actual hangup needed.
1143  */
1144  AST_SOFTHANGUP_APPUNLOAD = (1 << 4),
1145  /*!
1146  * Soft hangup requested by non-associated party. Actual hangup
1147  * needed.
1148  */
1149  AST_SOFTHANGUP_EXPLICIT = (1 << 5),
1150  /*!
1151  * Used to indicate that the channel is currently executing hangup
1152  * logic in the dialplan. The channel has been hungup when this is
1153  * set.
1154  */
1155  AST_SOFTHANGUP_HANGUP_EXEC = (1 << 7),
1156  /*!
1157  * \brief All softhangup flags.
1158  *
1159  * This can be used as an argument to ast_channel_clear_softhangup()
1160  * to clear all softhangup flags from a channel.
1161  */
1162  AST_SOFTHANGUP_ALL = (0xFFFFFFFF)
1163 };
All softhangup flags.
Definition: channel.h:1162

◆ ama_flags

enum ama_flags

Channel AMA Flags.

Enumerator
AST_AMA_NONE 
AST_AMA_OMIT 
AST_AMA_BILLING 
AST_AMA_DOCUMENTATION 

Definition at line 1178 of file channel.h.

◆ ast_bridge_result

Enumerator
AST_BRIDGE_COMPLETE 
AST_BRIDGE_FAILED 
AST_BRIDGE_FAILED_NOWARN 
AST_BRIDGE_RETRY 

Definition at line 207 of file channel.h.

◆ ast_channel_adsicpe

Enumerator
AST_ADSI_UNKNOWN 
AST_ADSI_AVAILABLE 
AST_ADSI_UNAVAILABLE 
AST_ADSI_OFFHOOKONLY 

Definition at line 869 of file channel.h.

◆ ast_channel_error

Enumerator
AST_CHANNEL_ERROR_UNKNOWN 
AST_CHANNEL_ERROR_ID_EXISTS 

Definition at line 5020 of file channel.h.

5020  {
5021  /* Unable to determine what error occurred. */
5023  /* Channel with this ID already exists */
5025 };

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

1477  {
1478  /*! The requestor is the future bridge peer of the channel. */
1480  /*! The requestor is to be replaced by the channel. */
1482 };

◆ AST_MONITORING_STATE

Enumerator
AST_MONITOR_RUNNING 
AST_MONITOR_PAUSED 

Definition at line 4233 of file channel.h.

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

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

879  {
880  T38_STATE_UNAVAILABLE, /*!< T38 is unavailable on this channel or disabled by configuration */
881  T38_STATE_UNKNOWN, /*!< The channel supports T38 but the current status is unknown */
882  T38_STATE_NEGOTIATING, /*!< T38 is being negotiated */
883  T38_STATE_REJECTED, /*!< Remote side has rejected our offer */
884  T38_STATE_NEGOTIATED, /*!< T38 established */
885 };

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

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

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

2705 {
2706  int res = 0;
2707  enum ast_channel_state old_state;
2708  SCOPE_TRACE(1, "%s\n", ast_channel_name(chan));
2709 
2710  old_state = ast_channel_state(chan);
2711  if ((res = ast_raw_answer(chan))) {
2712  return res;
2713  }
2714 
2715  switch (old_state) {
2716  case AST_STATE_RINGING:
2717  case AST_STATE_RING:
2718  /* wait for media to start flowing, but don't wait any longer
2719  * than 'delay' or 500 milliseconds, whichever is longer
2720  */
2721  do {
2723  struct ast_frame *cur;
2724  struct ast_frame *new_frame;
2725  int timeout_ms = MAX(delay, 500);
2726  unsigned int done = 0;
2727  struct timeval start;
2728 
2730 
2731  start = ast_tvnow();
2732  for (;;) {
2733  int ms = ast_remaining_ms(start, timeout_ms);
2734  ms = ast_waitfor(chan, ms);
2735  if (ms < 0) {
2736  ast_log(LOG_WARNING, "Error condition occurred when polling channel %s for a voice frame: %s\n", ast_channel_name(chan), strerror(errno));
2737  res = -1;
2738  break;
2739  }
2740  if (ms == 0) {
2741  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));
2742  break;
2743  }
2744  cur = ast_read(chan);
2745  if (!cur || ((cur->frametype == AST_FRAME_CONTROL) &&
2746  (cur->subclass.integer == AST_CONTROL_HANGUP))) {
2747  if (cur) {
2748  ast_frfree(cur);
2749  }
2750  res = -1;
2751  ast_debug(2, "Hangup of channel %s detected in answer routine\n", ast_channel_name(chan));
2752  break;
2753  }
2754 
2755  if ((new_frame = ast_frisolate(cur)) != cur) {
2756  ast_frfree(cur);
2757  }
2758 
2759  AST_LIST_INSERT_HEAD(&frames, new_frame, frame_list);
2760 
2761  /* if a specific delay period was requested, continue
2762  * until that delay has passed. don't stop just because
2763  * incoming media has arrived.
2764  */
2765  if (delay) {
2766  continue;
2767  }
2768 
2769  switch (new_frame->frametype) {
2770  /* all of these frametypes qualify as 'media' */
2771  case AST_FRAME_VOICE:
2772  case AST_FRAME_VIDEO:
2773  case AST_FRAME_TEXT:
2774  case AST_FRAME_TEXT_DATA:
2775  case AST_FRAME_DTMF_BEGIN:
2776  case AST_FRAME_DTMF_END:
2777  case AST_FRAME_IMAGE:
2778  case AST_FRAME_HTML:
2779  case AST_FRAME_MODEM:
2780  case AST_FRAME_RTCP:
2781  done = 1;
2782  break;
2783  case AST_FRAME_CONTROL:
2784  case AST_FRAME_IAX:
2787  case AST_FRAME_NULL:
2788  case AST_FRAME_CNG:
2789  break;
2790  }
2791 
2792  if (done) {
2793  break;
2794  }
2795  }
2796 
2797  ast_channel_lock(chan);
2798  while ((cur = AST_LIST_REMOVE_HEAD(&frames, frame_list))) {
2799  if (res == 0) {
2800  ast_queue_frame_head(chan, cur);
2801  }
2802  ast_frfree(cur);
2803  }
2804  ast_channel_unlock(chan);
2805  } while (0);
2806  break;
2807  default:
2808  break;
2809  }
2810 
2811  return res;
2812 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define LOG_WARNING
Definition: logger.h:274
ast_channel_state
ast_channel states
Definition: channelstate.h:35
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:150
struct ast_frame_subclass subclass
int done
Definition: test_amihooks.c:48
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
#define MAX(a, b)
Definition: utils.h:228
static int frames
Definition: parser.c:51
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:832
AST_LIST_HEAD_NOLOCK(contactliststruct, contact)
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
Definition: main/utils.c:2033
int errno
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4302
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: linkedlists.h:710
#define ast_channel_unlock(chan)
Definition: channel.h:2946
#define ast_frisolate(fr)
Makes a frame independent of any static storage.
int ast_raw_answer(struct ast_channel *chan)
Answer a channel.
Definition: channel.c:2699
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
Definition: linkedlists.h:680
#define SCOPE_TRACE(level,...)
Print a trace message with details when a scope is entered or existed.
Definition: logger.h:749
const char * ast_channel_name(const struct ast_channel *chan)
int ast_waitfor(struct ast_channel *c, int ms)
Wait for input on a channel.
Definition: channel.c:3171
#define ast_frfree(fr)
Data structure associated with a single frame of data.
enum ast_frame_type frametype
int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to the head of a channel&#39;s frame queue.
Definition: channel.c:1144

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

References __ast_channel_alloc_ap(), and result.

967 {
968  va_list ap;
969  struct ast_channel *result;
970 
971  va_start(ap, name_fmt);
972  result = __ast_channel_alloc_ap(needqueue, state, cid_num, cid_name, acctcode, exten, context,
973  assignedids, requestor, amaflag, endpoint, file, line, function, name_fmt, ap);
974  va_end(ap);
975 
976  return result;
977 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
Main Channel structure associated with a channel.
static char cid_num[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:164
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, const char *file, int line, const char *function, const char *name_fmt, va_list ap)
Create a new channel structure.
Definition: channel.c:739
static char cid_name[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:165
static PGresult * result
Definition: cel_pgsql.c:88
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116

◆ __ast_dummy_channel_alloc()

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

Definition at line 981 of file channel.c.

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(), NULL, and tmp().

982 {
983  struct ast_channel *tmp;
984  struct varshead *headp;
985 
987  file, line, function);
988  if (!tmp) {
989  /* Dummy channel structure allocation failure. */
990  return NULL;
991  }
992 
995 
996  /*
997  * Init file descriptors to unopened state just in case
998  * autoservice is called on the channel or something tries to
999  * read a frame from it.
1000  */
1001  ast_channel_timingfd_set(tmp, -1);
1004 
1006 
1008 
1009  headp = ast_channel_varshead(tmp);
1011 
1012  return tmp;
1013 }
void ast_channel_internal_alertpipe_clear(struct ast_channel *chan)
Main Channel structure associated with a channel.
static void ast_dummy_channel_destructor(void *obj)
Free a dummy channel structure.
Definition: channel.c:2338
void ast_pbx_hangup_handler_init(struct ast_channel *chan)
Init the hangup handler container on a channel.
static int tmp()
Definition: bt_open.c:389
struct varshead * ast_channel_varshead(struct ast_channel *chan)
#define NULL
Definition: resample.c:96
void ast_channel_internal_fd_clear_all(struct ast_channel *chan)
struct ast_datastore_list * ast_channel_datastores(struct ast_channel *chan)
void ast_channel_timingfd_set(struct ast_channel *chan, int value)
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
Definition: linkedlists.h:680
void ast_channel_hold_state_set(struct ast_channel *chan, int value)
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_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 6066 of file channel.c.

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(), chanlist::chan, outgoing_helper::cid_name, outgoing_helper::cid_num, outgoing_helper::connect_on_early_media, outgoing_helper::context, ast_frame::data, ast_frame::datalen, outgoing_helper::exten, ast_frame::frametype, handle_cause(), ast_party_connected_line::id, ast_frame_subclass::integer, LOG_NOTICE, ast_party_id::name, NULL, ast_party_id::number, outgoing_helper::parent_channel, ast_party_name::presentation, ast_party_number::presentation, outgoing_helper::priority, ast_frame::ptr, ast_party_name::str, ast_party_number::str, ast_frame::subclass, ast_party_name::valid, ast_party_number::valid, and outgoing_helper::vars.

Referenced by announce_to_dial(), and ast_request_and_dial().

6067 {
6068  int dummy_outstate;
6069  int cause = 0;
6070  struct ast_channel *chan;
6071  int res = 0;
6072  int last_subclass = 0;
6074 
6075  if (outstate)
6076  *outstate = 0;
6077  else
6078  outstate = &dummy_outstate; /* make outstate always a valid pointer */
6079 
6080  chan = ast_request(type, cap, assignedids, requestor, addr, &cause);
6081  if (!chan) {
6082  ast_log(LOG_NOTICE, "Unable to request channel %s/%s\n", type, addr);
6083  handle_cause(cause, outstate);
6084  return NULL;
6085  }
6086 
6087  if (oh) {
6088  if (oh->vars) {
6089  ast_channel_lock(chan);
6090  ast_set_variables(chan, oh->vars);
6091  ast_channel_unlock(chan);
6092  }
6093  if (!ast_strlen_zero(oh->cid_num) && !ast_strlen_zero(oh->cid_name)) {
6094  /*
6095  * Use the oh values instead of the function parameters for the
6096  * outgoing CallerID.
6097  */
6098  cid_num = oh->cid_num;
6099  cid_name = oh->cid_name;
6100  }
6101  if (oh->parent_channel) {
6102  /* Safely inherit variables and datastores from the parent channel. */
6108  ast_channel_unlock(chan);
6109  }
6110  if (!ast_strlen_zero(oh->account)) {
6111  ast_channel_lock(chan);
6113  ast_channel_accountcode_set(chan, oh->account);
6114  ast_channel_peeraccount_set(chan, oh->account);
6116  ast_channel_unlock(chan);
6117  }
6118  }
6119 
6120  /*
6121  * I seems strange to set the CallerID on an outgoing call leg
6122  * to whom we are calling, but this function's callers are doing
6123  * various Originate methods. This call leg goes to the local
6124  * user. Once the local user answers, the dialplan needs to be
6125  * able to access the CallerID from the CALLERID function as if
6126  * the local user had placed this call.
6127  */
6129 
6130  ast_channel_lock(chan);
6132  ast_channel_unlock(chan);
6134  if (cid_num) {
6135  connected.id.number.valid = 1;
6136  connected.id.number.str = (char *) cid_num;
6137  connected.id.number.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
6138  }
6139  if (cid_name) {
6140  connected.id.name.valid = 1;
6141  connected.id.name.str = (char *) cid_name;
6143  }
6145  if (requestor) {
6146  ast_channel_lock_both(chan, (struct ast_channel *) requestor);
6148  ast_channel_unlock(chan);
6149  ast_channel_unlock((struct ast_channel *) requestor);
6150  }
6151 
6152  if (ast_call(chan, addr, 0)) { /* ast_call failed... */
6153  ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, addr);
6154  } else {
6155  struct timeval start = ast_tvnow();
6156  res = 1; /* mark success in case chan->_state is already AST_STATE_UP */
6157  while (timeout && ast_channel_state(chan) != AST_STATE_UP) {
6158  struct ast_frame *f;
6159  int ms = ast_remaining_ms(start, timeout);
6160 
6161  res = ast_waitfor(chan, ms);
6162  if (res == 0) { /* timeout, treat it like ringing */
6163  *outstate = AST_CONTROL_RINGING;
6164  break;
6165  }
6166  if (res < 0) /* error or done */
6167  break;
6169  if (!(chan = ast_call_forward(NULL, chan, NULL, cap, oh, outstate))) {
6170  return NULL;
6171  }
6172  continue;
6173  }
6174 
6175  f = ast_read(chan);
6176  if (!f) {
6177  *outstate = AST_CONTROL_HANGUP;
6178  res = 0;
6179  break;
6180  }
6181  if (f->frametype == AST_FRAME_CONTROL) {
6182  switch (f->subclass.integer) {
6183  case AST_CONTROL_RINGING: /* record but keep going */
6184  *outstate = f->subclass.integer;
6185  break;
6186 
6187  case AST_CONTROL_BUSY:
6188  *outstate = f->subclass.integer;
6189  timeout = 0;
6190  break;
6191 
6193  *outstate = AST_CONTROL_CONGESTION;
6194  timeout = 0;
6195  break;
6196 
6198  *outstate = f->subclass.integer;
6199  timeout = 0;
6200  break;
6201 
6202  case AST_CONTROL_ANSWER:
6203  *outstate = f->subclass.integer;
6204  timeout = 0; /* trick to force exit from the while() */
6205  break;
6206 
6209  break;
6210 
6211  case AST_CONTROL_PROGRESS:
6212  if (oh && oh->connect_on_early_media) {
6213  *outstate = f->subclass.integer;
6214  timeout = 0; /* trick to force exit from the while() */
6215  break;
6216  }
6217  /* Fallthrough */
6218  /* Ignore these */
6220  case AST_CONTROL_HOLD:
6221  case AST_CONTROL_UNHOLD:
6222  case AST_CONTROL_VIDUPDATE:
6223  case AST_CONTROL_SRCUPDATE:
6224  case AST_CONTROL_SRCCHANGE:
6227  case AST_CONTROL_CC:
6228  case -1: /* Ignore -- just stopping indications */
6229  break;
6230 
6231  default:
6232  ast_log(LOG_NOTICE, "Don't know what to do with control frame %d\n", f->subclass.integer);
6233  }
6234  last_subclass = f->subclass.integer;
6235  }
6236  ast_frfree(f);
6237  }
6238  }
6239 
6240  /* Final fixups */
6241  if (oh) {
6242  if (!ast_strlen_zero(oh->context))
6243  ast_channel_context_set(chan, oh->context);
6244  if (!ast_strlen_zero(oh->exten))
6245  ast_channel_exten_set(chan, oh->exten);
6246  if (oh->priority)
6248  }
6249  if (ast_channel_state(chan) == AST_STATE_UP)
6250  *outstate = AST_CONTROL_ANSWER;
6251 
6252  if (res <= 0) {
6253  ast_channel_lock(chan);
6254  if (AST_CONTROL_RINGING == last_subclass) {
6256  }
6257  ast_channel_unlock(chan);
6258  ast_hangup(chan);
6259  chan = NULL;
6260  }
6261  return chan;
6262 }
static const char type[]
Definition: chan_ooh323.c:109
#define ast_channel_lock(chan)
Definition: channel.h:2945
Main Channel structure associated with a channel.
const char * cid_num
Definition: channel.h:1110
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:2045
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:8404
struct ast_channel * parent_channel
Definition: channel.h:1114
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
#define ast_set_flag(p, flag)
Definition: utils.h:70
static int timeout
Definition: cdr_mysql.c:86
ast_channel_state
ast_channel states
Definition: channelstate.h:35
int connect_on_early_media
Definition: channel.h:1109
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:150
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:6866
#define NULL
Definition: resample.c:96
#define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED
Definition: callerid.h:329
const char * ast_channel_call_forward(const struct ast_channel *chan)
static char cid_num[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:164
struct ast_variable * vars
Definition: channel.h:1113
struct ast_frame_subclass subclass
int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to)
Inherit datastores from a parent to a child.
Definition: channel.c:2373
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&#39;s call_forward str...
Definition: channel.c:5988
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_log
Definition: astobj2.c:42
const char * exten
Definition: channel.h:1107
const char * cid_name
Definition: channel.h:1111
int ast_call(struct ast_channel *chan, const char *addr, int timeout)
Make a call.
Definition: channel.c:6553
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
const char * account
Definition: channel.h:1112
static void handle_cause(int cause, int *outstate)
Definition: channel.c:5936
#define AST_CAUSE_NO_ANSWER
Definition: causes.h:108
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
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:6526
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
Definition: main/utils.c:2033
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:7434
Connected Line/Party information.
Definition: channel.h:457
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4302
#define LOG_NOTICE
Definition: logger.h:263
#define ast_channel_unlock(chan)
Definition: channel.h:2946
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:4391
static char cid_name[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:165
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition: channel.h:2952
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:6444
int ast_max_forwards_decrement(struct ast_channel *chan)
Decrement the max forwards count for a particular channel.
Definition: max_forwards.c:135
void ast_channel_context_set(struct ast_channel *chan, const char *value)
const char * context
Definition: channel.h:1106
int ast_waitfor(struct ast_channel *c, int ms)
Wait for input on a channel.
Definition: channel.c:3171
#define ast_frfree(fr)
void ast_hangup(struct ast_channel *chan)
Hangup a channel.
Definition: channel.c:2548
Data structure associated with a single frame of data.
union ast_frame::@263 data
enum ast_frame_type frametype
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
void ast_channel_priority_set(struct ast_channel *chan, int value)
char connected
Definition: eagi_proxy.c:82
void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars)
adds a list of channel variables to a channel
Definition: channel.c:8217

◆ ast_activate_generator()

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

Activate a given generator

Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 2960 of file channel.c.

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(), 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(), eivr_comm(), local_ast_moh_start(), old_milliwatt_exec(), sms_exec(), spandsp_fax_gateway_start(), and transmit_audio().

2961 {
2962  int res = 0;
2963  void *generatordata = NULL;
2964 
2965  ast_channel_lock(chan);
2966  if (ast_channel_generatordata(chan)) {
2967  struct ast_generator *generator_old = ast_channel_generator(chan);
2968 
2969  if (generator_old && generator_old->release) {
2970  generator_old->release(chan, ast_channel_generatordata(chan));
2971  }
2972  }
2973  if (gen->alloc && !(generatordata = gen->alloc(chan, params))) {
2974  res = -1;
2975  }
2976  ast_channel_generatordata_set(chan, generatordata);
2977  if (!res) {
2978  ast_settimeout(chan, 50, generator_force, chan);
2979  ast_channel_generator_set(chan, gen);
2980  }
2981  ast_channel_unlock(chan);
2982 
2983  ast_prod(chan);
2984 
2985  return res;
2986 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
void * ast_channel_generatordata(const struct ast_channel *chan)
void *(* alloc)(struct ast_channel *chan, void *params)
Definition: channel.h:227
void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator *value)
#define NULL
Definition: resample.c:96
void ast_channel_generatordata_set(struct ast_channel *chan, void *value)
void(* release)(struct ast_channel *chan, void *data)
Definition: channel.h:229
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:3189
struct ast_generator * ast_channel_generator(const struct ast_channel *chan)
#define ast_channel_unlock(chan)
Definition: channel.h:2946
int ast_prod(struct ast_channel *chan)
Send empty audio to prime a channel driver.
Definition: channel.c:5045
static int generator_force(const void *data)
Definition: channel.c:2925

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

References ao2_container_count().

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

500 {
501  return channels ? ao2_container_count(channels) : 0;
502 }
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:124

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

Referenced by ast_waitfor_nandfds().

2843 {
2844  pfd->fd = fd;
2845  pfd->events = POLLIN | POLLPRI;
2846  return fd >= 0;
2847 }

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

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

Referenced by agent_login_exec(), agi_exec_full(), alarmreceiver_exec(), announce_request(), answer_trunk_chan(), 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(), dahdiras_exec(), dial_exec_full(), dictate_exec(), directory_exec(), disa_exec(), eivr_comm(), handle_answer(), ices_exec(), 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(), sms_exec(), speech_background(), testclient_exec(), testserver_exec(), transmit(), vm_exec(), vm_execmain(), vm_playmsgexec(), waitfor_exec(), and zapateller_exec().

2815 {
2816  SCOPE_TRACE(1, "%s\n", ast_channel_name(chan));
2817  return __ast_answer(chan, 0);
2818 }
int __ast_answer(struct ast_channel *chan, unsigned int delay)
Answer a channel, with a selectable delay before returning.
Definition: channel.c:2704
#define SCOPE_TRACE(level,...)
Print a trace message with details when a scope is entered or existed.
Definition: logger.h:749
const char * ast_channel_name(const struct ast_channel *chan)

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

References ast_answer(), and AST_STATE_UP.

Referenced by record_file().

2821 {
2822  if (ast_channel_state(chan) == AST_STATE_UP) {
2823  /* Already answered */
2824  return 0;
2825  }
2826  return ast_answer(chan);
2827 }
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition: channel.c:2814
ast_channel_state
ast_channel states
Definition: channelstate.h:35

◆ 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.
Returns
Nothing

Definition at line 342 of file autoservice.c.

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

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

343 {
344  if (chan && !ast_autoservice_start(chan)) {
345  ast_hangup(peer);
346  ast_autoservice_stop(chan);
347  } else {
348  ast_hangup(peer);
349  }
350 }
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
Definition: autoservice.c:200
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:266
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2548

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

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

353 {
354  struct asent *as;
355  int res = -1;
356 
358  AST_LIST_TRAVERSE(&aslist, as, list) {
359  if (as->chan == chan) {
360  res = 0;
361  as->ignore_frame_types |= (1 << ftype);
362  break;
363  }
364  }
366  return res;
367 }
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
struct ast_channel * chan
Definition: autoservice.c:55
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
unsigned int ignore_frame_types
Definition: autoservice.c:62
struct asent::@346 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
Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 200 of file autoservice.c.

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 _macro_exec(), acf_curl_helper(), acf_jabberreceive_read(), acf_odbc_read(), acf_odbc_write(), action_toggle_mute_participants(), app_exec(), ast_app_exec_macro(), 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(), 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(), originate_exec(), osplookup_exec(), pbx_find_extension(), playback_common(), post_join_play_begin(), push_announcer(), realtimefield_read(), ring_one(), shell_helper(), sla_station_exec(), smdi_msg_retrieve_read(), srv_datastore_setup(), system_exec_helper(), try_calling(), trylock_read(), and valid_priv_reply().

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",
208  ast_channel_name(chan));
209  return 0;
210  }
211 
213  AST_LIST_TRAVERSE(&aslist, as, list) {
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 
233  ast_channel_lock(chan);
235  if (!as->orig_end_dtmf_flag)
237  ast_channel_unlock(chan);
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. */
252  AST_LIST_REMOVE(&aslist, as, list);
253  ast_free(as);
255  res = -1;
256  } else {
257  pthread_kill(asthread, SIGURG);
258  }
259  }
260 
262 
263  return res;
264 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define LOG_WARNING
Definition: logger.h:274
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
Definition: linkedlists.h:449
static void * autoservice_run(void *ign)
Definition: autoservice.c:78
#define NULL
Definition: resample.c:96
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
Definition: linkedlists.h:855
#define ast_cond_signal(cond)
Definition: lock.h:201
static ast_cond_t as_cond
Definition: autoservice.c:71
#define ast_pthread_create_background(a, b, c, d)
Definition: utils.h:567
int ast_thread_is_user_interface(void)
Indicates whether the current thread is a user interface.
Definition: main/utils.c:2996
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
struct ast_channel * chan
Definition: autoservice.c:55
#define AST_PTHREADT_NULL
Definition: lock.h:66
unsigned int orig_end_dtmf_flag
Definition: autoservice.c:60
unsigned int use_count
Definition: autoservice.c:59
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: linkedlists.h:710
#define ast_channel_unlock(chan)
Definition: channel.h:2946
#define ast_free(a)
Definition: astmm.h:182
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
static pthread_t asthread
Definition: autoservice.c:73
const char * ast_channel_name(const struct ast_channel *chan)
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
struct asent::@346 list

◆ 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
Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 266 of file autoservice.c.

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, asent::list, NULL, asent::orig_end_dtmf_flag, and asent::use_count.

Referenced by _macro_exec(), acf_curl_helper(), acf_jabberreceive_read(), acf_odbc_read(), acf_odbc_write(), action_toggle_mute_participants(), app_exec(), array(), ast_app_exec_macro(), 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(), 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(), originate_exec(), osplookup_exec(), pbx_find_extension(), playback_common(), post_join_play_begin(), realtimefield_read(), ring_one(), shell_helper(), sla_station_exec(), smdi_msg_retrieve_read(), srv_datastore_setup(), system_exec_helper(), try_calling(), trylock_read(), and valid_priv_reply().

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  /* Wait while autoservice thread rebuilds its list. */
313  while (chan_list_state == as_chan_list_state) {
314  usleep(1000);
315  }
316 
317  /* Now autoservice thread should have no references to our entry
318  and we can safely destroy it */
319 
321  res = 0;
322  }
323 
324  ast_channel_lock(chan);
325  if (!as->orig_end_dtmf_flag) {
327  }
328 
329  while ((f = AST_LIST_REMOVE_HEAD(&as->deferred_frames, frame_list))) {
330  if (!((1 << f->frametype) & as->ignore_frame_types)) {
331  ast_queue_frame_head(chan, f);
332  }
333  ast_frfree(f);
334  }
335  ast_channel_unlock(chan);
336 
337  ast_free(as);
338 
339  return res;
340 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
#define NULL
Definition: resample.c:96
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:614
int ast_thread_is_user_interface(void)
Indicates whether the current thread is a user interface.
Definition: main/utils.c:2996
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
static int as_chan_list_state
Definition: autoservice.c:76
struct ast_channel * chan
Definition: autoservice.c:55
#define AST_PTHREADT_NULL
Definition: lock.h:66
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:556
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:832
unsigned int orig_end_dtmf_flag
Definition: autoservice.c:60
unsigned int use_count
Definition: autoservice.c:59
#define ast_channel_unlock(chan)
Definition: channel.h:2946
#define ast_free(a)
Definition: astmm.h:182
static pthread_t asthread
Definition: autoservice.c:73
#define ast_clear_flag(p, flag)
Definition: utils.h:77
int ast_channel_softhangup_internal_flag(struct ast_channel *chan)
const char * ast_channel_name(const struct ast_channel *chan)
struct asent::@345 deferred_frames
#define ast_frfree(fr)
Data structure associated with a single frame of data.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:528
enum ast_frame_type frametype
unsigned int ignore_frame_types
Definition: autoservice.c:62
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to the head of a channel&#39;s frame queue.
Definition: channel.c:1144

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

References ast_channel_flags(), ast_channel_lock, ast_channel_tech(), ast_channel_unlock, ast_check_hangup(), AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, ast_set_flag, ast_test_flag, ast_channel_tech::call, and 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().

6554 {
6555  /* Place an outgoing call, but don't wait any longer than timeout ms before returning.
6556  If the remote end does not answer within the timeout, then do NOT hang up, but
6557  return anyway. */
6558  int res = -1;
6559  /* Stop if we're a zombie or need a soft hangup */
6560  ast_channel_lock(chan);
6562  if (ast_channel_tech(chan)->call)
6563  res = ast_channel_tech(chan)->call(chan, addr, timeout);
6565  }
6566  ast_channel_unlock(chan);
6567  return res;
6568 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define ast_set_flag(p, flag)
Definition: utils.h:70
static int timeout
Definition: cdr_mysql.c:86
static int call(void *data)
Definition: chan_pjsip.c:2358
int(*const call)(struct ast_channel *chan, const char *addr, int timeout)
Make a call.
Definition: channel.h:702
int ast_check_hangup(struct ast_channel *chan)
Checks to see if a channel is needing hang up.
Definition: channel.c:445
#define ast_channel_unlock(chan)
Definition: channel.h:2946
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)

◆ 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 uncuccessful)
Returns
Returns the forwarded call's ast_channel on success or NULL on failure

Definition at line 5988 of file channel.c.

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

5989 {
5990  char tmpchan[256];
5991  char forwarder[AST_CHANNEL_NAME];
5992  struct ast_channel *new_chan = NULL;
5993  char *data, *type;
5994  int cause = 0;
5995  int res;
5996 
5997  /* gather data and request the new forward channel */
5998  ast_copy_string(tmpchan, ast_channel_call_forward(orig), sizeof(tmpchan));
5999  ast_copy_string(forwarder, ast_channel_name(orig), sizeof(forwarder));
6000  if ((data = strchr(tmpchan, '/'))) {
6001  *data++ = '\0';
6002  type = tmpchan;
6003  } else {
6004  const char *forward_context;
6005  ast_channel_lock(orig);
6006  forward_context = pbx_builtin_getvar_helper(orig, "FORWARD_CONTEXT");
6007  snprintf(tmpchan, sizeof(tmpchan), "%s@%s", ast_channel_call_forward(orig), S_OR(forward_context, ast_channel_context(orig)));
6008  ast_channel_unlock(orig);
6009  data = tmpchan;
6010  type = "Local";
6011  }
6012  if (!(new_chan = ast_request(type, cap, NULL, orig, data, &cause))) {
6013  ast_log(LOG_NOTICE, "Unable to create channel for call forward to '%s/%s' (cause = %d)\n", type, data, cause);
6014  handle_cause(cause, outstate);
6015  ast_hangup(orig);
6016  return NULL;
6017  }
6018 
6019  /* Copy/inherit important information into new channel */
6020  if (oh) {
6021  if (oh->vars) {
6022  ast_channel_lock(new_chan);
6023  ast_set_variables(new_chan, oh->vars);
6024  ast_channel_unlock(new_chan);
6025  }
6026  if (oh->parent_channel) {
6027  call_forward_inherit(new_chan, oh->parent_channel, orig);
6028  }
6029  if (!ast_strlen_zero(oh->account)) {
6030  ast_channel_lock(new_chan);
6031  ast_channel_stage_snapshot(new_chan);
6032  ast_channel_accountcode_set(new_chan, oh->account);
6033  ast_channel_peeraccount_set(new_chan, oh->account);
6035  ast_channel_unlock(new_chan);
6036  }
6037  } else if (caller) { /* no outgoing helper so use caller if available */
6038  call_forward_inherit(new_chan, caller, orig);
6039  }
6040 
6041  ast_channel_lock_both(orig, new_chan);
6043  pbx_builtin_setvar_helper(new_chan, "FORWARDERNAME", forwarder);
6047  ast_channel_unlock(new_chan);
6048  ast_channel_unlock(orig);
6049 
6050  /* call new channel */
6051  res = ast_call(new_chan, data, 0);
6052  if (timeout) {
6053  *timeout = res;
6054  }
6055  if (res) {
6056  ast_log(LOG_NOTICE, "Unable to call forward to channel %s/%s\n", type, (char *)data);
6057  ast_hangup(orig);
6058  ast_hangup(new_chan);
6059  return NULL;
6060  }
6061  ast_hangup(orig);
6062 
6063  return new_chan;
6064 }
static const char type[]
Definition: chan_ooh323.c:109
#define ast_channel_lock(chan)
Definition: channel.h:2945
Main Channel structure associated with a channel.
struct ast_channel * parent_channel
Definition: channel.h:1114
static int timeout
Definition: cdr_mysql.c:86
#define NULL
Definition: resample.c:96
const char * data
const char * ast_channel_call_forward(const struct ast_channel *chan)
struct ast_variable * vars
Definition: channel.h:1113
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_log
Definition: astobj2.c:42
int ast_call(struct ast_channel *chan, const char *addr, int timeout)
Make a call.
Definition: channel.c:6553
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
const char * account
Definition: channel.h:1112
static void handle_cause(int cause, int *outstate)
Definition: channel.c:5936
void ast_channel_set_flag(struct ast_channel *chan, unsigned int flag)
Set a flag on a channel.
Definition: channel.c:11228
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:2031
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
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:6526
#define LOG_NOTICE
Definition: logger.h:263
#define ast_channel_unlock(chan)
Definition: channel.h:2946
#define AST_CHANNEL_NAME
Definition: channel.h:172
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:2135
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
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 ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition: channel.h:2952
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:6444
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
const char * ast_channel_name(const struct ast_channel *chan)
static void call_forward_inherit(struct ast_channel *new_chan, struct ast_channel *parent, struct ast_channel *orig)
Definition: channel.c:5959
void ast_hangup(struct ast_channel *chan)
Hangup a channel.
Definition: channel.c:2548
const char * ast_channel_context(const struct ast_channel *chan)
void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars)
adds a list of channel variables to a channel
Definition: channel.c:8217

◆ ast_cause2str()

const char* ast_cause2str ( int  cause)

Gives the string form of a given cause code.

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

Gives the string form of a given cause code.

Definition at line 612 of file channel.c.

References ARRAY_LEN, and causes_map::desc.

Referenced by __transmit_response(), bridge_dissolve(), channel_destroyed_event(), channel_state_change(), dial_exec_full(), findmeexec(), hangupcause_read(), rfc3326_add_reason_header(), sip_hangup(), and transmit_request_with_auth().

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 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static const struct causes_map causes[]
Definition: channel.c:136
const char * desc
Definition: channel.c:133
char x
Definition: extconf.c:81

◆ ast_change_name()

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

Change channel name.

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

Definition at line 6854 of file channel.c.

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

Referenced by update_name().

6855 {
6856  /* We must re-link, as the hash value will change here. */
6857  ao2_lock(channels);
6858  ast_channel_lock(chan);
6859  ao2_unlink(channels, chan);
6860  __ast_change_name_nolink(chan, newname);
6861  ao2_link(channels, chan);
6862  ast_channel_unlock(chan);
6864 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
#define ao2_unlink(container, obj)
Definition: astobj2.h:1598
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:124
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:6839
#define ast_channel_unlock(chan)
Definition: channel.h:2946
#define ao2_link(container, obj)
Definition: astobj2.h:1549

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

782 {
783  return chan->adsicpe;
784 }

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

References ast_alertpipe_writable().

Referenced by __ast_queue_frame().

1126 {
1127  return ast_alertpipe_writable(chan->alertpipe);
1128 }
int ast_alertpipe_writable(int alert_pipe[2])
Determine if the alert pipe is writable.
Definition: alertpipe.h:127

◆ ast_channel_alert_write()

int ast_channel_alert_write ( struct ast_channel chan)

Definition at line 1110 of file channel_internal_api.c.

References ast_alertpipe_write().

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

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

◆ ast_channel_amaflags()

enum ama_flags ast_channel_amaflags ( const struct ast_channel chan)

Definition at line 406 of file channel_internal_api.c.

Referenced by ast_channel_log(), ast_channel_snapshot_create(), ast_channel_yank(), ast_var_channels_table(), and func_channel_read().

407 {
408  return chan->amaflags;
409 }

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

References AST_AMA_BILLING, AST_AMA_DOCUMENTATION, and AST_AMA_OMIT.

Referenced by _sip_show_peer(), _skinny_show_line(), ast_cdr_format_var(), beanstalk_put(), build_csv_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(), sip_show_user(), and tds_log().

4419 {
4420  switch (flag) {
4421  case AST_AMA_OMIT:
4422  return "OMIT";
4423  case AST_AMA_BILLING:
4424  return "BILLING";
4425  case AST_AMA_DOCUMENTATION:
4426  return "DOCUMENTATION";
4427  default:
4428  return "Unknown";
4429  }
4430 }
long int flag
Definition: f2c.h:83

◆ ast_channel_amaflags_set()

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

Definition at line 411 of file channel_internal_api.c.

References 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(), mgcp_new(), ooh323_new(), pbx_builtin_setamaflags(), sip_new(), and skinny_new().

412 {
413  if (chan->amaflags == value) {
414  return;
415  }
416  chan->amaflags = value;
418 }
int value
Definition: syslog.c:37
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.

◆ ast_channel_answertime()

struct timeval ast_channel_answertime ( struct ast_channel chan)

Definition at line 986 of file channel_internal_api.c.

Referenced by ast_channel_get_up_time_ms(), ospfinished_exec(), and set_channel_answer_time().

987 {
988  return chan->answertime;
989 }
struct timeval answertime

◆ ast_channel_answertime_set()

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

Definition at line 991 of file channel_internal_api.c.

References ast_channel::answertime, and value.

Referenced by set_channel_answer_time().

992 {
993  chan->answertime = *value;
994 }
struct timeval answertime
int value
Definition: syslog.c:37

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

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

322 {
323  chan->appl = value;
325 }
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.
int value
Definition: syslog.c:37
const char * appl

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

References ast_channel::audiohooks, and value.

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

586 {
587  chan->audiohooks = value;
588 }
int value
Definition: syslog.c:37
struct ast_audiohook_list * audiohooks

◆ ast_channel_autochans()

struct ast_autochan_list* ast_channel_autochans ( struct ast_channel chan)

Definition at line 872 of file channel_internal_api.c.

References ast_channel::autochans.

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

873 {
874  return &chan->autochans;
875 }
struct ast_autochan_list autochans

◆ ast_channel_blocker()

pthread_t ast_channel_blocker ( const struct ast_channel chan)

Definition at line 1213 of file channel_internal_api.c.

References ast_channel::blocker.

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

1214 {
1215  return chan->blocker;
1216 }

◆ ast_channel_blocker_set()

void ast_channel_blocker_set ( struct ast_channel chan,
pthread_t  value 
)

Definition at line 1217 of file channel_internal_api.c.

References ast_channel::blocker, and value.

1218 {
1219  chan->blocker = value;
1220 }
int value
Definition: syslog.c:37

◆ ast_channel_blocker_tid()

int ast_channel_blocker_tid ( const struct ast_channel chan)

Definition at line 1222 of file channel_internal_api.c.

References ast_channel::blocker_tid.

Referenced by ast_hangup().

1223 {
1224  return chan->blocker_tid;
1225 }

◆ ast_channel_blocker_tid_set()

void ast_channel_blocker_tid_set ( struct ast_channel chan,
int  tid 
)

Definition at line 1226 of file channel_internal_api.c.

References ast_channel::blocker_tid, and value.

1227 {
1228  chan->blocker_tid = value;
1229 }
int value
Definition: syslog.c:37

◆ ast_channel_blockproc()

const char* ast_channel_blockproc ( const struct ast_channel chan)

Definition at line 326 of file channel_internal_api.c.

References ast_channel::blockproc.

Referenced by ast_hangup(), and serialize_showchan().

327 {
328  return chan->blockproc;
329 }
const char * blockproc

◆ ast_channel_blockproc_set()

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

Definition at line 330 of file channel_internal_api.c.

References ast_channel::blockproc, and value.

331 {
332  chan->blockproc = value;
333 }
const char * blockproc
int value
Definition: syslog.c:37

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

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

Referenced by _skinny_show_lines(), analog_ss_thread(), ast_rtp_instance_set_stats_vars(), ast_set_hangupsource(), ast_unreal_queryoption(), ast_var_channels_table(), attach_barge(), cb_events(), channel_do_masquerade(), create_jb(), export_aoc_vars(), fax_detect_framehook(), fax_gateway_framehook(), func_channel_read(), get_refer_info(), handle_incoming_request(), handle_request_bye(), manager_park(), mgcp_hangup(), my_get_sigpvt_bridged_channel(), and spandsp_fax_gateway_start().

10766 {
10767  struct ast_channel *peer;
10768  struct ast_bridge *bridge;
10769 
10770  /* Get the bridge the channel is in. */
10771  ast_channel_lock(chan);
10772  bridge = ast_channel_get_bridge(chan);
10773  ast_channel_unlock(chan);
10774  if (!bridge) {
10775  return NULL;
10776  }
10777 
10778  peer = ast_bridge_peer(bridge, chan);
10779  ao2_ref(bridge, -1);
10780  return peer;
10781 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
Main Channel structure associated with a channel.
#define NULL
Definition: resample.c:96
struct ast_channel * ast_bridge_peer(struct ast_bridge *bridge, struct ast_channel *chan)
Get the channel&#39;s bridge peer only if the bridge is two-party.
Definition: bridge.c:4142
struct ast_bridge * ast_channel_get_bridge(const struct ast_channel *chan)
Get the bridge associated with a channel.
Definition: channel.c:10735
#define ao2_ref(o, delta)
Definition: astobj2.h:464
Structure that contains information about a bridge.
Definition: bridge.h:357
#define ast_channel_unlock(chan)
Definition: channel.h:2946

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

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

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

Definition at line 1278 of file channel.c.

References ao2_callback_data.

Referenced by ast_channel_get_by_exten(), ast_channel_get_by_name_prefix(), ast_channel_iterator_by_exten_new(), ast_channel_iterator_by_name_new(), ast_pickup_find_by_group(), does_id_conflict(), find_by_channel(), find_by_part(), handle_core_set_debug_channel(), and pickup_by_mark().

1280 {
1281  return ao2_callback_data(channels, ao2_flags, cb_fn, arg, data);
1282 }
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:124
#define ao2_callback_data(container, flags, cb_fn, arg, data)
Definition: astobj2.h:1743

◆ ast_channel_caller()

struct ast_party_caller* ast_channel_caller ( struct ast_channel chan)
Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 888 of file channel_internal_api.c.

References ast_channel::caller.

Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_channel_alloc_ap(), __ast_goto_if_exists(), __ast_pbx_run(), _macro_exec(), acf_isexten_exec(), 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(), cb_events(), 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(), do_immediate_setup(), eval_exten_read(), fax_detect_framehook(), find_matching_endif(), find_matching_endwhile(), findmeexec(), forward_message(), get_pai(), get_rpid(), gosub_exec(), gosub_run(), handle_cli_confbridge_list_item(), handle_cli_misdn_show_channels(), handle_gosub(), handle_setpriority(), handle_showchan(), incoming_in_dialog_request(), isAnsweringMachine(), isexten_function_read(), leave_voicemail(), local_call(), manager_queues_status(), meetme_show_cmd(), mgcp_hangup(), mgcp_new(), mgcp_ss(), minivm_greet_exec(), minivm_notify_exec(), misdn_call(), misdn_hangup(), misdn_new(), misdn_update_caller_id(), misdn_write(), my_handle_dtmf(), onModeChanged(), ooh323_rtp_read(), originate_exec(), ospauth_exec(), osplookup_exec(), oss_call(), oss_new(), park_local_transfer(), parse_oli(), pbx_builtin_background(), pbx_builtin_waitexten(), pbx_outgoing_attempt(), pbx_parseable_goto(), phone_new(), print_bc_info(), privacy_exec(), process_ast_dsp(), process_sdp(), push_callinfo(), queue_connected_line_update(), queue_exec(), readexten_exec(), recalling_enter(), release_chan(), ring_entry(), run_externnotify(), send_callinfo(), serialize_showchan(), setup_env(), setup_privacy_args(), sip_call(), sip_new(), sip_read(), skinny_new(), skinny_newcall(), sla_ring_station(), sms_exec(), socket_process_helper(), start_automixmonitor(), start_automonitor(), state_notify_build_xml(), try_calling(), unistim_new(), unreal_colp_redirect_indicate(), update_connected_line_from_peer(), update_connectedline(), update_initial_connected_line(), valid_exit(), vm_allocate_dh(), vm_authenticate(), wait_for_answer(), waitstream_core(), write_metadata(), and zapateller_exec().

889 {
890  return &chan->caller;
891 }
struct ast_party_caller caller
Channel Caller ID information.

◆ ast_channel_caller_set()

void ast_channel_caller_set ( struct ast_channel chan,
struct ast_party_caller value 
)

Definition at line 944 of file channel_internal_api.c.

References AST_CHANNEL_SNAPSHOT_INVALIDATE_CALLER, ast_channel_snapshot_invalidate_segment(), ast_channel::caller, and value.

Referenced by channel_do_masquerade(), dial_trunk(), and sla_ring_station().

945 {
946  chan->caller = *value;
948 }
struct ast_party_caller caller
Channel Caller ID information.
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.
int value
Definition: syslog.c:37

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

References ast_channel::callgroup, and value.

Referenced by chan_pjsip_new(), dahdi_new(), func_channel_write_real(), jingle_new(), mgcp_new(), read_config(), sip_new(), skinny_new(), and unistim_new().

1079 {
1080  chan->callgroup = value;
1081 }
int value
Definition: syslog.c:37
ast_group_t callgroup

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

References ast_channel::callid.

Referenced by ast_channel_destructor().

1069 {
1070  chan->callid = 0;
1071 }

◆ ast_channel_callid_set()

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

Definition at line 797 of file channel_internal_api.c.

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(), request_channel(), and sip_new().

798 {
799  char call_identifier_from[AST_CALLID_BUFFER_LENGTH];
800  char call_identifier_to[AST_CALLID_BUFFER_LENGTH];
801  call_identifier_from[0] = '\0';
802  ast_callid_strnprint(call_identifier_to, sizeof(call_identifier_to), callid);
803  if (chan->callid) {
804  ast_callid_strnprint(call_identifier_from, sizeof(call_identifier_from), chan->callid);
805  ast_debug(3, "Channel Call ID changing from %s to %s\n", call_identifier_from, call_identifier_to);
806  }
807 
808  chan->callid = callid;
809 
810  ast_test_suite_event_notify("CallIDChange",
811  "State: CallIDChange\r\n"
812  "Channel: %s\r\n"
813  "CallID: %s\r\n"
814  "PriorCallID: %s",
815  ast_channel_name(chan),
816  call_identifier_to,
817  call_identifier_from);
818 }
ast_callid callid
Definition: bridge.h:369
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_test_suite_event_notify(s, f,...)
Definition: test.h:196
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:1952
const char * ast_channel_name(const struct ast_channel *chan)
#define AST_CALLID_BUFFER_LENGTH
Definition: logger.h:46

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

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

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

10654 {
10655  struct ast_cc_config_params *cc_params;
10656  struct ast_datastore *cc_datastore;
10657 
10658  if (!(cc_params = ast_cc_config_params_init())) {
10659  return -1;
10660  }
10661 
10662  if (!(cc_datastore = ast_datastore_alloc(&cc_channel_datastore_info, NULL))) {
10663  ast_cc_config_params_destroy(cc_params);
10664  return -1;
10665  }
10666 
10667  if (base_params) {
10668  ast_cc_copy_config_params(cc_params, base_params);
10669  }
10670  cc_datastore->data = cc_params;
10671  ast_channel_datastore_add(chan, cc_datastore);
10672  return 0;
10673 }
static const struct ast_datastore_info cc_channel_datastore_info
Definition: channel.c:10646
void ast_cc_config_params_destroy(struct ast_cc_config_params *params)
Free memory from CCSS configuration params.
Definition: ccss.c:693
Structure for a data store object.
Definition: datastore.h:68
#define NULL
Definition: resample.c:96
#define ast_cc_config_params_init()
Allocate and initialize an ast_cc_config_params structure.
Definition: ccss.h:135
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:861
void * data
Definition: datastore.h:70
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition: channel.c:2390
#define ast_datastore_alloc(info, uid)
Definition: datastore.h:89

◆ ast_channel_cdr()

struct ast_cdr* ast_channel_cdr ( const struct ast_channel chan)

Definition at line 589 of file channel_internal_api.c.

References ast_channel::cdr.

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

590 {
591  return chan->cdr;
592 }
struct ast_cdr * cdr

◆ ast_channel_cdr_set()

void ast_channel_cdr_set ( struct ast_channel chan,
struct ast_cdr value 
)

Definition at line 593 of file channel_internal_api.c.

References ast_channel::cdr, and value.

Referenced by ast_channel_destructor(), ast_dummy_channel_destructor(), custom_log(), load_values_config(), manager_log(), and syslog_log().

594 {
595  chan->cdr = value;
596 }
struct ast_cdr * cdr
int value
Definition: syslog.c:37

◆ ast_channel_clear_flag()

void ast_channel_clear_flag ( struct ast_channel chan,
unsigned int  flag 
)
Since
13.17.0
Parameters
Cleara flag on a channel
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 11235 of file channel.c.

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(), handle_exec(), and waitstream_core().

11236 {
11237  ast_channel_lock(chan);
11239  ast_channel_unlock(chan);
11240 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
long int flag
Definition: f2c.h:83
#define ast_channel_unlock(chan)
Definition: channel.h:2946
#define ast_clear_flag(p, flag)
Definition: utils.h:77
struct ast_flags * ast_channel_flags(struct ast_channel *chan)

◆ 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
Returns
Nothing.

Definition at line 2437 of file channel.c.

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

2438 {
2439  ast_channel_lock(chan);
2440 
2442 
2444  struct ast_frame *fr;
2445 
2446  /* If we have completely cleared the softhangup flag,
2447  * then we need to fully abort the hangup process. This requires
2448  * pulling the END_OF_Q frame out of the channel frame queue if it
2449  * still happens to be there. */
2450 
2451  fr = AST_LIST_LAST(ast_channel_readq(chan));
2452  if (fr && fr->frametype == AST_FRAME_CONTROL &&
2455  ast_frfree(fr);
2456  }
2457  }
2458 
2459  ast_channel_unlock(chan);
2460 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
Definition: linkedlists.h:855
struct ast_frame_subclass subclass
struct ast_readq_list * ast_channel_readq(struct ast_channel *chan)
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.
Definition: linkedlists.h:428
long int flag
Definition: f2c.h:83
#define ast_channel_unlock(chan)
Definition: channel.h:2946
int ast_channel_softhangup_internal_flag(struct ast_channel *chan)
#define ast_frfree(fr)
Data structure associated with a single frame of data.
enum ast_frame_type frametype
void ast_channel_softhangup_internal_flag_clear(struct ast_channel *chan, int value)

◆ 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
Returns
1, 0, or -1 This function compares a offset from current time with the absolute time out on a channel (when to hang up). If the absolute time out on a channel is earlier than current time plus the offset, it returns 1, if the two time values are equal, it return 0, otherwise, it return -1.
Since
1.6.1

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

Definition at line 523 of file channel.c.

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

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:108
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:150
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:98
struct timeval * ast_channel_whentohangup(struct ast_channel *chan)
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
Definition: extconf.c:2283

◆ ast_channel_connected()

struct ast_party_connected_line* ast_channel_connected ( struct ast_channel chan)

Definition at line 892 of file channel_internal_api.c.

References ast_channel::connected.

Referenced by __ast_channel_alloc_ap(), __ast_read(), __ast_request_and_dial(), action_meetmelist(), after_bridge_move_channel(), agent_login_channel_config(), analog_call(), ari_channels_handle_originate_with_id(), ast_ari_channels_dial(), ast_call_forward(), ast_channel_connected_line_macro(), ast_channel_connected_line_sub(), ast_channel_destructor(), ast_channel_set_connected_line(), ast_do_pickup(), ast_dummy_channel_destructor(), ast_unreal_call_setup(), attended_transfer_properties_alloc(), begin_dial_prerun(), channel_do_masquerade(), channel_snapshot_connected_create(), connectedline_read(), connectedline_write(), copy_caller_data(), dahdi_call(), dial_exec_full(), dialog_info_generate_body_content(), do_forward(), findmeexec(), handle_showchan(), iax2_call(), indicate_connected_line(), launch_monitor_thread(), manager_queues_status(), mgcp_call(), ooh323_call(), ooh323_indicate(), park_local_transfer(), pbx_outgoing_attempt(), phone_call(), push_callinfo(), recalling_enter(), retransfer_enter(), ring_entry(), send_callerid_screen(), send_callinfo(), serialize_showchan(), skinny_newcall(), state_notify_build_xml(), try_calling(), unistim_indicate(), unreal_colp_redirect_indicate(), update_config(), update_connectedline(), and wait_for_answer().

893 {
894  return &chan->connected;
895 }
struct ast_party_connected_line connected
Channel Connected Line ID information.

◆ ast_channel_connected_effective_id()

struct ast_party_id ast_channel_connected_effective_id ( struct ast_channel chan)

Definition at line 900 of file channel_internal_api.c.

References ast_party_id_merge().

Referenced by add_rpid(), caller_id_outgoing_request(), caller_id_outgoing_response(), generate_status(), handle_showchan(), initreqprep(), is_colp_update_allowed(), misdn_call(), misdn_get_connected_line(), push_callinfo(), send_callinfo(), set_from_header(), setsubstate(), and update_connectedline().

901 {
902  return ast_party_id_merge(&chan->connected.id, &chan->connected.priv);
903 }
struct ast_party_connected_line connected
Channel Connected Line ID information.
struct ast_party_id id
Connected party ID.
Definition: channel.h:459
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:1902
struct ast_party_id priv
Private connected party ID.
Definition: channel.h:469

◆ ast_channel_connected_indicated()

struct ast_party_connected_line* ast_channel_connected_indicated ( struct ast_channel chan)

Definition at line 896 of file channel_internal_api.c.

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

897 {
898  return &chan->connected_indicated;
899 }
struct ast_party_connected_line connected_indicated
Channel Connected Line ID information that was last indicated.

◆ ast_channel_connected_line_macro()

int ast_channel_connected_line_macro ( struct ast_channel autoservice_chan,
struct ast_channel macro_chan,
const void *  connected_info,
int  is_caller,
int  frame 
)

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

Since
1.8
Deprecated:
You should use the ast_channel_connected_line_sub() function instead.

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

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

Have multiple return codes based on the MACRO_RESULT

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

Definition at line 10435 of file channel.c.

References ast_app_run_macro(), ast_channel_connected(), ast_channel_lock, ast_channel_unlock, ast_channel_update_connected_line(), ast_connected_line_parse_data(), ast_log, ast_party_connected_line_copy(), ast_party_connected_line_free(), ast_party_connected_line_init(), ast_strdupa, ast_strlen_zero, channel_set_intercept_mode(), chanlist::connected, ast_frame::data, ast_frame::datalen, LOG_WARNING, NULL, pbx_builtin_getvar_helper(), ast_frame::ptr, retval, and S_OR.

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

10436 {
10437  static int deprecation_warning = 0;
10438  const char *macro;
10439  const char *macro_args;
10440  int retval;
10441 
10442  ast_channel_lock(macro_chan);
10443  macro = pbx_builtin_getvar_helper(macro_chan, is_caller
10444  ? "CONNECTED_LINE_CALLER_SEND_MACRO" : "CONNECTED_LINE_CALLEE_SEND_MACRO");
10445  macro = ast_strdupa(S_OR(macro, ""));
10446  macro_args = pbx_builtin_getvar_helper(macro_chan, is_caller
10447  ? "CONNECTED_LINE_CALLER_SEND_MACRO_ARGS" : "CONNECTED_LINE_CALLEE_SEND_MACRO_ARGS");
10448  macro_args = ast_strdupa(S_OR(macro_args, ""));
10449 
10450  if (ast_strlen_zero(macro)) {
10451  ast_channel_unlock(macro_chan);
10452  return -1;
10453  }
10454 
10455  if (!deprecation_warning) {
10456  deprecation_warning = 1;
10457  ast_log(LOG_WARNING, "Usage of CONNECTED_LINE_CALLE[ER]_SEND_MACRO is deprecated. Please use CONNECTED_LINE_SEND_SUB instead.\n");
10458  }
10459  if (is_frame) {
10460  const struct ast_frame *frame = connected_info;
10461 
10463  } else {
10464  const struct ast_party_connected_line *connected = connected_info;
10465 
10466  ast_party_connected_line_copy(ast_channel_connected(macro_chan), connected);
10467  }
10468  ast_channel_unlock(macro_chan);
10469 
10471  retval = ast_app_run_macro(autoservice_chan, macro_chan, macro, macro_args);
10473  if (!retval) {
10474  struct ast_party_connected_line saved_connected;
10475 
10476  ast_party_connected_line_init(&saved_connected);
10477  ast_channel_lock(macro_chan);
10478  ast_party_connected_line_copy(&saved_connected, ast_channel_connected(macro_chan));
10479  ast_channel_unlock(macro_chan);
10480  ast_channel_update_connected_line(macro_chan, &saved_connected, NULL);
10481  ast_party_connected_line_free(&saved_connected);
10482  }
10483 
10484  return retval;
10485 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
int ast_app_run_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char *macro_name, const char *macro_args)
Run a macro on a channel, placing an optional second channel into autoservice.
Definition: main/app.c:320
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:8881
#define LOG_WARNING
Definition: logger.h:274
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
Definition: channel.c:2022
static void channel_set_intercept_mode(int in_intercept_mode)
Definition: channel.c:10419
#define NULL
Definition: resample.c:96
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_log
Definition: astobj2.c:42
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition: channel.c:2072
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
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:2031
Connected Line/Party information.
Definition: channel.h:457
#define ast_channel_unlock(chan)
Definition: channel.h:2946
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
static ENTRY retval
Definition: hsearch.c:50
Data structure associated with a single frame of data.
union ast_frame::@263 data
char connected
Definition: eagi_proxy.c:82
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:9189

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

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(), chanlist::connected, ast_frame::data, ast_frame::datalen, NULL, pbx_builtin_getvar_helper(), ast_frame::ptr, retval, 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(), and wait_for_answer().

10540 {
10541  const char *sub;
10542  const char *sub_args;
10543  int retval;
10544 
10545  ast_channel_lock(sub_chan);
10546  sub = pbx_builtin_getvar_helper(sub_chan, "CONNECTED_LINE_SEND_SUB");
10547  sub = ast_strdupa(S_OR(sub, ""));
10548  sub_args = pbx_builtin_getvar_helper(sub_chan, "CONNECTED_LINE_SEND_SUB_ARGS");
10549  sub_args = ast_strdupa(S_OR(sub_args, ""));
10550 
10551  if (ast_strlen_zero(sub)) {
10552  ast_channel_unlock(sub_chan);
10553  return -1;
10554  }
10555 
10556  if (is_frame) {
10557  const struct ast_frame *frame = connected_info;
10558 
10560  } else {
10561  const struct ast_party_connected_line *connected = connected_info;
10562 
10564  }
10565  ast_channel_unlock(sub_chan);
10566 
10568  retval = ast_app_run_sub(autoservice_chan, sub_chan, sub, sub_args, 0);
10570  if (!retval) {
10571  struct ast_party_connected_line saved_connected;
10572 
10573  ast_party_connected_line_init(&saved_connected);
10574  ast_channel_lock(sub_chan);
10575  ast_party_connected_line_copy(&saved_connected, ast_channel_connected(sub_chan));
10576  ast_channel_unlock(sub_chan);
10577  ast_channel_update_connected_line(sub_chan, &saved_connected, NULL);
10578  ast_party_connected_line_free(&saved_connected);
10579  }
10580 
10581  return retval;
10582 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
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:8881
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
Definition: channel.c:2022
static void channel_set_intercept_mode(int in_intercept_mode)
Definition: channel.c:10419
#define NULL
Definition: resample.c:96
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
#define ast_strlen_zero(foo)
Definition: strings.h:52
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition: channel.c:2072
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
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:2031
Connected Line/Party information.
Definition: channel.h:457
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:401
#define ast_channel_unlock(chan)
Definition: channel.h:2946
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
static ENTRY retval
Definition: hsearch.c:50
struct stasis_forward * sub
Definition: res_corosync.c:240
Data structure associated with a single frame of data.
union ast_frame::@263 data
char connected
Definition: eagi_proxy.c:82
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:9189

◆ ast_channel_connected_set()

void ast_channel_connected_set ( struct ast_channel chan,
struct ast_party_connected_line value 
)

Definition at line 949 of file channel_internal_api.c.

References AST_CHANNEL_SNAPSHOT_INVALIDATE_CONNECTED, ast_channel_snapshot_invalidate_segment(), ast_channel::connected, and value.

Referenced by channel_do_masquerade().

950 {
951  chan->connected = *value;
953 }
struct ast_party_connected_line connected
Channel Connected Line ID information.
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.
int value
Definition: syslog.c:37

◆ ast_channel_context()

const char* ast_channel_context ( const struct ast_channel chan)
Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 344 of file channel_internal_api.c.

Referenced by __analog_ss_thread(), __ast_goto_if_exists(), __ast_pbx_run(), _if_exec(), _macro_exec(), _while_exec(), acf_isexten_exec(), action_blind_transfer(), action_bridge(), action_dialplan_exec(), analog_ss_thread(), ast_app_exec_macro(), ast_bridge_setup_after_goto(), ast_call_forward(), ast_cc_call_init(), ast_channel_by_exten_cb(), 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(), cc_generic_agent_init(), cc_interfaces_datastore_init(), chan_pjsip_cng_tone_detected(), channel_snapshot_dialplan_create(), collect_digits(), common_exec(), conf_run(), console_transfer(), dahdi_handle_dtmf(), dial_exec_full(), dialout(), do_forward(), do_immediate_setup(), 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(), launch_monitor_thread(), leave_voicemail(), log_exec(), lua_pbx_exec(), mgcp_ss(), minivm_greet_exec(), misdn_call(), misdn_hangup(), 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_parseable_goto(), pickup_exec(), print_bc_info(), process_ast_dsp(), process_sdp(), raise_exception(), readexten_exec(), realtime_exec(), release_chan(), ring_entry(), serialize_showchan(), setsubstate(), setup_env(), setup_peer_after_bridge_goto(), sip_read(), skinny_dialer(), skinny_newcall(), try_calling(), vm_authenticate(), vm_execmain(), vmauthenticate(), and wait_for_answer().

345 {
346  return chan->context;
347 }

◆ ast_channel_context_set()

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

Definition at line 348 of file channel_internal_api.c.

References AST_CHANNEL_SNAPSHOT_INVALIDATE_DIALPLAN, ast_channel_snapshot_invalidate_segment(), and ast_copy_string().

Referenced by __ast_channel_alloc_ap(), __ast_request_and_dial(), _macro_exec(), action_dialplan_exec(), alsa_new(), 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(), dahdi_new(), dial_exec_full(), dialout(), do_notify(), eval_exten_read(), forward_message(), generic_recall(), gosub_exec(), gosub_run(), handle_gosub(), handle_setcontext(), iax2_call(), jingle_new(), leave_voicemail(), mgcp_new(), minivm_greet_exec(), my_distinctive_ring(), nbs_new(), ooh323_new(), pbx_builtin_background(), pbx_extension_helper(), pbx_outgoing_exec(), phone_new(), read_config(), return_exec(), setsubstate(), sip_new(), and skinny_new().

349 {
350  ast_copy_string(chan->context, value, sizeof(chan->context));
352 }
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.
int value
Definition: syslog.c:37
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401

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

Definition at line 980 of file channel_internal_api.c.

References AST_CHANNEL_SNAPSHOT_INVALIDATE_BASE, ast_channel_snapshot_invalidate_segment(), ast_channel::creationtime, and value.

Referenced by __ast_channel_alloc_ap().

981 {
982  chan->creationtime = *value;
984 }
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.
int value
Definition: syslog.c:37
struct timeval creationtime

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

Definition at line 338 of file channel_internal_api.c.

References AST_CHANNEL_SNAPSHOT_INVALIDATE_DIALPLAN, ast_channel_snapshot_invalidate_segment(), ast_channel::data, 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(), retrydial_exec(), and ring_entry().

339 {
340  chan->data = value;
342 }
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.
const char * data
int value
Definition: syslog.c:37

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

References ast_channel_datastores(), and AST_LIST_INSERT_HEAD.

Referenced by __after_bridge_set_goto(), _macro_exec(), acf_curlopt_write(), acf_iaxvar_write(), acf_odbc_read(), 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_verification(), 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_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(), 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(), MYSQL_exec(), pitchshift_helper(), raise_exception(), reload(), 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(), and volume_write().

2391 {
2392  int res = 0;
2393 
2395 
2396  return res;
2397 }
struct ast_datastore_list * ast_channel_datastores(struct ast_channel *chan)
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: linkedlists.h:710
Definition: search.h:40

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

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

Referenced by _macro_exec(), acf_curl_helper(), acf_curlopt_helper(), acf_curlopt_write(), acf_exception_read(), acf_fetch(), acf_iaxvar_read(), acf_iaxvar_write(), acf_odbc_read(), add_agi_cmd(), add_features_datastore(), add_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_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(), 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(), 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_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_chan_by_ast_name(), 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(), MYSQL_exec(), pitchshift_cb(), pitchshift_helper(), pop_exec(), raise_exception(), remb_hook_event_cb(), remove_detect(), remove_dtmf_store(), 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().

2405 {
2406  struct ast_datastore *datastore = NULL;
2407 
2408  if (info == NULL)
2409  return NULL;
2410 
2411  AST_LIST_TRAVERSE(ast_channel_datastores(chan), datastore, entry) {
2412  if (datastore->info != info) {
2413  continue;
2414  }
2415 
2416  if (uid == NULL) {
2417  /* matched by type only */
2418  break;
2419  }
2420 
2421  if ((datastore->uid != NULL) && !strcasecmp(uid, datastore->uid)) {
2422  /* Matched by type AND uid */
2423  break;
2424  }
2425  }
2426 
2427  return datastore;
2428 }
Structure for a data store object.
Definition: datastore.h:68
#define NULL
Definition: resample.c:96
const char * uid
Definition: datastore.h:69
struct ast_datastore_list * ast_channel_datastores(struct ast_channel *chan)
const struct ast_datastore_info * info
Definition: datastore.h:71
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
Definition: search.h:40

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

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

2374 {
2375  struct ast_datastore *datastore = NULL, *datastore2;
2376 
2377  AST_LIST_TRAVERSE(ast_channel_datastores(from), datastore, entry) {
2378  if (datastore->inheritance > 0) {
2379  datastore2 = ast_datastore_alloc(datastore->info, datastore->uid);
2380  if (datastore2) {
2381  datastore2->data = datastore->info->duplicate ? datastore->info->duplicate(datastore->data) : NULL;
2382  datastore2->inheritance = datastore->inheritance == DATASTORE_INHERIT_FOREVER ? DATASTORE_INHERIT_FOREVER : datastore->inheritance - 1;
2384  }
2385  }
2386  }
2387  return 0;
2388 }
void *(* duplicate)(void *data)
Definition: datastore.h:33
Structure for a data store object.
Definition: datastore.h:68
#define NULL
Definition: resample.c:96
const char * uid
Definition: datastore.h:69
struct ast_datastore_list * ast_channel_datastores(struct ast_channel *chan)
const struct ast_datastore_info * info
Definition: datastore.h:71
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:730
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
#define DATASTORE_INHERIT_FOREVER
Definition: channel.h:193
unsigned int inheritance
Definition: datastore.h:73
void * data
Definition: datastore.h:70
Definition: search.h:40
#define ast_datastore_alloc(info, uid)
Definition: datastore.h:89

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

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(), and find_cache().

1258 {
1259  int pre = 0;
1260 
1261  if (chan) {
1262  ast_channel_lock(chan);
1265  ast_channel_unlock(chan);
1266  }
1267  return pre;
1268 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define ast_channel_unlock(chan)
Definition: channel.h:2946
struct ast_flags * ast_channel_flags(struct ast_channel *chan)

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

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

Referenced by ast_channel_hangupcause_hash_set().

1293 {
1294  struct ast_control_pvt_cause_code *ao2_cause_code;
1295  ao2_find(chan->dialed_causes, cause_code->chan_name, OBJ_KEY | OBJ_UNLINK | OBJ_NODATA);
1296  ao2_cause_code = ao2_alloc(datalen, NULL);
1297 
1298  if (ao2_cause_code) {
1299  memcpy(ao2_cause_code, cause_code, datalen);
1300  ao2_link(chan->dialed_causes, ao2_cause_code);
1301  ao2_ref(ao2_cause_code, -1);
1302  return 0;
1303  } else {
1304  return -1;
1305  }
1306 }
char chan_name[AST_CHANNEL_NAME]
#define OBJ_KEY
Definition: astobj2.h:1155
#define NULL
Definition: resample.c:96
#define ao2_ref(o, delta)
Definition: astobj2.h:464
struct ao2_container * dialed_causes
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1756
#define ao2_link(container, obj)
Definition: astobj2.h:1549

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

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

Referenced by hangupcause_keys_read().

1275 {
1276  struct ast_str *chanlist = ast_str_create(128);
1277 
1278  if (!chanlist) {
1279  return NULL;
1280  }
1281 
1282  ao2_callback(chan->dialed_causes, 0, collect_names_cb, &chanlist);
1283 
1284  return chanlist;
1285 }
static int collect_names_cb(void *obj, void *arg, int flags)
#define ao2_callback(c, flags, cb_fn, arg)
Definition: astobj2.h:1716
#define NULL
Definition: resample.c:96
List of channel drivers.
Definition: app_dial.c:796
struct ao2_container * dialed_causes
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
#define ast_str_create(init_len)
Create a malloc&#39;ed dynamic length string.
Definition: strings.h:620

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

1309 {
1311 }
#define ao2_callback(c, flags, cb_fn, arg)
Definition: astobj2.h:1716
#define NULL
Definition: resample.c:96
struct ao2_container * dialed_causes

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

References ao2_find, ast_channel::dialed_causes, and OBJ_KEY.

Referenced by hangupcause_read().

1288 {
1289  return ao2_find(chan->dialed_causes, chan_name, OBJ_KEY);
1290 }
#define OBJ_KEY
Definition: astobj2.h:1155
struct ao2_container * dialed_causes
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1756

◆ ast_channel_dialed_set()

void ast_channel_dialed_set ( struct ast_channel chan,
struct ast_party_dialed value 
)

Definition at line 954 of file channel_internal_api.c.

References AST_CHANNEL_SNAPSHOT_INVALIDATE_CALLER, ast_channel_snapshot_invalidate_segment(), ast_channel::dialed, and value.

Referenced by channel_do_masquerade().

955 {
956  chan->dialed = *value;
958 }
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.
int value
Definition: syslog.c:37
struct ast_party_dialed dialed
Dialed/Called information.

◆ ast_channel_dtmf_digit_to_emulate()

char ast_channel_dtmf_digit_to_emulate ( const struct ast_channel chan)

Definition at line 379 of file channel_internal_api.c.

Referenced by __ast_read().

380 {
381  return chan->dtmf_digit_to_emulate;
382 }

◆ ast_channel_dtmf_digit_to_emulate_set()

void ast_channel_dtmf_digit_to_emulate_set ( struct ast_channel chan,
char  value 
)

Definition at line 383 of file channel_internal_api.c.

References value.

Referenced by __ast_read().

384 {
385  chan->dtmf_digit_to_emulate = value;
386 }
int value
Definition: syslog.c:37

◆ ast_channel_dtmf_tv()

struct timeval* ast_channel_dtmf_tv ( struct ast_channel chan)

Definition at line 924 of file channel_internal_api.c.

References ast_channel::dtmf_tv.

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

925 {
926  return &chan->dtmf_tv;
927 }
struct timeval dtmf_tv

◆ ast_channel_dtmf_tv_set()

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

Definition at line 964 of file channel_internal_api.c.

References ast_channel::dtmf_tv, and value.

Referenced by __ast_read().

965 {
966  chan->dtmf_tv = *value;
967 }
int value
Definition: syslog.c:37
struct timeval dtmf_tv

◆ ast_channel_dtmff()

struct ast_frame* ast_channel_dtmff ( struct ast_channel chan)

Definition at line 880 of file channel_internal_api.c.

References ast_channel::dtmff.

Referenced by __ast_read(), and queue_dtmf_readq().

881 {
882  return &chan->dtmff;
883 }
struct ast_frame dtmff

◆ ast_channel_dtmff_set()

void ast_channel_dtmff_set ( struct ast_channel chan,
struct ast_frame value 
)

Definition at line 936 of file channel_internal_api.c.

References ast_channel::dtmff, and value.

937 {
938  chan->dtmff = *value;
939 }
int value
Definition: syslog.c:37
struct ast_frame dtmff

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

References ast_channel_tech(), and ast_channel_tech::early_bridge.

Referenced by dial_exec_full(), and wait_for_answer().

7513 {
7514  /* Make sure we can early bridge, if not error out */
7515  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)))
7516  return -1;
7517 
7518  return ast_channel_tech(c0)->early_bridge(c0, c1);
7519 }
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:769
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)

◆ ast_channel_emulate_dtmf_duration()

unsigned int ast_channel_emulate_dtmf_duration ( const struct ast_channel chan)

Definition at line 509 of file channel_internal_api.c.

Referenced by __ast_read().

510 {
511  return chan->emulate_dtmf_duration;
512 }

◆ ast_channel_emulate_dtmf_duration_set()

void ast_channel_emulate_dtmf_duration_set ( struct ast_channel chan,
unsigned int  value 
)

Definition at line 513 of file channel_internal_api.c.

References value.

Referenced by __ast_read().

514 {
515  chan->emulate_dtmf_duration = value;
516 }
int value
Definition: syslog.c:37

◆ 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.
Returns
Nothing

Definition at line 11070 of file channel.c.

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_SOFTHANGUP_ASYNCGOTO, ast_test_flag, ast_tvdiff_ms(), ast_tvnow(), LOG_DTMF, and option_dtmfminduration.

Referenced by bridge_channel_internal_join(), and channel_do_masquerade().

11071 {
11072  int dead;
11073  long duration;
11074 
11075  ast_channel_lock(chan);
11079  ast_channel_unlock(chan);
11080  if (dead) {
11081  /* Channel is a zombie or a real hangup. */
11082  return;
11083  }
11084 
11085  duration = ast_tvdiff_ms(ast_tvnow(), start);
11086  if (duration < option_dtmfminduration) {
11087  duration = option_dtmfminduration;
11088  }
11089  ast_senddigit_end(chan, digit, duration);
11090  ast_log(LOG_DTMF, "DTMF end '%c' simulated on %s due to %s, duration %ld ms\n",
11091  digit, ast_channel_name(chan), why, duration);
11092 }
char digit
#define ast_channel_lock(chan)
Definition: channel.h:2945
unsigned int option_dtmfminduration
Definition: options.c:83
#define ast_test_flag(p, flag)
Definition: utils.h:63
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:150
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:98
#define ast_log
Definition: astobj2.c:42
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition: channel.c:4969
#define ast_channel_unlock(chan)
Definition: channel.h:2946
#define LOG_DTMF
Definition: logger.h:307
int ast_channel_softhangup_internal_flag(struct ast_channel *chan)
const char * ast_channel_name(const struct ast_channel *chan)
struct ast_flags * ast_channel_flags(struct ast_channel *chan)

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

References ast_channel_internal_errno().

Referenced by ari_channels_handle_originate_with_id(), and ast_ari_channels_create().

11163 {
11164  return ast_channel_internal_errno();
11165 }
enum ast_channel_error ast_channel_internal_errno(void)

◆ ast_channel_exten()

const char* ast_channel_exten ( const struct ast_channel chan)
Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 353 of file channel_internal_api.c.

Referenced by __ast_goto_if_exists(), __ast_pbx_run(), _if_exec(), _macro_exec(), _while_exec(), action_bridge(), action_dialplan_exec(), ast_app_exec_macro(), ast_bridge_setup_after_goto(), ast_cc_call_init(), ast_channel_by_exten_cb(), ast_channel_log(), ast_channel_yank(), ast_pbx_h_exten_run(), ast_str_retrieve_variable(), AST_TEST_DEFINE(), ast_var_channels_table(), bridge_exec(), cb_events(), cc_generic_agent_init(), cc_interfaces_datastore_init(), chan_pjsip_cng_tone_detected(), channel_snapshot_dialplan_create(), dahdi_handle_dtmf(), dial_exec_full(), do_forward(), do_immediate_setup(), dundi_exec(), dundi_helper(), eval_exten_read(), expand_gosub_args(), fax_detect_framehook(), feature_blind_transfer(), find_matching_endif(), find_matching_endwhile(), forward_message(), func_channel_read(), func_channel_write_real(), get_cid_name(), gosub_exec(), gosub_run(), goto_parser(), handle_cli_misdn_show_channels(), handle_frame(), handle_gosub(), handle_setpriority(), handle_showchan(), launch_monitor_thread(), leave_voicemail(), log_exec(), lua_pbx_exec(), misdn_hangup(), misdn_update_redirecting(), misdn_write(), my_handle_dtmf(), onModeChanged(), ooh323_rtp_read(), ospauth_exec(), pbx_builtin_goto(), pbx_builtin_setvar_multiple(), pbx_builtin_waitexten(), pbx_extension_helper(), pbx_parseable_goto(), print_bc_info(), process_ast_dsp(), process_sdp(), raise_exception(), realtime_exec(), release_chan(), ring_entry(), serialize_showchan(), setup_env(), setup_peer_after_bridge_goto(), setup_privacy_args(), sip_read(), skinny_newcall(), try_calling(), and wait_for_answer().

354 {
355  return chan->exten;
356 }

◆ ast_channel_exten_set()

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

Definition at line 357 of file channel_internal_api.c.

References AST_CHANNEL_SNAPSHOT_INVALIDATE_DIALPLAN, ast_channel_snapshot_invalidate_segment(), and ast_copy_string().

Referenced by __analog_ss_thread(), __ast_channel_alloc_ap(), __ast_request_and_dial(), _macro_exec(), action_dialplan_exec(), alsa_new(), 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(), cb_events(), dahdi_new(), dial_exec_full(), dialout(), do_immediate_setup(), do_monitor_headset(), do_notify(), eval_exten_read(), forward_message(), generic_recall(), gosub_exec(), gosub_run(), handle_gosub(), handle_response_cmgr(), handle_setextension(), jingle_new(), leave_voicemail(), mgcp_new(), mgcp_ss(), minivm_greet_exec(), misdn_call(), misdn_digit_end(), misdn_new(), misdn_overlap_dial_task(), nbs_new(), ooh323_new(), pbx_builtin_background(), pbx_extension_helper(), pbx_outgoing_exec(), phone_new(), read_config(), return_exec(), ring_entry(), select_entry(), set_ext_pri(), setsubstate(), sip_new(), skinny_new(), unistim_ss(), and wait_for_answer().

358 {
359  ast_copy_string(chan->exten, value, sizeof(chan->exten));
361 }
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.
int value
Definition: syslog.c:37
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401

◆ ast_channel_fd()

int ast_channel_fd ( const struct ast_channel chan,
int  which 
)

Definition at line 1186 of file channel_internal_api.c.

References AST_VECTOR_GET, and AST_VECTOR_SIZE.

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

1187 {
1188  return (which >= AST_VECTOR_SIZE(&chan->fds)) ? -1 : AST_VECTOR_GET(&chan->fds, which);
1189 }
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

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

References ast_channel_fd_isset(), AST_EXTENDED_FDS, and AST_VECTOR_REPLACE.

Referenced by AST_TEST_DEFINE().

1201 {
1202  int pos = AST_EXTENDED_FDS;
1203 
1204  while (ast_channel_fd_isset(chan, pos)) {
1205  pos += 1;
1206  }
1207 
1208  AST_VECTOR_REPLACE(&chan->fds, pos, value);
1209 
1210  return pos;
1211 }
int value
Definition: syslog.c:37
#define AST_EXTENDED_FDS
Definition: channel.h:196
#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:284
int ast_channel_fd_isset(const struct ast_channel *chan, int which)

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

References AST_VECTOR_SIZE.

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

1196 {
1197  return AST_VECTOR_SIZE(&chan->fds);
1198 }
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ ast_channel_fd_isset()

int ast_channel_fd_isset ( const struct ast_channel chan,
int  which 
)

Definition at line 1190 of file channel_internal_api.c.

References ast_channel_fd().

Referenced by __ast_read(), and ast_channel_fd_add().

1191 {
1192  return ast_channel_fd(chan, which) > -1;
1193 }
int ast_channel_fd(const struct ast_channel *chan, int which)

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

References value.

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

424 {
425  chan->fdno = value;
426 }
int value
Definition: syslog.c:37

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

References channel_feature_hooks_set_full().

Referenced by AST_TEST_DEFINE().

11153 {
11154  return channel_feature_hooks_set_full(chan, features, 0);
11155 }
static int channel_feature_hooks_set_full(struct ast_channel *chan, struct ast_bridge_features *features, int replace)
Definition: channel.c:11115

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

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

Referenced by bridge_channel_internal_join().

11105 {
11106  struct ast_datastore *datastore;
11107 
11109  if (!datastore) {
11110  return NULL;
11111  }
11112  return datastore->data;
11113 }
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:2404
Structure for a data store object.
Definition: datastore.h:68
#define NULL
Definition: resample.c:96
void * data
Definition: datastore.h:70
static const struct ast_datastore_info bridge_features_info
Definition: channel.c:11099

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

References channel_feature_hooks_set_full().

11158 {
11159  return channel_feature_hooks_set_full(chan, features, 1);
11160 }
static int channel_feature_hooks_set_full(struct ast_channel *chan, struct ast_bridge_features *features, int replace)
Definition: channel.c:11115

◆ ast_channel_fin()

unsigned int ast_channel_fin ( const struct ast_channel chan)

Definition at line 517 of file channel_internal_api.c.

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

518 {
519  return chan->fin;
520 }

◆ ast_channel_fin_set()

void ast_channel_fin_set ( struct ast_channel chan,
unsigned int  value 
)

Definition at line 521 of file channel_internal_api.c.

References value.

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

522 {
523  chan->fin = value;
524 }
int value
Definition: syslog.c:37

◆ ast_channel_flags()

struct ast_flags* ast_channel_flags ( struct ast_channel chan)
Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 1260 of file channel_internal_api.c.

Referenced by __analog_ss_thread(), __ast_pbx_run(), __ast_queue_frame(), __ast_read(), __ast_request_and_dial(), _macro_exec(), 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_transfer_protocol(), ast_unreal_new_channels(), ast_var_channels_table(), ast_waitfor_nandfds(), ast_waitfordigit_full(), ast_write_stream(), bridge_channel_handle_control(), 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(), phone_read(), playtones_alloc(), retrydial_exec(), return_exec(), serialize_showchan(), should_skip_dtmf(), should_trigger_dtmf_emulating(), sip_fixup(), sip_new(), sip_peer_hold(), tonepair_alloc(), and waitstream_core().

1261 {
1262  return &chan->flags;
1263 }

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

References ast_assert, ast_channel_topic(), ast_endpoint_topic(), NULL, and stasis_forward_all().

Referenced by ast_endpoint_add_channel().

1513 {
1514  ast_assert(chan != NULL);
1515  ast_assert(endpoint != NULL);
1516 
1517  chan->endpoint_forward =
1519  ast_endpoint_topic(endpoint));
1520  if (!chan->endpoint_forward) {
1521  return -1;
1522  }
1523 
1524  return 0;
1525 }
struct stasis_topic * ast_endpoint_topic(struct ast_endpoint *endpoint)
Returns the topic for a specific endpoint.
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
struct stasis_topic * ast_channel_topic(struct ast_channel *chan)
A topic which publishes the events for a particular channel.
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:1578

◆ ast_channel_fout()

unsigned int ast_channel_fout ( const struct ast_channel chan)

Definition at line 525 of file channel_internal_api.c.

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

526 {
527  return chan->fout;
528 }

◆ ast_channel_fout_set()

void ast_channel_fout_set ( struct ast_channel chan,
unsigned int  value 
)

Definition at line 529 of file channel_internal_api.c.

References value.

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

530 {
531  chan->fout = value;
532 }
int value
Definition: syslog.c:37

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

References ast_channel::framehooks, and value.

Referenced by ast_framehook_attach(), and ast_framehook_list_destroy().

710 {
711  chan->framehooks = value;
712 }
int value
Definition: syslog.c:37
struct ast_framehook_list * framehooks

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

References ast_channel::generator, and value.

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

718 {
719  chan->generator = value;
720 }
struct ast_generator * generator
int value
Definition: syslog.c:37

◆ 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.
NULL on error

Definition at line 8090 of file channel.c.

References ari_vars, and channel_get_external_vars().

Referenced by ast_channel_snapshot_create().

8091 {
8092  return channel_get_external_vars(&ari_vars, chan);
8093 }
static struct external_vars ari_vars
Definition: channel.c:7934
static struct varshead * channel_get_external_vars(struct external_vars *channelvars, struct ast_channel *chan)
Definition: channel.c:8038

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

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

10736 {
10737  struct ast_bridge *bridge;
10738 
10739  bridge = ast_channel_internal_bridge(chan);
10740  if (bridge) {
10741  ao2_ref(bridge, +1);
10742  }
10743  return bridge;
10744 }
struct ast_bridge * ast_channel_internal_bridge(const struct ast_channel *chan)
#define ao2_ref(o, delta)
Definition: astobj2.h:464
Structure that contains information about a bridge.
Definition: bridge.h:357

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

References ao2_ref, and ast_channel_internal_bridge_channel().

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(), handle_soft_key_event_message(), handle_stimulus_message(), hold(), internal_bridge_after_cb(), manager_park_bridged(), mgcp_ss(), parker_parked_call_message_response(), play_sound(), recall_pull(), ringing(), send_message(), set_interval_hook(), transfer_pull(), try_parking(), and unhold().

10784 {
10785  struct ast_bridge_channel *bridge_channel;
10786 
10787  bridge_channel = ast_channel_internal_bridge_channel(chan);
10788  if (bridge_channel) {
10789  ao2_ref(bridge_channel, +1);
10790  }
10791  return bridge_channel;
10792 }
#define ao2_ref(o, delta)
Definition: astobj2.h:464
struct ast_bridge_channel * ast_channel_internal_bridge_channel(const struct ast_channel *chan)
Structure that contains information regarding a channel in a bridge.

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

References ast_channel_by_exten_cb(), and ast_channel_callback().

1460 {
1461  char *l_exten = (char *) exten;
1462  char *l_context = (char *) context;
1463 
1464  return ast_channel_callback(ast_channel_by_exten_cb, l_context, l_exten, 0);
1465 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
static int ast_channel_by_exten_cb(void *obj, void *arg, void *data, int flags)
Definition: channel.c:1306
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:1278
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116

◆ ast_channel_get_by_name()

struct ast_channel* ast_channel_get_by_name ( const char *  name)

Find a channel by name.

Channel search functions

Parameters
namethe name or uniqueid of the channel to search for

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

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

Definition at line 1454 of file channel.c.

References ast_channel_get_by_name_prefix().

Referenced by action_add_agi_cmd(), action_aocmessage(), action_atxfer(), action_blind_transfer(), action_cancel_atxfer(), action_getvar(), action_hangup(), 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_async_goto_by_name(), asyncgoto_exec(), bridge_channel_attended_transfer(), call_forwarded_handler(), change_monitor_action(), channel_find(), cli_channelstats_print_body(), common_exec(), controlplayback_manager(), do_pause_or_unpause(), find_control(), func_mchan_read(), func_mchan_write(), handle_cli_agi_add_cmd(), handle_core_set_debug_channel(), handle_getvariablefull(), 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_stop_mixmonitor(), moh_channel_thread(), parker_parked_call_message_response(), parking_park_bridge_channel(), pbx_builtin_importvar(), push_notify_channel(), refer_progress_bridge(), rtp_check_timeout(), senddtmf_exec(), sendmf_exec(), shared_read(), shared_write(), start_monitor_action(), stasis_app_bridge_moh_channel(), stasis_app_bridge_moh_stop(), stasis_app_bridge_playback_channel_find(), and stop_monitor_action().

1455 {
1457 }
static const char name[]
Definition: cdr_mysql.c:74
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:1434

◆ 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
nameThe channel name or uniqueid prefix to search for
name_lenOnly search for up to this many characters from the name

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

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

Definition at line 1434 of file channel.c.

References ast_channel_by_name_cb(), ast_channel_by_uniqueid_cb(), ast_channel_callback(), ast_strlen_zero, chanlist::chan, NULL, and OBJ_KEY.

Referenced by action_aocmessage(), action_bridge(), ast_channel_get_by_name(), 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().

1435 {
1436  struct ast_channel *chan;
1437  char *l_name = (char *) name;
1438 
1439  chan = ast_channel_callback(ast_channel_by_name_cb, l_name, &name_len,
1440  (name_len == 0) /* optimize if it is a complete name match */ ? OBJ_KEY : 0);
1441  if (chan) {
1442  return chan;
1443  }
1444 
1445  if (ast_strlen_zero(l_name)) {
1446  /* We didn't have a name to search for so quit. */
1447  return NULL;
1448  }
1449 
1450  /* Now try a search for uniqueid. */
1451  return ast_channel_callback(ast_channel_by_uniqueid_cb, l_name, &name_len, 0);
1452 }
Main Channel structure associated with a channel.
#define OBJ_KEY
Definition: astobj2.h:1155
#define NULL
Definition: resample.c:96
#define ast_strlen_zero(foo)
Definition: strings.h:52
static int ast_channel_by_uniqueid_cb(void *obj, void *arg, void *data, int flags)
Definition: channel.c:1329
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:1278
static const char name[]
Definition: cdr_mysql.c:74
static int ast_channel_by_name_cb(void *obj, void *arg, void *data, int flags)
Definition: channel.c:1284

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

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

Referenced by find_agent_callbacks().

10715 {
10716  int len = size;
10717  char *slash;
10718 
10720  return 0;
10721  }
10722 
10724  if ((slash = strchr(agent_type, '/'))) {
10725  *slash = '\0';
10726  }
10727  return 0;
10728 }
static struct aco_type agent_type
#define AST_OPTION_CC_AGENT_TYPE
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
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:7542
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
const char * ast_channel_name(const struct ast_channel *chan)

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

References ast_assert, ast_channel_cc_params_init(), ast_channel_datastore_find(), 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().

10676 {
10677  struct ast_datastore *cc_datastore;
10678 
10679  if (!(cc_datastore = ast_channel_datastore_find(chan, &cc_channel_datastore_info, NULL))) {
10680  /* If we can't find the datastore, it almost definitely means that the channel type being
10681  * used has not had its driver modified to parse CC config parameters. The best action
10682  * to take here is to create the parameters on the spot with the defaults set.
10683  */
10684  if (ast_channel_cc_params_init(chan, NULL)) {
10685  return NULL;
10686  }
10687  if (!(cc_datastore = ast_channel_datastore_find(chan, &cc_channel_datastore_info, NULL))) {
10688  /* Should be impossible */
10689  return NULL;
10690  }
10691  }
10692 
10693  ast_assert(cc_datastore->data != NULL);
10694  return cc_datastore->data;
10695 }
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:2404
static const struct ast_datastore_info cc_channel_datastore_info
Definition: channel.c:10646
#define ast_assert(a)
Definition: utils.h:695
Structure for a data store object.
Definition: datastore.h:68
#define NULL
Definition: resample.c:96
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:10652
void * data
Definition: datastore.h:70

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

References ast_assert, AST_MEDIA_TYPE_END, NULL, and type.

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

1621 {
1622  ast_assert(chan != NULL);
1624 
1625  return chan->default_streams[type];
1626 }
static const char type[]
Definition: chan_ooh323.c:109
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96

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

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(), sip_call(), and sip_handle_cc().

10698 {
10699  int len = name_buffer_length;
10700  char *dash;
10701  if (!ast_channel_queryoption(chan, AST_OPTION_DEVICE_NAME, device_name, &len, 0)) {
10702  return 0;
10703  }
10704 
10705  /* Dang. Do it the old-fashioned way */
10706  ast_copy_string(device_name, ast_channel_name(chan), name_buffer_length);
10707  if ((dash = strrchr(device_name, '-'))) {
10708  *dash = '\0';
10709  }
10710 
10711  return 0;
10712 }
#define AST_OPTION_DEVICE_NAME
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
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:7542
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
const char * ast_channel_name(const struct ast_channel *chan)

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

References ast_channel_get_duration_ms().

Referenced by end_bridge_callback(), serialize_showchan(), and show_chanstats_cb().

2840 {
2841  return (ast_channel_get_duration_ms(chan) / 1000);
2842 }
int64_t ast_channel_get_duration_ms(struct ast_channel *chan)
Obtain how long it&#39;s been, in milliseconds, since the channel was created.
Definition: channel.c:2829

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

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

2830 {
2831  ast_assert(NULL != chan);
2832 
2833  if (ast_tvzero(ast_channel_creationtime(chan))) {
2834  return 0;
2835  }
2837 }
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:108
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:150
#define ast_assert(a)
Definition: utils.h:695
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:98
#define NULL
Definition: resample.c:96
struct timeval ast_channel_creationtime(struct ast_channel *chan)

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

References ast_threadstorage_get_ptr().

Referenced by run_agi().

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

◆ 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.
NULL on error

Definition at line 8085 of file channel.c.

References ami_vars, and channel_get_external_vars().

Referenced by append_channel_vars(), and ast_channel_snapshot_create().

8086 {
8087  return channel_get_external_vars(&ami_vars, chan);
8088 }
static struct external_vars ami_vars
Definition: channel.c:7933
static struct varshead * channel_get_external_vars(struct external_vars *channelvars, struct ast_channel *chan)
Definition: channel.c:8038

◆ ast_channel_get_stream_topology()

struct ast_stream_topology* ast_channel_get_stream_topology ( const struct ast_channel chan)

Retrieve the topology of streams on a channel.

Parameters
chanThe channel to get the stream topology of
Precondition
chan is locked
Return values
non-NULLsuccess
NULLfailure

Definition at line 1583 of file channel_internal_api.c.

References ast_assert, and NULL.

Referenced by __ast_read(), ast_bridge_channel_stream_map(), ast_channel_request_stream_topology_change(), AST_TEST_DEFINE(), ast_unreal_indicate(), ast_write_stream(), dial_exec_full(), do_forward(), handle_showchan(), map_source_to_destinations(), native_rtp_bridge_join(), native_rtp_stream_topology_changed(), sfu_topologies_on_join(), sfu_topologies_on_source_change(), simple_bridge_join(), simple_bridge_stream_topology_changed(), softmix_bridge_stream_sources_update(), softmix_bridge_stream_topology_changed(), stream_echo_exec(), stream_echo_write(), and stream_echo_write_error().

1585 {
1586  ast_assert(chan != NULL);
1587 
1588  return chan->stream_topology;
1589 }
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96

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

Referenced by native_rtp_stream_topology_changed(), and simple_bridge_stream_topology_changed().

673 {
674  return chan->stream_topology_change_source;
675 }

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

References ast_channel_queryoption(), AST_OPTION_T38_STATE, 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(), spandsp_fax_gateway_start(), transmit(), transmit_audio(), and transmit_t38().

2874 {
2876  int datalen = sizeof(state);
2877 
2878  ast_channel_queryoption(chan, AST_OPTION_T38_STATE, &state, &datalen, 0);
2879 
2880  return state;
2881 }
enum sip_cc_notify_state state
Definition: chan_sip.c:959
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:7542
ast_t38_state
Possible T38 states on channels.
Definition: channel.h:879
#define AST_OPTION_T38_STATE

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

References ast_channel_get_up_time_ms().

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

2855 {
2856  return (ast_channel_get_up_time_ms(chan) / 1000);
2857 }
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:2844

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

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

2845 {
2846  ast_assert(NULL != chan);
2847 
2848  if (ast_tvzero(ast_channel_answertime(chan))) {
2849  return 0;
2850  }
2852 }
struct timeval ast_channel_answertime(struct ast_channel *chan)
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:108
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:150
#define ast_assert(a)
Definition: utils.h:695
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:98
#define NULL
Definition: resample.c:96

◆ 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.
NULL on error

Definition at line 8013 of file channel.c.

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

8014 {
8015  RAII_VAR(struct varshead *, ret, NULL, ao2_cleanup);
8016  struct ast_var_t *cv;
8017 
8018  ret = ao2_alloc(sizeof(*ret), varshead_dtor);
8019 
8020  if (!ret) {
8021  return NULL;
8022  }
8023 
8026 
8027  if (!var) {
8028  return NULL;
8029  }
8030 
8031  AST_LIST_INSERT_TAIL(ret, var, entries);
8032  }
8033 
8034  ao2_ref(ret, +1);
8035  return ret;
8036 }
const char * ast_var_value(const struct ast_var_t *var)
Definition: chanvars.c:80
const char * ast_var_name(const struct ast_var_t *var)
Definition: chanvars.c:60
#define var
Definition: ast_expr2f.c:614
struct varshead * ast_channel_varshead(struct ast_channel *chan)
#define NULL
Definition: resample.c:96
static void varshead_dtor(void *obj)
Destructor for lists of variables.
Definition: channel.c:8003
#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:911
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:730
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
struct ast_var_t::@249 entries
#define ast_var_assign(name, value)
Definition: chanvars.h:40
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

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

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_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(), handle_clear_alarms(), handle_incoming(), iax2_key_rotate(), indicate_data_internal(), jingle_action_session_terminate(), misdn_write(), and socket_process_helper().

4392 {
4393  char causevar[256];
4394 
4395  if (ast_channel_dialed_causes_add(chan, cause_code, datalen)) {
4396  ast_log(LOG_WARNING, "Unable to store hangup cause for %s on %s\n", cause_code->chan_name, ast_channel_name(chan));
4397  }
4398 
4399  if (cause_code->emulate_sip_cause) {
4400  snprintf(causevar, sizeof(causevar), "HASH(SIP_CAUSE,%s)", cause_code->chan_name);
4401  ast_func_write(chan, causevar, cause_code->code);
4402  }
4403 }
char chan_name[AST_CHANNEL_NAME]
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42
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.
const char * ast_channel_name(const struct ast_channel *chan)
int ast_func_write(struct ast_channel *chan, const char *function, const char *value)
executes a write operation on a function

◆ ast_channel_hangupcause_set()

void ast_channel_hangupcause_set ( struct ast_channel chan,
int  value 
)

Definition at line 431 of file channel_internal_api.c.

References AST_CHANNEL_SNAPSHOT_INVALIDATE_HANGUP, ast_channel_snapshot_invalidate_segment(), and value.

Referenced by __ast_read(), __ast_request_and_dial(), __attempt_transmit(), agent_run(), ast_ari_channels_hangup(), ast_channel_softhangup_withcause_locked(), ast_do_pickup(), AST_TEST_DEFINE(), ast_unreal_call_setup(), ast_unreal_hangup(), call_pickup_incoming_request(), cb_events(), channel_set_cause(), check_rtp_timeout(), console_new(), dahdi_indicate(), dial_exec_full(), disa_exec(), eivr_comm(), handle_call_outgoing(), handle_clear_alarms(), handle_request_invite(), handle_response(), handle_response_invite(), hangup_channel(), hangupcalls(), hanguptree(), iax2_call(), indicate_busy(), indicate_congestion(), jingle_indicate(), mbl_queue_hangup(), misdn_call(), onCallCleared(), pbx_builtin_hangup(), pbx_start_incoming_request(), receive_dtmf_digits(), refer_incoming_invite_request(), retrans_pkt(), rfc3326_use_reason_header(), ring_entry(), rtp_check_timeout(), send_cause2ast(), session_inv_on_media_update(), set_hangup_source_and_cause(), sip_call(), sip_pickup_thread(), socket_process_helper(), use_reason_header(), wait_for_answer(), and wait_for_winner().

432 {
433  chan->hangupcause = value;
435 }
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.
int value
Definition: syslog.c:37

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

References ari_vars, and channel_has_external_vars().

7963 {
7965 }
static struct external_vars ari_vars
Definition: channel.c:7934
static int channel_has_external_vars(struct external_vars *channelvars)
Definition: channel.c:7946

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

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

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

2524 {
2525  return ast_channel_monitor(chan)
2528 }
int ast_audiohook_write_list_empty(struct ast_audiohook_list *audiohook_list)
Determine if a audiohook_list is empty or not.
Definition: audiohook.c:1112
struct ast_framehook_list * ast_channel_framehooks(const struct ast_channel *chan)
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
struct ast_audiohook_list * ast_channel_audiohooks(const struct ast_channel *chan)
struct ast_channel_monitor * ast_channel_monitor(const struct ast_channel *chan)

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

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

Referenced by native_rtp_bridge_capable().

2531 {
2532  return ast_channel_monitor(chan)
2535 }
int ast_audiohook_write_list_empty(struct ast_audiohook_list *audiohook_list)
Determine if a audiohook_list is empty or not.
Definition: audiohook.c:1112
struct ast_framehook_list * ast_channel_framehooks(const struct ast_channel *chan)
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
struct ast_audiohook_list * ast_channel_audiohooks(const struct ast_channel *chan)
struct ast_channel_monitor * ast_channel_monitor(const struct ast_channel *chan)

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

References ami_vars, and channel_has_external_vars().

Referenced by ast_channel_publish_varset().

7958 {
7960 }
static struct external_vars ami_vars
Definition: channel.c:7933
static int channel_has_external_vars(struct external_vars *channelvars)
Definition: channel.c:7946

◆ ast_channel_hold_state()

int ast_channel_hold_state ( const struct ast_channel chan)

Definition at line 485 of file channel_internal_api.c.

Referenced by ast_parse_device_state(), bridge_channel_internal_join(), channel_do_masquerade(), func_channel_read(), and softmix_bridge_join().

486 {
487  return chan->hold_state;
488 }

◆ ast_channel_hold_state_set()

void ast_channel_hold_state_set ( struct ast_channel chan,
int  value 
)

Definition at line 489 of file channel_internal_api.c.

References value.

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

490 {
491  chan->hold_state = value;
492 }
int value
Definition: syslog.c:37

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

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

6867 {
6868  struct ast_var_t *current;
6869  struct ast_var_t *newvar;
6870  const char *varname;
6871  int vartype;
6872 
6873  AST_LIST_TRAVERSE(ast_channel_varshead((struct ast_channel *) parent), current, entries) {
6874  varname = ast_var_full_name(current);
6875  if (!varname) {
6876  continue;
6877  }
6878 
6879  vartype = 0;
6880  if (varname[0] == '_') {
6881  vartype = 1;
6882  if (varname[1] == '_') {
6883  vartype = 2;
6884  }
6885  }
6886 
6887  switch (vartype) {
6888  case 1:
6889  newvar = ast_var_assign(&varname[1], ast_var_value(current));
6890  break;
6891  case 2:
6892  newvar = ast_var_assign(varname, ast_var_value(current));
6893  break;
6894  default:
6895  continue;
6896  }
6897  if (newvar) {
6898  ast_debug(1, "Inheriting variable %s from %s to %s.\n",
6899  ast_var_full_name(newvar), ast_channel_name(parent),
6900  ast_channel_name(child));
6903  ast_var_value(newvar));
6904  }
6905  }
6906 }
Main Channel structure associated with a channel.
const char * ast_var_value(const struct ast_var_t *var)
Definition: chanvars.c:80
struct varshead * ast_channel_varshead(struct ast_channel *chan)
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:730
void ast_channel_publish_varset(struct ast_channel *chan, const char *variable, const char *value)
Publish a ast_channel_varset for a channel.
const char * ast_var_full_name(const struct ast_var_t *var)
Definition: chanvars.c:75
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
struct ast_var_t::@249 entries
#define ast_var_assign(name, value)
Definition: chanvars.h:40
const char * ast_channel_name(const struct ast_channel *chan)

◆ ast_channel_insmpl()

unsigned long ast_channel_insmpl ( const struct ast_channel chan)

Definition at line 533 of file channel_internal_api.c.

References ast_channel::insmpl.

Referenced by __ast_read(), and ast_write_stream().

534 {
535  return chan->insmpl;
536 }
unsigned long insmpl

◆ ast_channel_insmpl_set()

void ast_channel_insmpl_set ( struct ast_channel chan,
unsigned long  value 
)

Definition at line 537 of file channel_internal_api.c.

References ast_channel::insmpl, and value.

Referenced by __ast_read(), and ast_monitor_start().

538 {
539  chan->insmpl = value;
540 }
int value
Definition: syslog.c:37
unsigned long insmpl

◆ ast_channel_internal_alert_flush()

ast_alert_status_t ast_channel_internal_alert_flush ( struct ast_channel chan)

Definition at line 1115 of file channel_internal_api.c.

References ast_alertpipe_flush().

Referenced by chan_cleanup().

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

◆ ast_channel_internal_alert_read()

ast_alert_status_t ast_channel_internal_alert_read ( struct ast_channel chan)

Definition at line 1120 of file channel_internal_api.c.

References ast_alertpipe_read().

Referenced by __ast_queue_frame(), and __ast_read().

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

◆ ast_channel_internal_alert_readable()

int ast_channel_internal_alert_readable ( struct ast_channel chan)

Definition at line 1130 of file channel_internal_api.c.

References ast_alertpipe_readable().

1131 {
1132  return ast_alertpipe_readable(chan->alertpipe);
1133 }
int ast_alertpipe_readable(int alert_pipe[2])
Determine if the alert pipe is readable.
Definition: alertpipe.h:112

◆ ast_channel_internal_alert_readfd()

int ast_channel_internal_alert_readfd ( struct ast_channel chan)

Definition at line 1150 of file channel_internal_api.c.

References ast_alertpipe_readfd().

Referenced by __ast_channel_alloc_ap().

1151 {
1152  return ast_alertpipe_readfd(chan->alertpipe);
1153 }
int ast_alertpipe_readfd(int alert_pipe[2])
Get the alert pipe&#39;s read file descriptor.
Definition: alertpipe.h:143

◆ ast_channel_internal_alertpipe_clear()

void ast_channel_internal_alertpipe_clear ( struct ast_channel chan)

Definition at line 1135 of file channel_internal_api.c.

References ast_alertpipe_clear().

Referenced by __ast_channel_alloc_ap(), and __ast_dummy_channel_alloc().

1136 {
1137  ast_alertpipe_clear(chan->alertpipe);
1138 }
void ast_alertpipe_clear(int alert_pipe[2])
Sets the alert pipe file descriptors to default values.
Definition: alertpipe.h:97

◆ ast_channel_internal_alertpipe_close()

void ast_channel_internal_alertpipe_close ( struct ast_channel chan)

Definition at line 1140 of file channel_internal_api.c.

References ast_alertpipe_close().

Referenced by ast_channel_destructor().

1141 {
1142  ast_alertpipe_close(chan->alertpipe);
1143 }
void ast_alertpipe_close(int alert_pipe[2])
Close an alert pipe.
Definition: alertpipe.c:79

◆ ast_channel_internal_alertpipe_init()

int ast_channel_internal_alertpipe_init ( struct ast_channel chan)

Definition at line 1145 of file channel_internal_api.c.

References ast_alertpipe_init().

Referenced by __ast_channel_alloc_ap().

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

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

References ast_alertpipe_swap().

Referenced by channel_do_masquerade().

1156 {
1157  ast_alertpipe_swap(chan1->alertpipe, chan2->alertpipe);
1158 }
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:158

◆ ast_channel_internal_bridge()

struct ast_bridge* ast_channel_internal_bridge ( const struct ast_channel chan)

Definition at line 1240 of file channel_internal_api.c.

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

1241 {
1242  return chan->bridge;
1243 }

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

Definition at line 1255 of file channel_internal_api.c.

References value.

Referenced by ast_bridge_depart(), ast_bridge_join(), bridge_channel_ind_thread(), and bridge_impart_internal().

1256 {
1257  chan->bridge_channel = value;
1258 }
int value
Definition: syslog.c:37

◆ ast_channel_internal_bridge_set()

void ast_channel_internal_bridge_set ( struct ast_channel chan,
struct ast_bridge value 
)
Precondition
chan is locked

Definition at line 1244 of file channel_internal_api.c.

References ast_channel_publish_snapshot(), AST_CHANNEL_SNAPSHOT_INVALIDATE_BRIDGE, ast_channel_snapshot_invalidate_segment(), and value.

Referenced by bridge_channel_change_bridge(), and bridge_channel_internal_join().

1245 {
1246  chan->bridge = value;
1249 }
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.
int value
Definition: syslog.c:37
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.

◆ 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
Returns
void

Definition at line 1404 of file channel_internal_api.c.

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

1405 {
1406  if (dest->linkedid.creation_time == source->linkedid.creation_time
1407  && dest->linkedid.creation_unique == source->linkedid.creation_unique
1408  && !strcmp(dest->linkedid.unique_id, source->linkedid.unique_id)) {
1409  return;
1410  }
1411  dest->linkedid = source->linkedid;
1414 }
struct ast_channel_id linkedid
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.
char unique_id[AST_MAX_UNIQUEID]
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.

◆ ast_channel_internal_fd_clear()

void ast_channel_internal_fd_clear ( struct ast_channel chan,
int  which 
)

Definition at line 1174 of file channel_internal_api.c.

References AST_VECTOR_REPLACE, and AST_VECTOR_SIZE.

Referenced by handle_negotiated_sdp().

1175 {
1176  if (which >= AST_VECTOR_SIZE(&chan->fds)) {
1177  return;
1178  }
1179 
1180  AST_VECTOR_REPLACE(&chan->fds, which, -1);
1181 }
#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:284
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ ast_channel_internal_fd_clear_all()

void ast_channel_internal_fd_clear_all ( struct ast_channel chan)

Definition at line 1182 of file channel_internal_api.c.

References AST_VECTOR_ELEM_CLEANUP_NOOP, and AST_VECTOR_RESET.

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

1183 {
1185 }
#define AST_VECTOR_ELEM_CLEANUP_NOOP(elem)
Vector element cleanup that does nothing.
Definition: vector.h:573
#define AST_VECTOR_RESET(vec, cleanup)
Reset vector.
Definition: vector.h:627

◆ ast_channel_internal_fd_set()

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

Definition at line 1161 of file channel_internal_api.c.

References AST_VECTOR_REPLACE, and AST_VECTOR_SIZE.

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

1162 {
1163  int pos;
1164 
1165  /* This ensures that if the vector has to grow with unused positions they will be
1166  * initialized to -1.
1167  */
1168  for (pos = AST_VECTOR_SIZE(&chan->fds); pos < which; pos++) {
1169  AST_VECTOR_REPLACE(&chan->fds, pos, -1);
1170  }
1171 
1172  AST_VECTOR_REPLACE(&chan->fds, which, value);
1173 }
int value
Definition: syslog.c:37
#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:284
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

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

References a, ast_assert, b, ast_channel_id::creation_time, ast_channel_id::creation_unique, and ast_channel::linkedid.

Referenced by ast_bridge_channel_update_linkedids().

1388 {
1391 
1393  return a;
1394  }
1396  return b;
1397  }
1399  return a;
1400  }
1401  return b;
1402 }
struct ast_channel_id linkedid
#define ast_assert(a)
Definition: utils.h:695
static struct test_val b
static struct test_val a

◆ 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
Returns
void
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 1465 of file channel_internal_api.c.

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

Referenced by ast_cel_fabricate_channel_from_event().

1466 {
1467  ast_copy_string(chan->uniqueid.unique_id, uniqueid, sizeof(chan->uniqueid.unique_id));
1468  ast_copy_string(chan->linkedid.unique_id, linkedid, sizeof(chan->linkedid.unique_id));
1469 }
struct ast_channel_id linkedid
char unique_id[AST_MAX_UNIQUEID]
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
struct ast_channel_id uniqueid

◆ 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
Returns
void
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 1447 of file channel_internal_api.c.

Referenced by channel_do_masquerade().

1448 {
1449  struct stasis_forward *temp;
1450 
1451  temp = a->endpoint_forward;
1452  a->endpoint_forward = b->endpoint_forward;
1453  b->endpoint_forward = temp;
1454 }
Forwarding information.
Definition: stasis.c:1531

◆ 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
Returns
void
Note
This is used in masquerade to exchange snapshots

Definition at line 1456 of file channel_internal_api.c.

Referenced by channel_do_masquerade().

1457 {
1458  struct ast_channel_snapshot *snapshot;
1459 
1460  snapshot = a->snapshot;
1461  a->snapshot = b->snapshot;
1462  b->snapshot = snapshot;
1463 }
Structure representing a snapshot of channel state.

◆ 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
Returns
void
Note
This is used in masquerade to exchange topics for message routing

Definition at line 1433 of file channel_internal_api.c.

Referenced by channel_do_masquerade().

1434 {
1435  struct stasis_topic *topic;
1436  struct stasis_forward *forward;
1437 
1438  topic = a->topic;
1439  a->topic = b->topic;
1440  b->topic = topic;
1441 
1442  forward = a->channel_forward;
1443  a->channel_forward = b->channel_forward;
1444  b->channel_forward = forward;
1445 }
Forwarding information.
Definition: stasis.c:1531

◆ 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
Returns
void
Note
This is used in masquerade to exchange identities

Definition at line 1416 of file channel_internal_api.c.

References ast_channel::linkedid, and ast_channel::uniqueid.

Referenced by channel_do_masquerade().

1417 {
1418  struct ast_channel_id temp;
1419 
1420  /* This operation is used as part of masquerading and so does not invalidate the peer
1421  * segment. This is due to the masquerade process invalidating all segments.
1422  */
1423 
1424  temp = a->uniqueid;
1425  a->uniqueid = b->uniqueid;
1426  b->uniqueid = temp;
1427 
1428  temp = a->linkedid;
1429  a->linkedid = b->linkedid;
1430  b->linkedid = temp;
1431 }
struct ast_channel_id linkedid
Channel UniqueId structure.
struct ast_channel_id uniqueid

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

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(), audio_audiohook_write_list(), chan_pjsip_read_stream(), chan_pjsip_set_rtp_peer(), common_exec(), console_transfer(), dtmf_audiohook_write_list(), mixmonitor_autochan_is_bridged(), set_caps(), set_timeout(), sip_set_rtp_peer(), wait_for_bridged(), and wait_for_unbridged().

10747 {
10748  return ast_channel_internal_bridge(chan) != NULL;
10749 }
struct ast_bridge * ast_channel_internal_bridge(const struct ast_channel *chan)
#define NULL
Definition: resample.c:96

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

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

Referenced by ast_indicate_data(), and bridge_channel_internal_pull().

10752 {
10753  int hangup_flags = ast_channel_softhangup_internal_flag(chan);
10754  int hangup_test = hangup_flags & AST_SOFTHANGUP_ASYNCGOTO;
10755  int unbridge = ast_channel_unbridged(chan);
10756 
10757  /* This function should only return true if either the unbridged flag or
10758  * the ASYNCGOTO soft hangup flag is set and when no other soft hangup
10759  * flags are set. Any other soft hangup flags being set should make it
10760  * return false.
10761  */
10762  return ((hangup_test || unbridge) && (hangup_test == hangup_flags));
10763 }
int ast_channel_softhangup_internal_flag(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.

◆ ast_channel_is_multistream()

int ast_channel_is_multistream ( struct ast_channel chan)

Determine if a channel is multi-stream capable.

Parameters
channelThe channel to test
Precondition
chan is locked
Returns
Returns true if the channel is multi-stream capable.

Definition at line 1643 of file channel_internal_api.c.

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

1644 {
1645  return (chan && chan->tech && chan->tech->read_stream && chan->tech->write_stream);
1646 }
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.h), with stream num.
Definition: channel.h:748
const struct ast_channel_tech * tech
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:754

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

References ast_channel_is_t38_active_nolock(), ast_channel_lock, and ast_channel_unlock.

Referenced by bridge_channel_internal_join().

1047 {
1048  int res;
1049 
1050  ast_channel_lock(chan);
1052  ast_channel_unlock(chan);
1053  return res;
1054 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
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...
#define ast_channel_unlock(chan)
Definition: channel.h:2946

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

Referenced by ast_channel_is_t38_active().

1042 {
1043  return chan->is_t38_active;
1044 }

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

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

Referenced by action_hangup(), action_status(), 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().

1409 {
1410  struct ast_channel_iterator *i;
1411 
1412  if (!(i = ast_calloc(1, sizeof(*i)))) {
1413  return NULL;
1414  }
1415 
1418 
1419  return i;
1420 }
#define NULL
Definition: resample.c:96
struct ao2_iterator simple_iterator
Definition: channel.c:1353
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:124
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
struct ao2_iterator * active_iterator
Definition: channel.c:1357
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.

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

References ast_channel_iterator::active_iterator, ast_calloc, ast_channel_by_exten_cb(), ast_channel_callback(), ast_free, NULL, and OBJ_MULTIPLE.

Referenced by common_exec(), and pickup_by_exten().

1369 {
1370  struct ast_channel_iterator *i;
1371  char *l_exten = (char *) exten;
1372  char *l_context = (char *) context;
1373 
1374  if (!(i = ast_calloc(1, sizeof(*i)))) {
1375  return NULL;
1376  }
1377 
1379  l_context, l_exten, OBJ_MULTIPLE);
1380  if (!i->active_iterator) {
1381  ast_free(i);
1382  return NULL;
1383  }
1384 
1385  return i;
1386 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
static int ast_channel_by_exten_cb(void *obj, void *arg, void *data, int flags)
Definition: channel.c:1306
#define NULL
Definition: resample.c:96
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:1278
#define ast_free(a)
Definition: astmm.h:182
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
struct ao2_iterator * active_iterator
Definition: channel.c:1357
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116

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

References ast_channel_iterator::active_iterator, ast_calloc, ast_channel_by_name_cb(), ast_channel_callback(), ast_free, NULL, OBJ_KEY, and OBJ_MULTIPLE.

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

1389 {
1390  struct ast_channel_iterator *i;
1391  char *l_name = (char *) name;
1392 
1393  if (!(i = ast_calloc(1, sizeof(*i)))) {
1394  return NULL;
1395  }
1396 
1398  l_name, &name_len,
1399  OBJ_MULTIPLE | (name_len == 0 /* match the whole word, so optimize */ ? OBJ_KEY : 0));
1400  if (!i->active_iterator) {
1401  ast_free(i);
1402  return NULL;
1403  }
1404 
1405  return i;
1406 }
#define OBJ_KEY
Definition: astobj2.h:1155
#define NULL
Definition: resample.c:96
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:1278
static const char name[]
Definition: cdr_mysql.c:74
#define ast_free(a)
Definition: astmm.h:182
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
static int ast_channel_by_name_cb(void *obj, void *arg, void *data, int flags)
Definition: channel.c:1284
struct ao2_iterator * active_iterator
Definition: channel.c:1357

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

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

Definition at line 1360 of file channel.c.

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

Referenced by action_hangup(), action_status(), 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().

1361 {
1363  ast_free(i);
1364 
1365  return NULL;
1366 }
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define NULL
Definition: resample.c:96
#define ast_free(a)
Definition: astmm.h:182
struct ao2_iterator * active_iterator
Definition: channel.c:1357

◆ 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.
NULL,ifno more channels match the iterator parameters.
Since
1.8

Definition at line 1422 of file channel.c.

References ast_channel_iterator::active_iterator, and ao2_iterator_next.

Referenced by action_hangup(), action_status(), 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().

1423 {
1425 }
#define ao2_iterator_next(iter)
Definition: astobj2.h:1933
struct ao2_iterator * active_iterator
Definition: channel.c:1357

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

References ast_channel::jb, and value.

941 {
942  chan->jb = *value;
943 }
int value
Definition: syslog.c:37
struct ast_jb jb

◆ ast_channel_language()

const char* ast_channel_language ( const struct ast_channel chan)
Examples:
/usr/src/asterisk-18.5.0/main/app.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(), ast_app_getdata(), ast_app_getdata_full(), ast_ari_channels_dial(), ast_moh_files_next(), 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(), leave_voicemail(), limits_interval_playback(), meetme_menu_admin(), meetme_menu_admin_extended(), meetme_menu_normal(), mgcp_ss(), minivm_greet_exec(), page_exec(), pbx_builtin_background(), pbx_builtin_saycharacters(), pbx_builtin_saycharacters_case(), pbx_builtin_saydigits(), pbx_builtin_saymoney(), pbx_builtin_saynumber(), 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_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(), and wait_for_winner().

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

Definition at line 311 of file channel_internal_api.c.

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

Referenced by ast_channel_log(), AST_TEST_DEFINE(), channel_snapshot_peer_create(), func_channel_read(), func_mchan_read(), func_mchan_write(), handle_showchan(), and serialize_showchan().

312 {
313  ast_assert(chan->linkedid.unique_id[0] != '\0');
314  return chan->linkedid.unique_id;
315 }
struct ast_channel_id linkedid
char unique_id[AST_MAX_UNIQUEID]
#define ast_assert(a)
Definition: utils.h:695

◆ ast_channel_macrocontext()

const char* ast_channel_macrocontext ( const struct ast_channel chan)

◆ ast_channel_macrocontext_set()

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

Definition at line 366 of file channel_internal_api.c.

References ast_copy_string().

Referenced by _macro_exec().

367 {
368  ast_copy_string(chan->macrocontext, value, sizeof(chan->macrocontext));
369 }
int value
Definition: syslog.c:37
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401

◆ ast_channel_macroexten()

const char* ast_channel_macroexten ( const struct ast_channel chan)

◆ ast_channel_macroexten_set()

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

Definition at line 374 of file channel_internal_api.c.

References ast_copy_string().

Referenced by _macro_exec().

375 {
376  ast_copy_string(chan->macroexten, value, sizeof(chan->macroexten));
377 }
int value
Definition: syslog.c:37
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401

◆ ast_channel_macropriority()

int ast_channel_macropriority ( const struct ast_channel chan)

Definition at line 436 of file channel_internal_api.c.

Referenced by ast_channel_log(), and ast_var_channels_table().

437 {
438  return chan->macropriority;
439 }

◆ ast_channel_macropriority_set()

void ast_channel_macropriority_set ( struct ast_channel chan,
int  value 
)

Definition at line 440 of file channel_internal_api.c.

References value.

Referenced by _macro_exec().

441 {
442  chan->macropriority = value;
443 }
int value
Definition: syslog.c:37

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

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

6818 {
6819  /*
6820  * Set up translation from the peer to the chan first in case we
6821  * need to hear any in-band tones and the other direction fails.
6822  */
6823  if (ast_channel_make_compatible_helper(peer, chan)) {
6824  return -1;
6825  }
6826 
6827  /* Set up translation from the chan to the peer */
6828  if (ast_channel_make_compatible_helper(chan, peer)) {
6829  return -1;
6830  }
6831 
6832  return 0;
6833 }
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:6738

◆ ast_channel_masq()

struct ast_channel* ast_channel_masq ( const struct ast_channel chan)

Definition at line 597 of file channel_internal_api.c.

References ast_channel::masq.

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

598 {
599  return chan->masq;
600 }
struct ast_channel * masq

◆ ast_channel_masq_set()

void ast_channel_masq_set ( struct ast_channel chan,
struct ast_channel value 
)

Definition at line 601 of file channel_internal_api.c.

References ast_channel::masq, and value.

Referenced by ast_channel_move(), and channel_do_masquerade().

602 {
603  chan->masq = value;
604 }
struct ast_channel * masq
int value
Definition: syslog.c:37

◆ ast_channel_masqr()

struct ast_channel* ast_channel_masqr ( const struct ast_channel chan)

Definition at line 605 of file channel_internal_api.c.

References ast_channel::masqr.

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

606 {
607  return chan->masqr;
608 }
struct ast_channel * masqr

◆ ast_channel_masqr_set()

void ast_channel_masqr_set ( struct ast_channel chan,
struct ast_channel value 
)

Definition at line 609 of file channel_internal_api.c.

References ast_channel::masqr, and value.

Referenced by ast_channel_move(), and channel_do_masquerade().

610 {
611  chan->masqr = value;
612 }
struct ast_channel * masqr
int value
Definition: syslog.c:37

◆ ast_channel_monitor()

struct ast_channel_monitor* ast_channel_monitor ( const struct ast_channel chan)

◆ ast_channel_monitor_set()

void ast_channel_monitor_set ( struct ast_channel chan,
struct ast_channel_monitor value 
)

Definition at line 617 of file channel_internal_api.c.

References ast_channel::monitor, and value.

Referenced by ast_monitor_start(), ast_monitor_stop(), and channel_do_masquerade().

618 {
619  chan->monitor = value;
620 }
int value
Definition: syslog.c:37
struct ast_channel_monitor * monitor

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

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(), handle_invite_replaces(), local_call(), and refer_incoming_invite_request().

10868 {
10869  RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
10871 
10872  if (dest == source) {
10873  ast_log(LOG_WARNING, "Can't move channel '%s' into itself!\n",
10874  ast_channel_name(dest));
10875  return -1;
10876  }
10877 
10878  ast_channel_lock_both(dest, source);
10879 
10882  /* Zombies! Run! */
10884  "Can't move channel. One or both is dead (%s <-- %s)\n",
10885  ast_channel_name(dest), ast_channel_name(source));
10886  ast_channel_unlock(source);
10887  ast_channel_unlock(dest);
10888  return -1;
10889  }
10890 
10891  ast_channel_masq_set(dest, source);
10892  ast_channel_masqr_set(source, dest);
10893 
10894  blob = ast_json_pack("{s: s}",
10895  "newchanneluniqueid", ast_channel_uniqueid(dest));
10897 
10898  ast_channel_unlock(dest);
10899  ast_channel_unlock(source);
10900 
10901  channel_do_masquerade(dest, source);
10902  return 0;
10903 }
static ast_mutex_t channel_move_lock
Definition: channel.c:10865
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:591
#define ast_test_flag(p, flag)
Definition: utils.h:63
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
#define LOG_WARNING
Definition: logger.h:274
#define NULL
Definition: resample.c:96
#define ast_log
Definition: astobj2.c:42
void ast_channel_masq_set(struct ast_channel *chan, struct ast_channel *value)
#define SCOPED_MUTEX(varname, lock)
scoped lock specialization for mutexes
Definition: lock.h:587
#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:911
ast_mutex_t lock
Definition: app_meetme.c:1091
void ast_channel_masqr_set(struct ast_channel *chan, struct ast_channel *value)
const char * ast_channel_uniqueid(const struct ast_channel *chan)
static void channel_do_masquerade(struct ast_channel *original, struct ast_channel *clonechan)
Masquerade a channel.
Definition: channel.c:6952
#define ast_channel_unlock(chan)
Definition: channel.h:2946
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition: channel.h:2952
const char * ast_channel_name(const struct ast_channel *chan)
Abstract JSON element (object, array, string, int, ...).
void ast_channel_publish_blob(struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
Publish a channel blob message.
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
struct stasis_message_type * ast_channel_masquerade_type(void)
Message type for when a channel is being masqueraded.

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

References ast_channel::music_state, and value.

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

562 {
563  chan->music_state = value;
564 }
int value
Definition: syslog.c:37

◆ 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)
Examples:
/usr/src/asterisk-18.5.0/main/app.c.

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(), __print_debug_details(), __sip_autodestruct(), _analog_get_index(), _dahdi_get_index(), _macro_exec(), _skinny_show_lines(), acf_curl_helper(), acf_faxopt_read(), acf_faxopt_write(), acf_jabberreceive_read(), action_add_agi_cmd(), action_bridge(), action_confbridgesetsinglevideosrc(), action_dahdishowchannels(), action_hangup(), action_kick_last(), action_meetmelist(), add_agi_cmd(), adsi_prog(), 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(), alsa_indicate(), alsa_new(), analog_answer(), analog_attempt_transfer(), analog_call(), analog_exception(), analog_fixup(), analog_handle_dtmf(), analog_hangup(), analog_ss_thread(), announce_to_dial(), answer(), aoc_display_decoded_debug(), app_control_redirect(), app_exec(), append_channel_vars(), aqm_exec(), ari_bridges_play_new(), ari_originate_dial(), assign_uuid(), ast_agi_send(), ast_answer(), ast_app_exec_macro(), ast_async_goto(), 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_by_name_cb(), 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_hash_cb(), ast_channel_inherit_variables(), ast_channel_log(), ast_channel_make_compatible_helper(), ast_channel_move(), ast_channel_nativeformats_set(), 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_moh_files_next(), ast_monitor_change_fname(), ast_monitor_start(), 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_verification(), ast_str_retrieve_variable(), ast_streamfile(), 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(), attempt_transfer(), attended_transfer_bridge(), attended_transfer_properties_alloc(), audiosocket_exec(), audiosocket_run(), 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_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(), builtin_features_helper(), 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(), chanavail_exec(), change_priority_caller_on_queue(), change_t38_state(), channel_cmp(), 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(), check_rtp_timeout(), comeback_goto(), common_exec(), complete_bridge_participant(), complete_confbridge_participant(), conf_exec(), conf_play(), conf_queue_dtmf(), conf_run(), conf_send_event_to_participants(), conf_update_user_mute(), confbridge_exec(), confbridge_handle_atxfer(), console_indicate(), console_transfer(), 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(), dahdiras_exec(), deactivate_silence_generator(), defer_action(), defer_incoming_sdp_stream(), destroy_all_channels(), dial_bridge_after_cb(), dial_bridge_after_cb_failed(), dial_exec_full(), dial_masquerade_breakdown(), dial_masquerade_fixup(), dial_transfer(), dial_trunk(), dialog_unlink_all(), disa_exec(), disable_t38(), display_parked_call(), do_forward(), do_monitor(), do_waiting(), does_id_conflict(), 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_generator_generate(), fax_session_new(), feature_attended_transfer(), feature_automixmonitor(), feature_automonitor(), feature_blind_transfer(), find_by_name(), find_details(), find_or_create_details(), flash_exec(), forkcdr_exec(), func_channel_read(), func_channels_read(), func_get_parkingslot_channel(), func_read_header(), func_write_header(), generic_fax_exec(), generic_mute_unmute_helper(), generic_mute_unmute_user(), get_agi_cmd(), get_chan_by_ast_name(), gosub_exec(), gosub_run(), grab_transfer(), group_count_function_read(), group_show_channels(), handle_bridge_kick_channel(), handle_call_outgoing(), handle_clear_alarms(), handle_cli_agi_add_cmd(), handle_cli_confbridge_list_item(), handle_cli_iax2_show_channels(), handle_cli_locks_show(), handle_cli_misdn_show_channel(), handle_frame(), handle_gosub(), handle_incoming(), handle_incoming_request(), handle_invite_replaces(), handle_offhook_message(), handle_participant_join(), handle_recordfile(), handle_request_info(), handle_request_invite(), handle_request_refer(), handle_response(), handle_response_notify(), handle_showchan(), handle_softhangup(), handle_stimulus_message(), handle_streamfile(), hangup(), 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(), 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(), linear_alloc(), linear_release(), locals_show(), log_caps(), 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(), mgcp_answer(), mgcp_call(), mgcp_fixup(), mgcp_hangup(), mgcp_indicate(), mgcp_new(), mgcp_ss(), milliwatt_generate(), misdn_attempt_transfer(), misdn_call(), misdn_hangup(), misdn_indication(), misdn_write(), moh_alloc(), moh_files_generator(), 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(), nbs_call(), nbs_hangup(), nbs_new(), nbs_xread(), next_channel(), nocdr_exec(), 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(), oss_indicate(), oss_new(), 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_setamaflags(), pbx_builtin_waitexten(), pbx_extension_helper(), pbx_outgoing_exec(), pbx_outgoing_state_callback(), pbx_start_incoming_request(), phone_answer(), phone_call(), phone_hangup(), phone_indicate(), phone_new(), 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(), play_moh_exec(), play_on_channel(), playback_exec(), playtones_alloc(), pre_bridge_setup(), print_bc_info(), print_escaped_uri(), print_queue(), prnt_channel_key(), process_ast_dsp(), process_sdp(), publish_app_cdr_message(), publish_transfer_fail(), publish_transfer_success(), publish_transfer_threeway(), queue_exec(), queue_function_queuegetchannel(), read_mf_digits(), read_pjsip(), read_sf_digits(), readexten_exec(), realtime_exec(), receive_dtmf_digits(), receivefax_exec(), receivefax_t38_init(), record_exec(), refer_attended_task(), refer_blind_callback(), 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(), reload(), remove_detect(), remove_dtmf_store(), remove_hold_intercept(), remove_scrambler(), remove_talk_detect(), resetcdr_exec(), revert_fax_buffers(), ring_entry(), rqm_exec(), rtp_check_timeout(), run_agi(), run_ras(), say_number_full(), say_position(), send_digit_to_chan(), send_direct_media_request(), 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_fax_t38_caps(), set_format(), set_hangup_source_and_cause(), set_hold_intercept(), set_transfer_variables_all(), setup_env(), setup_privacy_args(), setup_udptl_connection(), sfu_topologies_on_join(), sfu_topologies_on_leave(), sfu_topologies_on_source_change(), sip_answer(), sip_call(), sip_fixup(), sip_hangup(), sip_indicate(), sip_new(), sip_pickup(), sip_pvt_dtor(), sip_queryoption(), sip_queue_hangup_cause(), sip_read(), sip_rtp_read(), sip_senddigit_begin(), sip_senddigit_end(), sip_sendtext(), sip_set_rtp_peer(), sip_setoption(), sip_show_channel(), sip_transfer(), sipinfo_send(), skinny_answer(), skinny_call(), skinny_fixup(), skinny_get_rtp_peer(), skinny_indicate(), skinny_new(), smart_bridge_operation(), sms_exec(), 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_automonitor(), start_moh_exec(), start_monitor_action(), start_monitor_exec(), start_spying(), stasis_app_exec(), stop_automixmonitor(), stop_automonitor(), 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(), transmit(), transmit_audio(), transmit_invite(), transmit_t38(), try_calling(), try_merge_optimize_out(), try_swap_optimize_out(), unistim_answer(), unistim_call(), unistim_fixup(), unistim_hangup(), unistim_indicate(), unistim_new(), update_connectedline(), update_name(), update_qe_rule(), user_chan_cb(), wait_exec(), wait_for_answer(), wait_for_digits(), wait_for_winner(), waitstream_control(), waitstream_core(), and xfer_client_on_evsub_state().

◆ ast_channel_name_set()

void ast_channel_name_set ( struct ast_channel chan,
const char *  name 
)

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

Referenced by parked_user_set_parker_dial_string(), and setup_park_common_datastore().

6935 {
6936  char *dash;
6937 
6938  /* Truncate after the dash */
6939  dash = strrchr(channel_name, '-');
6940  if (dash) {
6941  *dash = '\0';
6942  }
6943 }

◆ ast_channel_named_callgroups()

struct ast_namedgroups* ast_channel_named_callgroups ( const struct ast_channel chan)

Definition at line 1090 of file channel_internal_api.c.

References ast_channel::named_callgroups.

Referenced by find_channel_by_group(), and func_channel_read().

1091 {
1092  return chan->named_callgroups;
1093 }
struct ast_namedgroups * named_callgroups

◆ ast_channel_named_callgroups_set()

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

Definition at line 1094 of file channel_internal_api.c.

References ast_ref_namedgroups(), ast_unref_namedgroups(), and ast_channel::named_callgroups.

Referenced by ast_channel_destructor(), chan_pjsip_new(), dahdi_new(), func_channel_write_real(), read_config(), sip_new(), and skinny_new().

1095 {
1098 }
int value
Definition: syslog.c:37
struct ast_namedgroups * ast_ref_namedgroups(struct ast_namedgroups *groups)
Definition: channel.c:7838
struct ast_namedgroups * named_callgroups
struct ast_namedgroups * ast_unref_namedgroups(struct ast_namedgroups *groups)
Definition: channel.c:7832

◆ ast_channel_named_pickupgroups()

struct ast_namedgroups* ast_channel_named_pickupgroups ( const struct ast_channel chan)

Definition at line 1099 of file channel_internal_api.c.

References ast_channel::named_pickupgroups.

Referenced by find_channel_by_group(), and func_channel_read().

1100 {
1101  return chan->named_pickupgroups;
1102 }
struct ast_namedgroups * named_pickupgroups

◆ ast_channel_named_pickupgroups_set()

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

Definition at line 1103 of file channel_internal_api.c.

References ast_ref_namedgroups(), ast_unref_namedgroups(), and ast_channel::named_pickupgroups.

Referenced by ast_channel_destructor(), chan_pjsip_new(), dahdi_new(), func_channel_write_real(), read_config(), sip_new(), and skinny_new().

1104 {
1107 }
int value
Definition: syslog.c:37
struct ast_namedgroups * named_pickupgroups
struct ast_namedgroups * ast_ref_namedgroups(struct ast_namedgroups *groups)
Definition: channel.c:7838
struct ast_namedgroups * ast_unref_namedgroups(struct ast_namedgroups *groups)
Definition: channel.c:7832

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

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(), NULL, S_COR, S_OR, SCOPE_ENTER, and SCOPE_EXIT_RTN.

Referenced by __ast_channel_alloc_ap(), alsa_new(), ast_channel_destructor(), ast_iax2_new(), 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(), iax2_request(), jingle_interpret_content(), jingle_new(), jingle_read(), make_channel(), mbl_new(), mgcp_new(), mgcp_rtp_read(), misdn_new(), multicast_rtp_request(), nbs_new(), ooh323_new(), ooh323_rtp_read(), ooh323_set_read_format(), ooh323_set_write_format(), oss_new(), phone_new(), process_sdp(), rec_request(), set_caps(), set_format(), set_test_formats(), sip_new(), sip_rtp_read(), skinny_new(), skinny_rtp_read(), socket_process_helper(), stasis_app_control_snoop(), unicast_rtp_request(), unistim_new(), and unistim_rtp_read().

679 {
680  SCOPE_ENTER(2, "%s: %sFormats: %s\n", S_OR(ast_channel_name(chan), "<initializing>"),
681  S_COR(ast_channel_is_multistream(chan), "Multistream", ""),
682  ast_str_tmp(128, ast_format_cap_get_names(value, &STR_TMP)));
683 
684  ast_assert(chan != NULL);
685 
686  ao2_replace(chan->nativeformats, value);
687 
688  /* If chan->stream_topology is NULL, the channel is being destroyed
689  * and topology is destroyed.
690  */
691  if (!chan->stream_topology) {
692  SCOPE_EXIT_RTN("Channel is being initialized or destroyed\n");
693  }
694 
695  if (!ast_channel_is_multistream(chan) || !value) {
696  struct ast_stream_topology *new_topology;
697 
698  new_topology = ast_stream_topology_create_from_format_cap(value);
699  ast_channel_internal_set_stream_topology(chan, new_topology);
700  SCOPE_EXIT_RTN("New %stopology set\n", value ? "" : "empty ");
701  }
702  SCOPE_EXIT_RTN("Set native formats but not topology\n");
703 }
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:848
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
int ast_channel_is_multistream(struct ast_channel *chan)
Determine if a channel is multi-stream capable.
#define ast_str_tmp(init_len, __expr)
Definition: strings.h:1136
#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:85
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:736
#define SCOPE_EXIT_RTN(...)
Scope Exit with return.
Definition: logger.h:854
#define SCOPE_ENTER(level,...)
Non RAII_VAR Scope Trace macros The advantage of these macros is that the EXITs will have the actual ...
Definition: logger.h:780
#define ao2_replace(dst, src)
Definition: astobj2.h:517
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
const char * ast_channel_name(const struct ast_channel *chan)
void ast_channel_internal_set_stream_topology(struct ast_channel *chan, struct ast_stream_topology *topology)

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

Referenced by ast_stopstream().

845 {
846  return chan->oldwriteformat;
847 }

◆ ast_channel_outsmpl()

unsigned long ast_channel_outsmpl ( const struct ast_channel chan)

Definition at line 541 of file channel_internal_api.c.

References ast_channel::outsmpl.

Referenced by __ast_read(), and ast_write_stream().

542 {
543  return chan->outsmpl;
544 }
unsigned long outsmpl

◆ ast_channel_outsmpl_set()

void ast_channel_outsmpl_set ( struct ast_channel chan,
unsigned long  value 
)

Definition at line 545 of file channel_internal_api.c.

References ast_channel::outsmpl, and value.

Referenced by ast_monitor_start(), and ast_write_stream().

546 {
547  chan->outsmpl = value;
548 }
unsigned long outsmpl
int value
Definition: syslog.c:37

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

Definition at line 725 of file channel_internal_api.c.

References ast_channel::pbx, and value.

Referenced by __ast_pbx_run(), action_dialplan_exec(), control_swap_channel_in_bridge(), handle_gosub(), and internal_bridge_after_cb().

726 {
727  chan->pbx = value;
728 }
int value
Definition: syslog.c:37
struct ast_pbx * pbx

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

References ast_channel::pickupgroup, and value.

Referenced by chan_pjsip_new(), dahdi_new(), func_channel_write_real(), jingle_new(), mgcp_new(), read_config(), sip_new(), skinny_new(), and unistim_new().

1087 {
1088  chan->pickupgroup = value;
1089 }
int value
Definition: syslog.c:37
ast_group_t pickupgroup

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

References ast_channel_lock, ast_channel_tech(), ast_channel_unlock, ast_log, 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(), rcvfax_exec(), and sndfax_exec().

7543 {
7544  int res;
7545 
7546  ast_channel_lock(chan);
7547  if (!ast_channel_tech(chan)->queryoption) {
7548  errno = ENOSYS;
7549  ast_channel_unlock(chan);
7550  return -1;
7551  }
7552 
7553  if (block)
7554  ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n");
7555 
7556  res = ast_channel_tech(chan)->queryoption(chan, option, data, datalen);
7557  ast_channel_unlock(chan);
7558 
7559  return res;
7560 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define ast_log
Definition: astobj2.c:42
#define LOG_ERROR
Definition: logger.h:285
int errno
#define ast_channel_unlock(chan)
Definition: channel.h:2946
int(*const queryoption)(struct ast_channel *chan, int option, void *data, int *datalen)
Query a given option. Called with chan locked.
Definition: channel.h:781
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)

◆ 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.
Returns
Nothing

Definition at line 9202 of file channel.c.

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

Referenced by after_bridge_move_channel(), ast_do_pickup(), handle_request_invite(), handle_request_update(), handle_response_invite(), misdn_queue_connected_line_update(), onAlerting(), onCallEstablished(), onProgress(), queue_connected_line_update(), sip_call(), and update_initial_connected_line().

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

◆ 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.
Returns
Nothing

Definition at line 10392 of file channel.c.

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

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

10393 {
10394  unsigned char data[1024]; /* This should be large enough */
10395  size_t datalen;
10396 
10397  datalen = ast_redirecting_build_data(data, sizeof(data), redirecting, update);
10398  if (datalen == (size_t) -1) {
10399  return;
10400  }
10401 
10402  ast_queue_control_data(chan, AST_CONTROL_REDIRECTING, data, datalen);
10403 }
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:9363
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:1238

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

References ast_channel::readtrans, and value.

Referenced by ast_set_read_format_path(), and free_translation().

758 {
759  chan->readtrans = value;
760 }
int value
Definition: syslog.c:37
struct ast_trans_pvt * readtrans

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

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

Referenced by attempt_thread().

5914 {
5915  switch (reason) /* the following appear to be the only ones actually returned by request_and_dial */
5916  {
5917  case 0:
5918  return "Call Failure (not BUSY, and not NO_ANSWER, maybe Circuit busy or down?)";
5919  case AST_CONTROL_HANGUP:
5920  return "Hangup";
5921  case AST_CONTROL_RING:
5922  return "Local Ring";
5923  case AST_CONTROL_RINGING:
5924  return "Remote end Ringing";
5925  case AST_CONTROL_ANSWER:
5926  return "Remote end has Answered";
5927  case AST_CONTROL_BUSY:
5928  return "Remote end is Busy";
5930  return "Congestion (circuits busy)";
5931  default:
5932  return "Unknown Reason!!";
5933  }
5934 }

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

References ast_party_id_merge().

Referenced by add_diversion(), and misdn_copy_redirecting_from_ast().

917 {
919 }
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:528
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:537
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
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:1902

◆ ast_channel_redirecting_effective_orig()

struct ast_party_id ast_channel_redirecting_effective_orig ( struct ast_channel chan)

Definition at line 912 of file channel_internal_api.c.

References ast_party_id_merge().

913 {
915 }
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:534
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
struct ast_party_id orig
Who originally redirected the call (Sent to the party the call is redirected toward) ...
Definition: channel.h:525
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:1902

◆ ast_channel_redirecting_effective_to()

struct ast_party_id ast_channel_redirecting_effective_to ( struct ast_channel chan)

Definition at line 920 of file channel_internal_api.c.

References ast_party_id_merge().

Referenced by misdn_copy_redirecting_from_ast().

921 {
922  return ast_party_id_merge(&chan->redirecting.to, &chan->redirecting.priv_to);
923 }
struct ast_party_id priv_to
Call is redirecting to a new party (Sent to the caller) - private representation. ...
Definition: channel.h:540
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
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:1902
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:531

◆ ast_channel_redirecting_macro()

int ast_channel_redirecting_macro ( struct ast_channel autoservice_chan,
struct ast_channel macro_chan,
const void *  redirecting_info,
int  is_caller,
int  is_frame 
)

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

Since
1.8
Deprecated:
You should use the ast_channel_redirecting_sub() function instead.

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

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

Have multiple return codes based on the MACRO_RESULT

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

Definition at line 10487 of file channel.c.

References ast_app_run_macro(), ast_channel_lock, ast_channel_redirecting(), ast_channel_unlock, ast_channel_update_redirecting(), ast_log, 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, LOG_WARNING, NULL, pbx_builtin_getvar_helper(), ast_frame::ptr, retval, and S_OR.

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

10488 {
10489  static int deprecation_warning = 0;
10490  const char *macro;
10491  const char *macro_args;
10492  int retval;
10493 
10494  ast_channel_lock(macro_chan);
10495  macro = pbx_builtin_getvar_helper(macro_chan, is_caller
10496  ? "REDIRECTING_CALLER_SEND_MACRO" : "REDIRECTING_CALLEE_SEND_MACRO");
10497  macro = ast_strdupa(S_OR(macro, ""));
10498  macro_args = pbx_builtin_getvar_helper(macro_chan, is_caller
10499  ? "REDIRECTING_CALLER_SEND_MACRO_ARGS" : "REDIRECTING_CALLEE_SEND_MACRO_ARGS");
10500  macro_args = ast_strdupa(S_OR(macro_args, ""));
10501 
10502  if (ast_strlen_zero(macro)) {
10503  ast_channel_unlock(macro_chan);
10504  return -1;
10505  }
10506 
10507  if (!deprecation_warning) {
10508  deprecation_warning = 1;
10509  ast_log(LOG_WARNING, "Usage of REDIRECTING_CALLE[ER]_SEND_MACRO is deprecated. Please use REDIRECTING_SEND_SUB instead.\n");
10510  }
10511  if (is_frame) {
10512  const struct ast_frame *frame = redirecting_info;
10513 
10514  ast_redirecting_parse_data(frame->data.ptr, frame->datalen, ast_channel_redirecting(macro_chan));
10515  } else {
10516  const struct ast_party_redirecting *redirecting = redirecting_info;
10517 
10518  ast_party_redirecting_copy(ast_channel_redirecting(macro_chan), redirecting);
10519  }
10520  ast_channel_unlock(macro_chan);
10521 
10523  retval = ast_app_run_macro(autoservice_chan, macro_chan, macro, macro_args);
10525  if (!retval) {
10526  struct ast_party_redirecting saved_redirecting;
10527 
10528  ast_party_redirecting_init(&saved_redirecting);
10529  ast_channel_lock(macro_chan);
10530  ast_party_redirecting_copy(&saved_redirecting, ast_channel_redirecting(macro_chan));
10531  ast_channel_unlock(macro_chan);
10532  ast_channel_update_redirecting(macro_chan, &saved_redirecting, NULL);
10533  ast_party_redirecting_free(&saved_redirecting);
10534  }
10535 
10536  return retval;
10537 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
int ast_app_run_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char *macro_name, const char *macro_args)
Run a macro on a channel, placing an optional second channel into autoservice.
Definition: main/app.c:320
#define LOG_WARNING
Definition: logger.h:274
static void channel_set_intercept_mode(int in_intercept_mode)
Definition: channel.c:10419
#define NULL
Definition: resample.c:96
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_log
Definition: astobj2.c:42
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:9574
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition: channel.c:2179
void ast_party_redirecting_init(struct ast_party_redirecting *init)
Initialize the given redirecting structure.
Definition: channel.c:2122
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
Definition: channel.h:523
#define ast_channel_unlock(chan)
Definition: channel.h:2946
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:2135
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:10379
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
static ENTRY retval
Definition: hsearch.c:50
Data structure associated with a single frame of data.
union ast_frame::@263 data

◆ ast_channel_redirecting_set()

void ast_channel_redirecting_set ( struct ast_channel chan,
struct ast_party_redirecting value 
)

Definition at line 959 of file channel_internal_api.c.

References AST_CHANNEL_SNAPSHOT_INVALIDATE_CALLER, ast_channel_snapshot_invalidate_segment(), ast_channel::redirecting, and value.

Referenced by channel_do_masquerade().

960 {
961  chan->redirecting = *value;
963 }
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.
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
int value
Definition: syslog.c:37

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

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, retval, S_OR, and sub.

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

10585 {
10586  const char *sub;
10587  const char *sub_args;
10588  int retval;
10589 
10590  ast_channel_lock(sub_chan);
10591  sub = pbx_builtin_getvar_helper(sub_chan, "REDIRECTING_SEND_SUB");
10592  sub = ast_strdupa(S_OR(sub, ""));
10593  sub_args = pbx_builtin_getvar_helper(sub_chan, "REDIRECTING_SEND_SUB_ARGS");
10594  sub_args = ast_strdupa(S_OR(sub_args, ""));
10595 
10596  if (ast_strlen_zero(sub)) {
10597  ast_channel_unlock(sub_chan);
10598  return -1;
10599  }
10600 
10601  if (is_frame) {
10602  const struct ast_frame *frame = redirecting_info;
10603 
10605  } else {
10606  const struct ast_party_redirecting *redirecting = redirecting_info;
10607 
10608  ast_party_redirecting_copy(ast_channel_redirecting(sub_chan), redirecting);
10609  }
10610  ast_channel_unlock(sub_chan);
10611 
10613  retval = ast_app_run_sub(autoservice_chan, sub_chan, sub, sub_args, 0);
10615  if (!retval) {
10616  struct ast_party_redirecting saved_redirecting;
10617 
10618  ast_party_redirecting_init(&saved_redirecting);
10619  ast_channel_lock(sub_chan);
10620  ast_party_redirecting_copy(&saved_redirecting, ast_channel_redirecting(sub_chan));
10621  ast_channel_unlock(sub_chan);
10622  ast_channel_update_redirecting(sub_chan, &saved_redirecting, NULL);
10623  ast_party_redirecting_free(&saved_redirecting);
10624  }
10625 
10626  return retval;
10627 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
static void channel_set_intercept_mode(int in_intercept_mode)
Definition: channel.c:10419
#define NULL
Definition: resample.c:96
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
#define ast_strlen_zero(foo)
Definition: strings.h:52
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:9574
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition: channel.c:2179
void ast_party_redirecting_init(struct ast_party_redirecting *init)
Initialize the given redirecting structure.
Definition: channel.c:2122
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
Definition: channel.h:523
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:401
#define ast_channel_unlock(chan)
Definition: channel.h:2946
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:2135
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:10379
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
static ENTRY retval
Definition: hsearch.c:50
struct stasis_forward * sub
Definition: res_corosync.c:240
Data structure associated with a single frame of data.
union ast_frame::@263 data

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

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

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

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(1, "Registered handler for '%s' (%s)\n", chan->tech->type, chan->tech->description);
561 
562  ast_verb(2, "Registered channel type '%s' (%s)\n", chan->tech->type, chan->tech->description);
563 
565 
566  return 0;
567 }
const char *const type
Definition: channel.h:630
const char * tech
Definition: app_dial.c:802
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
struct chanlist::@369 list
#define LOG_WARNING
Definition: logger.h:274
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define ast_verb(level,...)
Definition: logger.h:463
the list of registered channel types
Definition: channel.c:121
#define AST_RWLIST_INSERT_HEAD
Definition: linkedlists.h:717
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
struct ast_channel * chan
Definition: app_dial.c:798
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
List of channel drivers.
Definition: app_dial.c:796
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204

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

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

Definition at line 1584 of file channel.c.

References ao2_unlink, and ast_channel_unref.

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

1585 {
1586  /* Safe, even if already unlinked. */
1587  ao2_unlink(channels, chan);
1588  return ast_channel_unref(chan);
1589 }
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2981
#define ao2_unlink(container, obj)
Definition: astobj2.h:1598
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:124

◆ 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.
Returns
Nothing

Definition at line 6526 of file channel.c.

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

6527 {
6528  channel_req_accountcodes(chan, requestor, relationship, 0);
6529 }
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:6468

◆ 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.
Returns
Nothing

Definition at line 6531 of file channel.c.

References channel_req_accountcodes().

Referenced by ring_entry().

6532 {
6533  channel_req_accountcodes(chan, requestor, relationship, 1);
6534 }
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:6468

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

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_tech(), ast_channel_unlock, AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE, ast_debug, ast_str_tmp, ast_stream_topology_equal(), ast_stream_topology_to_str(), ast_channel_tech::indicate, indicate(), and NULL.

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

11169 {
11170  int res;
11171 
11172  ast_assert(chan != NULL);
11173  ast_assert(topology != NULL);
11174 
11175  ast_channel_lock(chan);
11176  if (!ast_channel_is_multistream(chan) || !ast_channel_tech(chan)->indicate) {
11177  ast_channel_unlock(chan);
11178  return -1;
11179  }
11180 
11182  ast_debug(2, "%s: Topologies already match. Current: %s Requested: %s\n",
11183  ast_channel_name(chan),
11185  ast_str_tmp(256, ast_stream_topology_to_str(topology, &STR_TMP)));
11186  ast_channel_unlock(chan);
11187  return 0;
11188  }
11189 
11191 
11192  res = ast_channel_tech(chan)->indicate(chan, AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE, topology, sizeof(topology));
11193  ast_channel_unlock(chan);
11194  return res;
11195 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
static int indicate(void *data)
Definition: chan_pjsip.c:1333
int ast_channel_is_multistream(struct ast_channel *chan)
Determine if a channel is multi-stream capable.
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_internal_set_stream_topology_change_source(struct ast_channel *chan, void *change_source)
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
#define ast_str_tmp(init_len, __expr)
Definition: strings.h:1136
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
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:936
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:696
#define ast_channel_unlock(chan)
Definition: channel.h:2946
const char * ast_channel_name(const struct ast_channel *chan)
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:772
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)

◆ ast_channel_rings()

int ast_channel_rings ( const struct ast_channel chan)

Definition at line 453 of file channel_internal_api.c.

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

454 {
455  return chan->rings;
456 }

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

References ast_channel::sched, and value.

Referenced by __ast_channel_alloc_ap(), and ast_hangup().

734 {
735  chan->sched = value;
736 }
struct ast_sched_context * sched
int value
Definition: syslog.c:37

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

References ast_channel_tech(), and ast_channel_tech::send_html.

Referenced by ast_channel_sendurl(), and wait_for_answer().

6726 {
6727  if (ast_channel_tech(chan)->send_html)
6728  return ast_channel_tech(chan)->send_html(chan, subclass, data, datalen);
6729  return -1;
6730 }
int(*const send_html)(struct ast_channel *chan, int subclass, const char *data, int len)
Send HTML data.
Definition: channel.h:763
struct ast_channel * chan
Definition: app_dial.c:798
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)

◆ ast_channel_sending_dtmf_digit()

char ast_channel_sending_dtmf_digit ( const struct ast_channel chan)

Definition at line 388 of file channel_internal_api.c.

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

389 {
390  return chan->sending_dtmf_digit;
391 }

◆ ast_channel_sending_dtmf_digit_set()

void ast_channel_sending_dtmf_digit_set ( struct ast_channel chan,
char  value 
)

Definition at line 392 of file channel_internal_api.c.

References value.

Referenced by ast_senddigit_begin(), and ast_senddigit_end().

393 {
394  chan->sending_dtmf_digit = value;
395 }
int value
Definition: syslog.c:37

◆ ast_channel_sending_dtmf_tv()

struct timeval ast_channel_sending_dtmf_tv ( const struct ast_channel chan)

Definition at line 397 of file channel_internal_api.c.

Referenced by bridge_channel_internal_join(), and channel_do_masquerade().

398 {
399  return chan->sending_dtmf_tv;
400 }

◆ ast_channel_sending_dtmf_tv_set()

void ast_channel_sending_dtmf_tv_set ( struct ast_channel chan,
struct timeval  value 
)

Definition at line 401 of file channel_internal_api.c.

References value.

Referenced by ast_senddigit_begin().

402 {
403  chan->sending_dtmf_tv = value;
404 }
int value
Definition: syslog.c:37

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

References ast_channel_sendhtml(), and AST_HTML_URL.

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

6733 {
6734  return ast_channel_sendhtml(chan, AST_HTML_URL, url, strlen(url) + 1);
6735 }
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:6725
struct ast_channel * chan
Definition: app_dial.c:798
#define AST_HTML_URL
static char url[512]

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

References ari_vars, and channel_set_external_vars().

Referenced by channelvars_handler().

7995 {
7996  channel_set_external_vars(&ari_vars, varc, vars);
7997 }
static struct external_vars ari_vars
Definition: channel.c:7934
static void channel_set_external_vars(struct external_vars *channelvars, size_t varc, char **vars)
Definition: channel.c:7967

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

Definition at line 7459 of file channel.c.

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

Referenced by create_alice_channel().

7460 {
7461  if (ast_channel_caller(chan) == caller) {
7462  /* Don't set to self */
7463  return;
7464  }
7465 
7466  ast_channel_lock(chan);
7467  ast_party_caller_set(ast_channel_caller(chan), caller, update);
7469  ast_channel_unlock(chan);
7470 }
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
#define ast_channel_lock(chan)
Definition: channel.h:2945
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:2007
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.
#define ast_channel_unlock(chan)
Definition: channel.h:2946

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

Definition at line 7472 of file channel.c.

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

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

7473 {
7474  if (ast_channel_caller(chan) == caller) {
7475  /* Don't set to self */
7476  return;
7477  }
7478 
7479  ast_channel_lock(chan);
7480  ast_party_caller_set(ast_channel_caller(chan), caller, update);
7483  ast_channel_unlock(chan);
7484 }
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
#define ast_channel_lock(chan)
Definition: channel.h:2945
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:2007
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.
#define ast_channel_unlock(chan)
Definition: channel.h:2946
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.

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

Definition at line 8404 of file channel.c.

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

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

8405 {
8406  if (ast_channel_connected(chan) == connected) {
8407  /* Don't set to self */
8408  return;
8409  }
8410 
8411  ast_channel_lock(chan);
8412  ast_party_connected_line_set(ast_channel_connected(chan), connected, update);
8415  ast_channel_unlock(chan);
8416 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
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.
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
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:2054
#define ast_channel_unlock(chan)
Definition: channel.h:2946
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.

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

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(), and waitstream_core().

11229 {
11230  ast_channel_lock(chan);
11232  ast_channel_unlock(chan);
11233 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define ast_set_flag(p, flag)
Definition: utils.h:70
long int flag
Definition: f2c.h:83
#define ast_channel_unlock(chan)
Definition: channel.h:2946
struct ast_flags * ast_channel_flags(struct ast_channel *chan)

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

References ast_channel_lock, ast_channel_set_is_t38_active_nolock(), and ast_channel_unlock.

1062 {
1063  ast_channel_lock(chan);
1064  ast_channel_set_is_t38_active_nolock(chan, is_t38_active);
1065  ast_channel_unlock(chan);
1066 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define ast_channel_unlock(chan)
Definition: channel.h:2946
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...

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

Referenced by ast_channel_set_is_t38_active(), and indicate_data_internal().

1057 {
1058  chan->is_t38_active = !!is_t38_active;
1059 }

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

References ami_vars, and channel_set_external_vars().

Referenced by load_channelvars().

7990 {
7991  channel_set_external_vars(&ami_vars, varc, vars);
7992 }
static struct external_vars ami_vars
Definition: channel.c:7933
static void channel_set_external_vars(struct external_vars *channelvars, size_t varc, char **vars)
Definition: channel.c:7967

◆ ast_channel_set_oldwriteformat()

void ast_channel_set_oldwriteformat ( struct ast_channel chan,
struct ast_format format 
)

Definition at line 824 of file channel_internal_api.c.

References ao2_replace.

Referenced by ast_channel_destructor(), and ast_openstream_full().

825 {
826  ao2_replace(chan->oldwriteformat, format);
827 }
#define ao2_replace(dst, src)
Definition: astobj2.h:517

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

Definition at line 9215 of file channel.c.

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

Referenced by handle_request_invite(), handle_response(), indicate_redirecting(), misdn_copy_redirecting_to_ast(), redirecting_write(), and set_redirecting().

9216 {
9217  if (ast_channel_redirecting(chan) == redirecting) {
9218  /* Don't set to self */
9219  return;
9220  }
9221 
9222  ast_channel_lock(chan);
9223  ast_party_redirecting_set(ast_channel_redirecting(chan), redirecting, update);
9225  ast_channel_unlock(chan);
9226 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
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.
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:2166
#define ast_channel_unlock(chan)
Definition: channel.h:2946
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)

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

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_unreal_indicate(), ast_unreal_new_channels(), chan_pjsip_new(), handle_negotiated_sdp(), make_channel(), and unreal_colp_stream_topology_request_change().

1593 {
1594  struct ast_stream_topology *new_topology;
1595  SCOPE_ENTER(1, "%s: %s\n", ast_channel_name(chan),
1596  ast_str_tmp(256, ast_stream_topology_to_str(topology, &STR_TMP)));
1597 
1598  ast_assert(chan != NULL);
1599 
1600  /* A non-MULTISTREAM channel can't manipulate topology directly */
1602 
1603  /* Unless the channel is being destroyed, we always want a topology on
1604  * it even if its empty.
1605  */
1606  if (!topology) {
1607  new_topology = ast_stream_topology_alloc();
1608  } else {
1609  new_topology = topology;
1610  }
1611 
1612  if (new_topology) {
1613  ast_channel_internal_set_stream_topology(chan, new_topology);
1614  }
1615 
1616  SCOPE_EXIT_RTN_VALUE(new_topology, "Used %s topology\n", topology ? "provided" : "empty");
1617 }
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
int ast_channel_is_multistream(struct ast_channel *chan)
Determine if a channel is multi-stream capable.
#define ast_str_tmp(init_len, __expr)
Definition: strings.h:1136
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:936
struct ast_stream_topology * ast_stream_topology_alloc(void)
Create a stream topology.
Definition: stream.c:650
#define SCOPE_ENTER(level,...)
Non RAII_VAR Scope Trace macros The advantage of these macros is that the EXITs will have the actual ...
Definition: logger.h:780
#define SCOPE_EXIT_RTN_VALUE(__return_value,...)
Scope Exit with return value.
Definition: logger.h:875
const char * ast_channel_name(const struct ast_channel *chan)
void ast_channel_internal_set_stream_topology(struct ast_channel *chan, struct ast_stream_topology *topology)

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

References ast_channel_lock, ast_channel_set_unbridged_nolock(), and ast_channel_unlock.

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

1035 {
1036  ast_channel_lock(chan);
1038  ast_channel_unlock(chan);
1039 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
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...
int value
Definition: syslog.c:37
#define ast_channel_unlock(chan)
Definition: channel.h:2946

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

References ast_null_frame, ast_queue_frame(), 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().

1029 {
1030  chan->unbridged = !!value;
1032 }
int value
Definition: syslog.c:37
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1139
struct ast_frame ast_null_frame
Definition: main/frame.c:79

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

References ast_channel_lock, ast_channel_tech(), ast_channel_unlock, ast_log, 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(), rcvfax_exec(), reset_volumes(), set_format(), set_listen_volume(), set_security_requirements(), set_talk_volume(), sndfax_exec(), try_calling(), and vm_forwardoptions().

7523 {
7524  int res;
7525 
7526  ast_channel_lock(chan);
7527  if (!ast_channel_tech(chan)->setoption) {
7528  errno = ENOSYS;
7529  ast_channel_unlock(chan);
7530  return -1;
7531  }
7532 
7533  if (block)
7534  ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n");
7535 
7536  res = ast_channel_tech(chan)->setoption(chan, option, data, datalen);
7537  ast_channel_unlock(chan);
7538 
7539  return res;
7540 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
int(*const setoption)(struct ast_channel *chan, int option, void *data, int datalen)
Set a given option. Called with chan locked.
Definition: channel.h:778
#define ast_log
Definition: astobj2.c:42
#define LOG_ERROR
Definition: logger.h:285
int errno
#define ast_channel_unlock(chan)
Definition: channel.h:2946
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)

◆ 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
Returns
Nothing
Since
1.6.1

Set when to hang a channel up.

Definition at line 510 of file channel.c.

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

511 {
512  if (ast_tvzero(offset)) {
513  ast_channel_whentohangup_set(chan, &offset);
514  } else {
515  struct timeval tv = ast_tvadd(offset, ast_tvnow());
516  ast_channel_whentohangup_set(chan, &tv);
517  }
519  return;
520 }
void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value)
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:108
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:150
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1139
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
Definition: extconf.c:2283
struct ast_frame ast_null_frame
Definition: main/frame.c:79

◆ ast_channel_snapshot()

struct ast_channel_snapshot* ast_channel_snapshot ( const struct ast_channel chan)

Definition at line 1648 of file channel_internal_api.c.

Referenced by aoc_publish_blob(), ast_channel_blob_create(), ast_channel_snapshot_create(), and channel_snapshot_update_create().

1649 {
1650  return chan->snapshot;
1651 }

◆ ast_channel_snapshot_segment_flags()

struct ast_flags* ast_channel_snapshot_segment_flags ( struct ast_channel chan)

Definition at line 1659 of file channel_internal_api.c.

Referenced by ast_channel_publish_snapshot(), ast_channel_snapshot_create(), ast_channel_snapshot_invalidate_segment(), and channel_do_masquerade().

1660 {
1661  return &chan->snapshot_segment_flags;
1662 }

◆ ast_channel_snapshot_set()

void ast_channel_snapshot_set ( struct ast_channel chan,
struct ast_channel_snapshot snapshot 
)

Definition at line 1653 of file channel_internal_api.c.

References ao2_bump, and ao2_cleanup.

Referenced by ast_channel_publish_final_snapshot(), and ast_channel_publish_snapshot().

1654 {
1655  ao2_cleanup(chan->snapshot);
1656  chan->snapshot = ao2_bump(snapshot);
1657 }
#define ao2_bump(obj)
Definition: astobj2.h:491
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

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

Referenced by ast_channel_clear_softhangup().

1010 {
1011  chan ->softhangup &= ~value;
1012 }
int value
Definition: syslog.c:37

◆ ast_channel_softhangup_internal_flag_set()

void ast_channel_softhangup_internal_flag_set ( struct ast_channel chan,
int  value 
)

Definition at line 1001 of file channel_internal_api.c.

References value.

Referenced by channel_do_masquerade().

1002 {
1003  chan->softhangup = value;
1004 }
int value
Definition: syslog.c:37

◆ 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)
Returns
Nothing

Definition at line 468 of file channel.c.

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

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 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
int ast_softhangup_nolock(struct ast_channel *chan, int cause)
Softly hangup a channel, don&#39;t lock.
Definition: channel.c:2463
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_channel_unlock(chan)
Definition: channel.h:2946
int ast_channel_hangupcause(const struct ast_channel *chan)
const char * ast_channel_name(const struct ast_channel *chan)

◆ 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.
Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 8266 of file channel.c.

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, ast_silence_generator::old_write_format, and state.

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

8267 {
8268  struct ast_silence_generator *state;
8269 
8270  if (!(state = ast_calloc(1, sizeof(*state)))) {
8271  return NULL;
8272  }
8273 
8275 
8276  if (ast_set_write_format(chan, ast_format_slin) < 0) {
8277  ast_log(LOG_ERROR, "Could not set write format to SLINEAR\n");
8278  ast_free(state);
8279  return NULL;
8280  }
8281 
8283 
8284  ast_debug(1, "Started silence generator on '%s'\n", ast_channel_name(chan));
8285 
8286  return state;
8287 }
enum sip_cc_notify_state state
Definition: chan_sip.c:959
#define NULL
Definition: resample.c:96
#define ao2_bump(obj)
Definition: astobj2.h:491
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
static struct ast_generator silence_generator
Definition: channel.c:8256
#define LOG_ERROR
Definition: logger.h:285
#define ast_free(a)
Definition: astmm.h:182
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
const char * ast_channel_name(const struct ast_channel *chan)
struct ast_format * old_write_format
Definition: channel.c:8263
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
Definition: format_cache.c:41
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
Definition: channel.c:5890
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
Definition: channel.c:2960

◆ ast_channel_state()

enum ast_channel_state ast_channel_state ( const struct ast_channel chan)

Definition at line 789 of file channel_internal_api.c.

790 {
791  return chan->state;
792 }

◆ ast_channel_state_set()

void ast_channel_state_set ( struct ast_channel chan,
enum  ast_channel_state 
)

Definition at line 820 of file channel_internal_api.c.

References value.

Referenced by __ast_channel_alloc_ap(), ast_setstate(), AST_TEST_DEFINE(), and channel_do_masquerade().

821 {
822  chan->state = value;
823 }
int value
Definition: syslog.c:37

◆ 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.
Returns
nothing

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

Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 8312 of file channel.c.

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

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

8313 {
8314  if (!state) {
8315  return;
8316  }
8317 
8318  if (deactivate_silence_generator(chan)) {
8319  ast_debug(1, "Stopped silence generator on '%s'\n", ast_channel_name(chan));
8320  if (ast_set_write_format(chan, state->old_write_format) < 0) {
8321  ast_log(LOG_ERROR, "Could not return write format to its original state\n");
8322  }
8323  }
8324  ao2_cleanup(state->old_write_format);
8325  ast_free(state);
8326 }
static int deactivate_silence_generator(struct ast_channel *chan)
Definition: channel.c:8289
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
#define LOG_ERROR
Definition: logger.h:285
#define ast_free(a)
Definition: astmm.h:182
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
const char * ast_channel_name(const struct ast_channel *chan)
struct ast_format * old_write_format
Definition: channel.c:8263
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
Definition: channel.c:5890

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

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

Referenced by __ast_read(), and AST_TEST_DEFINE().

11198 {
11199  ast_assert(chan != NULL);
11200  ast_assert(topology != NULL);
11201 
11202  if (!ast_channel_is_multistream(chan) || !ast_channel_tech(chan)->indicate) {
11203  return -1;
11204  }
11205 
11206  return ast_channel_tech(chan)->indicate(chan, AST_CONTROL_STREAM_TOPOLOGY_CHANGED, topology, sizeof(topology));
11207 }
static int indicate(void *data)
Definition: chan_pjsip.c:1333
int ast_channel_is_multistream(struct ast_channel *chan)
Determine if a channel is multi-stream capable.
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
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:772
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)

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

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, and NULL.

Referenced by handle_negotiated_sdp(), and unreal_colp_stream_topology_request_change().

11210 {
11211  int res;
11212  struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_STREAM_TOPOLOGY_CHANGED };
11213 
11214  ast_assert(chan != NULL);
11215 
11216  if (!ast_channel_is_multistream(chan)) {
11217  return -1;
11218  }
11219 
11220  ast_channel_lock(chan);
11222  res = ast_queue_frame(chan, &f);
11223  ast_channel_unlock(chan);
11224 
11225  return res;
11226 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
int ast_channel_is_multistream(struct ast_channel *chan)
Determine if a channel is multi-stream capable.
void ast_channel_internal_set_stream_topology_change_source(struct ast_channel *chan, void *change_source)
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1139
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:222
#define ast_channel_unlock(chan)
Definition: channel.h:2946
Data structure associated with a single frame of data.

◆ ast_channel_streamid()

int ast_channel_streamid ( const struct ast_channel chan)

Definition at line 461 of file channel_internal_api.c.

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

462 {
463  return chan->streamid;
464 }

◆ ast_channel_streamid_set()

void ast_channel_streamid_set ( struct ast_channel chan,
int  value 
)

Definition at line 465 of file channel_internal_api.c.

References value.

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

466 {
467  chan->streamid = value;
468 }
int value
Definition: syslog.c:37

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

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

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

4406 {
4407  if (!strcasecmp(flag, "default"))
4408  return DEFAULT_AMA_FLAGS;
4409  if (!strcasecmp(flag, "omit"))
4410  return AST_AMA_OMIT;
4411  if (!strcasecmp(flag, "billing"))
4412  return AST_AMA_BILLING;
4413  if (!strcasecmp(flag, "documentation"))
4414  return AST_AMA_DOCUMENTATION;
4415  return AST_AMA_NONE;
4416 }
#define DEFAULT_AMA_FLAGS
Definition: channel.c:108
long int flag
Definition: f2c.h:83

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

References ast_channel_tech().

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

6721 {
6722  return (ast_channel_tech(chan)->send_html) ? 1 : 0;
6723 }
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)

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

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

10979 {
10980  struct suppress_data *suppress;
10981  const struct ast_datastore_info *datastore_info = NULL;
10982  struct ast_datastore *datastore = NULL;
10983  struct ast_framehook_interface interface = {
10985  .event_cb = suppress_framehook_event_cb,
10986  .destroy_cb = suppress_framehook_destroy_cb,
10987  .chan_fixup_cb = suppress_framehook_fixup_cb,
10988  };
10989  int framehook_id;
10990 
10991  if (!(datastore_info = suppress_get_datastore_information(frametype))) {
10992  ast_log(LOG_WARNING, "Attempted to suppress an unsupported frame type (%u).\n", frametype);
10993  return -1;
10994  }
10995 
10996  if ((datastore = ast_channel_datastore_find(chan, datastore_info, NULL))) {
10997  suppress = datastore->data;
10998  suppress->direction |= direction;
10999  return 0;
11000  }
11001 
11002  if (!(suppress = ao2_alloc(sizeof(*suppress), NULL))) {
11003  ast_log(LOG_WARNING, "Failed to allocate data while attempting to suppress a stream.\n");
11004  return -1;
11005  }
11006 
11007  suppress->frametype = frametype;
11008  suppress->direction |= direction;
11009 
11010  interface.data = suppress;
11011 
11012  framehook_id = ast_framehook_attach(chan, &interface);
11013  if (framehook_id < 0) {
11014  /* Hook attach failed. Get rid of the evidence. */
11015  ast_log(LOG_WARNING, "Failed to attach framehook while attempting to suppress a stream.\n");
11016  ao2_ref(suppress, -1);
11017  return -1;
11018  }
11019 
11020  /* One ref for the framehook */
11021  ao2_ref(suppress, +1);
11022 
11023  suppress->framehook_id = framehook_id;
11024 
11025  if (!(datastore = ast_datastore_alloc(datastore_info, NULL))) {
11026  ast_log(LOG_WARNING, "Failed to allocate datastore while attempting to suppress a stream.\n");
11027  ast_framehook_detach(chan, framehook_id);
11028  ao2_ref(suppress, -1);
11029  return -1;
11030  }
11031 
11032  /* the ref provided by the allocation is taken by the datastore */
11033  datastore->data = suppress;
11034 
11035  ast_channel_datastore_add(chan, datastore);
11036 
11037  return 0;
11038 }
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:2404
static void suppress_framehook_destroy_cb(void *data)
Definition: channel.c:10915
#define LOG_WARNING
Definition: logger.h:274
int ast_framehook_detach(struct ast_channel *chan, int framehook_id)
Detach an framehook from a channel.
Definition: framehook.c:177
Structure for a data store type.
Definition: datastore.h:31
static const struct ast_datastore_info * suppress_get_datastore_information(enum ast_frame_type frametype)
Definition: channel.c:10968
enum ast_frame_type frametype
Definition: channel.c:10921
Structure for a data store object.
Definition: datastore.h:68
#define NULL
Definition: resample.c:96
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
static void suppress_framehook_fixup_cb(void *data, int framehook_id, struct ast_channel *old_chan, struct ast_channel *new_chan)
Definition: channel.c:10926
#define ast_log
Definition: astobj2.c:42
#define ao2_ref(o, delta)
Definition: astobj2.h:464
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:10933
#define AST_FRAMEHOOK_INTERFACE_VERSION
Definition: framehook.h:227
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
int framehook_id
Definition: channel.c:10923
void * data
Definition: datastore.h:70
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition: channel.c:2390
#define ast_datastore_alloc(info, uid)
Definition: datastore.h:89
unsigned int direction
Definition: channel.c:10922
direction

◆ ast_channel_tech()

const struct ast_channel_tech* ast_channel_tech ( const struct ast_channel chan)

Definition at line 769 of file channel_internal_api.c.

References ast_channel::tech.

Referenced by __ast_read(), acf_channel_read(), action_dahdishowchannels(), analog_ss_thread(), ast_ari_channels_rtpstatistics(), ast_call(), ast_channel_early_bridge(), ast_channel_queryoption(), ast_channel_request_stream_topology_change(), ast_channel_sendhtml(), ast_channel_setoption(), ast_channel_snapshot_create(), ast_channel_stream_topology_changed(), ast_channel_supports_html(), ast_hangup(), ast_jb_do_usecheck(), ast_pre_call(), ast_raw_answer_with_stream_topology(), ast_rtp_dtmf_compatible(), ast_rtp_instance_early_bridge(), ast_rtp_instance_early_bridge_make_compatible(), ast_rtp_instance_make_compatible(), ast_send_image(), ast_senddigit(), ast_senddigit_begin(), ast_senddigit_end(), ast_senddigit_external(), ast_senddigit_mf(), ast_sendtext_data(), ast_supports_images(), ast_transfer_protocol(), ast_var_channel_types_table(), ast_var_channels_table(), ast_write_stream(), ast_write_video(), channel_do_masquerade(), channel_sanitizer(), channel_snapshot_base_create(), conf_run(), dahdi_setoption(), dahdiras_exec(), destroy_all_channels(), flash_exec(), func_channel_read(), func_channel_write_real(), func_header_read(), func_headers_read2(), function_iaxpeer(), function_ooh323_read(), function_ooh323_write(), generate_status(), handle_request_bye(), handle_showchan(), iax2_key_rotate(), iax2_prov_app(), indicate_data_internal(), misdn_facility_exec(), misdn_set_opt_exec(), my_get_sigpvt_bridged_channel(), native_bridge_is_capable(), 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(), push_notify_channel(), reload(), rtp_glue_data_get(), sendtext_exec(), serialize_showchan(), setup_env(), sip_acf_channel_read(), sip_cc_agent_init(), sip_dtmfmode(), sipinfo_send(), softhangup_exec(), t38_masq(), tech_write(), transfer_exec(), and try_calling().

770 {
771  return chan->tech;
772 }
const struct ast_channel_tech * tech

◆ ast_channel_tech_pvt()

void* ast_channel_tech_pvt ( const struct ast_channel chan)

Definition at line 565 of file channel_internal_api.c.

References ast_channel::tech_pvt.

Referenced by __analog_ss_thread(), __dahdi_exception(), acf_channel_read(), action_dahdishowchannels(), alsa_fixup(), analog_hangup(), analog_ss_thread(), announce_hangup(), ast_channel_destructor(), ast_local_get_peer(), ast_local_lock_all(), ast_local_setup_bridge(), ast_local_setup_masquerade(), 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_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(), 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(), destroy_all_channels(), dialog_unlink_all(), func_header_read(), func_headers_read2(), func_read_header(), func_write_header(), function_iaxpeer(), function_ooh323_read(), function_ooh323_write(), get_video_desc(), handle_callforward_button(), handle_clear_alarms(), handle_enbloc_call_message(), handle_offhook_message(), handle_request_bye(), handle_soft_key_event_message(), handle_stimulus_message(), handle_transfer_button(), hangup(), iax2_answer(), iax2_call(), iax2_digit_begin(), iax2_digit_end(), iax2_fixup(), iax2_hangup(), iax2_indicate(), iax2_key_rotate(), 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(), mgcp_answer(), mgcp_call(), mgcp_fixup(), mgcp_get_codec(), mgcp_get_rtp_peer(), mgcp_hangup(), mgcp_indicate(), mgcp_read(), mgcp_senddigit_begin(), mgcp_senddigit_end(), mgcp_set_rtp_peer(), mgcp_ss(), mgcp_write(), 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(), nbs_call(), nbs_hangup(), nbs_xwrite(), 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(), oss_answer(), oss_call(), oss_fixup(), oss_hangup(), oss_indicate(), oss_read(), oss_write(), phone_answer(), phone_call(), phone_digit_end(), phone_exception(), phone_fixup(), phone_hangup(), phone_indicate(), phone_read(), phone_send_text(), phone_setup(), phone_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(), push_notify_channel(), read_test(), rtp_call(), rtp_hangup(), rtp_read(), rtp_write(), send_direct_media_request(), sendtext_data_create(), sip_acf_channel_read(), sip_allow_anyrtp_remote(), sip_answer(), sip_call(), sip_cc_agent_init(), sip_dtmfmode(), sip_fixup(), sip_get_callid(), sip_get_rtp_peer(), sip_get_trtp_peer(), sip_get_vrtp_peer(), sip_hangup(), sip_indicate(), sip_queryoption(), sip_read(), sip_senddigit_begin(), sip_senddigit_end(), sip_sendhtml(), sip_sendtext(), sip_set_rtp_peer(), sip_setoption(), sip_transfer(), sip_write(), sipinfo_send(), skinny_answer(), skinny_call(), skinny_fixup(), skinny_get_rtp_peer(), skinny_get_vrtp_peer(), skinny_hangup(), skinny_indicate(), skinny_newcall(), skinny_read(), skinny_request(), skinny_set_rtp_peer(), skinny_write(), 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(), and unistim_write().

566 {
567  return chan->tech_pvt;
568 }

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

Definition at line 773 of file channel_internal_api.c.

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

Referenced by __ast_channel_alloc_ap(), alsa_new(), ast_iax2_new(), AST_TEST_DEFINE(), ast_unreal_new_channels(), audiosocket_request(), chan_pjsip_new(), channel_do_masquerade(), console_new(), create_alice_channel(), create_msg_q_chan(), dahdi_new(), do_notify(), jingle_new(), make_channel(), mbl_new(), mgcp_new(), misdn_new(), multicast_rtp_request(), nbs_new(), ooh323_new(), oss_new(), phone_new(), rec_request(), sip_new(), skinny_new(), stasis_app_control_snoop(), test_vm_api_create_mock_channel(), unicast_rtp_request(), and unistim_new().

774 {
775  if (value->read_stream || value->write_stream) {
776  ast_assert(value->read_stream && value->write_stream);
777  }
778 
779  chan->tech = value;
780 }
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.h), with stream num.
Definition: channel.h:748
#define ast_assert(a)
Definition: utils.h:695
int value
Definition: syslog.c:37
const struct ast_channel_tech * tech
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:754

◆ ast_channel_timer()

struct ast_timer* ast_channel_timer ( const struct ast_channel chan)

Definition at line 737 of file channel_internal_api.c.

Referenced by __ast_channel_alloc_ap(), __ast_queue_frame(), __ast_read(), ast_channel_destructor(), ast_deactivate_generator(), and ast_settimeout_full().

738 {
739  return chan->timer;
740 }

◆ ast_channel_timer_set()

void ast_channel_timer_set ( struct ast_channel chan,
struct ast_timer value 
)

Definition at line 741 of file channel_internal_api.c.

References value.

Referenced by __ast_channel_alloc_ap(), and ast_channel_destructor().

742 {
743  chan->timer = value;
744 }
int value
Definition: syslog.c:37

◆ ast_channel_timingdata()

void* ast_channel_timingdata ( const struct ast_channel chan)

Definition at line 573 of file channel_internal_api.c.

References ast_channel::timingdata.

Referenced by __ast_read(), and ast_settimeout_full().

574 {
575  return chan->timingdata;
576 }

◆ ast_channel_timingdata_set()

void ast_channel_timingdata_set ( struct ast_channel chan,
void *  value 
)

Definition at line 577 of file channel_internal_api.c.

References ast_channel::timingdata, and value.

Referenced by ast_settimeout_full().

578 {
579  chan->timingdata = value;
580 }
int value
Definition: syslog.c:37

◆ ast_channel_timingfd()

int ast_channel_timingfd ( const struct ast_channel chan)

Definition at line 469 of file channel_internal_api.c.

Referenced by __ast_channel_alloc_ap(), __ast_queue_frame(), __ast_read(), add_sdp(), ast_readaudio_callback(), ast_settimeout_full(), and channel_do_masquerade().

470 {
471  return chan->timingfd;
472 }

◆ ast_channel_timingfd_set()

void ast_channel_timingfd_set ( struct ast_channel chan,
int  value 
)

Definition at line 473 of file channel_internal_api.c.

References value.

Referenced by __ast_channel_alloc_ap(), and __ast_dummy_channel_alloc().

474 {
475  chan->timingfd = value;
476 }
int value
Definition: syslog.c:37

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

References ast_channel::timingfunc, and value.

Referenced by ast_settimeout_full().

1236 {
1237  chan->timingfunc = value;
1238 }
ast_timing_func_t timingfunc
int value
Definition: syslog.c:37

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

References ast_channel_topic_all().

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_monitor_start(), ast_monitor_stop(), ast_multi_object_blob_single_channel_publish(), AST_TEST_DEFINE(), 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(), phase_e_handler(), 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().

1503 {
1504  if (!chan) {
1505  return ast_channel_topic_all();
1506  }
1507 
1508  return chan->topic;
1509 }
struct stasis_topic * ast_channel_topic_all(void)
A topic which publishes the events for all channels.

◆ ast_channel_transfercapability()

unsigned short ast_channel_transfercapability ( const struct ast_channel chan)

Definition at line 501 of file channel_internal_api.c.

Referenced by ast_ari_channels_dial(), ast_var_channels_table(), begin_dial_prerun(), dahdi_call(), dial_exec_full(), func_channel_read(), misdn_call(), and ooh323_call().

502 {
503  return chan->transfercapability;
504 }

◆ ast_channel_transfercapability_set()

void ast_channel_transfercapability_set ( struct ast_channel chan,
unsigned short  value 
)

Definition at line 505 of file channel_internal_api.c.

References value.

Referenced by ast_ari_channels_dial(), begin_dial_prerun(), cb_events(), dial_exec_full(), and func_channel_write_real().

506 {
507  chan->transfercapability = value;
508 }
int value
Definition: syslog.c:37

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

References ast_channel_lock, ast_channel_unbridged_nolock(), and ast_channel_unlock.

Referenced by ast_channel_is_leaving_bridge(), and bridge_channel_wait().

1020 {
1021  int res;
1022  ast_channel_lock(chan);
1023  res = ast_channel_unbridged_nolock(chan);
1024  ast_channel_unlock(chan);
1025  return res;
1026 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
int ast_channel_unbridged_nolock(struct ast_channel *chan)
ast_channel_unbridged variant. Use this if the channel is already locked prior to calling...
#define ast_channel_unlock(chan)
Definition: channel.h:2946

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

Referenced by ast_channel_unbridged().

1015 {
1016  return chan->unbridged;
1017 }

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

References ast_channel_clear_flag(), and AST_FLAG_DEFER_DTMF.

Referenced by __adsi_transmit_messages(), and find_cache().

1272 {
1273  if (chan) {
1275  }
1276 }
void ast_channel_clear_flag(struct ast_channel *chan, unsigned int flag)
Definition: channel.c:11235

◆ ast_channel_uniqueid()

const char* ast_channel_uniqueid ( const struct ast_channel chan)

Definition at line 305 of file channel_internal_api.c.

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_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_by_uniqueid_cb(), ast_channel_log(), ast_channel_move(), ast_channel_publish_cached_blob(), ast_channel_publish_dial_internal(), ast_do_pickup(), ast_endpoint_add_channel(), ast_monitor_start(), ast_monitor_stop(), ast_str_retrieve_variable(), 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(), call(), chan_pjsip_fixup(), chan_pjsip_indicate(), chan_pjsip_new(), chan_pjsip_session_end(), channel_replaced_cb(), channel_snapshot_base_create(), conf_rec_name(), conf_run(), conf_send_event_to_participants(), create_parked_subscription_full(), 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(), mgcp_set_owner(), minivm_mwi_exec(), mixmonitor_exec(), moh_post_start(), moh_post_stop(), multicast_rtp_request(), notify_new_message(), pack_channel_into_message(), park_and_announce_app_exec(), park_common_setup(), park_local_transfer(), parking_blind_transfer_park(), parking_park_bridge_channel(), phase_e_handler(), 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(), sip_set_owner(), skinny_set_owner(), 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().

306 {
307  ast_assert(chan->uniqueid.unique_id[0] != '\0');
308  return chan->uniqueid.unique_id;
309 }
char unique_id[AST_MAX_UNIQUEID]
#define ast_assert(a)
Definition: utils.h:695
struct ast_channel_id uniqueid

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

References ao2_unlink.

Referenced by create_msg_q_chan().

10731 {
10732  ao2_unlink(channels, chan);
10733 }
#define ao2_unlink(container, obj)
Definition: astobj2.h:1598
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:124

◆ 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
Returns
No return value.

Unregister a channel technology.

Definition at line 570 of file channel.c.

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

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

571 {
572  struct chanlist *chan;
573 
574  ast_debug(1, "Unregistering channel type '%s'\n", tech->type);
575 
577 
579  if (chan->tech == tech) {
581  ast_free(chan);
582  ast_verb(2, "Unregistered channel type '%s'\n", tech->type);
583  break;
584  }
585  }
587 
589 }
const char *const type
Definition: channel.h:630
const char * tech
Definition: app_dial.c:802
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
struct chanlist::@369 list
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:614
#define ast_verb(level,...)
Definition: logger.h:463
the list of registered channel types
Definition: channel.c:121
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
struct ast_channel * chan
Definition: app_dial.c:798
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:556
List of channel drivers.
Definition: app_dial.c:796
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
Definition: linkedlists.h:544
#define ast_free(a)
Definition: astmm.h:182

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

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, LOG_WARNING, NULL, and suppress_get_datastore_information().

Referenced by app_control_unmute(), and mute_channel().

11041 {
11042  const struct ast_datastore_info *datastore_info = NULL;
11043  struct ast_datastore *datastore = NULL;
11044  struct suppress_data *suppress;
11045 
11046  if (!(datastore_info = suppress_get_datastore_information(frametype))) {
11047  ast_log(LOG_WARNING, "Attempted to unsuppress an unsupported frame type (%u).\n", frametype);
11048  return -1;
11049  }
11050 
11051  if (!(datastore = ast_channel_datastore_find(chan, datastore_info, NULL))) {
11052  /* Nothing to do! */
11053  return 0;
11054  }
11055 
11056  suppress = datastore->data;
11057 
11058  suppress->direction &= ~(direction);
11059 
11060  if (suppress->direction == 0) {
11061  /* Nothing left to suppress. Bye! */
11062  ast_framehook_detach(chan, suppress->framehook_id);
11063  ast_channel_datastore_remove(chan, datastore);
11064  ast_datastore_free(datastore);
11065  }
11066 
11067  return 0;
11068 }
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:2404
#define LOG_WARNING
Definition: logger.h:274
int ast_framehook_detach(struct ast_channel *chan, int framehook_id)
Detach an framehook from a channel.
Definition: framehook.c:177
Structure for a data store type.
Definition: datastore.h:31
static const struct ast_datastore_info * suppress_get_datastore_information(enum ast_frame_type frametype)
Definition: channel.c:10968
enum ast_frame_type frametype
Definition: channel.c:10921
Structure for a data store object.
Definition: datastore.h:68
#define NULL
Definition: resample.c:96
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Definition: datastore.c:68
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
Definition: channel.c:2399
#define ast_log
Definition: astobj2.c:42
int framehook_id
Definition: channel.c:10923
void * data
Definition: datastore.h:70
unsigned int direction
Definition: channel.c:10922
direction

◆ 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.
Returns
Nothing

Definition at line 9189 of file channel.c.

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

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

9190 {
9191  unsigned char data[1024]; /* This should be large enough */
9192  size_t datalen;
9193 
9194  datalen = ast_connected_line_build_data(data, sizeof(data), connected, update);
9195  if (datalen == (size_t) -1) {
9196  return;
9197  }
9198 
9199  ast_indicate_data(chan, AST_CONTROL_CONNECTED_LINE, data, datalen);
9200 }
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:4698
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:8793

◆ 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.
Returns
Nothing

Definition at line 10379 of file channel.c.

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

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

10380 {
10381  unsigned char data[1024]; /* This should be large enough */
10382  size_t datalen;
10383 
10384  datalen = ast_redirecting_build_data(data, sizeof(data), redirecting, update);
10385  if (datalen == (size_t) -1) {
10386  return;
10387  }
10388 
10389  ast_indicate_data(chan, AST_CONTROL_REDIRECTING, data, datalen);
10390 }
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:4698
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:9363

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

References value, and ast_channel::varshead.

973 {
974  chan->varshead = *value;
975 }
int value
Definition: syslog.c:37
struct varshead varshead

◆ ast_channel_visible_indication()

int ast_channel_visible_indication ( const struct ast_channel chan)

Definition at line 477 of file channel_internal_api.c.

Referenced by channel_do_masquerade(), and pre_bridge_setup().

478 {
479  return chan->visible_indication;
480 }

◆ ast_channel_visible_indication_set()

void ast_channel_visible_indication_set ( struct ast_channel chan,
int  value 
)

Definition at line 481 of file channel_internal_api.c.

References value.

Referenced by dial_exec_full(), and indicate_data_internal().

482 {
483  chan->visible_indication = value;
484 }
int value
Definition: syslog.c:37

◆ ast_channel_vstream()

struct ast_filestream* ast_channel_vstream ( const struct ast_channel chan)

Definition at line 629 of file channel_internal_api.c.

References ast_channel::vstream.

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

630 {
631  return chan->vstream;
632 }
struct ast_filestream * vstream

◆ ast_channel_vstream_set()

void ast_channel_vstream_set ( struct ast_channel chan,
struct ast_filestream value 
)

Definition at line 633 of file channel_internal_api.c.

References value, and ast_channel::vstream.

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

634 {
635  chan->vstream = value;
636 }
int value
Definition: syslog.c:37
struct ast_filestream * vstream

◆ ast_channel_vstreamid()

int ast_channel_vstreamid ( const struct ast_channel chan)

Definition at line 493 of file channel_internal_api.c.

Referenced by filestream_close().

494 {
495  return chan->vstreamid;
496 }

◆ ast_channel_vstreamid_set()

void ast_channel_vstreamid_set ( struct ast_channel chan,
int  value 
)

Definition at line 497 of file channel_internal_api.c.

References value.

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

498 {
499  chan->vstreamid = value;
500 }
int value
Definition: syslog.c:37

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

References value, and ast_channel::whentohangup.

Referenced by ast_channel_setwhentohangup_tv(), and dial_exec_full().

969 {
970  chan->whentohangup = *value;
971 }
int value
Definition: syslog.c:37
struct timeval whentohangup

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

References value, and ast_channel::writetrans.

Referenced by ast_set_write_format_path(), and free_translation().

766 {
767  chan->writetrans = value;
768 }
int value
Definition: syslog.c:37
struct ast_trans_pvt * writetrans

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

References accountcode, 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, context, exten, name, ast_channel::name, NULL, and priority.

Referenced by ast_async_goto(), and ast_bridge_add_channel().

10795 {
10796  struct ast_channel *yanked_chan;
10797  struct {
10798  char *accountcode;
10799  char *exten;
10800  char *context;
10801  char *name;
10802  int amaflags;
10803  int priority;
10804  struct ast_format *readformat;
10805  struct ast_format *writeformat;
10806  } my_vars = { 0, };
10807 
10808  ast_channel_lock(yankee);
10809  my_vars.accountcode = ast_strdupa(ast_channel_accountcode(yankee));
10810  my_vars.exten = ast_strdupa(ast_channel_exten(yankee));
10811  my_vars.context = ast_strdupa(ast_channel_context(yankee));
10812  my_vars.name = ast_strdupa(ast_channel_name(yankee));
10813  my_vars.amaflags = ast_channel_amaflags(yankee);
10814  my_vars.priority = ast_channel_priority(yankee);
10815  /* The priority as returned by ast_channel_yank is where the channel
10816  * should go if the dialplan is executed on it. If the channel is
10817  * already executing dialplan then the priority currently set is
10818  * where it is currently. We increment it so it becomes where it should
10819  * execute.
10820  */
10822  my_vars.priority++;
10823  }
10824  my_vars.writeformat = ao2_bump(ast_channel_writeformat(yankee));
10825  my_vars.readformat = ao2_bump(ast_channel_readformat(yankee));
10826  ast_channel_unlock(yankee);
10827 
10828  /* Do not hold any channel locks while calling channel_alloc() since the function
10829  * locks the channel container when linking the new channel in. */
10830  if (!(yanked_chan = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, my_vars.accountcode,
10831  my_vars.exten, my_vars.context, NULL, yankee, my_vars.amaflags,
10832  "Surrogate/%s", my_vars.name))) {
10833  ao2_cleanup(my_vars.writeformat);
10834  ao2_cleanup(my_vars.readformat);
10835  return NULL;
10836  }
10837 
10838  /* Make formats okay */
10839  ast_channel_set_readformat(yanked_chan, my_vars.readformat);
10840  ast_channel_set_writeformat(yanked_chan, my_vars.writeformat);
10841  ao2_cleanup(my_vars.readformat);
10842  ao2_cleanup(my_vars.writeformat);
10843  ast_channel_priority_set(yanked_chan, my_vars.priority);
10844 
10845  ast_channel_unlock(yanked_chan);
10846 
10847  if (ast_channel_move(yanked_chan, yankee)) {
10848  ast_hangup(yanked_chan);
10849  return NULL;
10850  }
10851 
10852  return yanked_chan;
10853 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
Main Channel structure associated with a channel.
static int amaflags
Definition: chan_iax2.c:431
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
#define ast_test_flag(p, flag)
Definition: utils.h:63
Definition of a media format.
Definition: format.c:43
#define NULL
Definition: resample.c:96
static int priority
int ast_channel_priority(const struct ast_channel *chan)
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
#define ao2_bump(obj)
Definition: astobj2.h:491
const char * ast_channel_accountcode(const struct ast_channel *chan)
void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
const char * ast_channel_exten(const struct ast_channel *chan)
const ast_string_field name
#define ast_channel_unlock(chan)
Definition: channel.h:2946
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
const char * ast_channel_name(const struct ast_channel *chan)
void ast_hangup(struct ast_channel *chan)
Hangup a channel.
Definition: channel.c:2548
const ast_string_field accountcode
const char * ast_channel_context(const struct ast_channel *chan)
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
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:10867
void ast_channel_priority_set(struct ast_channel *chan, int value)
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
Definition: channel.h:1259
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
enum ama_flags ast_channel_amaflags(const struct ast_channel *chan)

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

References value, and ast_channel::zone.

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

750 {
751  chan->zone = value;
752 }
struct ast_tone_zone * zone
int value
Definition: syslog.c:37

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

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

Referenced by ast_var_channel_types(), and ast_var_channel_types_table().

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 }
const char * tech
Definition: app_dial.c:802
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
Structure for variables, used for configurations and for channel variables.
#define var
Definition: ast_expr2f.c:614
#define NULL
Definition: resample.c:96
the list of registered channel types
Definition: channel.c:121
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
List of channel drivers.
Definition: app_dial.c:796
#define ast_variable_new(name, value, filename)

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

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(), _macro_exec(), 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(), destroy_all_channels(), dial_exec_full(), directory_exec(), dundi_lookup_internal(), eagi_exec(), eivr_comm(), fax_gateway_framehook(), findmeexec(), func_channel_read(), gosub_run(), handle_sendimage(), iax2_key_rotate(), join_conference_bridge(), launch_asyncagi(), lua_check_hangup(), ospfinished_exec(), pbx_builtin_incomplete(), pbx_builtin_waitexten(), playback_exec(), read_exec(), readexten_exec(), run_agi(), run_ras(), stasis_app_exec(), transfer_target_framehook_cb(), try_calling(), and wait_for_answer().

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 }
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:108
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:150
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:98
struct timeval * ast_channel_whentohangup(struct ast_channel *chan)
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_test_suite_event_notify(s, f,...)
Definition: test.h:196
int ast_channel_softhangup_internal_flag(struct ast_channel *chan)
const char * ast_channel_name(const struct ast_channel *chan)
void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)

◆ ast_check_hangup_locked()

int ast_check_hangup_locked ( struct ast_channel chan)
Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 459 of file channel.c.

References ast_channel_lock, ast_channel_unlock, and ast_check_hangup().

Referenced by action_redirect(), agent_run(), ast_app_exec_macro(), ast_app_exec_sub(), ast_bridge_channel_feature_digit(), bridge_channel_handle_action(), bridge_reconfigured_connected_line_update(), bridge_stasis_run_cb(), bridgewait_exec(), dial_exec_full(), launch_asyncagi(), pbx_builtin_saynumber(), stasis_app_exec(), and wait_for_answer().

460 {
461  int res;
462  ast_channel_lock(chan);
463  res = ast_check_hangup(chan);
464  ast_channel_unlock(chan);
465  return res;
466 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
int ast_check_hangup(struct ast_channel *chan)
Checks to see if a channel is needing hang up.
Definition: channel.c:445
#define ast_channel_unlock(chan)
Definition: channel.h:2946

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

References AST_CONNECTED_LINE_ID_PRESENTATION, AST_CONNECTED_LINE_NAME, AST_CONNECTED_LINE_NAME_CHAR_SET, AST_CONNECTED_LINE_NAME_PRESENTATION, AST_CONNECTED_LINE_NAME_VALID, AST_CONNECTED_LINE_NUMBER, AST_CONNECTED_LINE_NUMBER_PLAN, AST_CONNECTED_LINE_NUMBER_PRESENTATION, AST_CONNECTED_LINE_NUMBER_VALID, AST_CONNECTED_LINE_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, ast_party_connected_line::id, ast_set_party_connected_line::id, LOG_WARNING, ast_party_id_ies::name, NULL, party_id_build_data(), ast_party_connected_line::priv, ast_set_party_connected_line::priv, ast_party_connected_line::source, ast_party_name_ies::str, 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().

8794 {
8795  int32_t value;
8796  size_t pos = 0;
8797  int res;
8798 
8799  static const struct ast_party_id_ies ies = {
8801  .name.char_set = AST_CONNECTED_LINE_NAME_CHAR_SET,
8802  .name.presentation = AST_CONNECTED_LINE_NAME_PRESENTATION,
8803  .name.valid = AST_CONNECTED_LINE_NAME_VALID,
8804 
8805  .number.str = AST_CONNECTED_LINE_NUMBER,
8806  .number.plan = AST_CONNECTED_LINE_NUMBER_PLAN,
8807  .number.presentation = AST_CONNECTED_LINE_NUMBER_PRESENTATION,
8808  .number.valid = AST_CONNECTED_LINE_NUMBER_VALID,
8809 
8810  .subaddress.str = AST_CONNECTED_LINE_SUBADDRESS,
8811  .subaddress.type = AST_CONNECTED_LINE_SUBADDRESS_TYPE,
8812  .subaddress.odd_even_indicator = AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN,
8813  .subaddress.valid = AST_CONNECTED_LINE_SUBADDRESS_VALID,
8814 
8815  .tag = AST_CONNECTED_LINE_TAG,
8816  .combined_presentation = AST_CONNECTED_LINE_ID_PRESENTATION,
8817  };
8818 
8819  static const struct ast_party_id_ies priv_ies = {
8821  .name.char_set = AST_CONNECTED_LINE_PRIV_NAME_CHAR_SET,
8822  .name.presentation = AST_CONNECTED_LINE_PRIV_NAME_PRESENTATION,
8823  .name.valid = AST_CONNECTED_LINE_PRIV_NAME_VALID,
8824 
8825  .number.str = AST_CONNECTED_LINE_PRIV_NUMBER,
8826  .number.plan = AST_CONNECTED_LINE_PRIV_NUMBER_PLAN,
8827  .number.presentation = AST_CONNECTED_LINE_PRIV_NUMBER_PRESENTATION,
8828  .number.valid = AST_CONNECTED_LINE_PRIV_NUMBER_VALID,
8829 
8830  .subaddress.str = AST_CONNECTED_LINE_PRIV_SUBADDRESS,
8831  .subaddress.type = AST_CONNECTED_LINE_PRIV_SUBADDRESS_TYPE,
8832  .subaddress.odd_even_indicator = AST_CONNECTED_LINE_PRIV_SUBADDRESS_ODD_EVEN,
8833  .subaddress.valid = AST_CONNECTED_LINE_PRIV_SUBADDRESS_VALID,
8834 
8836  .combined_presentation = 0,/* Not sent. */
8837  };
8838 
8839  /*
8840  * The size of integer values must be fixed in case the frame is
8841  * shipped to another machine.
8842  */
8843 
8844  /* Connected line frame version */
8845  if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8846  ast_log(LOG_WARNING, "No space left for connected line frame version\n");
8847  return -1;
8848  }
8849  data[pos++] = AST_CONNECTED_LINE_VERSION;
8850  data[pos++] = 1;
8851  data[pos++] = 2;/* Version 1 did not have a version ie */
8852 
8853  res = party_id_build_data(data + pos, datalen - pos, &connected->id,
8854  "connected line", &ies, update ? &update->id : NULL);
8855  if (res < 0) {
8856  return -1;
8857  }
8858  pos += res;
8859 
8860  res = party_id_build_data(data + pos, datalen - pos, &connected->priv,
8861  "connected line priv", &priv_ies, update ? &update->priv : NULL);
8862  if (res < 0) {
8863  return -1;
8864  }
8865  pos += res;
8866 
8867  /* Connected line source */
8868  if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) {
8869  ast_log(LOG_WARNING, "No space left for connected line source\n");
8870  return -1;
8871  }
8872  data[pos++] = AST_CONNECTED_LINE_SOURCE;
8873  data[pos++] = sizeof(value);
8874  value = htonl(connected->source);
8875  memcpy(data + pos, &value, sizeof(value));
8876  pos += sizeof(value);
8877 
8878  return pos;
8879 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:459
#define LOG_WARNING
Definition: logger.h:274
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
struct ast_party_name_ies name
Subscriber name ies.
Definition: channel.c:8644
#define ast_log
Definition: astobj2.c:42
struct ast_set_party_id priv
Definition: channel.h:496
int source
Information about the source of an update.
Definition: channel.h:483
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:8673
struct ast_set_party_id id
Definition: channel.h:492
int int32_t
Definition: db.h:60
struct ast_party_id priv
Private connected party ID.
Definition: channel.h:469
int str
Subscriber name ie.
Definition: channel.c:8421

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

Definition at line 8389 of file channel.c.

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

Referenced by 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(), and wait_for_answer().

8390 {
8391  ast_party_id_copy(&dest->id, &src->id);
8392  ast_party_id_copy(&dest->ani, &src->ani);
8393  dest->ani2 = src->ani2;
8394 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:459
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:1765
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:476
struct ast_party_id id
Caller party ID.
Definition: channel.h:421
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:428
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:466
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:434

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

Definition at line 8396 of file channel.c.

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

Referenced by ast_unreal_call_setup(), and unreal_colp_redirect_indicate().

8397 {
8398  ast_party_id_copy(&dest->id, &src->id);
8399  ast_party_id_copy(&dest->ani, &src->ani);
8400 
8401  dest->ani2 = src->ani2;
8402 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:459
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:1765
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:476
struct ast_party_id id
Caller party ID.
Definition: channel.h:421
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:428
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:466
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:434

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

References AST_CONNECTED_LINE_ID_PRESENTATION, AST_CONNECTED_LINE_NAME, AST_CONNECTED_LINE_NAME_CHAR_SET, AST_CONNECTED_LINE_NAME_PRESENTATION, AST_CONNECTED_LINE_NAME_VALID, AST_CONNECTED_LINE_NUMBER, AST_CONNECTED_LINE_NUMBER_PLAN, AST_CONNECTED_LINE_NUMBER_PRESENTATION, AST_CONNECTED_LINE_NUMBER_VALID, AST_CONNECTED_LINE_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_name::char_set, ast_party_id_ies::combined_presentation, ast_party_connected_line::id, LOG_WARNING, ast_party_id::name, ast_party_id::number, ast_party_subaddress::odd_even_indicator, ast_party_number::plan, ast_party_name::presentation, ast_party_number::presentation, ast_party_connected_line::priv, ast_party_connected_line::source, ast_party_name::str, ast_party_number::str, ast_party_subaddress::str, ast_party_id::subaddress, ast_party_id::tag, ast_party_subaddress::type, ast_party_name::valid, ast_party_number::valid, ast_party_subaddress::valid, and value.

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

8882 {
8883  size_t pos;
8884  unsigned char ie_len;
8885  unsigned char ie_id;
8886  int32_t value;
8887  int frame_version = 1;
8888  int combined_presentation = 0;
8889  int got_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
8890 
8891  for (pos = 0; pos < datalen; pos += ie_len) {
8892  if (datalen < pos + sizeof(ie_id) + sizeof(ie_len)) {
8893  ast_log(LOG_WARNING, "Invalid connected line update\n");
8894  return -1;
8895  }
8896  ie_id = data[pos++];
8897  ie_len = data[pos++];
8898  if (datalen < pos + ie_len) {
8899  ast_log(LOG_WARNING, "Invalid connected line update\n");
8900  return -1;
8901  }
8902 
8903  switch (ie_id) {
8904 /* Connected line party frame version */
8906  if (ie_len != 1) {
8907  ast_log(LOG_WARNING, "Invalid connected line frame version (%u)\n",
8908  (unsigned) ie_len);
8909  break;
8910  }
8911  frame_version = data[pos];
8912  break;
8913 /* Connected line party id name */
8915  ast_free(connected->id.name.str);
8916  connected->id.name.str = ast_malloc(ie_len + 1);
8917  if (connected->id.name.str) {
8918  memcpy(connected->id.name.str, data + pos, ie_len);
8919  connected->id.name.str[ie_len] = 0;
8920  }
8921  break;
8923  if (ie_len != 1) {
8924  ast_log(LOG_WARNING, "Invalid connected line name char set (%u)\n",
8925  (unsigned) ie_len);
8926  break;
8927  }
8928  connected->id.name.char_set = data[pos];
8929  break;
8931  if (ie_len != 1) {
8932  ast_log(LOG_WARNING, "Invalid connected line name presentation (%u)\n",
8933  (unsigned) ie_len);
8934  break;
8935  }
8936  connected->id.name.presentation = data[pos];
8937  break;
8939  if (ie_len != 1) {
8940  ast_log(LOG_WARNING, "Invalid connected line name valid (%u)\n",
8941  (unsigned) ie_len);
8942  break;
8943  }
8944  connected->id.name.valid = data[pos];
8945  break;
8946 /* Connected line party id number */
8948  ast_free(connected->id.number.str);
8949  connected->id.number.str = ast_malloc(ie_len + 1);
8950  if (connected->id.number.str) {
8951  memcpy(connected->id.number.str, data + pos, ie_len);
8952  connected->id.number.str[ie_len] = 0;
8953  }
8954  break;
8956  if (ie_len != 1) {
8957  ast_log(LOG_WARNING, "Invalid connected line numbering plan (%u)\n",
8958  (unsigned) ie_len);
8959  break;
8960  }
8961  connected->id.number.plan = data[pos];
8962  break;
8964  if (ie_len != 1) {
8965  ast_log(LOG_WARNING, "Invalid connected line number presentation (%u)\n",
8966  (unsigned) ie_len);
8967  break;
8968  }
8969  connected->id.number.presentation = data[pos];
8970  break;
8972  if (ie_len != 1) {
8973  ast_log(LOG_WARNING, "Invalid connected line number valid (%u)\n",
8974  (unsigned) ie_len);
8975  break;
8976  }
8977  connected->id.number.valid = data[pos];
8978  break;
8979 /* Connected line party id subaddress */
8981  ast_free(connected->id.subaddress.str);
8982  connected->id.subaddress.str = ast_malloc(ie_len + 1);
8983  if (connected->id.subaddress.str) {
8984  memcpy(connected->id.subaddress.str, data + pos, ie_len);
8985  connected->id.subaddress.str[ie_len] = 0;
8986  }
8987  break;
8989  if (ie_len != 1) {
8990  ast_log(LOG_WARNING, "Invalid connected line type of subaddress (%u)\n",
8991  (unsigned) ie_len);
8992  break;
8993  }
8994  connected->id.subaddress.type = data[pos];
8995  break;
8997  if (ie_len != 1) {
8999  "Invalid connected line subaddress odd-even indicator (%u)\n",
9000  (unsigned) ie_len);
9001  break;
9002  }
9003  connected->id.subaddress.odd_even_indicator = data[pos];
9004  break;
9006  if (ie_len != 1) {
9007  ast_log(LOG_WARNING, "Invalid connected line subaddress valid (%u)\n",
9008  (unsigned) ie_len);
9009  break;
9010  }
9011  connected->id.subaddress.valid = data[pos];
9012  break;
9013 /* Connected line party tag */
9015  ast_free(connected->id.tag);
9016  connected->id.tag = ast_malloc(ie_len + 1);
9017  if (connected->id.tag) {
9018  memcpy(connected->id.tag, data + pos, ie_len);
9019  connected->id.tag[ie_len] = 0;
9020  }
9021  break;
9022 /* Connected line party id combined presentation */
9024  if (ie_len != 1) {
9025  ast_log(LOG_WARNING, "Invalid connected line combined presentation (%u)\n",
9026  (unsigned) ie_len);
9027  break;
9028  }
9029  combined_presentation = data[pos];
9030  got_combined_presentation = 1;
9031  break;
9032 /* Private connected line party id name */
9034  ast_free(connected->priv.name.str);
9035  connected->priv.name.str = ast_malloc(ie_len + 1);
9036  if (connected->priv.name.str) {
9037  memcpy(connected->priv.name.str, data + pos, ie_len);
9038  connected->priv.name.str[ie_len] = 0;
9039  }
9040  break;
9042  if (ie_len != 1) {
9043  ast_log(LOG_WARNING, "Invalid connected line private name char set (%u)\n",
9044  (unsigned) ie_len);
9045  break;
9046  }
9047  connected->priv.name.char_set = data[pos];
9048  break;
9050  if (ie_len != 1) {
9051  ast_log(LOG_WARNING, "Invalid connected line private name presentation (%u)\n",
9052  (unsigned) ie_len);
9053  break;
9054  }
9055  connected->priv.name.presentation = data[pos];
9056  break;
9058  if (ie_len != 1) {
9059  ast_log(LOG_WARNING, "Invalid connected line private name valid (%u)\n",
9060  (unsigned) ie_len);
9061  break;
9062  }
9063  connected->priv.name.valid = data[pos];
9064  break;
9065 /* Private connected line party id number */
9067  ast_free(connected->priv.number.str);
9068  connected->priv.number.str = ast_malloc(ie_len + 1);
9069  if (connected->priv.number.str) {
9070  memcpy(connected->priv.number.str, data + pos, ie_len);
9071  connected->priv.number.str[ie_len] = 0;
9072  }
9073  break;
9075  if (ie_len != 1) {
9076  ast_log(LOG_WARNING, "Invalid connected line private numbering plan (%u)\n",
9077  (unsigned) ie_len);
9078  break;
9079  }
9080  connected->priv.number.plan = data[pos];
9081  break;
9083  if (ie_len != 1) {
9084  ast_log(LOG_WARNING, "Invalid connected line private number presentation (%u)\n",
9085  (unsigned) ie_len);
9086  break;
9087  }
9088  connected->priv.number.presentation = data[pos];
9089  break;
9091  if (ie_len != 1) {
9092  ast_log(LOG_WARNING, "Invalid connected line private number valid (%u)\n",
9093  (unsigned) ie_len);
9094  break;
9095  }
9096  connected->priv.number.valid = data[pos];
9097  break;
9098 /* Private connected line party id subaddress */
9100  ast_free(connected->priv.subaddress.str);
9101  connected->priv.subaddress.str = ast_malloc(ie_len + 1);
9102  if (connected->priv.subaddress.str) {
9103  memcpy(connected->priv.subaddress.str, data + pos, ie_len);
9104  connected->priv.subaddress.str[ie_len] = 0;
9105  }
9106  break;
9108  if (ie_len != 1) {
9109  ast_log(LOG_WARNING, "Invalid connected line private type of subaddress (%u)\n",
9110  (unsigned) ie_len);
9111  break;
9112  }
9113  connected->priv.subaddress.type = data[pos];
9114  break;
9116  if (ie_len != 1) {
9118  "Invalid connected line private subaddress odd-even indicator (%u)\n",
9119  (unsigned) ie_len);
9120  break;
9121  }
9122  connected->priv.subaddress.odd_even_indicator = data[pos];
9123  break;
9125  if (ie_len != 1) {
9126  ast_log(LOG_WARNING, "Invalid connected line private subaddress valid (%u)\n",
9127  (unsigned) ie_len);
9128  break;
9129  }
9130  connected->priv.subaddress.valid = data[pos];
9131  break;
9132 /* Private connected line party tag */
9134  ast_free(connected->priv.tag);
9135  connected->priv.tag = ast_malloc(ie_len + 1);
9136  if (connected->priv.tag) {
9137  memcpy(connected->priv.tag, data + pos, ie_len);
9138  connected->priv.tag[ie_len] = 0;
9139  }
9140  break;
9141 /* Connected line party source */
9143  if (ie_len != sizeof(value)) {
9144  ast_log(LOG_WARNING, "Invalid connected line source (%u)\n",
9145  (unsigned) ie_len);
9146  break;
9147  }
9148  memcpy(&value, data + pos, sizeof(value));
9149  connected->source = ntohl(value);
9150  break;
9151 /* Connected line party unknown element */
9152  default:
9153  ast_debug(1, "Unknown connected line element: %u (%u)\n",
9154  (unsigned) ie_id, (unsigned) ie_len);
9155  break;
9156  }
9157  }
9158 
9159  switch (frame_version) {
9160  case 1:
9161  /*
9162  * The other end is an earlier version that we need to adjust
9163  * for compatibility.
9164  */
9165  connected->id.name.valid = 1;
9167  connected->id.number.valid = 1;
9168  if (got_combined_presentation) {
9171  }
9172  break;
9173  case 2:
9174  /* The other end is at the same level as we are. */
9175  break;
9176  default:
9177  /*
9178  * The other end is newer than we are.
9179  * We need to assume that they are compatible with us.
9180  */
9181  ast_debug(1, "Connected line frame has newer version: %u\n",
9182  (unsigned) frame_version);
9183  break;
9184  }
9185 
9186  return 0;
9187 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:278
char * str
Subscriber phone number (Malloced)
Definition: channel.h:292
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:296
struct ast_party_id id
Connected party ID.
Definition: channel.h:459
struct ast_party_name name
Subscriber name.
Definition: channel.h:341
#define LOG_WARNING
Definition: logger.h:274
int char_set
Character set the name is using.
Definition: channel.h:273
char * str
Subscriber name (Malloced)
Definition: channel.h:265
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:329
char * str
Malloced subaddress string.
Definition: channel.h:314
int value
Definition: syslog.c:37
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:327
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:193
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:345
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:294
int source
Information about the source of an update.
Definition: channel.h:483
#define ast_free(a)
Definition: astmm.h:182
int combined_presentation
Combined name and number presentation ie.
Definition: channel.c:8655
char * tag
User-set "tag".
Definition: channel.h:355
int type
Q.931 subaddress type.
Definition: channel.h:321
int int32_t
Definition: db.h:60
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:280
struct ast_party_id priv
Private connected party ID.
Definition: channel.h:469
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:298
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:343

◆ ast_deactivate_generator()

void ast_deactivate_generator ( struct ast_channel chan)

Deactivate an active generator

Definition at line 2902 of file channel.c.

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(), ast_openstream_full(), ast_playtones_stop(), ast_read_generator_actions(), ast_tonepair_stop(), ast_write_stream(), cb_events(), channel_spy(), dial_exec_full(), generator_force(), local_ast_moh_stop(), old_milliwatt_exec(), sms_exec(), transmit_audio(), and wait_for_answer().

2903 {
2904  ast_channel_lock(chan);
2906  if (should_trigger_dtmf_emulating(chan)) {
2907  /* if in the middle of dtmf emulation keep 50 tick per sec timer on rolling */
2909  }
2910  ast_channel_unlock(chan);
2911 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
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:2864
#define ast_channel_unlock(chan)
Definition: channel.h:2946
int ast_timer_set_rate(const struct ast_timer *handle, unsigned int rate)
Set the timing tick rate.
Definition: timing.c:166
static void deactivate_generator_nolock(struct ast_channel *chan)
Definition: channel.c:2886
struct ast_timer * ast_channel_timer(const struct ast_channel *chan)

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

References dummy(), and ast_channel::x.

Referenced by do_monitor().

2851 {
2852  int x;
2853  int dummy = 0;
2854 
2855  if (fd < 0)
2856  return 0;
2857  if (!start)
2858  start = &dummy;
2859  for (x = *start; x < maximum; x++)
2860  if (pfds[x].fd == fd) {
2861  if (x == *start)
2862  (*start)++;
2863  return pfds[x].revents;
2864  }
2865  return 0;
2866 }
static void dummy(char *unused,...)
Definition: chan_unistim.c:220

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

References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, chanlist::list, 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().

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 }
const char * tech
Definition: app_dial.c:802
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define NULL
Definition: resample.c:96
the list of registered channel types
Definition: channel.c:121
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
List of channel drivers.
Definition: app_dial.c:796
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:629
static const char name[]
Definition: cdr_mysql.c:74

◆ ast_get_group()

ast_group_t ast_get_group ( const char *  s)

Definition at line 7718 of file channel.c.

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

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

7719 {
7720  char *piece;
7721  char *c;
7722  int start=0, finish=0, x;
7723  ast_group_t group = 0;
7724 
7725  if (ast_strlen_zero(s))
7726  return 0;
7727 
7728  c = ast_strdupa(s);
7729 
7730  while ((piece = strsep(&c, ","))) {
7731  if (sscanf(piece, "%30d-%30d", &start, &finish) == 2) {
7732  /* Range */
7733  } else if (sscanf(piece, "%30d", &start)) {
7734  /* Just one */
7735  finish = start;
7736  } else {
7737  ast_log(LOG_ERROR, "Syntax error parsing group configuration '%s' at '%s'. Ignoring.\n", s, piece);
7738  continue;
7739  }
7740  for (x = start; x <= finish; x++) {
7741  if ((x > 63) || (x < 0)) {
7742  ast_log(LOG_WARNING, "Ignoring invalid group %d (maximum group is 63)\n", x);
7743  } else
7744  group |= ((ast_group_t) 1 << x);
7745  }
7746  }
7747  return group;
7748 }
unsigned long long ast_group_t
Definition: channel.h:214
#define LOG_WARNING
Definition: logger.h:274
static struct test_val c
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_log
Definition: astobj2.c:42
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
#define LOG_ERROR
Definition: logger.h:285
char * strsep(char **str, const char *delims)

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

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, namedgroup_member::hash, len(), namedgroup_member::name, namedgroup_cmp_cb(), namedgroup_hash_cb(), NULL, OBJ_NODATA, OBJ_POINTER, OBJ_UNLINK, and strsep().

Referenced by _parse(), build_peer(), config_parse_variables(), func_channel_write_real(), named_groups_handler(), and process_dahdi().

7776 {
7777  struct ao2_container *namedgroups;
7778  char *piece;
7779  char *c;
7780 
7781  if (!s) {
7782  return NULL;
7783  }
7784 
7785  /*! \brief Remove leading and trailing whitespace */
7787  if (ast_strlen_zero(c)) {
7788  return NULL;
7789  }
7790 
7793  if (!namedgroups) {
7794  return NULL;
7795  }
7796 
7797  while ((piece = strsep(&c, ","))) {
7798  struct namedgroup_member *member;
7799  size_t len;
7800 
7801  /* remove leading/trailing whitespace */
7802  piece = ast_strip(piece);
7803 
7804  len = strlen(piece);
7805  if (!len) {
7806  continue;
7807  }
7808 
7809  member = ao2_alloc_options(sizeof(*member) + len, NULL, AO2_ALLOC_OPT_LOCK_NOLOCK);
7810  if (!member) {
7811  ao2_ref(namedgroups, -1);
7812  return NULL;
7813  }
7814  strcpy(member->name, piece);/* Safe */
7815  member->hash = ast_str_hash(member->name);
7816 
7817  /* every group name may exist only once, delete duplicates */
7818  ao2_find(namedgroups, member, OBJ_POINTER | OBJ_UNLINK | OBJ_NODATA);
7819  ao2_link(namedgroups, member);
7820  ao2_ref(member, -1);
7821  }
7822 
7823  if (!ao2_container_count(namedgroups)) {
7824  /* There were no group names specified. */
7825  ao2_ref(namedgroups, -1);
7826  namedgroups = NULL;
7827  }
7828 
7829  return (struct ast_namedgroups *) namedgroups;
7830 }
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
#define OBJ_POINTER
Definition: astobj2.h:1154
Named group member structure.
Definition: channel.c:7751
#define ao2_alloc_options(data_size, destructor_fn, options)
Definition: astobj2.h:406
static struct test_val c
#define NULL
Definition: resample.c:96
#define ast_strlen_zero(foo)
Definition: strings.h:52
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Definition: strings.h:219
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
unsigned int hash
Definition: channel.c:7753
static int namedgroup_hash_cb(const void *obj, const int flags)
Hashing function used for named group container.
Definition: channel.c:7768
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Definition: astobj2.h:1310
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
Definition: strings.h:157
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
Definition: strings.h:182
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1756
static int namedgroup_cmp_cb(void *obj, void *arg, int flags)
Comparison function used for named group container.
Definition: channel.c:7759
char * strsep(char **str, const char *delims)
Generic container type.
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
Definition: strings.h:1206
#define ao2_link(container, obj)
Definition: astobj2.h:1549

◆ 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)
Returns
Nothing

Hang up a channel.

Definition at line 2548 of file channel.c.

References ao2_ref, ao2_unlink, 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_tech(), 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(), ast_channel_tech::hangup, 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(), alsa_new(), 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_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_frame(), handle_hd_hf(), handle_init_event(), handle_invite_replaces(), handle_request_invite(), handle_soft_key_event_message(), handle_timeout_trip(), hangup_chan(), hangup_channel(), hangup_playback(), hangupcalls(), hanguptree(), iax2_request(), jingle_action_session_initiate(), local_call(), make_channel(), mbl_ast_hangup(), media_request_helper(), meetme_menu_admin_extended(), mgcp_new(), mgcp_ss(), moh_channel_thread(), monitor_dial(), mwi_thread(), my_distinctive_ring(), my_handle_notify_message(), nbs_new(), ooh323_new(), oss_new(), park_local_transfer(), parking_blind_transfer_park(), pbx_outgoing_exec(), pbx_start_incoming_request(), phone_new(), push_announcer(), read_test(), recalling_exit(), refer_incoming_invite_request(), request_channel(), retransfer_enter(), safe_hangup(), setsubstate(), sip_new(), sip_pickup_thread(), skinny_new(), snoop_stasis_thread(), stasis_app_control_snoop(), unistim_new(), and wait_for_answer().

2549 {
2550  /* Be NULL safe for RAII_VAR() usage. */
2551  if (!chan) {
2552  return;
2553  }
2554 
2555  ast_debug(1, "Channel %p '%s' hanging up. Refs: %d\n", chan, ast_channel_name(chan),
2556  ao2_ref(chan, 0));
2557 
2558  ast_autoservice_stop(chan);
2559 
2560  ast_channel_lock(chan);
2561 
2562  while (ast_channel_masq(chan) || ast_channel_masqr(chan)) {
2564  }
2565 
2566  /* Mark as a zombie so a masquerade cannot be setup on this channel. */
2568 
2569  ast_channel_unlock(chan);
2570 
2571  /*
2572  * XXX if running the hangup handlers here causes problems
2573  * because the handlers take too long to execute, we could move
2574  * the meat of this function into another thread. A thread
2575  * where channels go to die.
2576  *
2577  * If this is done, ast_autoservice_chan_hangup_peer() will no
2578  * longer be needed.
2579  */
2581  ao2_unlink(channels, chan);
2582  ast_channel_lock(chan);
2583 
2584  destroy_hooks(chan);
2585 
2586  free_translation(chan);
2587  /* Close audio stream */
2588  if (ast_channel_stream(chan)) {
2591  }
2592  /* Close video stream */
2593  if (ast_channel_vstream(chan)) {
2596  }
2597  if (ast_channel_sched(chan)) {
2599  ast_channel_sched_set(chan, NULL);
2600  }
2601 
2602  if (ast_channel_generatordata(chan)) { /* Clear any tone stuff remaining */
2603  if (ast_channel_generator(chan) && ast_channel_generator(chan)->release) {
2605  }
2606  }
2609 
2611  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",
2613  ast_channel_blockproc(chan));
2614  ast_assert(0);
2615  }
2616 
2617  if (ast_channel_tech(chan)->hangup) {
2618  ast_channel_tech(chan)->hangup(chan);
2619  }
2620 
2621  ast_channel_unlock(chan);
2622 
2623  ast_cc_offer(chan);
2624 
2625  ast_channel_unref(chan);
2626 }
const char * ast_channel_blockproc(const struct ast_channel *chan)
#define ast_channel_lock(chan)
Definition: channel.h:2945
struct ast_filestream * ast_channel_vstream(const struct ast_channel *chan)
void * ast_channel_generatordata(const struct ast_channel *chan)
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2981
#define ast_test_flag(p, flag)
Definition: utils.h:63
static void free_translation(struct ast_channel *clonechan)
Definition: channel.c:2492
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define LOG_WARNING
Definition: logger.h:274
static void destroy_hooks(struct ast_channel *chan)
Definition: channel.c:2537
void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator *value)
void ast_channel_vstream_set(struct ast_channel *chan, struct ast_filestream *value)
int(*const hangup)(struct ast_channel *chan)
Hangup (and possibly destroy) the channel.
Definition: channel.h:705
#define ast_assert(a)
Definition: utils.h:695
int ast_channel_blocker_tid(const struct ast_channel *chan)
static int hangup(void *data)
Definition: chan_pjsip.c:2483
#define NULL
Definition: resample.c:96
void ast_channel_stream_set(struct ast_channel *chan, struct ast_filestream *value)
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
void ast_channel_generatordata_set(struct ast_channel *chan, void *value)
int ast_get_tid(void)
Get current thread ID.
Definition: main/utils.c:2504
#define ao2_ref(o, delta)
Definition: astobj2.h:464
void(* release)(struct ast_channel *chan, void *data)
Definition: channel.h:229
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:266
struct ast_sched_context * ast_channel_sched(const struct ast_channel *chan)
struct ast_generator * ast_channel_generator(const struct ast_channel *chan)
int ast_cc_offer(struct ast_channel *caller_chan)
Offer CC to a caller.
Definition: ccss.c:3751
#define ao2_unlink(container, obj)
Definition: astobj2.h:1598
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:124
struct ast_channel * ast_channel_masq(const struct ast_channel *chan)
#define ast_channel_unlock(chan)
Definition: channel.h:2946
#define CHANNEL_DEADLOCK_AVOIDANCE(chan)
Definition: lock.h:352
int ast_closestream(struct ast_filestream *f)
Closes a stream.
Definition: file.c:1068
struct ast_filestream * ast_channel_stream(const struct ast_channel *chan)
int ast_pbx_hangup_handler_run(struct ast_channel *chan)
Run all hangup handlers on the channel.
const char * ast_channel_name(const struct ast_channel *chan)
void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context *value)
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
struct ast_channel * ast_channel_masqr(const struct ast_channel *chan)
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
Definition: sched.c:269

◆ 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
Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 4322 of file channel.c.

References ast_indicate_data(), and NULL.

Referenced by __ast_play_and_record(), alsa_call(), answer_trunk_chan(), app_control_dtmf(), app_control_hold(), app_control_moh_start(), 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(), mgcp_ss(), monitor_dial(), oss_call(), 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(), sla_handle_hold_event(), sla_station_exec(), sla_trunk_exec(), softmix_bridge_join(), try_calling(), valid_priv_reply(), vm_exec(), and wait_for_answer().

4323 {
4324  return ast_indicate_data(chan, condition, NULL, 0);
4325 }
#define NULL
Definition: resample.c:96
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:4698

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

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_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(), transmit_audio(), transmit_t38(), wait_for_answer(), and wait_for_winner().

4699 {
4700  int res;
4701  /* this frame is used by framehooks. if it is set, we must free it at the end of this function */
4702  struct ast_frame *awesome_frame = NULL;
4703 
4704  ast_channel_lock(chan);
4705 
4706  /* Don't bother if the channel is about to go away, anyway. */
4708  || (ast_check_hangup(chan) && !ast_channel_is_leaving_bridge(chan)))
4709  && _condition != AST_CONTROL_MASQUERADE_NOTIFY) {
4710  res = -1;
4711  goto indicate_cleanup;
4712  }
4713 
4715  /* Do framehooks now, do it, go, go now */
4716  struct ast_frame frame = {
4718  .subclass.integer = _condition,
4719  .data.ptr = (void *) data, /* this cast from const is only okay because we do the ast_frdup below */
4720  .datalen = datalen
4721  };
4722 
4723  /* we have now committed to freeing this frame */
4724  awesome_frame = ast_frdup(&frame);
4725 
4726  /* who knows what we will get back! the anticipation is killing me. */
4728  awesome_frame);
4729  if (!awesome_frame
4730  || awesome_frame->frametype != AST_FRAME_CONTROL) {
4731  res = 0;
4732  goto indicate_cleanup;
4733  }
4734 
4735  _condition = awesome_frame->subclass.integer;
4736  data = awesome_frame->data.ptr;
4737  datalen = awesome_frame->datalen;
4738  }
4739 
4740  res = indicate_data_internal(chan, _condition, data, datalen);
4741 
4742 indicate_cleanup:
4743  ast_channel_unlock(chan);
4744  if (awesome_frame) {
4745  ast_frfree(awesome_frame);
4746  }
4747 
4748  return res;
4749 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define ast_frdup(fr)
Copies a frame.
#define ast_test_flag(p, flag)
Definition: utils.h:63
struct ast_framehook_list * ast_channel_framehooks(const struct ast_channel *chan)
int ast_framehook_list_is_empty(struct ast_framehook_list *framehooks)
Determine if an framehook list is empty or not.
Definition: framehook.c:274
#define NULL
Definition: resample.c:96
struct ast_frame_subclass subclass
static int indicate_data_internal(struct ast_channel *chan, int _condition, const void *data, size_t datalen)
Definition: channel.c:4515
int ast_check_hangup(struct ast_channel *chan)
Checks to see if a channel is needing hang up.
Definition: channel.c:445
struct ast_frame * ast_framehook_list_write_event(struct ast_framehook_list *framehooks, struct ast_frame *frame)
This is used by the channel API push a frame write event to a channel&#39;s framehook list...
Definition: framehook.c:313
#define ast_channel_unlock(chan)
Definition: channel.h:2946
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:10751
#define ast_frfree(fr)
Data structure associated with a single frame of data.
union ast_frame::@263 data
enum ast_frame_type frametype
struct ast_flags * ast_channel_flags(struct ast_channel *chan)

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

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

1468 {
1469  /* Do not add a default entry in this switch statement. Each new
1470  * frame type should be addressed directly as to whether it should
1471  * be queued up or not.
1472  */
1473  switch (frame->frametype) {
1476  case AST_FRAME_CONTROL:
1477  case AST_FRAME_TEXT:
1478  case AST_FRAME_TEXT_DATA:
1479  case AST_FRAME_IMAGE:
1480  case AST_FRAME_HTML:
1481  return 1;
1482 
1483  case AST_FRAME_DTMF_END:
1484  case AST_FRAME_DTMF_BEGIN:
1485  case AST_FRAME_VOICE:
1486  case AST_FRAME_VIDEO:
1487  case AST_FRAME_NULL:
1488  case AST_FRAME_IAX:
1489  case AST_FRAME_CNG:
1490  case AST_FRAME_MODEM:
1491  case AST_FRAME_RTCP:
1492  return 0;
1493  }
1494  return 0;
1495 }
enum ast_frame_type frametype

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

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

Referenced by find_channel_by_group().

8193 {
8194  void *match;
8195  struct ao2_container *group_a = (struct ao2_container *) a;
8196  struct ao2_container *group_b = (struct ao2_container *) b;
8197 
8198  if (!a || !b) {
8199  return 0;
8200  }
8201 
8202  /*
8203  * Do groups a and b intersect? Since a and b are hash tables,
8204  * the average time complexity is:
8205  * O(a.count <= b.count ? a.count : b.count)
8206  */
8207  if (ao2_container_count(group_b) < ao2_container_count(group_a)) {
8208  /* Traverse over the smaller group. */
8209  SWAP(group_a, group_b);
8210  }
8211  match = ao2_callback(group_a, 0, namedgroup_match, group_b);
8212  ao2_cleanup(match);
8213 
8214  return match != NULL;
8215 }
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
#define ao2_callback(c, flags, cb_fn, arg)
Definition: astobj2.h:1716
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:2315
#define SWAP(a, b)
Definition: utils.h:230
#define NULL
Definition: resample.c:96
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static struct test_val b
Generic container type.
static int namedgroup_match(void *obj, void *arg, int flags)
Definition: channel.c:8182
static struct test_val a

◆ 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
Returns
Nothing

Definition at line 1986 of file channel.c.

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

1987 {
1988  if (dest == src) {
1989  /* Don't copy to self */
1990  return;
1991  }
1992 
1993  ast_party_id_copy(&dest->id, &src->id);
1994  ast_party_id_copy(&dest->ani, &src->ani);
1995  ast_party_id_copy(&dest->priv, &src->priv);
1996  dest->ani2 = src->ani2;
1997 }
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:1765
struct ast_party_id id
Caller party ID.
Definition: channel.h:421
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:428
struct ast_party_id priv
Private caller party ID.
Definition: channel.h:431
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:434

◆ 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.
Returns
Nothing

Definition at line 2015 of file channel.c.

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(), and sla_ring_station().

2016 {
2017  ast_party_id_free(&doomed->id);
2018  ast_party_id_free(&doomed->ani);
2019  ast_party_id_free(&doomed->priv);
2020 }
void ast_party_id_free(struct ast_party_id *doomed)
Destroy the party id contents.
Definition: channel.c:1811
struct ast_party_id id
Caller party ID.
Definition: channel.h:421
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:428
struct ast_party_id priv
Private caller party ID.
Definition: channel.h:431

◆ 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.
Returns
Nothing

Definition at line 1978 of file channel.c.

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(), sla_ring_station(), and vm_allocate_dh().

1979 {
1980  ast_party_id_init(&init->id);
1981  ast_party_id_init(&init->ani);
1982  ast_party_id_init(&init->priv);
1983  init->ani2 = 0;
1984 }
struct ast_party_id id
Caller party ID.
Definition: channel.h:421
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:428
struct ast_party_id priv
Private caller party ID.
Definition: channel.h:431
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:434
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition: channel.c:1757

◆ 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.
Returns
Nada

Definition at line 2007 of file channel.c.

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

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

2008 {
2009  ast_party_id_set(&dest->id, &src->id, update ? &update->id : NULL);
2010  ast_party_id_set(&dest->ani, &src->ani, update ? &update->ani : NULL);
2011  ast_party_id_set(&dest->priv, &src->priv, update ? &update->priv : NULL);
2012  dest->ani2 = src->ani2;
2013 }
struct ast_set_party_id ani
Definition: channel.h:445
#define NULL
Definition: resample.c:96
struct ast_party_id id
Caller party ID.
Definition: channel.h:421
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:1788
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:428
struct ast_party_id priv
Private caller party ID.
Definition: channel.h:431
struct ast_set_party_id id
Definition: channel.h:443
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:434
struct ast_set_party_id priv
Definition: channel.h:447

◆ 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.
Returns
Nothing

Definition at line 1999 of file channel.c.

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(), misdn_update_caller_id(), and ring_entry().

2000 {
2001  ast_party_id_set_init(&init->id, &guide->id);
2002  ast_party_id_set_init(&init->ani, &guide->ani);
2003  ast_party_id_set_init(&init->priv, &guide->priv);
2004  init->ani2 = guide->ani2;
2005 }
struct ast_party_id id
Caller party ID.
Definition: channel.h:421
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:428
struct ast_party_id priv
Private caller party ID.
Definition: channel.h:431
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:434
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:1780

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

Definition at line 2063 of file channel.c.

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

2064 {
2065  connected->id = caller->id;
2066  connected->ani = caller->ani;
2067  connected->priv = caller->priv;
2068  connected->ani2 = caller->ani2;
2070 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:459
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:476
struct ast_party_id id
Caller party ID.
Definition: channel.h:421
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:428
struct ast_party_id priv
Private caller party ID.
Definition: channel.h:431
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:466
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:434
int source
Information about the source of an update.
Definition: channel.h:483
struct ast_party_id priv
Private connected party ID.
Definition: channel.h:469

◆ 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
Returns
Nothing

Definition at line 2031 of file channel.c.

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_macro(), 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(), and wait_for_answer().

2032 {
2033  if (dest == src) {
2034  /* Don't copy to self */
2035  return;
2036  }
2037 
2038  ast_party_id_copy(&dest->id, &src->id);
2039  ast_party_id_copy(&dest->ani, &src->ani);
2040  ast_party_id_copy(&dest->priv, &src->priv);
2041  dest->ani2 = src->ani2;
2042  dest->source = src->source;
2043 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:459
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:1765
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:476
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:466
int source
Information about the source of an update.
Definition: channel.h:483
struct ast_party_id priv
Private connected party ID.
Definition: channel.h:469

◆ ast_party_connected_line_free()

void ast_party_connected_line_free ( struct ast_party_connected_line doomed)

Destroy the connected line information contents.

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

Definition at line 2072 of file channel.c.

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

Referenced by __ast_read(), after_bridge_move_channel(), agent_login_channel_config(), agent_pvt_destructor(), agent_request_exec(), app_exec(), ast_channel_connected_line_macro(), ast_channel_connected_line_sub(), ast_channel_destructor(), ast_do_pickup(), ast_dummy_channel_destructor(), attended_transfer_properties_destructor(), bridge_reconfigured_connected_line_update(), callattempt_free(), chanlist_free(), connectedline_write(), destroy_calling_node(), indicate_connected_line(), socket_process_helper(), update_connected_line_from_peer(), wait_for_answer(), and wait_for_winner().

2073 {
2074  ast_party_id_free(&doomed->id);
2075  ast_party_id_free(&doomed->ani);
2076  ast_party_id_free(&doomed->priv);
2077 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:459
void ast_party_id_free(struct ast_party_id *doomed)
Destroy the party id contents.
Definition: channel.c:1811
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:466
struct ast_party_id priv
Private connected party ID.
Definition: channel.h:469

◆ ast_party_connected_line_init()

void ast_party_connected_line_init ( struct ast_party_connected_line init)

Initialize the given connected line structure.

Since
1.8
Parameters
initConnected line structure to initialize.
Returns
Nothing

Definition at line 2022 of file channel.c.

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

Referenced by __ast_channel_alloc_ap(), __ast_read(), after_bridge_move_channel(), agent_login_channel_config(), agent_pvt_new(), agent_request_exec(), ast_channel_connected_line_macro(), ast_channel_connected_line_sub(), ast_do_pickup(), bridge_reconfigured_connected_line_update(), do_forward(), handle_request_invite(), handle_request_update(), handle_response_invite(), misdn_queue_connected_line_update(), onAlerting(), onCallEstablished(), onProgress(), queue_connected_line_update(), sip_call(), socket_process_helper(), update_connected_line_from_peer(), and update_initial_connected_line().

2023 {
2024  ast_party_id_init(&init->id);
2025  ast_party_id_init(&init->ani);
2026  ast_party_id_init(&init->priv);
2027  init->ani2 = 0;
2029 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:459
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:476
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:466
int source
Information about the source of an update.
Definition: channel.h:483
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition: channel.c:1757
struct ast_party_id priv
Private connected party ID.
Definition: channel.h:469

◆ 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.
Returns
Nothing

Definition at line 2054 of file channel.c.

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

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

2055 {
2056  ast_party_id_set(&dest->id, &src->id, update ? &update->id : NULL);
2057  ast_party_id_set(&dest->ani, &src->ani, update ? &update->ani : NULL);
2058  ast_party_id_set(&dest->priv, &src->priv, update ? &update->priv : NULL);
2059  dest->ani2 = src->ani2;
2060  dest->source = src->source;
2061 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:459
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:476
#define NULL
Definition: resample.c:96
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:1788
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:466
struct ast_set_party_id priv
Definition: channel.h:496
int source
Information about the source of an update.
Definition: channel.h:483
struct ast_set_party_id id
Definition: channel.h:492
struct ast_set_party_id ani
Definition: channel.h:494
struct ast_party_id priv
Private connected party ID.
Definition: channel.h:469

◆ 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.
Returns
Nothing

Definition at line 2045 of file channel.c.

References ast_party_connected_line::ani, ast_party_connected_line::ani2, ast_party_id_set_init(), ast_party_connected_line::id, 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(), and wait_for_winner().

2046 {
2047  ast_party_id_set_init(&init->id, &guide->id);
2048  ast_party_id_set_init(&init->ani, &guide->ani);
2049  ast_party_id_set_init(&init->priv, &guide->priv);
2050  init->ani2 = guide->ani2;
2051  init->source = guide->source;
2052 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:459
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:476
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:466
int source
Information about the source of an update.
Definition: channel.h:483
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:1780
struct ast_party_id priv
Private connected party ID.
Definition: channel.h:469

◆ 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
Returns
Nothing

Definition at line 1936 of file channel.c.

References ast_free, ast_party_subaddress_copy(), ast_strdup, ast_party_dialed::number, ast_party_dialed::plan, ast_party_dialed::str, ast_party_dialed::subaddress, and ast_party_dialed::transit_network_select.

Referenced by ast_unreal_call_setup().

1937 {
1938  if (dest == src) {
1939  /* Don't copy to self */
1940  return;
1941  }
1942 
1943  ast_free(dest->number.str);
1944  dest->number.str = ast_strdup(src->number.str);
1945  dest->number.plan = src->number.plan;
1948 }
struct ast_party_dialed::@246 number
Dialed/Called number.
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:389
char * str
Subscriber phone number (Malloced)
Definition: channel.h:387
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
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:1705
#define ast_free(a)
Definition: astmm.h:182
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition: channel.h:392
int transit_network_select
Transit Network Select.
Definition: channel.h:398

◆ 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.
Returns
Nothing

Definition at line 1971 of file channel.c.

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

1972 {
1973  ast_free(doomed->number.str);
1974  doomed->number.str = NULL;
1976 }
struct ast_party_dialed::@246 number
Dialed/Called number.
char * str
Subscriber phone number (Malloced)
Definition: channel.h:387
#define NULL
Definition: resample.c:96
void ast_party_subaddress_free(struct ast_party_subaddress *doomed)
Destroy the party subaddress contents.
Definition: channel.c:1744
#define ast_free(a)
Definition: astmm.h:182
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition: channel.h:392

◆ 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.
Returns
Nothing

Definition at line 1928 of file channel.c.

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

1929 {
1930  init->number.str = NULL;
1931  init->number.plan = 0;/* Unknown */
1933  init->transit_network_select = 0;
1934 }
struct ast_party_dialed::@246 number
Dialed/Called number.
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:389
char * str
Subscriber phone number (Malloced)
Definition: channel.h:387
#define NULL
Definition: resample.c:96
void ast_party_subaddress_init(struct ast_party_subaddress *init)
Initialize the given subaddress structure.
Definition: channel.c:1697
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition: channel.h:392
int transit_network_select
Transit Network Select.
Definition: channel.h:398

◆ 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
Returns
Nada

Definition at line 1958 of file channel.c.

References ast_free, ast_party_subaddress_set(), ast_strdup, ast_party_dialed::number, ast_party_dialed::plan, ast_party_dialed::str, ast_party_dialed::subaddress, and ast_party_dialed::transit_network_select.

Referenced by callerid_write().

1959 {
1960  if (src->number.str && src->number.str != dest->number.str) {
1961  ast_free(dest->number.str);
1962  dest->number.str = ast_strdup(src->number.str);
1963  }
1964  dest->number.plan = src->number.plan;
1965 
1967 
1969 }
struct ast_party_dialed::@246 number
Dialed/Called number.
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:389
char * str
Subscriber phone number (Malloced)
Definition: channel.h:387
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:1727
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define ast_free(a)
Definition: astmm.h:182
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition: channel.h:392
int transit_network_select
Transit Network Select.
Definition: channel.h:398

◆ 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.
Returns
Nothing

Definition at line 1950 of file channel.c.

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

1951 {
1952  init->number.str = NULL;
1953  init->number.plan = guide->number.plan;
1956 }
struct ast_party_dialed::@246 number
Dialed/Called number.
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:389
char * str
Subscriber phone number (Malloced)
Definition: channel.h:387
#define NULL
Definition: resample.c:96
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:1719
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition: channel.h:392
int transit_network_select
Transit Network Select.
Definition: channel.h:398

◆ 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
Returns
Nothing

Definition at line 1765 of file channel.c.

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

Referenced by ast_connected_line_copy_from_caller(), ast_connected_line_copy_to_caller(), ast_party_caller_copy(), ast_party_connected_line_copy(), ast_party_id_merge_copy(), ast_party_redirecting_copy(), ast_sip_session_create_outgoing(), caller_id_incoming_request(), caller_id_outgoing_request(), caller_id_outgoing_response(), chan_pjsip_new(), copy_redirecting_id(), queue_connected_line_update(), set_from_header(), and update_initial_connected_line().

1766 {
1767  if (dest == src) {
1768  /* Don't copy to self */
1769  return;
1770  }
1771 
1772  ast_party_name_copy(&dest->name, &src->name);
1773  ast_party_number_copy(&dest->number, &src->number);
1775 
1776  ast_free(dest->tag);
1777  dest->tag = ast_strdup(src->tag);
1778 }
struct ast_party_name name
Subscriber name.
Definition: channel.h:341
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
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:1652
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:1705
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:345
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:1599
#define ast_free(a)
Definition: astmm.h:182
char * tag
User-set "tag".
Definition: channel.h:355
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:343

◆ 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.
Returns
Nothing

Definition at line 1811 of file channel.c.

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(), session_destructor(), set_from_header(), and update_incoming_connected_line().

1812 {
1813  ast_party_name_free(&doomed->name);
1814  ast_party_number_free(&doomed->number);
1816 
1817  ast_free(doomed->tag);
1818  doomed->tag = NULL;
1819 }
struct ast_party_name name
Subscriber name.
Definition: channel.h:341
#define NULL
Definition: resample.c:96
void ast_party_number_free(struct ast_party_number *doomed)
Destroy the party number contents.
Definition: channel.c:1691
void ast_party_subaddress_free(struct ast_party_subaddress *doomed)
Destroy the party subaddress contents.
Definition: channel.c:1744
void ast_party_name_free(struct ast_party_name *doomed)
Destroy the party name contents.
Definition: channel.c:1638
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:345
#define ast_free(a)
Definition: astmm.h:182
char * tag
User-set "tag".
Definition: channel.h:355
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:343

◆ 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.
Returns
Nothing

Definition at line 1757 of file channel.c.

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(), set_from_header(), and update_incoming_connected_line().

1758 {
1759  ast_party_name_init(&init->name);
1760  ast_party_number_init(&init->number);
1762  init->tag = NULL;
1763 }
struct ast_party_name name
Subscriber name.
Definition: channel.h:341
#define NULL
Definition: resample.c:96
void ast_party_name_init(struct ast_party_name *init)
Initialize the given name structure.
Definition: channel.c:1591
void ast_party_subaddress_init(struct ast_party_subaddress *init)
Initialize the given subaddress structure.
Definition: channel.c:1697
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:345
void ast_party_number_init(struct ast_party_number *init)
Initialize the given number structure.
Definition: channel.c:1644
char * tag
User-set "tag".
Definition: channel.h:355
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:343

◆ 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.
Returns
Nothing

Definition at line 1889 of file channel.c.

1890 {
1891  id->name.valid = 0;
1892  id->number.valid = 0;
1893  id->subaddress.valid = 0;
1894 }

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

References ast_party_id::name.

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

1903 {
1904  struct ast_party_id merged;
1905 
1906  merged = *base;
1907  if (overlay->name.valid) {
1908  merged.name = overlay->name;
1909  }
1910  if (overlay->number.valid) {
1911  merged.number = overlay->number;
1912  }
1913  if (overlay->subaddress.valid) {
1914  merged.subaddress = overlay->subaddress;
1915  }
1916  /* Note the actual structure is returned and not a pointer to it! */
1917  return merged;
1918 }
Information needed to identify an endpoint in a call.
Definition: channel.h:339
struct ast_party_name name
Subscriber name.
Definition: channel.h:341
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:329
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:345
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:280
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:298
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:343

◆ 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.
Returns
Nothing

Definition at line 1920 of file channel.c.

References ast_party_id_copy(), and ast_party_id_merge().

1921 {
1922  struct ast_party_id merged;
1923 
1924  merged = ast_party_id_merge(base, overlay);
1925  ast_party_id_copy(dest, &merged);
1926 }
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:1902
Information needed to identify an endpoint in a call.
Definition: channel.h:339
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:1765

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

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

Referenced by add_id_headers(), add_privacy_header(), add_privacy_params(), add_rpid(), ast_json_party_id(), ast_str_retrieve_variable(), ast_var_channels_table(), channel_snapshot_caller_create(), iax2_call(), initreqprep(), is_colp_update_allowed(), my_on_hook(), party_id_build_data(), party_id_read(), push_callinfo(), redirecting_read(), send_callinfo(), set_from_header(), setsubstate(), setup_env(), sip_call(), and socket_process_helper().

1822 {
1823  int number_priority;
1824  int number_value;
1825  int number_screening;
1826  int name_priority;
1827  int name_value;
1828 
1829  /* Determine name presentation priority. */
1830  if (!id->name.valid) {
1831  name_value = AST_PRES_UNAVAILABLE;
1832  name_priority = 3;
1833  } else {
1834  name_value = id->name.presentation & AST_PRES_RESTRICTION;
1835  switch (name_value) {
1836  case AST_PRES_RESTRICTED:
1837  name_priority = 0;
1838  break;
1839  case AST_PRES_ALLOWED:
1840  name_priority = 1;
1841  break;
1842  case AST_PRES_UNAVAILABLE:
1843  name_priority = 2;
1844  break;
1845  default:
1846  name_value = AST_PRES_UNAVAILABLE;
1847  name_priority = 3;
1848  break;
1849  }
1850  }
1851 
1852  /* Determine number presentation priority. */
1853  if (!id->number.valid) {
1854  number_screening = AST_PRES_USER_NUMBER_UNSCREENED;
1855  number_value = AST_PRES_UNAVAILABLE;
1856  number_priority = 3;
1857  } else {
1858  number_screening = id->number.presentation & AST_PRES_NUMBER_TYPE;
1859  number_value = id->number.presentation & AST_PRES_RESTRICTION;
1860  switch (number_value) {
1861  case AST_PRES_RESTRICTED:
1862  number_priority = 0;
1863  break;
1864  case AST_PRES_ALLOWED:
1865  number_priority = 1;
1866  break;
1867  case AST_PRES_UNAVAILABLE:
1868  number_priority = 2;
1869  break;
1870  default:
1871  number_screening = AST_PRES_USER_NUMBER_UNSCREENED;
1872  number_value = AST_PRES_UNAVAILABLE;
1873  number_priority = 3;
1874  break;
1875  }
1876  }
1877 
1878  /* Select the wining presentation value. */
1879  if (name_priority < number_priority) {
1880  number_value = name_value;
1881  }
1882  if (number_value == AST_PRES_UNAVAILABLE) {
1884  }
1885 
1886  return number_value | number_screening;
1887 }
struct ast_party_name name
Subscriber name.
Definition: channel.h:341
#define AST_PRES_RESTRICTED
Definition: callerid.h:325
#define AST_PRES_USER_NUMBER_UNSCREENED
Definition: callerid.h:318
#define AST_PRES_NUMBER_TYPE
Definition: callerid.h:317
#define AST_PRES_NUMBER_NOT_AVAILABLE
Definition: callerid.h:353
#define AST_PRES_RESTRICTION
Definition: callerid.h:323
#define AST_PRES_ALLOWED
Definition: callerid.h:324
#define AST_PRES_UNAVAILABLE
Definition: callerid.h:326
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:280
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:298
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:343

◆ 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.
Returns
Nothing

Definition at line 1896 of file channel.c.

References ast_party_id_free(), and ast_party_id_init().

Referenced by after_bridge_move_channel(), ast_do_pickup(), cb_events(), channel_do_masquerade(), misdn_facility_ie_handler(), and retransfer_enter().

1897 {
1898  ast_party_id_free(id);
1899  ast_party_id_init(id);
1900 }
void ast_party_id_free(struct ast_party_id *doomed)
Destroy the party id contents.
Definition: channel.c:1811
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition: channel.c:1757

◆ 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.
Returns
Nothing

Definition at line 1788 of file channel.c.

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

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

1789 {
1790  if (dest == src) {
1791  /* Don't set to self */
1792  return;
1793  }
1794 
1795  if (!update || update->name) {
1796  ast_party_name_set(&dest->name, &src->name);
1797  }
1798  if (!update || update->number) {
1799  ast_party_number_set(&dest->number, &src->number);
1800  }
1801  if (!update || update->subaddress) {
1803  }
1804 
1805  if (src->tag && src->tag != dest->tag) {
1806  ast_free(dest->tag);
1807  dest->tag = ast_strdup(src->tag);
1808  }
1809 }
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:1621
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:1727
struct ast_party_name name
Subscriber name.
Definition: channel.h:341
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
unsigned char subaddress
Definition: channel.h:368
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:345
unsigned char number
Definition: channel.h:366
#define ast_free(a)
Definition: astmm.h:182
char * tag
User-set "tag".
Definition: channel.h:355
unsigned char name
Definition: channel.h:364
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:1674
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:343

◆ 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.
Returns
Nothing

Definition at line 1780 of file channel.c.

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

1781 {
1782  ast_party_name_set_init(&init->name, &guide->name);
1783  ast_party_number_set_init(&init->number, &guide->number);
1785  init->tag = NULL;
1786 }
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:1666
struct ast_party_name name
Subscriber name.
Definition: channel.h:341
#define NULL
Definition: resample.c:96
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:345
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:1719
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:1613
char * tag
User-set "tag".
Definition: channel.h:355
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:343

◆ 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
Returns
Nothing

Definition at line 1599 of file channel.c.

References ast_free, ast_strdup, ast_party_name::char_set, ast_party_name::presentation, ast_party_name::str, and ast_party_name::valid.

Referenced by ast_party_id_copy().

1600 {
1601  if (dest == src) {
1602  /* Don't copy to self */
1603  return;
1604  }
1605 
1606  ast_free(dest->str);
1607  dest->str = ast_strdup(src->str);
1608  dest->char_set = src->char_set;
1609  dest->presentation = src->presentation;
1610  dest->valid = src->valid;
1611 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:278
int char_set
Character set the name is using.
Definition: channel.h:273
char * str
Subscriber name (Malloced)
Definition: channel.h:265
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define ast_free(a)
Definition: astmm.h:182
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:280

◆ 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.
Returns
Nothing

Definition at line 1638 of file channel.c.

References ast_free, NULL, and ast_party_name::str.

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

1639 {
1640  ast_free(doomed->str);
1641  doomed->str = NULL;
1642 }
char * str
Subscriber name (Malloced)
Definition: channel.h:265
#define NULL
Definition: resample.c:96
#define ast_free(a)
Definition: astmm.h:182

◆ 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.
Returns
Nothing

Definition at line 1591 of file channel.c.

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(), analog_ss_thread(), ast_party_id_init(), and skinny_newcall().

1592 {
1593  init->str = NULL;
1596  init->valid = 0;
1597 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:278
int char_set
Character set the name is using.
Definition: channel.h:273
char * str
Subscriber name (Malloced)
Definition: channel.h:265
#define NULL
Definition: resample.c:96
#define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED
Definition: callerid.h:329
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:280

◆ 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
Returns
Nothing

Definition at line 1621 of file channel.c.

References ast_free, ast_strdup, ast_party_name::char_set, ast_party_name::presentation, ast_party_name::str, and ast_party_name::valid.

Referenced by ast_party_id_set().

1622 {
1623  if (dest == src) {
1624  /* Don't set to self */
1625  return;
1626  }
1627 
1628  if (src->str && src->str != dest->str) {
1629  ast_free(dest->str);
1630  dest->str = ast_strdup(src->str);
1631  }
1632 
1633  dest->char_set = src->char_set;
1634  dest->presentation = src->presentation;
1635  dest->valid = src->valid;
1636 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:278
int char_set
Character set the name is using.
Definition: channel.h:273
char * str
Subscriber name (Malloced)
Definition: channel.h:265
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define ast_free(a)
Definition: astmm.h:182
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:280

◆ 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.
Returns
Nothing

Definition at line 1613 of file channel.c.

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

1614 {
1615  init->str = NULL;
1616  init->char_set = guide->char_set;
1617  init->presentation = guide->presentation;
1618  init->valid = guide->valid;
1619 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:278
int char_set
Character set the name is using.
Definition: channel.h:273
char * str
Subscriber name (Malloced)
Definition: channel.h:265
#define NULL
Definition: resample.c:96
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:280

◆ 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
Returns
Nothing

Definition at line 1652 of file channel.c.

References ast_free, ast_strdup, ast_party_number::plan, ast_party_number::presentation, ast_party_number::str, and ast_party_number::valid.

Referenced by ast_party_id_copy().

1653 {
1654  if (dest == src) {
1655  /* Don't copy to self */
1656  return;
1657  }
1658 
1659  ast_free(dest->str);
1660  dest->str = ast_strdup(src->str);
1661  dest->plan = src->plan;
1662  dest->presentation = src->presentation;
1663  dest->valid = src->valid;
1664 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:292
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:296
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:294
#define ast_free(a)
Definition: astmm.h:182
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:298

◆ 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.
Returns
Nothing

Definition at line 1691 of file channel.c.

References ast_free, NULL, and ast_party_number::str.

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

1692 {
1693  ast_free(doomed->str);
1694  doomed->str = NULL;
1695 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:292
#define NULL
Definition: resample.c:96
#define ast_free(a)
Definition: astmm.h:182

◆ 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.
Returns
Nothing

Definition at line 1644 of file channel.c.

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(), analog_ss_thread(), ast_party_id_init(), do_forward(), skinny_newcall(), and wait_for_answer().

1645 {
1646  init->str = NULL;
1647  init->plan = 0;/* Unknown */
1649  init->valid = 0;
1650 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:292
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:296
#define NULL
Definition: resample.c:96
#define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED
Definition: callerid.h:329
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:294
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:298

◆ 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
Returns
Nothing

Definition at line 1674 of file channel.c.

References ast_free, ast_strdup, ast_party_number::plan, ast_party_number::presentation, ast_party_number::str, and ast_party_number::valid.

Referenced by ast_party_id_set().

1675 {
1676  if (dest == src) {
1677  /* Don't set to self */
1678  return;
1679  }
1680 
1681  if (src->str && src->str != dest->str) {
1682  ast_free(dest->str);
1683  dest->str = ast_strdup(src->str);
1684  }
1685 
1686  dest->plan = src->plan;
1687  dest->presentation = src->presentation;
1688  dest->valid = src->valid;
1689 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:292
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:296
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:294
#define ast_free(a)
Definition: astmm.h:182
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:298

◆ 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.
Returns
Nothing

Definition at line 1666 of file channel.c.

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

1667 {
1668  init->str = NULL;
1669  init->plan = guide->plan;
1670  init->presentation = guide->presentation;
1671  init->valid = guide->valid;
1672 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:292
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:296
#define NULL
Definition: resample.c:96
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:294
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:298

◆ 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
Returns
Nothing

Definition at line 2135 of file channel.c.

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_macro(), ast_channel_redirecting_sub(), ast_unreal_call_setup(), begin_dial_prerun(), call_forward_inherit(), cb_events(), dial_exec_full(), do_forward(), misdn_facility_ie_handler(), ring_entry(), and wait_for_answer().

2136 {
2137  if (dest == src) {
2138  /* Don't copy to self */
2139  return;
2140  }
2141 
2142  ast_party_id_copy(&dest->orig, &src->orig);
2143  ast_party_id_copy(&dest->from, &src->from);
2144  ast_party_id_copy(&dest->to, &src->to);
2145  ast_party_id_copy(&dest->priv_orig, &src->priv_orig);
2146  ast_party_id_copy(&dest->priv_from, &src->priv_from);
2147  ast_party_id_copy(&dest->priv_to, &src->priv_to);
2150  dest->count = src->count;
2151 }
struct ast_party_id priv_to
Call is redirecting to a new party (Sent to the caller) - private representation. ...
Definition: channel.h:540
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:534
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:528
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:537
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:1765
struct ast_party_id orig
Who originally redirected the call (Sent to the party the call is redirected toward) ...
Definition: channel.h:525
struct ast_party_redirecting_reason orig_reason
Reason for the redirection by the original party.
Definition: channel.h:546
struct ast_party_redirecting_reason reason
Reason for the redirection.
Definition: channel.h:543
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:2085
int count
Number of times the call was redirected.
Definition: channel.h:549
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:531

◆ ast_party_redirecting_free()

void ast_party_redirecting_free ( struct ast_party_redirecting doomed)

Destroy the redirecting information contents.

Since
1.8
Parameters
doomedThe redirecting information to destroy.
Returns
Nothing

Definition at line 2179 of file channel.c.

References ast_party_id_free(), ast_party_redirecting_reason_free(), 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_destructor(), ast_channel_redirecting_macro(), ast_channel_redirecting_sub(), ast_dummy_channel_destructor(), call_forward_inherit(), cb_events(), do_forward(), handle_request_invite(), handle_request_refer(), handle_response(), handle_response_invite(), indicate_redirecting(), misdn_facility_ie_handler(), redirecting_write(), set_redirecting(), and wait_for_answer().

2180 {
2181  ast_party_id_free(&doomed->orig);
2182  ast_party_id_free(&doomed->from);
2183  ast_party_id_free(&doomed->to);
2184  ast_party_id_free(&doomed->priv_orig);
2185  ast_party_id_free(&doomed->priv_from);
2186  ast_party_id_free(&doomed->priv_to);
2189 }
struct ast_party_id priv_to
Call is redirecting to a new party (Sent to the caller) - private representation. ...
Definition: channel.h:540
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:534
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:528
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:537
void ast_party_id_free(struct ast_party_id *doomed)
Destroy the party id contents.
Definition: channel.c:1811
void ast_party_redirecting_reason_free(struct ast_party_redirecting_reason *doomed)
Destroy the redirecting reason contents.
Definition: channel.c:2116
struct ast_party_id orig
Who originally redirected the call (Sent to the party the call is redirected toward) ...
Definition: channel.h:525
struct ast_party_redirecting_reason orig_reason
Reason for the redirection by the original party.
Definition: channel.h:546
struct ast_party_redirecting_reason reason
Reason for the redirection.
Definition: channel.h:543
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:531

◆ 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.
Returns
Nothing

Definition at line 2122 of file channel.c.

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_macro(), ast_channel_redirecting_sub(), call_forward_inherit(), cb_events(), do_forward(), handle_request_invite(), handle_request_refer(), handle_response(), handle_response_invite(), misdn_facility_ie_handler(), set_redirecting(), and wait_for_answer().

2123 {
2124  ast_party_id_init(&init->orig);
2125  ast_party_id_init(&init->from);
2126  ast_party_id_init(&init->to);
2127  ast_party_id_init(&init->priv_orig);
2128  ast_party_id_init(&init->priv_from);
2129  ast_party_id_init(&init->priv_to);
2132  init->count = 0;
2133 }
struct ast_party_id priv_to
Call is redirecting to a new party (Sent to the caller) - private representation. ...
Definition: channel.h:540
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:534
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:528
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:537
struct ast_party_id orig
Who originally redirected the call (Sent to the party the call is redirected toward) ...
Definition: channel.h:525
void ast_party_redirecting_reason_init(struct ast_party_redirecting_reason *init)
Initialize the given redirecting reason structure.
Definition: channel.c:2079
struct ast_party_redirecting_reason orig_reason
Reason for the redirection by the original party.
Definition: channel.h:546
struct ast_party_redirecting_reason reason
Reason for the redirection.
Definition: channel.h:543
int count
Number of times the call was redirected.
Definition: channel.h:549
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:531
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition: channel.c:1757

◆ 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
Returns
Nothing

Definition at line 2085 of file channel.c.

References ast_free, ast_strdup, ast_party_redirecting_reason::code, and ast_party_redirecting_reason::str.

Referenced by ast_party_redirecting_copy().

2086 {
2087  if (dest == src) {
2088  return;
2089  }
2090 
2091  ast_free(dest->str);
2092  dest->str = ast_strdup(src->str);
2093  dest->code = src->code;
2094 }
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
int code
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:511
char * str
a string value for the redirecting reason
Definition: channel.h:508
#define ast_free(a)
Definition: astmm.h:182

◆ 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.
Returns
Nothing

Definition at line 2116 of file channel.c.

References ast_free, and ast_party_redirecting_reason::str.

Referenced by ast_party_redirecting_free().

2117 {
2118  ast_free(doomed->str);
2119 }
char * str
a string value for the redirecting reason
Definition: channel.h:508
#define ast_free(a)
Definition: astmm.h:182

◆ 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
Returns
Nothing

Definition at line 2079 of file channel.c.

References AST_REDIRECTING_REASON_UNKNOWN, ast_party_redirecting_reason::code, NULL, and ast_party_redirecting_reason::str.

Referenced by ast_party_redirecting_init().

2080 {
2081  init->str = NULL;
2083 }
#define NULL
Definition: resample.c:96
int code
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:511
char * str
a string value for the redirecting reason
Definition: channel.h:508

◆ 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
Returns
Nothing

Definition at line 2102 of file channel.c.

References ast_free, ast_strdup, ast_party_redirecting_reason::code, and ast_party_redirecting_reason::str.

Referenced by ast_party_redirecting_set().

2103 {
2104  if (dest == src) {
2105  return;
2106  }
2107 
2108  if (src->str && src->str != dest->str) {
2109  ast_free(dest->str);
2110  dest->str = ast_strdup(src->str);
2111  }
2112 
2113  dest->code = src->code;
2114 }
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
int code
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:511
char * str
a string value for the redirecting reason
Definition: channel.h:508
#define ast_free(a)
Definition: astmm.h:182

◆ 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.
Returns
Nothing

Definition at line 2096 of file channel.c.

References ast_party_redirecting_reason::code, NULL, and ast_party_redirecting_reason::str.

Referenced by ast_party_redirecting_set_init().

2097 {
2098  init->str = NULL;
2099  init->code = guide->code;
2100 }
#define NULL
Definition: resample.c:96
int code
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:511
char * str
a string value for the redirecting reason
Definition: channel.h:508

◆ 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.
Returns
Nothing

Definition at line 2166 of file channel.c.

References ast_party_id_set(), ast_party_redirecting_reason_set(), ast_party_redirecting::count, ast_party_redirecting::from, ast_set_party_redirecting::from, NULL, ast_party_redirecting::orig, ast_set_party_redirecting::orig, ast_party_redirecting::orig_reason, ast_party_redirecting::priv_from, ast_set_party_redirecting::priv_from, ast_party_redirecting::priv_orig, ast_set_party_redirecting::priv_orig, ast_party_redirecting::priv_to, ast_set_party_redirecting::priv_to, ast_party_redirecting::reason, ast_party_redirecting::to, and ast_set_party_redirecting::to.

Referenced by ast_channel_set_redirecting().

2167 {
2168  ast_party_id_set(&dest->orig, &src->orig, update ? &update->orig : NULL);
2169  ast_party_id_set(&dest->from, &src->from, update ? &update->from : NULL);
2170  ast_party_id_set(&dest->to, &src->to, update ? &update->to : NULL);
2171  ast_party_id_set(&dest->priv_orig, &src->priv_orig, update ? &update->priv_orig : NULL);
2172  ast_party_id_set(&dest->priv_from, &src->priv_from, update ? &update->priv_from : NULL);
2173  ast_party_id_set(&dest->priv_to, &src->priv_to, update ? &update->priv_to : NULL);
2176  dest->count = src->count;
2177 }
struct ast_party_id priv_to
Call is redirecting to a new party (Sent to the caller) - private representation. ...
Definition: channel.h:540
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:534
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:528
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:537
struct ast_set_party_id priv_orig
Definition: channel.h:564
#define NULL
Definition: resample.c:96
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:2102
struct ast_set_party_id from
Definition: channel.h:560
struct ast_party_id orig
Who originally redirected the call (Sent to the party the call is redirected toward) ...
Definition: channel.h:525
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:1788
struct ast_party_redirecting_reason orig_reason
Reason for the redirection by the original party.
Definition: channel.h:546
struct ast_set_party_id priv_from
Definition: channel.h:566
struct ast_party_redirecting_reason reason
Reason for the redirection.
Definition: channel.h:543
struct ast_set_party_id orig
Definition: channel.h:558
struct ast_set_party_id to
Definition: channel.h:562
int count
Number of times the call was redirected.
Definition: channel.h:549
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:531
struct ast_set_party_id priv_to
Definition: channel.h:568

◆ 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.
Returns
Nothing

Definition at line 2153 of file channel.c.

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 handle_response_invite(), indicate_redirecting(), misdn_copy_redirecting_to_ast(), and redirecting_write().

2154 {
2155  ast_party_id_set_init(&init->orig, &guide->orig);
2156  ast_party_id_set_init(&init->from, &guide->from);
2157  ast_party_id_set_init(&init->to, &guide->to);
2158  ast_party_id_set_init(&init->priv_orig, &guide->priv_orig);
2159  ast_party_id_set_init(&init->priv_from, &guide->priv_from);
2160  ast_party_id_set_init(&init->priv_to, &guide->priv_to);
2163  init->count = guide->count;
2164 }
struct ast_party_id priv_to
Call is redirecting to a new party (Sent to the caller) - private representation. ...
Definition: channel.h:540
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:534
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:528
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:537
struct ast_party_id orig
Who originally redirected the call (Sent to the party the call is redirected toward) ...
Definition: channel.h:525
struct ast_party_redirecting_reason orig_reason
Reason for the redirection by the original party.
Definition: channel.h:546
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:2096
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:1780
struct ast_party_redirecting_reason reason
Reason for the redirection.
Definition: channel.h:543
int count
Number of times the call was redirected.
Definition: channel.h:549
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:531

◆ 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
Returns
Nothing

Definition at line 1705 of file channel.c.

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

Referenced by ast_party_dialed_copy(), and ast_party_id_copy().

1706 {
1707  if (dest == src) {
1708  /* Don't copy to self */
1709  return;
1710  }
1711 
1712  ast_free(dest->str);
1713  dest->str = ast_strdup(src->str);
1714  dest->type = src->type;
1716  dest->valid = src->valid;
1717 }
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:329
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
char * str
Malloced subaddress string.
Definition: channel.h:314
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:327
#define ast_free(a)
Definition: astmm.h:182
int type
Q.931 subaddress type.
Definition: channel.h:321

◆ 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.
Returns
Nothing

Definition at line 1744 of file channel.c.

References ast_free, NULL, and ast_party_subaddress::str.

Referenced by ast_party_dialed_free(), and ast_party_id_free().

1745 {
1746  ast_free(doomed->str);
1747  doomed->str = NULL;
1748 }
char * str
Malloced subaddress string.
Definition: channel.h:314
#define NULL
Definition: resample.c:96
#define ast_free(a)
Definition: astmm.h:182

◆ 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.
Returns
Nothing

Definition at line 1697 of file channel.c.

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

1698 {
1699  init->str = NULL;
1700  init->type = 0;
1701  init->odd_even_indicator = 0;
1702  init->valid = 0;
1703 }
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:329
char * str
Malloced subaddress string.
Definition: channel.h:314
#define NULL
Definition: resample.c:96
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:327
int type
Q.931 subaddress type.
Definition: channel.h:321

◆ 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
Returns
Nothing

Definition at line 1727 of file channel.c.

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

Referenced by ast_party_dialed_set(), and ast_party_id_set().

1728 {
1729  if (dest == src) {
1730  /* Don't set to self */
1731  return;
1732  }
1733 
1734  if (src->str && src->str != dest->str) {
1735  ast_free(dest->str);
1736  dest->str = ast_strdup(src->str);
1737  }
1738 
1739  dest->type = src->type;
1741  dest->valid = src->valid;
1742 }
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:329
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
char * str
Malloced subaddress string.
Definition: channel.h:314
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:327
#define ast_free(a)
Definition: astmm.h:182
int type
Q.931 subaddress type.
Definition: channel.h:321

◆ 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.
Returns
Nothing

Definition at line 1719 of file channel.c.

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

1720 {
1721  init->str = NULL;
1722  init->type = guide->type;
1723  init->odd_even_indicator = guide->odd_even_indicator;
1724  init->valid = guide->valid;
1725 }
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:329
char * str
Malloced subaddress string.
Definition: channel.h:314
#define NULL
Definition: resample.c:96
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:327
int type
Q.931 subaddress type.
Definition: channel.h:321

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

References ast_app_exec_sub(), ast_channel_lock, ast_channel_tech(), ast_channel_unlock, chanlist::chan, NULL, and ast_channel_tech::pre_call.

Referenced by begin_dial_prerun(), dial_exec_full(), findmeexec(), and ring_entry().

6537 {
6538  int (*pre_call)(struct ast_channel *chan, const char *sub_args);
6539 
6540  ast_channel_lock(chan);
6541  pre_call = ast_channel_tech(chan)->pre_call;
6542  if (pre_call) {
6543  int res;
6544 
6545  res = pre_call(chan, sub_args);
6546  ast_channel_unlock(chan);
6547  return res;
6548  }
6549  ast_channel_unlock(chan);
6550  return ast_app_exec_sub(NULL, chan, sub_args, 0);
6551 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
Main Channel structure associated with a channel.
#define NULL
Definition: resample.c:96
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:842
#define ast_channel_unlock(chan)
Definition: channel.h:2946
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:370
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)

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

References buf, and first.

Referenced by _sip_show_peer(), _skinny_show_line(), callgroup_to_str(), func_channel_read(), function_sippeer(), misdn_cfg_get_config_string(), pickupgroup_to_str(), print_group(), read_config(), and serialize_showchan().

8134 {
8135  unsigned int i;
8136  int first = 1;
8137  char num[3];
8138 
8139  buf[0] = '\0';
8140 
8141  if (!group) /* Return empty string if no group */
8142  return buf;
8143 
8144  for (i = 0; i <= 63; i++) { /* Max group is 63 */
8145  if (group & ((ast_group_t) 1 << i)) {
8146  if (!first) {
8147  strncat(buf, ", ", buflen - strlen(buf) - 1);
8148  } else {
8149  first = 0;
8150  }
8151  snprintf(num, sizeof(num), "%u", i);
8152  strncat(buf, num, buflen - strlen(buf) - 1);
8153  }
8154  }
8155  return buf;
8156 }
unsigned long long ast_group_t
Definition: channel.h:214
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
struct sla_ringing_trunk * first
Definition: app_meetme.c:1092

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

References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_str_append(), ast_str_buffer(), first, and namedgroup_member::name.

Referenced by _sip_show_peer(), _skinny_show_line(), func_channel_read(), function_sippeer(), misdn_cfg_get_config_string(), named_callgroups_to_str(), named_pickupgroups_to_str(), print_named_groups(), and read_config().

8159 {
8160  struct ao2_container *grp = (struct ao2_container *) group;
8161  struct namedgroup_member *ng;
8162  int first = 1;
8163  struct ao2_iterator it;
8164 
8165  if (!grp) {
8166  return ast_str_buffer(*buf);
8167  }
8168 
8169  for (it = ao2_iterator_init(grp, 0); (ng = ao2_iterator_next(&it)); ao2_ref(ng, -1)) {
8170  if (!first) {
8171  ast_str_append(buf, 0, ", ");
8172  } else {
8173  first = 0;
8174  }
8175  ast_str_append(buf, 0, "%s", ng->name);
8176  }
8177  ao2_iterator_destroy(&it);
8178 
8179  return ast_str_buffer(*buf);
8180 }
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:714
Named group member structure.
Definition: channel.c:7751
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:1091
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define ao2_ref(o, delta)
Definition: astobj2.h:464
struct sla_ringing_trunk * first
Definition: app_meetme.c:1092
#define ao2_iterator_next(iter)
Definition: astobj2.h:1933
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition: astobj2.h:1841
Generic container type.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.

◆ ast_prod()

int ast_prod ( struct ast_channel chan)

Send empty audio to prime a channel driver.

Definition at line 5045 of file channel.c.

References ast_channel_name(), ast_channel_rawwriteformat(), ast_debug, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log, AST_STATE_UP, ast_write(), ast_frame::data, ast_frame_subclass::format, LOG_WARNING, ast_frame::ptr, ast_frame::src, and ast_frame::subclass.

Referenced by ast_activate_generator().

5046 {
5047  struct ast_frame a = { AST_FRAME_VOICE };
5048  char nothing[128];
5049 
5050  /* Send an empty audio frame to get things moving */
5051  if (ast_channel_state(chan) != AST_STATE_UP) {
5052  ast_debug(1, "Prodding channel '%s'\n", ast_channel_name(chan));
5054  a.data.ptr = nothing + AST_FRIENDLY_OFFSET;
5055  a.src = "ast_prod"; /* this better match check in ast_write */
5056  if (ast_write(chan, &a))
5057  ast_log(LOG_WARNING, "Prodding channel '%s' failed\n", ast_channel_name(chan));
5058  }
5059  return 0;
5060 }
#define LOG_WARNING
Definition: logger.h:274
ast_channel_state
ast_channel states
Definition: channelstate.h:35
struct ast_frame_subclass subclass
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
#define AST_FRIENDLY_OFFSET
Offset into a frame&#39;s data buffer.
const char * src
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:5189
const char * ast_channel_name(const struct ast_channel *chan)
Data structure associated with a single frame of data.
union ast_frame::@263 data
struct ast_format * format
struct ast_format * ast_channel_rawwriteformat(struct ast_channel *chan)
static struct test_val a

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

References AST_CONTROL_ANSWER, AST_FRAME_CONTROL, and ast_queue_frame().

1247 {
1248  struct ast_frame f = {
1250  .subclass.integer = AST_CONTROL_ANSWER,
1251  .subclass.topology = (struct ast_stream_topology *)topology,
1252  };
1253  return ast_queue_frame(chan, &f);
1254 }
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1139
Data structure associated with a single frame of data.

◆ ast_queue_control()

int ast_queue_control ( struct ast_channel chan,
enum ast_control_frame_type  control 
)

Queue a control frame without payload.

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

Queue a control frame without payload.

Definition at line 1231 of file channel.c.

References AST_FRAME_CONTROL, and ast_queue_frame().

Referenced by __analog_handle_event(), __ast_read(), analog_call(), analog_exception(), analog_hangup(), apply_negotiated_sdp_stream(), ast_do_pickup(), attempt_transfer(), audiosocket_call(), auto_congest(), cb_events(), chan_pjsip_incoming_ack(), chan_pjsip_incoming_response(), cli_console_answer(), cli_console_flash(), console_answer(), console_call(), console_sendtext(), controlplayback_manager(), handle_call_incoming(), handle_incoming(), handle_request_info(), handle_request_invite(), handle_response(), handle_response_invite(), handle_response_refer(), jingle_action_session_accept(), jingle_action_session_info(), jingle_outgoing_hook(), mbl_queue_control(), misdn_facility_ie_handler(), nbs_call(), on_topology_change_response(), onAlerting(), onCallEstablished(), onProgress(), pbx_outgoing_state_callback(), phone_call(), rtp_call(), send_cause2ast(), setsubstate(), skinny_call(), skinny_cfwd_cb(), skinny_transfer_attended(), skinny_transfer_blind(), stasis_app_control_queue_control(), unistim_call(), unreal_colp_stream_topology_request_change(), and video_info_incoming_request().

1232 {
1233  struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = control };
1234  return ast_queue_frame(chan, &f);
1235 }
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1139
Data structure associated with a single frame of data.

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

References AST_FRAME_CONTROL, and ast_queue_frame().

Referenced by __analog_handle_event(), after_bridge_move_channel(), ast_channel_queue_connected_line_update(), ast_channel_queue_redirecting_update(), chan_pjsip_incoming_response_update_cause(), change_t38_state(), close_udptl_connection(), fax_gateway_indicate_t38(), handle_clear_alarms(), handle_incoming(), handle_request_notify(), handle_response_refer(), iax2_transfer(), interpret_t38_parameters(), jingle_action_session_terminate(), onModeChanged(), ooh323_indicate(), queue_read_action_payload(), setup_udptl_connection(), sip_sipredirect(), socket_process_helper(), t38_change_state(), t38_framehook(), t38_interpret_parameters(), transfer_redirect(), transfer_refer(), and xfer_client_on_evsub_state().

1240 {
1241  struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = control, .data.ptr = (void *) data, .datalen = datalen };
1242  return ast_queue_frame(chan, &f);
1243 }
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1139
Data structure associated with a single frame of data.
union ast_frame::@263 data

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

References __ast_queue_frame(), and NULL.

Referenced by __ast_read(), action_atxfer(), action_cancel_atxfer(), alsa_call(), 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(), attended_transfer_exec(), bridge_channel_internal_push_full(), bridge_channel_poke(), cb_events(), channel_do_masquerade(), cli_console_dial(), cli_console_sendtext(), conf_stop_record(), console_dial(), console_do_answer(), console_flash(), console_sendtext(), dahdi_queue_frame(), dahdi_read(), dictate_exec(), do_immediate_setup(), dtmf_info_incoming_request(), handle_incoming_request(), handle_keypad_button_message(), handle_negotiated_sdp(), handle_request_info(), handle_request_invite(), handle_response_invite(), iax2_queue_frame(), keypad_cfg_read(), load_stream_readqueue(), manager_play_dtmf(), mgcp_queue_frame(), ooh323_onReceivedDigit(), oss_call(), process_sdp(), queue_dtmf_readq(), receive_message(), set_interval_hook(), stream_monitor(), stream_periodic_frames(), t38_tx_packet_handler(), unistim_do_senddigit(), unreal_queue_frame(), and wakeup_sub().

1140 {
1141  return __ast_queue_frame(chan, fin, 0, NULL);
1142 }
static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, int head, struct ast_frame *after)
Definition: channel.c:1015
#define NULL
Definition: resample.c:96

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

References __ast_queue_frame(), and NULL.

Referenced by __ast_answer(), __ast_read(), ast_autoservice_stop(), bridge_channel_queue_deferred_frames(), and safe_sleep_conditional().

1145 {
1146  return __ast_queue_frame(chan, fin, 1, NULL);
1147 }
static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, int head, struct ast_frame *after)
Definition: channel.c:1015
#define NULL
Definition: resample.c:96

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

Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 1150 of file channel.c.

References ast_channel_hangup_request_type(), ast_channel_lock, ast_channel_publish_blob(), ast_channel_softhangup_internal_flag_add(), ast_channel_unlock, AST_CONTROL_HANGUP, AST_FRAME_CONTROL, ast_queue_frame(), AST_SOFTHANGUP_DEV, and NULL.

Referenced by ast_app_exec_macro(), ast_app_exec_sub(), ast_unreal_fixup(), call(), chan_pjsip_session_end(), cli_console_hangup(), close_call(), handle_request_bye(), iax2_destroy(), iax2_queue_hangup(), mbl_queue_hangup(), mgcp_queue_hangup(), refer_incoming_invite_request(), session_inv_on_media_update(), setsubstate(), and sip_queue_hangup_cause().

1151 {
1152  struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HANGUP };
1153  int res;
1154 
1155  /* Yeah, let's not change a lock-critical value without locking */
1156  ast_channel_lock(chan);
1159 
1160  res = ast_queue_frame(chan, &f);
1161  ast_channel_unlock(chan);
1162  return res;
1163 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define NULL
Definition: resample.c:96
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1139
#define ast_channel_unlock(chan)
Definition: channel.h:2946
Data structure associated with a single frame of data.
void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
void ast_channel_publish_blob(struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
Publish a channel blob message.
struct stasis_message_type * ast_channel_hangup_request_type(void)
Message type for when a hangup is requested on a channel.

◆ 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
Returns
0 on success, -1 on error
Since
1.6.1

Queue a hangup frame with hangupcause set.

Definition at line 1166 of file channel.c.

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_log, ast_queue_frame(), AST_SOFTHANGUP_DEV, ast_frame::data, LOG_WARNING, NULL, RAII_VAR, and ast_frame::uint32.

Referenced by __analog_handle_event(), __sip_autodestruct(), ast_unreal_hangup(), chan_pjsip_session_end(), close_call(), close_client(), console_hangup(), dahdi_handle_event(), discard_call(), handle_call_outgoing(), handle_clear_alarms(), handle_request_bye(), handle_response(), handle_response_invite(), hangup_chan(), jingle_action_session_terminate(), jingle_queue_hangup_with_cause(), misdn_answer(), onCallCleared(), retrans_pkt(), sip_queue_hangup_cause(), and transfer_cancel_step2().

1167 {
1168  RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
1169  struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HANGUP };
1170  int res;
1171 
1172  if (cause >= 0) {
1173  f.data.uint32 = cause;
1174  }
1175  ast_log(LOG_WARNING, "Queuing hangup with cause: %d !!!\n", cause);
1176  /* Yeah, let's not change a lock-critical value without locking */
1177  ast_channel_lock(chan);
1179  if (cause < 0) {
1181  }
1182  blob = ast_json_pack("{s: i}",
1183  "cause", cause);
1185 
1186  res = ast_queue_frame(chan, &f);
1187  ast_channel_unlock(chan);
1188  return res;
1189 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:591
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
#define LOG_WARNING
Definition: logger.h:274
#define NULL
Definition: resample.c:96
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1139
#define ast_log
Definition: astobj2.c:42
#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:911
#define ast_channel_unlock(chan)
Definition: channel.h:2946
int ast_channel_hangupcause(const struct ast_channel *chan)
Data structure associated with a single frame of data.
void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
Abstract JSON element (object, array, string, int, ...).
union ast_frame::@263 data
void ast_channel_publish_blob(struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
Publish a channel blob message.
struct stasis_message_type * ast_channel_hangup_request_type(void)
Message type for when a hangup is requested on a channel.

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

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, NULL, and ast_frame::ptr.

Referenced by __analog_handle_event(), analog_hangup(), apply_negotiated_sdp_stream(), cb_events(), dahdi_handle_event(), dahdi_hangup(), handle_request(), iax2_queue_hold(), jingle_action_session_info(), process_sdp(), setsubstate(), sub_hold(), and transfer_call_step1().

1192 {
1193  struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HOLD };
1194  struct ast_json *blob = NULL;
1195  int res;
1196 
1197  if (!ast_strlen_zero(musicclass)) {
1198  f.data.ptr = (void *) musicclass;
1199  f.datalen = strlen(musicclass) + 1;
1200 
1201  blob = ast_json_pack("{s: s}",
1202  "musicclass", musicclass);
1203  }
1204 
1205  ast_channel_lock(chan);
1207  ast_channel_unlock(chan);
1208 
1209  res = ast_queue_frame(chan, &f);
1210 
1211  ast_json_unref(blob);
1212 
1213  return res;
1214 }
struct stasis_message_type * ast_channel_hold_type(void)
Message type for when a channel is placed on hold.
static char musicclass[MAX_MUSICCLASS]
Definition: chan_mgcp.c:162
#define ast_channel_lock(chan)
Definition: channel.h:2945
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:591
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
#define NULL
Definition: resample.c:96
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1139
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_channel_unlock(chan)
Definition: channel.h:2946
Data structure associated with a single frame of data.
Abstract JSON element (object, array, string, int, ...).
union ast_frame::@263 data
void ast_channel_publish_blob(struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
Publish a channel blob message.

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

References ast_channel_lock, ast_channel_publish_blob(), ast_channel_unhold_type(), ast_channel_unlock, AST_CONTROL_UNHOLD, AST_FRAME_CONTROL, ast_queue_frame(), and NULL.

Referenced by __analog_handle_event(), __analog_ss_thread(), __dahdi_exception(), analog_exception(), analog_hangup(), analog_ss_thread(), apply_negotiated_sdp_stream(), attempt_transfer(), cb_events(), dahdi_handle_event(), dahdi_hangup(), handle_hd_hf(), handle_request(), handle_request_bye(), handle_request_invite(), iax2_queue_unhold(), jingle_action_session_info(), key_dial_page(), process_sdp(), session_inv_on_create_offer(), setsubstate(), sub_unhold(), transfer_cancel_step2(), and unistim_hangup().

1217 {
1218  struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_UNHOLD };
1219  int res;
1220 
1221  ast_channel_lock(chan);
1223  ast_channel_unlock(chan);
1224 
1225  res = ast_queue_frame(chan, &f);
1226 
1227  return res;
1228 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
struct stasis_message_type * ast_channel_unhold_type(void)
Message type for when a channel is removed from hold.
#define NULL
Definition: resample.c:96
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1139
#define ast_channel_unlock(chan)
Definition: channel.h:2946
Data structure associated with a single frame of data.
void ast_channel_publish_blob(struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
Publish a channel blob message.

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

References ast_raw_answer_with_stream_topology(), and NULL.

Referenced by __ast_answer(), app_control_answer(), handle_invite_replaces(), and refer_incoming_invite_request().

2700 {
2702 }
#define NULL
Definition: resample.c:96
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:2648

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

References answer(), ast_channel_tech::answer, ast_channel_tech::answer_with_stream_topology, ast_channel_flags(), ast_channel_lock, ast_channel_name(), ast_channel_tech(), ast_channel_unlock, ast_check_hangup(), AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, ast_indicate(), ast_setstate(), AST_STATE_RING, AST_STATE_RINGING, AST_STATE_UP, ast_test_flag, SCOPE_TRACE, and set_channel_answer_time().

Referenced by ast_raw_answer(), and pre_bridge_setup().

2649 {
2650  int res = 0;
2651  SCOPE_TRACE(1, "%s\n", ast_channel_name(chan));
2652 
2653  ast_channel_lock(chan);
2654 
2655  /* You can't answer an outbound call */
2657  ast_channel_unlock(chan);
2658  return 0;
2659  }
2660 
2661  /* Stop if we're a zombie or need a soft hangup */
2663  ast_channel_unlock(chan);
2664  return -1;
2665  }
2666 
2667  /*
2668  * Mark when incoming channel answered so we can know how
2669  * long the channel has been up.
2670  */
2672 
2673  ast_channel_unlock(chan);
2674 
2675  switch (ast_channel_state(chan)) {
2676  case AST_STATE_RINGING:
2677  case AST_STATE_RING:
2678  ast_channel_lock(chan);
2679  if (ast_channel_tech(chan)->answer_with_stream_topology) {
2680  res = ast_channel_tech(chan)->answer_with_stream_topology(chan, topology);
2681 
2682  } else if (ast_channel_tech(chan)->answer) {
2683  res = ast_channel_tech(chan)->answer(chan);
2684  }
2685  ast_setstate(chan, AST_STATE_UP);
2686  ast_channel_unlock(chan);
2687  break;
2688  case AST_STATE_UP:
2689  break;
2690  default:
2691  break;
2692  }
2693 
2694  ast_indicate(chan, -1);
2695 
2696  return res;
2697 }
int(*const answer_with_stream_topology)(struct ast_channel *chan, struct ast_stream_topology *topology)
Answer the channel with topology.
Definition: channel.h:721
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define ast_test_flag(p, flag)
Definition: utils.h:63
int(*const answer)(struct ast_channel *chan)
Answer the channel.
Definition: channel.h:708
ast_channel_state
ast_channel states
Definition: channelstate.h:35
static void set_channel_answer_time(struct ast_channel *chan)
Definition: channel.c:2637
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4322
int ast_check_hangup(struct ast_channel *chan)
Checks to see if a channel is needing hang up.
Definition: channel.c:445
static int answer(void *data)
Definition: chan_pjsip.c:682
#define ast_channel_unlock(chan)
Definition: channel.h:2946
#define SCOPE_TRACE(level,...)
Print a trace message with details when a scope is entered or existed.
Definition: logger.h:749
const char * ast_channel_name(const struct ast_channel *chan)
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
int ast_setstate(struct ast_channel *chan, enum ast_channel_state state)
Change the state of a channel.
Definition: channel.c:7486

◆ 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.
Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 4302 of file channel.c.

References __ast_read().

Referenced by __adsi_transmit_messages(), __analog_ss_thread(), __ast_answer(), __ast_play_and_record(), __ast_request_and_dial(), adsi_careful_send(), 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(), destroy_all_channels(), dial_exec_full(), dictate_exec(), disa_exec(), disable_t38(), do_waiting(), echo_exec(), eivr_comm(), find_cache(), generic_fax_exec(), handle_recordfile(), handle_speechrecognize(), iax2_key_rotate(), ices_exec(), isAnsweringMachine(), jack_exec(), measurenoise(), misdn_write(), moh_channel_thread(), monitor_dial(), mp3_exec(), NBScat_exec(), read_from_chan(), read_mf_digits(), read_sf_digits(), receive_dtmf_digits(), receivefax_t38_init(), record_exec(), recordthread(), run_agi(), safe_sleep_conditional(), send_waveform_to_channel(), sendfax_t38_init(), sendurl_exec(), sms_exec(), speech_background(), stasis_app_exec(), transmit_audio(), transmit_t38(), wait_exec(), wait_for_answer(), wait_for_hangup(), wait_for_winner(), waitforring_exec(), and waitstream_core().

4303 {
4304  return __ast_read(chan, 0, 1);
4305 }
static struct ast_frame * __ast_read(struct ast_channel *chan, int dropaudio, int dropnondefault)
Definition: channel.c:3529

◆ 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.
Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 4312 of file channel.c.

References __ast_read().

Referenced by ast_control_tone(), and conf_run().

4313 {
4314  return __ast_read(chan, 1, 1);
4315 }
static struct ast_frame * __ast_read(struct ast_channel *chan, int dropaudio, int dropnondefault)
Definition: channel.c:3529

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

References __ast_read().

Referenced by AST_TEST_DEFINE(), bridge_handle_trip(), read_from_chan(), and stream_echo_perform().

4308 {
4309  return __ast_read(chan, 0, 0);
4310 }
static struct ast_frame * __ast_read(struct ast_channel *chan, int dropaudio, int dropnondefault)
Definition: channel.c:3529

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

References __ast_read().

Referenced by bridge_handle_trip().

4318 {
4319  return __ast_read(chan, 1, 0);
4320 }
static struct ast_frame * __ast_read(struct ast_channel *chan, int dropaudio, int dropnondefault)
Definition: channel.c:3529

◆ 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:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 6655 of file channel.c.

References ast_readstring_full().

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

6656 {
6657  return ast_readstring_full(c, s, len, timeout, ftimeout, enders, -1, -1);
6658 }
static int timeout
Definition: cdr_mysql.c:86
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:6660
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)

◆ 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 
)
Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 6660 of file channel.c.

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(), d, NULL, and timeout.

Referenced by ast_app_getdata_full(), and ast_readstring().

6661 {
6662  int pos = 0; /* index in the buffer where we accumulate digits */
6663  int to = ftimeout;
6664 
6665  struct ast_silence_generator *silgen = NULL;
6666 
6667  /* Stop if we're a zombie or need a soft hangup */
6669  return -1;
6670  if (!len)
6671  return -1;
6672  for (;;) {
6673  int d;
6674  if (ast_channel_stream(c)) {
6675  d = ast_waitstream_full(c, AST_DIGIT_ANY, audiofd, ctrlfd);
6676  ast_stopstream(c);
6677  if (!silgen && ast_opt_transmit_silence)
6679  usleep(1000);
6680  if (!d)
6681  d = ast_waitfordigit_full(c, to, NULL, audiofd, ctrlfd);
6682  } else {
6683  if (!silgen && ast_opt_transmit_silence)
6685  d = ast_waitfordigit_full(c, to, NULL, audiofd, ctrlfd);
6686  }
6687  if (d < 0) {
6689  return AST_GETDATA_FAILED;
6690  }
6691  if (d == 0) {
6692  s[pos] = '\0';
6694  return AST_GETDATA_TIMEOUT;
6695  }
6696  if (d == 1) {
6697  s[pos] = '\0';
6699  return AST_GETDATA_INTERRUPTED;
6700  }
6701  if (strchr(enders, d) && (pos == 0)) {
6702  s[pos] = '\0';
6705  }
6706  if (!strchr(enders, d)) {
6707  s[pos++] = d;
6708  }
6709  if (strchr(enders, d) || (pos >= len)) {
6710  s[pos] = '\0';
6712  return AST_GETDATA_COMPLETE;
6713  }
6714  to = timeout;
6715  }
6716  /* Never reached */
6717  return 0;
6718 }
#define AST_DIGIT_ANY
Definition: file.h:48
#define ast_test_flag(p, flag)
Definition: utils.h:63
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
Definition: channel.c:8266
static struct test_val d
static int timeout
Definition: cdr_mysql.c:86
#define ast_opt_transmit_silence
Definition: options.h:124
#define NULL
Definition: resample.c:96
int ast_check_hangup(struct ast_channel *chan)
Checks to see if a channel is needing hang up.
Definition: channel.c:445
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:8312
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:3248
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
struct ast_filestream * ast_channel_stream(const struct ast_channel *chan)
int ast_waitstream_full(struct ast_channel *c, const char *breakon, int audiofd, int monfd)
Definition: file.c:1785
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
int ast_stopstream(struct ast_channel *c)
Stops a stream.
Definition: file.c:187

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

References ast_free, ast_recvtext(), buf, c, and NULL.

Referenced by handle_recvchar().

4752 {
4753  int c;
4754  char *buf = ast_recvtext(chan, timeout);
4755  if (buf == NULL)
4756  return -1; /* error or timeout */
4757  c = *(unsigned char *)buf;
4758  ast_free(buf);
4759  return c;
4760 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int timeout
Definition: cdr_mysql.c:86
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:4762
static struct test_val c
#define NULL
Definition: resample.c:96
#define ast_free(a)
Definition: astmm.h:182

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

References ast_check_hangup(), AST_CONTROL_HANGUP, AST_FRAME_CONTROL, AST_FRAME_TEXT, ast_frfree, ast_read(), ast_remaining_ms(), ast_strndup, ast_tvnow(), ast_waitfor(), 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(), and handle_recvtext().

4763 {
4764  int res;
4765  char *buf = NULL;
4766  struct timeval start = ast_tvnow();
4767  int ms;
4768 
4769  while ((ms = ast_remaining_ms(start, timeout))) {
4770  struct ast_frame *f;
4771 
4772  if (ast_check_hangup(chan)) {
4773  break;
4774  }
4775  res = ast_waitfor(chan, ms);
4776  if (res <= 0) {/* timeout or error */
4777  break;
4778  }
4779  f = ast_read(chan);
4780  if (f == NULL) {
4781  break; /* no frame */
4782  }
4784  ast_frfree(f);
4785  break;
4786  } else if (f->frametype == AST_FRAME_TEXT) { /* what we want */
4787  buf = ast_strndup((char *) f->data.ptr, f->datalen); /* dup and break */
4788  ast_frfree(f);
4789  break;
4790  }
4791  ast_frfree(f);
4792  }
4793  return buf;
4794 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int timeout
Definition: cdr_mysql.c:86
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:150
#define NULL
Definition: resample.c:96
struct ast_frame_subclass subclass
int ast_check_hangup(struct ast_channel *chan)
Checks to see if a channel is needing hang up.
Definition: channel.c:445
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
Definition: main/utils.c:2033
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4302
#define ast_strndup(str, len)
A wrapper for strndup()
Definition: astmm.h:258
int ast_waitfor(struct ast_channel *c, int ms)
Wait for input on a channel.
Definition: channel.c:3171
#define ast_frfree(fr)
Data structure associated with a single frame of data.
union ast_frame::@263 data
enum ast_frame_type frametype

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

References ast_log, AST_REDIRECTING_COUNT, AST_REDIRECTING_FROM_ID_PRESENTATION, AST_REDIRECTING_FROM_NAME, AST_REDIRECTING_FROM_NAME_CHAR_SET, AST_REDIRECTING_FROM_NAME_PRESENTATION, AST_REDIRECTING_FROM_NAME_VALID, AST_REDIRECTING_FROM_NUMBER, AST_REDIRECTING_FROM_NUMBER_PLAN, AST_REDIRECTING_FROM_NUMBER_PRESENTATION, AST_REDIRECTING_FROM_NUMBER_VALID, AST_REDIRECTING_FROM_SUBADDRESS, AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_FROM_SUBADDRESS_TYPE, AST_REDIRECTING_FROM_SUBADDRESS_VALID, AST_REDIRECTING_FROM_TAG, AST_REDIRECTING_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, ast_set_party_redirecting::from, LOG_WARNING, ast_party_id_ies::name, NULL, ast_party_redirecting::orig, ast_set_party_redirecting::orig, ast_party_redirecting::orig_reason, party_id_build_data(), ast_party_redirecting::priv_from, ast_set_party_redirecting::priv_from, ast_party_redirecting::priv_orig, ast_set_party_redirecting::priv_orig, ast_party_redirecting::priv_to, ast_set_party_redirecting::priv_to, ast_party_redirecting::reason, redirecting_reason_build_data(), ast_party_name_ies::str, ast_party_redirecting::to, ast_set_party_redirecting::to, and value.

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

9364 {
9365  int32_t value;
9366  size_t pos = 0;
9367  int res;
9368 
9369  static const struct ast_party_id_ies orig_ies = {
9371  .name.char_set = AST_REDIRECTING_ORIG_NAME_CHAR_SET,
9372  .name.presentation = AST_REDIRECTING_ORIG_NAME_PRESENTATION,
9373  .name.valid = AST_REDIRECTING_ORIG_NAME_VALID,
9374 
9375  .number.str = AST_REDIRECTING_ORIG_NUMBER,
9376  .number.plan = AST_REDIRECTING_ORIG_NUMBER_PLAN,
9377  .number.presentation = AST_REDIRECTING_ORIG_NUMBER_PRESENTATION,
9378  .number.valid = AST_REDIRECTING_ORIG_NUMBER_VALID,
9379 
9380  .subaddress.str = AST_REDIRECTING_ORIG_SUBADDRESS,
9381  .subaddress.type = AST_REDIRECTING_ORIG_SUBADDRESS_TYPE,
9382  .subaddress.odd_even_indicator = AST_REDIRECTING_ORIG_SUBADDRESS_ODD_EVEN,
9383  .subaddress.valid = AST_REDIRECTING_ORIG_SUBADDRESS_VALID,
9384 
9385  .tag = AST_REDIRECTING_ORIG_TAG,
9386  .combined_presentation = 0,/* Not sent. */
9387  };
9388  static const struct ast_party_id_ies from_ies = {
9390  .name.char_set = AST_REDIRECTING_FROM_NAME_CHAR_SET,
9391  .name.presentation = AST_REDIRECTING_FROM_NAME_PRESENTATION,
9392  .name.valid = AST_REDIRECTING_FROM_NAME_VALID,
9393 
9394  .number.str = AST_REDIRECTING_FROM_NUMBER,
9395  .number.plan = AST_REDIRECTING_FROM_NUMBER_PLAN,
9396  .number.presentation = AST_REDIRECTING_FROM_NUMBER_PRESENTATION,
9397  .number.valid = AST_REDIRECTING_FROM_NUMBER_VALID,
9398 
9399  .subaddress.str = AST_REDIRECTING_FROM_SUBADDRESS,
9400  .subaddress.type = AST_REDIRECTING_FROM_SUBADDRESS_TYPE,
9401  .subaddress.odd_even_indicator = AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN,
9402  .subaddress.valid = AST_REDIRECTING_FROM_SUBADDRESS_VALID,
9403 
9404  .tag = AST_REDIRECTING_FROM_TAG,
9405  .combined_presentation = AST_REDIRECTING_FROM_ID_PRESENTATION,
9406  };
9407  static const struct ast_party_id_ies to_ies = {
9409  .name.char_set = AST_REDIRECTING_TO_NAME_CHAR_SET,
9410  .name.presentation = AST_REDIRECTING_TO_NAME_PRESENTATION,
9411  .name.valid = AST_REDIRECTING_TO_NAME_VALID,
9412 
9413  .number.str = AST_REDIRECTING_TO_NUMBER,
9414  .number.plan = AST_REDIRECTING_TO_NUMBER_PLAN,
9415  .number.presentation = AST_REDIRECTING_TO_NUMBER_PRESENTATION,
9416  .number.valid = AST_REDIRECTING_TO_NUMBER_VALID,
9417 
9418  .subaddress.str = AST_REDIRECTING_TO_SUBADDRESS,
9419  .subaddress.type = AST_REDIRECTING_TO_SUBADDRESS_TYPE,
9420  .subaddress.odd_even_indicator = AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN,
9421  .subaddress.valid = AST_REDIRECTING_TO_SUBADDRESS_VALID,
9422 
9423  .tag = AST_REDIRECTING_TO_TAG,
9424  .combined_presentation = AST_REDIRECTING_TO_ID_PRESENTATION,
9425  };
9426  static const struct ast_party_id_ies priv_orig_ies = {
9428  .name.char_set = AST_REDIRECTING_PRIV_ORIG_NAME_CHAR_SET,
9429  .name.presentation = AST_REDIRECTING_PRIV_ORIG_NAME_PRESENTATION,
9431 
9432  .number.str = AST_REDIRECTING_PRIV_ORIG_NUMBER,
9434  .number.presentation = AST_REDIRECTING_PRIV_ORIG_NUMBER_PRESENTATION,
9436 
9437  .subaddress.str = AST_REDIRECTING_PRIV_ORIG_SUBADDRESS,
9438  .subaddress.type = AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_TYPE,
9439  .subaddress.odd_even_indicator = AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_ODD_EVEN,
9440  .subaddress.valid = AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_VALID,
9441 
9443  .combined_presentation = 0,/* Not sent. */
9444  };
9445  static const struct ast_party_id_ies priv_from_ies = {
9447  .name.char_set = AST_REDIRECTING_PRIV_FROM_NAME_CHAR_SET,
9448  .name.presentation = AST_REDIRECTING_PRIV_FROM_NAME_PRESENTATION,
9450 
9451  .number.str = AST_REDIRECTING_PRIV_FROM_NUMBER,
9453  .number.presentation = AST_REDIRECTING_PRIV_FROM_NUMBER_PRESENTATION,
9455 
9456  .subaddress.str = AST_REDIRECTING_PRIV_FROM_SUBADDRESS,
9457  .subaddress.type = AST_REDIRECTING_PRIV_FROM_SUBADDRESS_TYPE,
9458  .subaddress.odd_even_indicator = AST_REDIRECTING_PRIV_FROM_SUBADDRESS_ODD_EVEN,
9459  .subaddress.valid = AST_REDIRECTING_PRIV_FROM_SUBADDRESS_VALID,
9460 
9462  .combined_presentation = 0,/* Not sent. */
9463  };
9464  static const struct ast_party_id_ies priv_to_ies = {
9466  .name.char_set = AST_REDIRECTING_PRIV_TO_NAME_CHAR_SET,
9467  .name.presentation = AST_REDIRECTING_PRIV_TO_NAME_PRESENTATION,
9468  .name.valid = AST_REDIRECTING_PRIV_TO_NAME_VALID,
9469 
9470  .number.str = AST_REDIRECTING_PRIV_TO_NUMBER,
9471  .number.plan = AST_REDIRECTING_PRIV_TO_NUMBER_PLAN,
9472  .number.presentation = AST_REDIRECTING_PRIV_TO_NUMBER_PRESENTATION,
9473  .number.valid = AST_REDIRECTING_PRIV_TO_NUMBER_VALID,
9474 
9475  .subaddress.str = AST_REDIRECTING_PRIV_TO_SUBADDRESS,
9476  .subaddress.type = AST_REDIRECTING_PRIV_TO_SUBADDRESS_TYPE,
9477  .subaddress.odd_even_indicator = AST_REDIRECTING_PRIV_TO_SUBADDRESS_ODD_EVEN,
9478  .subaddress.valid = AST_REDIRECTING_PRIV_TO_SUBADDRESS_VALID,
9479 
9481  .combined_presentation = 0,/* Not sent. */
9482  };
9483  static const struct ast_party_redirecting_reason_ies reason_ies = {
9486  };
9487 
9488  static const struct ast_party_redirecting_reason_ies orig_reason_ies = {
9491  };
9492 
9493  /* Redirecting frame version */
9494  if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
9495  ast_log(LOG_WARNING, "No space left for redirecting frame version\n");
9496  return -1;
9497  }
9498  data[pos++] = AST_REDIRECTING_VERSION;
9499  data[pos++] = 1;
9500  data[pos++] = 2;/* Version 1 did not have a version ie */
9501 
9502  res = party_id_build_data(data + pos, datalen - pos, &redirecting->orig,
9503  "redirecting-orig", &orig_ies, update ? &update->orig : NULL);
9504  if (res < 0) {
9505  return -1;
9506  }
9507  pos += res;
9508 
9509  res = party_id_build_data(data + pos, datalen - pos, &redirecting->from,
9510  "redirecting-from", &from_ies, update ? &update->from : NULL);
9511  if (res < 0) {
9512  return -1;
9513  }
9514  pos += res;
9515 
9516  res = party_id_build_data(data + pos, datalen - pos, &redirecting->to,
9517  "redirecting-to", &to_ies, update ? &update->to : NULL);
9518  if (res < 0) {
9519  return -1;
9520  }
9521  pos += res;
9522 
9523  res = party_id_build_data(data + pos, datalen - pos, &redirecting->priv_orig,
9524  "redirecting-priv-orig", &priv_orig_ies, update ? &update->priv_orig : NULL);
9525  if (res < 0) {
9526  return -1;
9527  }
9528  pos += res;
9529 
9530  res = party_id_build_data(data + pos, datalen - pos, &redirecting->priv_from,
9531  "redirecting-priv-from", &priv_from_ies, update ? &update->priv_from : NULL);
9532  if (res < 0) {
9533  return -1;
9534  }
9535  pos += res;
9536 
9537  res = party_id_build_data(data + pos, datalen - pos, &redirecting->priv_to,
9538  "redirecting-priv-to", &priv_to_ies, update ? &update->priv_to : NULL);
9539  if (res < 0) {
9540  return -1;
9541  }
9542  pos += res;
9543 
9544  /* Redirecting reason */
9545  res = redirecting_reason_build_data(data + pos, datalen - pos, &redirecting->reason,
9546  "redirecting-reason", &reason_ies);
9547  if (res < 0) {
9548  return -1;
9549  }
9550  pos += res;
9551 
9552  /* Redirecting original reason */
9553  res = redirecting_reason_build_data(data + pos, datalen - pos, &redirecting->orig_reason,
9554  "redirecting-orig-reason", &orig_reason_ies);
9555  if (res < 0) {
9556  return -1;
9557  }
9558  pos += res;
9559 
9560  /* Redirecting count */
9561  if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) {
9562  ast_log(LOG_WARNING, "No space left for redirecting count\n");
9563  return -1;
9564  }
9565  data[pos++] = AST_REDIRECTING_COUNT;
9566  data[pos++] = sizeof(value);
9567  value = htonl(redirecting->count);
9568  memcpy(data + pos, &value, sizeof(value));
9569  pos += sizeof(value);
9570 
9571  return pos;
9572 }
struct ast_party_id priv_to
Call is redirecting to a new party (Sent to the caller) - private representation. ...
Definition: channel.h:540
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:534
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:528
#define LOG_WARNING
Definition: logger.h:274
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:537
struct ast_set_party_id priv_orig
Definition: channel.h:564
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
struct ast_party_name_ies name
Subscriber name ies.
Definition: channel.c:8644
struct ast_set_party_id from
Definition: channel.h:560
struct ast_party_id orig
Who originally redirected the call (Sent to the party the call is redirected toward) ...
Definition: channel.h:525
#define ast_log
Definition: astobj2.c:42
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:9330
struct ast_party_redirecting_reason orig_reason
Reason for the redirection by the original party.
Definition: channel.h:546
struct ast_set_party_id priv_from
Definition: channel.h:566
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:8673
struct ast_party_redirecting_reason reason
Reason for the redirection.
Definition: channel.h:543
struct ast_set_party_id orig
Definition: channel.h:558
struct ast_set_party_id to
Definition: channel.h:562
int count
Number of times the call was redirected.
Definition: channel.h:549
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:531
struct ast_set_party_id priv_to
Definition: channel.h:568
int int32_t
Definition: db.h:60
int str
Subscriber name ie.
Definition: channel.c:8421

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

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_macro(), ast_channel_redirecting_sub(), and indicate_redirecting().

9575 {
9576  size_t pos;
9577  unsigned char ie_len;
9578  unsigned char ie_id;
9579  int32_t value;
9580  int frame_version = 1;
9581  int from_combined_presentation = 0;
9582  int got_from_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
9583  int to_combined_presentation = 0;
9584  int got_to_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
9585 
9586  for (pos = 0; pos < datalen; pos += ie_len) {
9587  if (datalen < pos + sizeof(ie_id) + sizeof(ie_len)) {
9588  ast_log(LOG_WARNING, "Invalid redirecting update\n");
9589  return -1;
9590  }
9591  ie_id = data[pos++];
9592  ie_len = data[pos++];
9593  if (datalen < pos + ie_len) {
9594  ast_log(LOG_WARNING, "Invalid redirecting update\n");
9595  return -1;
9596  }
9597 
9598  switch (ie_id) {
9599 /* Redirecting frame version */
9601  if (ie_len != 1) {
9602  ast_log(LOG_WARNING, "Invalid redirecting frame version (%u)\n",
9603  (unsigned) ie_len);
9604  break;
9605  }
9606  frame_version = data[pos];
9607  break;
9608 /* Redirecting-orig party id name */
9610  ast_free(redirecting->orig.name.str);
9611  redirecting->orig.name.str = ast_malloc(ie_len + 1);
9612  if (redirecting->orig.name.str) {
9613  memcpy(redirecting->orig.name.str, data + pos, ie_len);
9614  redirecting->orig.name.str[ie_len] = 0;
9615  }
9616  break;
9618  if (ie_len != 1) {
9619  ast_log(LOG_WARNING, "Invalid redirecting-orig name char set (%u)\n",
9620  (unsigned) ie_len);
9621  break;
9622  }
9623  redirecting->orig.name.char_set = data[pos];
9624  break;
9626  if (ie_len != 1) {
9627  ast_log(LOG_WARNING, "Invalid redirecting-orig name presentation (%u)\n",
9628  (unsigned) ie_len);
9629  break;
9630  }
9631  redirecting->orig.name.presentation = data[pos];
9632  break;
9634  if (ie_len != 1) {
9635  ast_log(LOG_WARNING, "Invalid redirecting-orig name valid (%u)\n",
9636  (unsigned) ie_len);
9637  break;
9638  }
9639  redirecting->orig.name.valid = data[pos];
9640  break;
9641 /* Redirecting-orig party id number */
9643  ast_free(redirecting->orig.number.str);
9644  redirecting->orig.number.str = ast_malloc(ie_len + 1);
9645  if (redirecting->orig.number.str) {
9646  memcpy(redirecting->orig.number.str, data + pos, ie_len);
9647  redirecting->orig.number.str[ie_len] = 0;
9648  }
9649  break;
9651  if (ie_len != 1) {
9652  ast_log(LOG_WARNING, "Invalid redirecting-orig numbering plan (%u)\n",
9653  (unsigned) ie_len);
9654  break;
9655  }
9656  redirecting->orig.number.plan = data[pos];
9657  break;
9659  if (ie_len != 1) {
9660  ast_log(LOG_WARNING, "Invalid redirecting-orig number presentation (%u)\n",
9661  (unsigned) ie_len);
9662  break;
9663  }
9664  redirecting->orig.number.presentation = data[pos];
9665  break;
9667  if (ie_len != 1) {
9668  ast_log(LOG_WARNING, "Invalid redirecting-orig number valid (%u)\n",
9669  (unsigned) ie_len);
9670  break;
9671  }
9672  redirecting->orig.number.valid = data[pos];
9673  break;
9674 /* Redirecting-orig party id subaddress */
9676  ast_free(redirecting->orig.subaddress.str);
9677  redirecting->orig.subaddress.str = ast_malloc(ie_len + 1);
9678  if (redirecting->orig.subaddress.str) {
9679  memcpy(redirecting->orig.subaddress.str, data + pos, ie_len);
9680  redirecting->orig.subaddress.str[ie_len] = 0;
9681  }
9682  break;
9684  if (ie_len != 1) {
9685  ast_log(LOG_WARNING, "Invalid redirecting-orig type of subaddress (%u)\n",
9686  (unsigned) ie_len);
9687  break;
9688  }
9689  redirecting->orig.subaddress.type = data[pos];
9690  break;
9692  if (ie_len != 1) {
9694  "Invalid redirecting-orig subaddress odd-even indicator (%u)\n",
9695  (unsigned) ie_len);
9696  break;
9697  }
9698  redirecting->orig.subaddress.odd_even_indicator = data[pos];
9699  break;
9701  if (ie_len != 1) {
9702  ast_log(LOG_WARNING, "Invalid redirecting-orig subaddress valid (%u)\n",
9703  (unsigned) ie_len);
9704  break;
9705  }
9706  redirecting->orig.subaddress.valid = data[pos];
9707  break;
9708 /* Redirecting-orig party id tag */
9710  ast_free(redirecting->orig.tag);
9711  redirecting->orig.tag = ast_malloc(ie_len + 1);
9712  if (redirecting->orig.tag) {
9713  memcpy(redirecting->orig.tag, data + pos, ie_len);
9714  redirecting->orig.tag[ie_len] = 0;
9715  }
9716  break;
9717 /* Redirecting-from party id name */
9719  ast_free(redirecting->from.name.str);
9720  redirecting->from.name.str = ast_malloc(ie_len + 1);
9721  if (redirecting->from.name.str) {
9722  memcpy(redirecting->from.name.str, data + pos, ie_len);
9723  redirecting->from.name.str[ie_len] = 0;
9724  }
9725  break;
9727  if (ie_len != 1) {
9728  ast_log(LOG_WARNING, "Invalid redirecting-from name char set (%u)\n",
9729  (unsigned) ie_len);
9730  break;
9731  }
9732  redirecting->from.name.char_set = data[pos];
9733  break;
9735  if (ie_len != 1) {
9736  ast_log(LOG_WARNING, "Invalid redirecting-from name presentation (%u)\n",
9737  (unsigned) ie_len);
9738  break;
9739  }
9740  redirecting->from.name.presentation = data[pos];
9741  break;
9743  if (ie_len != 1) {
9744  ast_log(LOG_WARNING, "Invalid redirecting-from name valid (%u)\n",
9745  (unsigned) ie_len);
9746  break;
9747  }
9748  redirecting->from.name.valid = data[pos];
9749  break;
9750 /* Redirecting-from party id number */
9752  ast_free(redirecting->from.number.str);
9753  redirecting->from.number.str = ast_malloc(ie_len + 1);
9754  if (redirecting->from.number.str) {
9755  memcpy(redirecting->from.number.str, data + pos, ie_len);
9756  redirecting->from.number.str[ie_len] = 0;
9757  }
9758  break;
9760  if (ie_len != 1) {
9761  ast_log(LOG_WARNING, "Invalid redirecting-from numbering plan (%u)\n",
9762  (unsigned) ie_len);
9763  break;
9764  }
9765  redirecting->from.number.plan = data[pos];
9766  break;
9768  if (ie_len != 1) {
9769  ast_log(LOG_WARNING, "Invalid redirecting-from number presentation (%u)\n",
9770  (unsigned) ie_len);
9771  break;
9772  }
9773  redirecting->from.number.presentation = data[pos];
9774  break;
9776  if (ie_len != 1) {
9777  ast_log(LOG_WARNING, "Invalid redirecting-from number valid (%u)\n",
9778  (unsigned) ie_len);
9779  break;
9780  }
9781  redirecting->from.number.valid = data[pos];
9782  break;
9783 /* Redirecting-from party id combined presentation */
9785  if (ie_len != 1) {
9786  ast_log(LOG_WARNING, "Invalid redirecting-from combined presentation (%u)\n",
9787  (unsigned) ie_len);
9788  break;
9789  }
9790  from_combined_presentation = data[pos];
9791  got_from_combined_presentation = 1;
9792  break;
9793 /* Redirecting-from party id subaddress */
9795  ast_free(redirecting->from.subaddress.str);
9796  redirecting->from.subaddress.str = ast_malloc(ie_len + 1);
9797  if (redirecting->from.subaddress.str) {
9798  memcpy(redirecting->from.subaddress.str, data + pos, ie_len);
9799  redirecting->from.subaddress.str[ie_len] = 0;
9800  }
9801  break;
9803  if (ie_len != 1) {
9804  ast_log(LOG_WARNING, "Invalid redirecting-from type of subaddress (%u)\n",
9805  (unsigned) ie_len);
9806  break;
9807  }
9808  redirecting->from.subaddress.type = data[pos];
9809  break;
9811  if (ie_len != 1) {
9813  "Invalid redirecting-from subaddress odd-even indicator (%u)\n",
9814  (unsigned) ie_len);
9815  break;
9816  }
9817  redirecting->from.subaddress.odd_even_indicator = data[pos];
9818  break;
9820  if (ie_len != 1) {
9821  ast_log(LOG_WARNING, "Invalid redirecting-from subaddress valid (%u)\n",
9822  (unsigned) ie_len);
9823  break;
9824  }
9825  redirecting->from.subaddress.valid = data[pos];
9826  break;
9827 /* Redirecting-from party id tag */
9829  ast_free(redirecting->from.tag);
9830  redirecting->from.tag = ast_malloc(ie_len + 1);
9831  if (redirecting->from.tag) {
9832  memcpy(redirecting->from.tag, data + pos, ie_len);
9833  redirecting->from.tag[ie_len] = 0;
9834  }
9835  break;
9836 /* Redirecting-to party id name */
9838  ast_free(redirecting->to.name.str);
9839  redirecting->to.name.str = ast_malloc(ie_len + 1);
9840  if (redirecting->to.name.str) {
9841  memcpy(redirecting->to.name.str, data + pos, ie_len);
9842  redirecting->to.name.str[ie_len] = 0;
9843  }
9844  break;
9846  if (ie_len != 1) {
9847  ast_log(LOG_WARNING, "Invalid redirecting-to name char set (%u)\n",
9848  (unsigned) ie_len);
9849  break;
9850  }
9851  redirecting->to.name.char_set = data[pos];
9852  break;
9854  if (ie_len != 1) {
9855  ast_log(LOG_WARNING, "Invalid redirecting-to name presentation (%u)\n",
9856  (unsigned) ie_len);
9857  break;
9858  }
9859  redirecting->to.name.presentation = data[pos];
9860  break;
9862  if (ie_len != 1) {
9863  ast_log(LOG_WARNING, "Invalid redirecting-to name valid (%u)\n",
9864  (unsigned) ie_len);
9865  break;
9866  }
9867  redirecting->to.name.valid = data[pos];
9868  break;
9869 /* Redirecting-to party id number */
9871  ast_free(redirecting->to.number.str);
9872  redirecting->to.number.str = ast_malloc(ie_len + 1);
9873  if (redirecting->to.number.str) {
9874  memcpy(redirecting->to.number.str, data + pos, ie_len);
9875  redirecting->to.number.str[ie_len] = 0;
9876  }
9877  break;
9879  if (ie_len != 1) {
9880  ast_log(LOG_WARNING, "Invalid redirecting-to numbering plan (%u)\n",
9881  (unsigned) ie_len);
9882  break;
9883  }
9884  redirecting->to.number.plan = data[pos];
9885  break;
9887  if (ie_len != 1) {
9888  ast_log(LOG_WARNING, "Invalid redirecting-to number presentation (%u)\n",
9889  (unsigned) ie_len);
9890  break;
9891  }
9892  redirecting->to.number.presentation = data[pos];
9893  break;
9895  if (ie_len != 1) {
9896  ast_log(LOG_WARNING, "Invalid redirecting-to number valid (%u)\n",
9897  (unsigned) ie_len);
9898  break;
9899  }
9900  redirecting->to.number.valid = data[pos];
9901  break;
9902 /* Redirecting-to party id combined presentation */
9904  if (ie_len != 1) {
9905  ast_log(LOG_WARNING, "Invalid redirecting-to combined presentation (%u)\n",
9906  (unsigned) ie_len);
9907  break;
9908  }
9909  to_combined_presentation = data[pos];
9910  got_to_combined_presentation = 1;
9911  break;
9912 /* Redirecting-to party id subaddress */
9914  ast_free(redirecting->to.subaddress.str);
9915  redirecting->to.subaddress.str = ast_malloc(ie_len + 1);
9916  if (redirecting->to.subaddress.str) {
9917  memcpy(redirecting->to.subaddress.str, data + pos, ie_len);
9918  redirecting->to.subaddress.str[ie_len] = 0;
9919  }
9920  break;
9922  if (ie_len != 1) {
9923  ast_log(LOG_WARNING, "Invalid redirecting-to type of subaddress (%u)\n",
9924  (unsigned) ie_len);
9925  break;
9926  }
9927  redirecting->to.subaddress.type = data[pos];
9928  break;
9930  if (ie_len != 1) {
9932  "Invalid redirecting-to subaddress odd-even indicator (%u)\n",
9933  (unsigned) ie_len);
9934  break;
9935  }
9936  redirecting->to.subaddress.odd_even_indicator = data[pos];
9937  break;
9939  if (ie_len != 1) {
9940  ast_log(LOG_WARNING, "Invalid redirecting-to subaddress valid (%u)\n",
9941  (unsigned) ie_len);
9942  break;
9943  }
9944  redirecting->to.subaddress.valid = data[pos];
9945  break;
9946 /* Redirecting-to party id tag */
9948  ast_free(redirecting->to.tag);
9949  redirecting->to.tag = ast_malloc(ie_len + 1);
9950  if (redirecting->to.tag) {
9951  memcpy(redirecting->to.tag, data + pos, ie_len);
9952  redirecting->to.tag[ie_len] = 0;
9953  }
9954  break;
9955 /* Private redirecting-orig party id name */
9957  ast_free(redirecting->priv_orig.name.str);
9958  redirecting->priv_orig.name.str = ast_malloc(ie_len + 1);
9959  if (redirecting->priv_orig.name.str) {
9960  memcpy(redirecting->priv_orig.name.str, data + pos, ie_len);
9961  redirecting->priv_orig.name.str[ie_len] = 0;
9962  }
9963  break;
9965  if (ie_len != 1) {
9966  ast_log(LOG_WARNING, "Invalid private redirecting-orig name char set (%u)\n",
9967  (unsigned) ie_len);
9968  break;
9969  }
9970  redirecting->priv_orig.name.char_set = data[pos];
9971  break;
9973  if (ie_len != 1) {
9974  ast_log(LOG_WARNING, "Invalid private redirecting-orig name presentation (%u)\n",
9975  (unsigned) ie_len);
9976  break;
9977  }
9978  redirecting->priv_orig.name.presentation = data[pos];
9979  break;
9981  if (ie_len != 1) {
9982  ast_log(LOG_WARNING, "Invalid private redirecting-orig name valid (%u)\n",
9983  (unsigned) ie_len);
9984  break;
9985  }
9986  redirecting->priv_orig.name.valid = data[pos];
9987  break;
9988 /* Private redirecting-orig party id number */
9990  ast_free(redirecting->priv_orig.number.str);
9991  redirecting->priv_orig.number.str = ast_malloc(ie_len + 1);
9992  if (redirecting->priv_orig.number.str) {
9993  memcpy(redirecting->priv_orig.number.str, data + pos, ie_len);
9994  redirecting->priv_orig.number.str[ie_len] = 0;
9995  }
9996  break;
9998  if (ie_len != 1) {
9999  ast_log(LOG_WARNING, "Invalid private redirecting-orig numbering plan (%u)\n",
10000  (unsigned) ie_len);
10001  break;
10002  }
10003  redirecting->priv_orig.number.plan = data[pos];
10004  break;
10006  if (ie_len != 1) {
10007  ast_log(LOG_WARNING, "Invalid private redirecting-orig number presentation (%u)\n",
10008  (unsigned) ie_len);
10009  break;
10010  }
10011  redirecting->priv_orig.number.presentation = data[pos];
10012  break;
10014  if (ie_len != 1) {
10015  ast_log(LOG_WARNING, "Invalid private redirecting-orig number valid (%u)\n",
10016  (unsigned) ie_len);
10017  break;
10018  }
10019  redirecting->priv_orig.number.valid = data[pos];
10020  break;
10021 /* Private redirecting-orig party id subaddress */
10023  ast_free(redirecting->priv_orig.subaddress.str);
10024  redirecting->priv_orig.subaddress.str = ast_malloc(ie_len + 1);
10025  if (redirecting->priv_orig.subaddress.str) {
10026  memcpy(redirecting->priv_orig.subaddress.str, data + pos, ie_len);
10027  redirecting->priv_orig.subaddress.str[ie_len] = 0;
10028  }
10029  break;
10031  if (ie_len != 1) {
10032  ast_log(LOG_WARNING, "Invalid private redirecting-orig type of subaddress (%u)\n",
10033  (unsigned) ie_len);
10034  break;
10035  }
10036  redirecting->priv_orig.subaddress.type = data[pos];
10037  break;
10039  if (ie_len != 1) {
10041  "Invalid private redirecting-orig subaddress odd-even indicator (%u)\n",
10042  (unsigned) ie_len);
10043  break;
10044  }
10045  redirecting->priv_orig.subaddress.odd_even_indicator = data[pos];
10046  break;
10048  if (ie_len != 1) {
10049  ast_log(LOG_WARNING, "Invalid private redirecting-orig subaddress valid (%u)\n",
10050  (unsigned) ie_len);
10051  break;
10052  }
10053  redirecting->priv_orig.subaddress.valid = data[pos];
10054  break;
10055 /* Private redirecting-orig party id tag */
10057  ast_free(redirecting->priv_orig.tag);
10058  redirecting->priv_orig.tag = ast_malloc(ie_len + 1);
10059  if (redirecting->priv_orig.tag) {
10060  memcpy(redirecting->priv_orig.tag, data + pos, ie_len);
10061  redirecting->priv_orig.tag[ie_len] = 0;
10062  }
10063  break;
10064 /* Private redirecting-from party id name */
10066  ast_free(redirecting->priv_from.name.str);
10067  redirecting->priv_from.name.str = ast_malloc(ie_len + 1);
10068  if (redirecting->priv_from.name.str) {
10069  memcpy(redirecting->priv_from.name.str, data + pos, ie_len);
10070  redirecting->priv_from.name.str[ie_len] = 0;
10071  }
10072  break;
10074  if (ie_len != 1) {
10075  ast_log(LOG_WARNING, "Invalid private redirecting-from name char set (%u)\n",
10076  (unsigned) ie_len);
10077  break;
10078  }
10079  redirecting->priv_from.name.char_set = data[pos];
10080  break;
10082  if (ie_len != 1) {
10083  ast_log(LOG_WARNING, "Invalid private redirecting-from name presentation (%u)\n",
10084  (unsigned) ie_len);
10085  break;
10086  }
10087  redirecting->priv_from.name.presentation = data[pos];
10088  break;
10090  if (ie_len != 1) {
10091  ast_log(LOG_WARNING, "Invalid private redirecting-from name valid (%u)\n",
10092  (unsigned) ie_len);
10093  break;
10094  }
10095  redirecting->priv_from.name.valid = data[pos];
10096  break;
10097 /* Private redirecting-from party id number */
10099  ast_free(redirecting->priv_from.number.str);
10100  redirecting->priv_from.number.str = ast_malloc(ie_len + 1);
10101  if (redirecting->priv_from.number.str) {
10102  memcpy(redirecting->priv_from.number.str, data + pos, ie_len);
10103  redirecting->priv_from.number.str[ie_len] = 0;
10104  }
10105  break;
10107  if (ie_len != 1) {
10108  ast_log(LOG_WARNING, "Invalid private redirecting-from numbering plan (%u)\n",
10109  (unsigned) ie_len);
10110  break;
10111  }
10112  redirecting->priv_from.number.plan = data[pos];
10113  break;
10115  if (ie_len != 1) {
10116  ast_log(LOG_WARNING, "Invalid private redirecting-from number presentation (%u)\n",
10117  (unsigned) ie_len);
10118  break;
10119  }
10120  redirecting->priv_from.number.presentation = data[pos];
10121  break;
10123  if (ie_len != 1) {
10124  ast_log(LOG_WARNING, "Invalid private redirecting-from number valid (%u)\n",
10125  (unsigned) ie_len);
10126  break;
10127  }
10128  redirecting->priv_from.number.valid = data[pos];
10129  break;
10130 /* Private redirecting-from party id subaddress */
10132  ast_free(redirecting->priv_from.subaddress.str);
10133  redirecting->priv_from.subaddress.str = ast_malloc(ie_len + 1);
10134  if (redirecting->priv_from.subaddress.str) {
10135  memcpy(redirecting->priv_from.subaddress.str, data + pos, ie_len);
10136  redirecting->priv_from.subaddress.str[ie_len] = 0;
10137  }
10138  break;
10140  if (ie_len != 1) {
10141  ast_log(LOG_WARNING, "Invalid private redirecting-from type of subaddress (%u)\n",
10142  (unsigned) ie_len);
10143  break;
10144  }
10145  redirecting->priv_from.subaddress.type = data[pos];
10146  break;
10148  if (ie_len != 1) {
10150  "Invalid private redirecting-from subaddress odd-even indicator (%u)\n",
10151  (unsigned) ie_len);
10152  break;
10153  }
10154  redirecting->priv_from.subaddress.odd_even_indicator = data[pos];
10155  break;
10157  if (ie_len != 1) {
10158  ast_log(LOG_WARNING, "Invalid private redirecting-from subaddress valid (%u)\n",
10159  (unsigned) ie_len);
10160  break;
10161  }
10162  redirecting->priv_from.subaddress.valid = data[pos];
10163  break;
10164 /* Private redirecting-from party id tag */
10166  ast_free(redirecting->priv_from.tag);
10167  redirecting->priv_from.tag = ast_malloc(ie_len + 1);
10168  if (redirecting->priv_from.tag) {
10169  memcpy(redirecting->priv_from.tag, data + pos, ie_len);
10170  redirecting->priv_from.tag[ie_len] = 0;
10171  }
10172  break;
10173 /* Private redirecting-to party id name */
10175  ast_free(redirecting->priv_to.name.str);
10176  redirecting->priv_to.name.str = ast_malloc(ie_len + 1);
10177  if (redirecting->priv_to.name.str) {
10178  memcpy(redirecting->priv_to.name.str, data + pos, ie_len);
10179  redirecting->priv_to.name.str[ie_len] = 0;
10180  }
10181  break;
10183  if (ie_len != 1) {
10184  ast_log(LOG_WARNING, "Invalid private redirecting-to name char set (%u)\n",
10185  (unsigned) ie_len);
10186  break;
10187  }
10188  redirecting->priv_to.name.char_set = data[pos];
10189  break;
10191  if (ie_len != 1) {
10192  ast_log(LOG_WARNING, "Invalid private redirecting-to name presentation (%u)\n",
10193  (unsigned) ie_len);
10194  break;
10195  }
10196  redirecting->priv_to.name.presentation = data[pos];
10197  break;
10199  if (ie_len != 1) {
10200  ast_log(LOG_WARNING, "Invalid private redirecting-to name valid (%u)\n",
10201  (unsigned) ie_len);
10202  break;
10203  }
10204  redirecting->priv_to.name.valid = data[pos];
10205  break;
10206 /* Private redirecting-to party id number */
10208  ast_free(redirecting->priv_to.number.str);
10209  redirecting->priv_to.number.str = ast_malloc(ie_len + 1);
10210  if (redirecting->priv_to.number.str) {
10211  memcpy(redirecting->priv_to.number.str, data + pos, ie_len);
10212  redirecting->priv_to.number.str[ie_len] = 0;
10213  }
10214  break;
10216  if (ie_len != 1) {
10217  ast_log(LOG_WARNING, "Invalid private redirecting-to numbering plan (%u)\n",
10218  (unsigned) ie_len);
10219  break;
10220  }
10221  redirecting->priv_to.number.plan = data[pos];
10222  break;
10224  if (ie_len != 1) {
10225  ast_log(LOG_WARNING, "Invalid private redirecting-to number presentation (%u)\n",
10226  (unsigned) ie_len);
10227  break;
10228  }
10229  redirecting->priv_to.number.presentation = data[pos];
10230  break;
10232  if (ie_len != 1) {
10233  ast_log(LOG_WARNING, "Invalid private redirecting-to number valid (%u)\n",
10234  (unsigned) ie_len);
10235  break;
10236  }
10237  redirecting->priv_to.number.valid = data[pos];
10238  break;
10239 /* Private redirecting-to party id subaddress */
10241  ast_free(redirecting->priv_to.subaddress.str);
10242  redirecting->priv_to.subaddress.str = ast_malloc(ie_len + 1);
10243  if (redirecting->priv_to.subaddress.str) {
10244  memcpy(redirecting->priv_to.subaddress.str, data + pos, ie_len);
10245  redirecting->priv_to.subaddress.str[ie_len] = 0;
10246  }
10247  break;
10249  if (ie_len != 1) {
10250  ast_log(LOG_WARNING, "Invalid private redirecting-to type of subaddress (%u)\n",
10251  (unsigned) ie_len);
10252  break;
10253  }
10254  redirecting->priv_to.subaddress.type = data[pos];
10255  break;
10257  if (ie_len != 1) {
10259  "Invalid private redirecting-to subaddress odd-even indicator (%u)\n",
10260  (unsigned) ie_len);
10261  break;
10262  }
10263  redirecting->priv_to.subaddress.odd_even_indicator = data[pos];
10264  break;
10266  if (ie_len != 1) {
10267  ast_log(LOG_WARNING, "Invalid private redirecting-to subaddress valid (%u)\n",
10268  (unsigned) ie_len);
10269  break;
10270  }
10271  redirecting->priv_to.subaddress.valid = data[pos];
10272  break;
10273 /* Private redirecting-to party id tag */
10275  ast_free(redirecting->priv_to.tag);
10276  redirecting->priv_to.tag = ast_malloc(ie_len + 1);
10277  if (redirecting->priv_to.tag) {
10278  memcpy(redirecting->priv_to.tag, data + pos, ie_len);
10279  redirecting->priv_to.tag[ie_len] = 0;
10280  }
10281  break;
10282 /* Redirecting reason code */
10284  if (ie_len != sizeof(value)) {
10285  ast_log(LOG_WARNING, "Invalid redirecting reason (%u)\n",
10286  (unsigned) ie_len);
10287  break;
10288  }
10289  memcpy(&value, data + pos, sizeof(value));
10290  redirecting->reason.code = ntohl(value);
10291  break;
10292 /* Redirecting reason string */
10294  ast_free(redirecting->reason.str);
10295  redirecting->reason.str = ast_malloc(ie_len + 1);
10296  if (redirecting->reason.str) {
10297  memcpy(redirecting->reason.str, data + pos, ie_len);
10298  redirecting->reason.str[ie_len] = 0;
10299  }
10300  break;
10301 /* Redirecting orig-reason code */
10303  if (ie_len != sizeof(value)) {
10304  ast_log(LOG_WARNING, "Invalid redirecting original reason (%u)\n",
10305  (unsigned) ie_len);
10306  break;
10307  }
10308  memcpy(&value, data + pos, sizeof(value));
10309  redirecting->orig_reason.code = ntohl(value);
10310  break;
10311 /* Redirecting orig-reason string */
10313  ast_free(redirecting->orig_reason.str);
10314  redirecting->orig_reason.str = ast_malloc(ie_len + 1);
10315  if (redirecting->orig_reason.str) {
10316  memcpy(redirecting->orig_reason.str, data + pos, ie_len);
10317  redirecting->orig_reason.str[ie_len] = 0;
10318  }
10319  break;
10320 /* Redirecting count */
10321  case AST_REDIRECTING_COUNT:
10322  if (ie_len != sizeof(value)) {
10323  ast_log(LOG_WARNING, "Invalid redirecting count (%u)\n",
10324  (unsigned) ie_len);
10325  break;
10326  }
10327  memcpy(&value, data + pos, sizeof(value));
10328  redirecting->count = ntohl(value);
10329  break;
10330 /* Redirecting unknown element */
10331  default:
10332  ast_debug(1, "Unknown redirecting element: %u (%u)\n",
10333  (unsigned) ie_id, (unsigned) ie_len);
10334  break;
10335  }
10336  }
10337 
10338  switch (frame_version) {
10339  case 1:
10340  /*
10341  * The other end is an earlier version that we need to adjust
10342  * for compatibility.
10343  *
10344  * The earlier version did not have the orig party id or
10345  * orig_reason value.
10346  */
10347  redirecting->from.name.valid = 1;
10349  redirecting->from.number.valid = 1;
10350  if (got_from_combined_presentation) {
10351  redirecting->from.name.presentation = from_combined_presentation;
10352  redirecting->from.number.presentation = from_combined_presentation;
10353  }
10354 
10355  redirecting->to.name.valid = 1;
10357  redirecting->to.number.valid = 1;
10358  if (got_to_combined_presentation) {
10359  redirecting->to.name.presentation = to_combined_presentation;
10360  redirecting->to.number.presentation = to_combined_presentation;
10361  }
10362  break;
10363  case 2:
10364  /* The other end is at the same level as we are. */
10365  break;
10366  default:
10367  /*
10368  * The other end is newer than we are.
10369  * We need to assume that they are compatible with us.
10370  */
10371  ast_debug(1, "Redirecting frame has newer version: %u\n",
10372  (unsigned) frame_version);
10373  break;
10374  }
10375 
10376  return 0;
10377 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:278
char * str
Subscriber phone number (Malloced)
Definition: channel.h:292
struct ast_party_id priv_to
Call is redirecting to a new party (Sent to the caller) - private representation. ...
Definition: channel.h:540
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:296
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:534
struct ast_party_name name
Subscriber name.
Definition: channel.h:341
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:528
#define LOG_WARNING
Definition: logger.h:274
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:537
int char_set
Character set the name is using.
Definition: channel.h:273
char * str
Subscriber name (Malloced)
Definition: channel.h:265
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:329
char * str
Malloced subaddress string.
Definition: channel.h:314
int value
Definition: syslog.c:37
int code
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:511
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:327
struct ast_party_id orig
Who originally redirected the call (Sent to the party the call is redirected toward) ...
Definition: channel.h:525
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
struct ast_party_redirecting_reason orig_reason
Reason for the redirection by the original party.
Definition: channel.h:546
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:193
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:345
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:294
char * str
a string value for the redirecting reason
Definition: channel.h:508
#define ast_free(a)
Definition: astmm.h:182
struct ast_party_redirecting_reason reason
Reason for the redirection.
Definition: channel.h:543
char * tag
User-set "tag".
Definition: channel.h:355
int type
Q.931 subaddress type.
Definition: channel.h:321
int count
Number of times the call was redirected.
Definition: channel.h:549
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:531
int int32_t
Definition: db.h:60
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:280
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:298
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:343

◆ ast_ref_namedgroups()

struct ast_namedgroups* ast_ref_namedgroups ( struct ast_namedgroups *  groups)

Definition at line 7838 of file channel.c.

References ao2_ref, and groups.

Referenced by ast_channel_named_callgroups_set(), ast_channel_named_pickupgroups_set(), check_peer_ok(), create_addr_from_peer(), and mkintf().

7839 {
7840  if (groups) {
7841  ao2_ref(groups, 1);
7842  }
7843  return groups;
7844 }
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct groups groups

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

References NULL, and request_channel().

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

6445 {
6446  return request_channel(type, request_cap, NULL, assignedids, requestor, addr, cause);
6447 }
static const char type[]
Definition: chan_ooh323.c:109
#define NULL
Definition: resample.c:96
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:6309

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

References __ast_request_and_dial(), and NULL.

Referenced by generic_recall().

6265 {
6266  return __ast_request_and_dial(type, cap, assignedids, requestor, addr, timeout, outstate, cidnum, cidname, NULL);
6267 }
static const char type[]
Definition: chan_ooh323.c:109
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:6066
static int timeout
Definition: cdr_mysql.c:86
#define NULL
Definition: resample.c:96

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

References NULL, and request_channel().

Referenced by dial_exec_full(), and do_forward().

6450 {
6451  return request_channel(type, NULL, topology, assignedids, requestor, addr, cause);
6452 }
static const char type[]
Definition: chan_ooh323.c:109
#define NULL
Definition: resample.c:96
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:6309

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

Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 1574 of file channel.c.

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(), destroy_all_channels(), dial_trunk(), dictate_exec(), disa_exec(), dtmf_no_bridge(), dtmf_stream(), flash_exec(), mf_stream(), mgcp_ss(), milliwatt_exec(), misdn_check_l2l1(), old_milliwatt_exec(), pbx_builtin_wait(), play_moh_exec(), playtone(), privacy_exec(), send_tone_burst(), testclient_exec(), testserver_exec(), try_calling(), wait_for_hangup(), waituntil_exec(), and zapateller_exec().

1575 {
1576  return safe_sleep_conditional(chan, ms, NULL, NULL, 1);
1577 }
#define NULL
Definition: resample.c:96
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:1498

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

References cond, and safe_sleep_conditional().

Referenced by get_chan_by_ast_name().

1569 {
1570  return safe_sleep_conditional(chan, timeout_ms, cond, data, 1);
1571 }
ast_cond_t cond
Definition: app_meetme.c:1090
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:1498

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

References NULL, and safe_sleep_conditional().

1580 {
1581  return safe_sleep_conditional(chan, ms, NULL, NULL, 0);
1582 }
#define NULL
Definition: resample.c:96
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:1498

◆ 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
Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 5019 of file channel.c.

References ast_channel_tech(), AST_DEFAULT_EMULATE_DTMF_DURATION, ast_safe_sleep(), ast_senddigit_begin(), and ast_senddigit_end().

Referenced by dial_exec_full(), and dtmf_stream().

5020 {
5021  if (duration < AST_DEFAULT_EMULATE_DTMF_DURATION) {
5023  }
5024  if (ast_channel_tech(chan)->send_digit_begin) {
5025  ast_senddigit_begin(chan, digit);
5026  ast_safe_sleep(chan, duration);
5027  }
5028 
5029  return ast_senddigit_end(chan, digit, duration);
5030 }
char digit
#define AST_DEFAULT_EMULATE_DTMF_DURATION
Definition: channel.c:102
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait, look for hangups.
Definition: channel.c:1574
int ast_senddigit_begin(struct ast_channel *chan, char digit)
Send a DTMF digit to a channel.
Definition: channel.c:4919
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition: channel.c:4969
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)

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

References ast_channel_lock, ast_channel_name(), ast_channel_sending_dtmf_digit_set(), ast_channel_sending_dtmf_tv_set(), ast_channel_tech(), ast_channel_unlock, ast_debug, ast_playtones_start(), and ast_tvnow().

Referenced by ast_senddigit(), ast_senddigit_external(), and ast_write_stream().

4920 {
4921  /* Device does not support DTMF tones, lets fake
4922  * it by doing our own generation. */
4923  static const char * const dtmf_tones[] = {
4924  "941+1336", /* 0 */
4925  "697+1209", /* 1 */
4926  "697+1336", /* 2 */
4927  "697+1477", /* 3 */
4928  "770+1209", /* 4 */
4929  "770+1336", /* 5 */
4930  "770+1477", /* 6 */
4931  "852+1209", /* 7 */
4932  "852+1336", /* 8 */
4933  "852+1477", /* 9 */
4934  "697+1633", /* A */
4935  "770+1633", /* B */
4936  "852+1633", /* C */
4937  "941+1633", /* D */
4938  "941+1209", /* * */
4939  "941+1477" /* # */
4940  };
4941 
4942  if (!ast_channel_tech(chan)->send_digit_begin)
4943  return 0;
4944 
4945  ast_channel_lock(chan);
4948  ast_channel_unlock(chan);
4949 
4950  if (!ast_channel_tech(chan)->send_digit_begin(chan, digit))
4951  return 0;
4952 
4953  if (digit >= '0' && digit <='9')
4954  ast_playtones_start(chan, 0, dtmf_tones[digit-'0'], 0);
4955  else if (digit >= 'A' && digit <= 'D')
4956  ast_playtones_start(chan, 0, dtmf_tones[digit-'A'+10], 0);
4957  else if (digit == '*')
4958  ast_playtones_start(chan, 0, dtmf_tones[14], 0);
4959  else if (digit == '#')
4960  ast_playtones_start(chan, 0, dtmf_tones[15], 0);
4961  else {
4962  /* not handled */
4963  ast_debug(1, "Unable to generate DTMF tone '%c' for '%s'\n", digit, ast_channel_name(chan));
4964  }
4965 
4966  return 0;
4967 }
char digit
#define ast_channel_lock(chan)
Definition: channel.h:2945
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:150
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_channel_unlock(chan)
Definition: channel.h:2946
void ast_channel_sending_dtmf_tv_set(struct ast_channel *chan, struct timeval value)
const char * ast_channel_name(const struct ast_channel *chan)
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
Definition: indications.c:302
void ast_channel_sending_dtmf_digit_set(struct ast_channel *chan, char value)
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)

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

References ast_channel_generator(), ast_channel_lock, ast_channel_sending_dtmf_digit(), ast_channel_sending_dtmf_digit_set(), ast_channel_tech(), ast_channel_unlock, ast_playtones_stop(), and ast_channel_tech::send_digit_end.

Referenced by ast_channel_end_dtmf(), ast_senddigit(), ast_senddigit_external(), and ast_write_stream().

4970 {
4971  int res = -1;
4972 
4973  if (ast_channel_tech(chan)->send_digit_end)
4974  res = ast_channel_tech(chan)->send_digit_end(chan, digit, duration);
4975 
4976  ast_channel_lock(chan);
4977  if (ast_channel_sending_dtmf_digit(chan) == digit) {
4979  }
4980  ast_channel_unlock(chan);
4981 
4982  if (res && ast_channel_generator(chan))
4983  ast_playtones_stop(chan);
4984 
4985  return 0;
4986 }
char digit
#define ast_channel_lock(chan)
Definition: channel.h:2945
char ast_channel_sending_dtmf_digit(const struct ast_channel *chan)
int(*const send_digit_end)(struct ast_channel *chan, char digit, unsigned int duration)
Stop sending a literal DTMF digit.
Definition: channel.h:691
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
Definition: indications.c:393
struct ast_generator * ast_channel_generator(const struct ast_channel *chan)
#define ast_channel_unlock(chan)
Definition: channel.h:2946
void ast_channel_sending_dtmf_digit_set(struct ast_channel *chan, char value)
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)

◆ 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
Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 5032 of file channel.c.

References ast_channel_tech(), AST_DEFAULT_EMULATE_DTMF_DURATION, ast_senddigit_begin(), and ast_senddigit_end().

Referenced by dtmf_stream(), and manager_play_dtmf().

5033 {
5034  if (duration < AST_DEFAULT_EMULATE_DTMF_DURATION) {
5036  }
5037  if (ast_channel_tech(chan)->send_digit_begin) {
5038  ast_senddigit_begin(chan, digit);
5039  usleep(duration * 1000);
5040  }
5041 
5042  return ast_senddigit_end(chan, digit, duration);
5043 }
char digit
#define AST_DEFAULT_EMULATE_DTMF_DURATION
Definition: channel.c:102
int ast_senddigit_begin(struct ast_channel *chan, char digit)
Send a DTMF digit to a channel.
Definition: channel.c:4919
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition: channel.c:4969
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)

◆ 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
durationthe duration of a KP digit ending in ms
durationthe 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
Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 4997 of file channel.c.

References ast_channel_tech(), ast_safe_sleep(), ast_senddigit_mf_begin(), ast_senddigit_mf_end(), and DEFAULT_EMULATE_MF_DURATION.

Referenced by mf_stream().

4999 {
5000  if (duration < DEFAULT_EMULATE_MF_DURATION) {
5001  duration = DEFAULT_EMULATE_MF_DURATION;
5002  }
5003  if (ast_channel_tech(chan)->send_digit_begin) {
5004  if (digit == '*') {
5005  duration = durationkp;
5006  } else if (digit == '#' || digit == 'A' || digit == 'B' || digit == 'C') {
5007  duration = durationst;
5008  }
5010  if (is_external) {
5011  usleep(duration * 1000);
5012  } else {
5013  ast_safe_sleep(chan, duration);
5014  }
5015  }
5016  return ast_senddigit_mf_end(chan);
5017 }
char digit
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait, look for hangups.
Definition: channel.c:1574
int ast_senddigit_mf_begin(struct ast_channel *chan, char digit)
Send an MF digit to a channel.
Definition: channel.c:4880
int ast_senddigit_mf_end(struct ast_channel *chan)
End sending an MF digit to a channel.
Definition: channel.c:4988
#define DEFAULT_EMULATE_MF_DURATION
Definition: channel.c:106
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)

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

References ast_channel_name(), ast_log, ast_playtones_start(), LOG_WARNING, and mf_tones.

Referenced by ast_senddigit_mf().

4881 {
4882  static const char * const mf_tones[] = {
4883  "1300+1500", /* 0 */
4884  "700+900", /* 1 */
4885  "700+1100", /* 2 */
4886  "900+1100", /* 3 */
4887  "700+1300", /* 4 */
4888  "900+1300", /* 5 */
4889  "1100+1300", /* 6 */
4890  "700+1500", /* 7 */
4891  "900+1500", /* 8 */
4892  "1100+1500", /* 9 */
4893  "1100+1700", /* * (KP) */
4894  "1500+1700", /* # (ST) */
4895  "900+1700", /* A (STP) */
4896  "1300+1700", /* B (ST2P) */
4897  "700+1700" /* C (ST3P) */
4898  };
4899 
4900  if (digit >= '0' && digit <='9') {
4901  ast_playtones_start(chan, 0, mf_tones[digit-'0'], 0);
4902  } else if (digit == '*') {
4903  ast_playtones_start(chan, 0, mf_tones[10], 0);
4904  } else if (digit == '#') {
4905  ast_playtones_start(chan, 0, mf_tones[11], 0);
4906  } else if (digit == 'A') {
4907  ast_playtones_start(chan, 0, mf_tones[12], 0);
4908  } else if (digit == 'B') {
4909  ast_playtones_start(chan, 0, mf_tones[13], 0);
4910  } else if (digit == 'C') {
4911  ast_playtones_start(chan, 0, mf_tones[14], 0);
4912  } else {
4913  /* not handled */
4914  ast_log(LOG_WARNING, "Unable to generate MF tone '%c' for '%s'\n", digit, ast_channel_name(chan));
4915  }
4916  return 0;
4917 }
char digit
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42
static const float mf_tones[]
Definition: dsp.c:323
const char * ast_channel_name(const struct ast_channel *chan)
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
Definition: indications.c:302

◆ 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
Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 4988 of file channel.c.

References ast_channel_generator(), and ast_playtones_stop().

Referenced by ast_senddigit_mf(), and mf_stream().

4989 {
4990  if (ast_channel_generator(chan)) {
4991  ast_playtones_stop(chan);
4992  return 0;
4993  }
4994  return -1;
4995 }
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
Definition: indications.c:393
struct ast_generator * ast_channel_generator(const struct ast_channel *chan)

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

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, and ast_msg_data_attribute::type.

Referenced by __ast_read(), handle_sendtext(), sendtext_exec(), and sendtext_safe().

4855 {
4856  struct ast_msg_data *msg;
4857  int rc;
4858  struct ast_msg_data_attribute attrs[] =
4859  {
4860  {
4862  .value = (char *)text,
4863  }
4864  };
4865 
4866  if (ast_strlen_zero(text)) {
4867  return 0;
4868  }
4869 
4871  if (!msg) {
4872  return -1;
4873  }
4874  rc = ast_sendtext_data(chan, msg);
4875  ast_free(msg);
4876 
4877  return rc;
4878 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
enum ast_msg_data_attribute_type type
Definition: message.h:463
Structure used to transport a message through the frame core.
Definition: message.c:1406
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.
Definition: message.c:1418
char * text
Definition: app_queue.c:1508
#define ast_strlen_zero(foo)
Definition: strings.h:52
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:4796
#define ast_free(a)
Definition: astmm.h:182

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

References ast_begins_with(), AST_CHAN_TP_SEND_TEXT_DATA, ast_channel_flags(), ast_channel_lock, ast_channel_name(), ast_channel_nativeformats(), ast_channel_tech(), 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, ast_channel_tech::send_text, 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().

4797 {
4798  int res = 0;
4799  const char *body = ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_BODY);
4800  const char *content_type = ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_CONTENT_TYPE);
4801 
4802  ast_channel_lock(chan);
4803  /* Stop if we're a zombie or need a soft hangup */
4805  ast_channel_unlock(chan);
4806  return -1;
4807  }
4808 
4809  CHECK_BLOCKING(chan);
4810  if (ast_channel_tech(chan)->write_text
4811  && (ast_strlen_zero(content_type) || ast_begins_with(content_type, "text/"))
4813  struct ast_frame f;
4814  /* T.140 payload does not include the null byte terminator */
4815  size_t body_len = strlen(body);
4816 
4817  /* Process as T.140 text (moved here from ast_sendtext() */
4818  memset(&f, 0, sizeof(f));
4819  f.src = "DIALPLAN";
4820  f.subclass.format = ast_format_t140;
4821  f.frametype = AST_FRAME_TEXT;
4822  f.datalen = body_len;
4823  f.mallocd = AST_MALLOCD_DATA;
4824  f.data.ptr = ast_strdup(body);
4825  if (f.data.ptr) {
4826  res = ast_channel_tech(chan)->write_text(chan, &f);
4827  } else {
4828  res = -1;
4829  }
4830  ast_frfree(&f);
4831  } else if ((ast_channel_tech(chan)->properties & AST_CHAN_TP_SEND_TEXT_DATA)
4832  && ast_channel_tech(chan)->send_text_data) {
4833  /* Send enhanced message to a channel driver that supports it */
4834  ast_debug(1, "Sending TEXT_DATA from '%s' to %s:%s %s\n",
4837  ast_channel_name(chan), body);
4838  res = ast_channel_tech(chan)->send_text_data(chan, msg);
4839  } else if (ast_channel_tech(chan)->send_text
4840  && (ast_strlen_zero(content_type) || ast_begins_with(content_type, "text/"))) {
4841  /* Send the body of an enhanced message to a channel driver that supports only a char str */
4842  ast_debug(1, "Sending TEXT to %s: %s\n", ast_channel_name(chan), body);
4843  res = ast_channel_tech(chan)->send_text(chan, body);
4844  } else {
4845  ast_debug(1, "Channel technology does not support sending content type '%s' on channel '%s'\n",
4846  S_OR(content_type, "text/plain"), ast_channel_name(chan));
4847  res = -1;
4848  }
4850  ast_channel_unlock(chan);
4851  return res;
4852 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
Channels have this property if they implement send_text_data.
Definition: channel.h:976
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define AST_MALLOCD_DATA
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define ast_strlen_zero(foo)
Definition: strings.h:52
int ast_check_hangup(struct ast_channel *chan)
Checks to see if a channel is needing hang up.
Definition: channel.c:445
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
int(*const write_text)(struct ast_channel *chan, struct ast_frame *frame)
Write a text frame, in standard format.
Definition: channel.h:790
int(*const send_text)(struct ast_channel *chan, const char *text)
Display or transmit text.
Definition: channel.h:757
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.
Definition: message.c:1533
#define ast_channel_unlock(chan)
Definition: channel.h:2946
#define ast_clear_flag(p, flag)
Definition: utils.h:77
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:2894
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
const char * ast_channel_name(const struct ast_channel *chan)
#define ast_frfree(fr)
Data structure associated with a single frame of data.
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
Definition: strings.h:94
int(*const send_text_data)(struct ast_channel *chan, struct ast_msg_data *data)
Display or transmit text with data.
Definition: channel.h:845
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
struct ast_format * ast_format_t140
Built-in cached t140 format.
Definition: format_cache.c:236
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
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:615

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

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(), cb_events(), disa_exec(), get_pai(), get_rpid(), handle_setcallerid(), mgcp_ss(), pbx_outgoing_attempt(), privacy_exec(), ring_entry(), skinny_newcall(), and socket_process_helper().

7435 {
7436  ast_channel_lock(chan);
7437 
7438  if (cid_num) {
7439  ast_channel_caller(chan)->id.number.valid = 1;
7440  ast_free(ast_channel_caller(chan)->id.number.str);
7442  }
7443  if (cid_name) {
7444  ast_channel_caller(chan)->id.name.valid = 1;
7445  ast_free(ast_channel_caller(chan)->id.name.str);
7447  }
7448  if (cid_ani) {
7449  ast_channel_caller(chan)->ani.number.valid = 1;
7450  ast_free(ast_channel_caller(chan)->ani.number.str);
7451  ast_channel_caller(chan)->ani.number.str = ast_strdup(cid_ani);
7452  }
7453 
7455 
7456  ast_channel_unlock(chan);
7457 }
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
#define ast_channel_lock(chan)
Definition: channel.h:2945
char * str
Subscriber phone number (Malloced)
Definition: channel.h:292
struct ast_party_name name
Subscriber name.
Definition: channel.h:341
char * str
Subscriber name (Malloced)
Definition: channel.h:265
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
static char cid_num[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:164
Number structure.
Definition: app_followme.c:154
struct ast_party_id id
Caller party ID.
Definition: channel.h:421
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:428
#define ast_channel_unlock(chan)
Definition: channel.h:2946
static const char name[]
Definition: cdr_mysql.c:74
#define ast_free(a)
Definition: astmm.h:182
static char cid_name[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:165
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:280
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:298
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:343

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

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(), set_hangup_source_and_cause(), and sip_queue_hangup_cause().

2505 {
2507 
2508  ast_channel_lock(chan);
2509  if (force || ast_strlen_zero(ast_channel_hangupsource(chan))) {
2510  ast_channel_hangupsource_set(chan, source);
2511  }
2512  ast_channel_unlock(chan);
2513 
2514  if (bridge) {
2515  ast_channel_lock(bridge);
2516  if (force || ast_strlen_zero(ast_channel_hangupsource(bridge))) {
2517  ast_channel_hangupsource_set(bridge, source);
2518  }
2519  ast_channel_unlock(bridge);
2520  }
2521 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
Main Channel structure associated with a channel.
#define ast_strlen_zero(foo)
Definition: strings.h:52
#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:911
#define ast_channel_cleanup(c)
Cleanup a channel reference.
Definition: channel.h:2992
#define ast_channel_unlock(chan)
Definition: channel.h:2946
struct ast_channel * ast_channel_bridge_peer(struct ast_channel *chan)
Get the channel&#39;s bridge peer only if the bridge is two-party.
Definition: channel.c:10765
const char * ast_channel_hangupsource(const struct ast_channel *chan)

◆ 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.
Returns
Nothing

Definition at line 1750 of file channel.c.

References ast_set_party_id::name, ast_set_party_id::number, and ast_set_party_id::subaddress.

Referenced by handle_request_invite(), handle_request_update(), handle_response_invite(), misdn_queue_connected_line_update(), set_redirecting(), and sip_call().

1751 {
1752  update_id->name = 1;
1753  update_id->number = 1;
1754  update_id->subaddress = 1;
1755 }
unsigned char subaddress
Definition: channel.h:368
unsigned char number
Definition: channel.h:366
unsigned char name
Definition: channel.h:364

◆ 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
Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 5849 of file channel.c.

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(), ices_exec(), isAnsweringMachine(), jack_exec(), jingle_interpret_content(), jingle_read(), measurenoise(), meetme_menu_admin_extended(), mgcp_rtp_read(), old_milliwatt_exec(), ooh323_new(), ooh323_rtp_read(), ooh323_set_read_format(), ooh323_set_write_format(), process_sdp(), record_exec(), set_caps(), set_read_to_slin(), sip_rtp_read(), skinny_rtp_read(), sms_exec(), socket_process_helper(), speech_background(), transmit_audio(), and unistim_rtp_read().

5850 {
5852  int res;
5853 
5854  ast_assert(format != NULL);
5855 
5856  if (!cap) {
5857  return -1;
5858  }
5859  ast_format_cap_append(cap, format, 0);
5860 
5861  res = set_format(chan, cap, 0, 0);
5862 
5863  ao2_cleanup(cap);
5864  return res;
5865 }
static int set_format(struct ast_channel *chan, struct ast_format_cap *cap_set, const int direction, int interleaved_stereo)
Definition: channel.c:5680
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
#define ast_format_cap_append(cap, format, framing)
Definition: format_cap.h:103
#define ast_format_cap_alloc(flags)
Definition: format_cap.h:52
Format capabilities structure, holds formats + preference order + etc.
Definition: format_cap.c:54
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

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

References set_format().

5868 {
5869  return set_format(chan, cap, 0, 0);
5870 }
static int set_format(struct ast_channel *chan, struct ast_format_cap *cap_set, const int direction, int interleaved_stereo)
Definition: channel.c:5680

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

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

5576 {
5577  struct ast_trans_pvt *trans_old;
5578  struct ast_trans_pvt *trans_new;
5579 
5581  && ast_format_cmp(ast_channel_readformat(chan), core_format) == AST_FORMAT_CMP_EQUAL) {
5582  /* Nothing to setup */
5583  return 0;
5584  }
5585 
5586  ast_debug(1, "Channel %s setting read format path: %s -> %s\n",
5587  ast_channel_name(chan),
5588  ast_format_get_name(raw_format),
5589  ast_format_get_name(core_format));
5590 
5591  /* Setup new translation path. */
5592  if (ast_format_cmp(raw_format, core_format) != AST_FORMAT_CMP_EQUAL) {
5593  trans_new = ast_translator_build_path(core_format, raw_format);
5594  if (!trans_new) {
5595  return -1;
5596  }
5597  } else {
5598  /* No translation needed. */
5599  trans_new = NULL;
5600  }
5601  trans_old = ast_channel_readtrans(chan);
5602  if (trans_old) {
5603  ast_translator_free_path(trans_old);
5604  }
5605  ast_channel_readtrans_set(chan, trans_new);
5606  ast_channel_set_rawreadformat(chan, raw_format);
5607  ast_channel_set_readformat(chan, core_format);
5608  return 0;
5609 }
void ast_channel_readtrans_set(struct ast_channel *chan, struct ast_trans_pvt *value)
const char * ast_format_get_name(const struct ast_format *format)
Get the name associated with a format.
Definition: format.c:334
#define NULL
Definition: resample.c:96
struct ast_trans_pvt * ast_channel_readtrans(const struct ast_channel *chan)
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format)
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
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:485
void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
struct ast_format * ast_channel_rawreadformat(struct ast_channel *chan)
Default structure for translators, with the basic fields and buffers, all allocated as part of the sa...
Definition: translate.h:213
const char * ast_channel_name(const struct ast_channel *chan)
void ast_translator_free_path(struct ast_trans_pvt *tr)
Frees a translator path Frees the given translator path structure.
Definition: translate.c:475

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

References ast_variable::name, ast_variable::next, pbx_builtin_setvar_helper(), and ast_variable::value.

Referenced by __ast_request_and_dial(), ari_channels_handle_originate_with_id(), ast_ari_channels_create(), ast_call_forward(), ast_pbx_outgoing_exten_predial(), and pbx_outgoing_attempt().

8218 {
8219  struct ast_variable *cur;
8220 
8221  for (cur = vars; cur; cur = cur->next) {
8222  pbx_builtin_setvar_helper(chan, cur->name, cur->value);
8223  }
8224 }
struct ast_variable * next
Structure for variables, used for configurations and for channel variables.
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...

◆ 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
Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 5890 of file channel.c.

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(), 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(), mgcp_rtp_read(), moh_alloc(), moh_files_release(), moh_files_write_format_change(), moh_release(), mp3_exec(), NBScat_exec(), old_milliwatt_exec(), ooh323_new(), ooh323_rtp_read(), ooh323_set_write_format(), ooh323_write(), participant_reaction_announcer_join(), playtones_alloc(), playtones_release(), process_sdp(), send_waveform_to_channel(), set_caps(), set_softmix_bridge_data(), sip_rtp_read(), skinny_rtp_read(), sms_exec(), socket_process_helper(), tonepair_alloc(), tonepair_release(), transmit_audio(), and unistim_rtp_read().

5891 {
5893  int res;
5894 
5895  ast_assert(format != NULL);
5896 
5897  if (!cap) {
5898  return -1;
5899  }
5900  ast_format_cap_append(cap, format, 0);
5901 
5902  res = set_format(chan, cap, 1, 0);
5903 
5904  ao2_cleanup(cap);
5905  return res;
5906 }
static int set_format(struct ast_channel *chan, struct ast_format_cap *cap_set, const int direction, int interleaved_stereo)
Definition: channel.c:5680
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
#define ast_format_cap_append(cap, format, framing)
Definition: format_cap.h:103
#define ast_format_cap_alloc(flags)
Definition: format_cap.h:52
Format capabilities structure, holds formats + preference order + etc.
Definition: format_cap.c:54
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

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

References set_format().

Referenced by ast_openstream_full().

5909 {
5910  return set_format(chan, cap, 1, 0);
5911 }
static int set_format(struct ast_channel *chan, struct ast_format_cap *cap_set, const int direction, int interleaved_stereo)
Definition: channel.c:5680

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

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

5873 {
5875  int res;
5876 
5877  ast_assert(format != NULL);
5878 
5879  if (!cap) {
5880  return -1;
5881  }
5882  ast_format_cap_append(cap, format, 0);
5883 
5884  res = set_format(chan, cap, 1, 1);
5885 
5886  ao2_cleanup(cap);
5887  return res;
5888 }
static int set_format(struct ast_channel *chan, struct ast_format_cap *cap_set, const int direction, int interleaved_stereo)
Definition: channel.c:5680
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
#define ast_format_cap_append(cap, format, framing)
Definition: format_cap.h:103
#define ast_format_cap_alloc(flags)
Definition: format_cap.h:52
Format capabilities structure, holds formats + preference order + etc.
Definition: format_cap.c:54
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

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

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

5612 {
5613  struct ast_trans_pvt *trans_old;
5614  struct ast_trans_pvt *trans_new;
5615 
5617  && ast_format_cmp(ast_channel_writeformat(chan), core_format) == AST_FORMAT_CMP_EQUAL) {
5618  /* Nothing to setup */
5619  return 0;
5620  }
5621 
5622  ast_debug(1, "Channel %s setting write format path: %s -> %s\n",
5623  ast_channel_name(chan),
5624  ast_format_get_name(core_format),
5625  ast_format_get_name(raw_format));
5626 
5627  /* Setup new translation path. */
5628  if (ast_format_cmp(raw_format, core_format) != AST_FORMAT_CMP_EQUAL) {
5629  trans_new = ast_translator_build_path(raw_format, core_format);
5630  if (!trans_new) {
5631  return -1;
5632  }
5633  } else {
5634  /* No translation needed. */
5635  trans_new = NULL;
5636  }
5637  trans_old = ast_channel_writetrans(chan);
5638  if (trans_old) {
5639  ast_translator_free_path(trans_old);
5640  }
5641  ast_channel_writetrans_set(chan, trans_new);
5642  ast_channel_set_rawwriteformat(chan, raw_format);
5643  ast_channel_set_writeformat(chan, core_format);
5644  return 0;
5645 }
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format)
const char * ast_format_get_name(const struct ast_format *format)
Get the name associated with a format.
Definition: format.c:334
#define NULL
Definition: resample.c:96
void ast_channel_writetrans_set(struct ast_channel *chan, struct ast_trans_pvt *value)
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
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
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:485
struct ast_trans_pvt * ast_channel_writetrans(const struct ast_channel *chan)
Default structure for translators, with the basic fields and buffers, all allocated as part of the sa...
Definition: translate.h:213
const char * ast_channel_name(const struct ast_channel *chan)
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
struct ast_format * ast_channel_rawwriteformat(struct ast_channel *chan)
void ast_translator_free_path(struct ast_trans_pvt *tr)
Frees a translator path Frees the given translator path structure.
Definition: translate.c:475

◆ 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, accomodates new timing methods

Definition at line 3189 of file channel.c.

References ast_settimeout_full().

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

3190 {
3191  return ast_settimeout_full(c, rate, func, data, 0);
3192 }
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:3194

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

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, and NULL.

Referenced by ast_readaudio_callback(), and ast_settimeout().

3195 {
3196  int res;
3197  unsigned int real_rate = rate, max_rate;
3198 
3199  ast_channel_lock(c);
3200 
3201  if (ast_channel_timingfd(c) == -1) {
3202  ast_channel_unlock(c);
3203  return -1;
3204  }
3205 
3206  if (!func) {
3207  rate = 0;
3208  data = NULL;
3209  }
3210 
3211  if (rate && rate > (max_rate = ast_timer_get_max_rate(ast_channel_timer(c)))) {
3212  real_rate = max_rate;
3213  }
3214 
3215  ast_debug(1, "Scheduling timer at (%u requested / %u actual) timer ticks per second\n", rate, real_rate);
3216 
3217  res = ast_timer_set_rate(ast_channel_timer(c), real_rate);
3218 
3221  }
3222 
3223  ast_channel_timingfunc_set(c, func);
3224  ast_channel_timingdata_set(c, data);
3225 
3226  if (data && is_ao2_obj) {
3227  ao2_ref(data, 1);
3229  } else {
3231  }
3232 
3233  if (func == NULL && rate == 0 && ast_channel_fdno(c) == AST_TIMING_FD) {
3234  /* Clearing the timing func and setting the rate to 0
3235  * means that we don't want to be reading from the timingfd
3236  * any more. Setting c->fdno to -1 means we won't have any
3237  * errant reads from the timingfd, meaning we won't potentially
3238  * miss any important frames.
3239  */
3240  ast_channel_fdno_set(c, -1);
3241  }
3242 
3243  ast_channel_unlock(c);
3244 
3245  return res;
3246 }
void ast_channel_fdno_set(struct ast_channel *chan, int value)
void ast_channel_timingfunc_set(struct ast_channel *chan, ast_timing_func_t value)
#define ast_channel_lock(chan)
Definition: channel.h:2945
unsigned int ast_timer_get_max_rate(const struct ast_timer *handle)
Get maximum rate supported for a timer.
Definition: timing.c:191
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define NULL
Definition: resample.c:96
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ao2_ref(o, delta)
Definition: astobj2.h:464
void * ast_channel_timingdata(const struct ast_channel *chan)
int ast_channel_fdno(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)
#define AST_TIMING_FD
Definition: channel.h:202
#define ast_channel_unlock(chan)
Definition: channel.h:2946
int ast_timer_set_rate(const struct ast_timer *handle, unsigned int rate)
Set the timing tick rate.
Definition: timing.c:166
#define ast_clear_flag(p, flag)
Definition: utils.h:77
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
struct ast_timer * ast_channel_timer(const struct ast_channel *chan)

◆ ast_softhangup()

int ast_softhangup ( struct ast_channel chan,
int  cause 
)

Softly hangup up a channel.

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

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

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

Softly hangup up a channel.

Definition at line 2476 of file channel.c.

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(), mgcp_pktcgate_remove(), retransfer_exit(), rtp_check_timeout(), sla_handle_hold_event(), softhangup_exec(), stasis_app_bridge_moh_stop(), and unload_module().

2477 {
2478  RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
2479  int res;
2480 
2481  ast_channel_lock(chan);
2482  res = ast_softhangup_nolock(chan, cause);
2483  blob = ast_json_pack("{s: i, s: b}",
2484  "cause", cause,
2485  "soft", 1);
2487  ast_channel_unlock(chan);
2488 
2489  return res;
2490 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:591
int ast_softhangup_nolock(struct ast_channel *chan, int cause)
Softly hangup a channel, don&#39;t lock.
Definition: channel.c:2463
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
#define NULL
Definition: resample.c:96
#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:911
#define ast_channel_unlock(chan)
Definition: channel.h:2946
Abstract JSON element (object, array, string, int, ...).
void ast_channel_publish_blob(struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
Publish a channel blob message.
struct stasis_message_type * ast_channel_hangup_request_type(void)
Message type for when a hangup is requested on a channel.

◆ ast_softhangup_all()

void ast_softhangup_all ( void  )

Soft hangup all active channels.

Since
13.3.0
Returns
Nothing

Definition at line 493 of file channel.c.

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

Referenced by can_safely_quit().

494 {
496 }
#define ao2_callback(c, flags, cb_fn, arg)
Definition: astobj2.h:1716
#define NULL
Definition: resample.c:96
static int ast_channel_softhangup_cb(void *obj, void *arg, int flags)
Definition: channel.c:484
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:124

◆ 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
reasonan AST_SOFTHANGUP_* reason code

Softly hangup up a channel (no channel lock)

Definition at line 2463 of file channel.c.

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(), check_pendings(), check_rtp_timeout(), dahdi_softhangup_all(), do_monitor(), gosub_run(), internal_bridge_after_cb(), jingle_indicate(), pbx_builtin_hangup(), proc_session_timer(), and sip_indicate().

2464 {
2465  ast_debug(1, "Soft-Hanging (%#04x) up channel '%s'\n", (unsigned)cause, ast_channel_name(chan));
2466  /* Inform channel driver that we need to be hung up, if it cares */
2469  /* Interrupt any poll call or such */
2471  pthread_kill(ast_channel_blocker(chan), SIGURG);
2472  return 0;
2473 }
#define ast_test_flag(p, flag)
Definition: utils.h:63
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1139
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
pthread_t ast_channel_blocker(const struct ast_channel *chan)
struct ast_frame ast_null_frame
Definition: main/frame.c:79
const char * ast_channel_name(const struct ast_channel *chan)
void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
struct ast_flags * ast_channel_flags(struct ast_channel *chan)

◆ ast_state2str()

const char* ast_state2str ( enum ast_channel_state  state)

Gives the string form of a given channel state.

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

Definition at line 642 of file channel.c.

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, STATE2STR_BUFSIZE, and state2str_threadbuf.

Referenced by ast_channel_snapshot_to_json(), ast_manager_build_channel_state_string_prefix(), cli_channel_print_body(), func_channel_read(), handle_chanlist(), handle_showchan(), mgcp_new(), serialize_showchan(), sip_hangup(), and update_connectedline().

643 {
644  char *buf;
645 
646  switch (state) {
647  case AST_STATE_DOWN:
648  return "Down";
649  case AST_STATE_RESERVED:
650  return "Rsrvd";
651  case AST_STATE_OFFHOOK:
652  return "OffHook";
653  case AST_STATE_DIALING:
654  return "Dialing";
655  case AST_STATE_RING:
656  return "Ring";
657  case AST_STATE_RINGING:
658  return "Ringing";
659  case AST_STATE_UP:
660  return "Up";
661  case AST_STATE_BUSY:
662  return "Busy";
664  return "Dialing Offhook";
665  case AST_STATE_PRERING:
666  return "Pre-ring";
667  case AST_STATE_MUTE:
668  return "Mute";
669  default:
671  return "Unknown";
672  snprintf(buf, STATE2STR_BUFSIZE, "Unknown (%u)", state);
673  return buf;
674  }
675 }
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
#define STATE2STR_BUFSIZE
Definition: channel.c:98
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static struct ast_threadstorage state2str_threadbuf
Definition: channel.c:97

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

References ARRAY_LEN.

Referenced by dial_exec_full(), and pbx_builtin_hangup().

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 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static const struct causes_map causes[]
Definition: channel.c:136
static const char name[]
Definition: cdr_mysql.c:74

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

References ast_channel_generatordata(), ast_frfree, ast_read(), ast_tonepair_start(), and ast_waitfor().

Referenced by zapateller_exec().

7701 {
7702  int res;
7703 
7704  if ((res = ast_tonepair_start(chan, freq1, freq2, duration, vol)))
7705  return res;
7706 
7707  /* Give us some wiggle room */
7708  while (ast_channel_generatordata(chan) && ast_waitfor(chan, 100) >= 0) {
7709  struct ast_frame *f = ast_read(chan);
7710  if (f)
7711  ast_frfree(f);
7712  else
7713  return -1;
7714  }
7715  return 0;
7716 }
void * ast_channel_generatordata(const struct ast_channel *chan)
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4302
int ast_waitfor(struct ast_channel *c, int ms)
Wait for input on a channel.
Definition: channel.c:3171
#define ast_frfree(fr)
Data structure associated with a single frame of data.
int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
Definition: channel.c:7682

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

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

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

7683 {
7684  struct tonepair_def d = { 0, };
7685 
7686  d.freq1 = freq1;
7687  d.freq2 = freq2;
7688  d.duration = duration;
7689  d.vol = (vol < 1) ? 8192 : vol; /* force invalid to 8192 */
7690  if (ast_activate_generator(chan, &tonepair, &d))
7691  return -1;
7692  return 0;
7693 }
static struct test_val d
int duration
Definition: channel.c:7565
static struct ast_generator tonepair
Definition: channel.c:7676
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
Definition: channel.c:2960

◆ ast_tonepair_stop()

void ast_tonepair_stop ( struct ast_channel chan)

Stop a tone from playing

Definition at line 7695 of file channel.c.

References ast_deactivate_generator().

Referenced by sendnoise().

7696 {
7698 }
void ast_deactivate_generator(struct ast_channel *chan)
Definition: channel.c:2902

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

References ast_transfer_protocol().

Referenced by app_control_redirect().

6578 {
6579  int protocol;
6580  return ast_transfer_protocol(chan, dest, &protocol);
6581 }
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:6595

◆ 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
chancurrent channel
destdestination extension for transfer
protocolspecific error code in case of failure Example, sip 0 success, else sip error code

Transfer a channel (if supported) receieve protocol result.

Parameters
chanchannel to transfer
destdestination to transfer to
protocolis the protocol result SIP example, 0=success, 3xx-6xx is SIP error code

Called by:

  • app_transfer
  • the manager interface

Definition at line 6595 of file channel.c.

References ast_channel_flags(), ast_channel_lock, ast_channel_tech(), 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().

6596 {
6597  int res = -1;
6598 
6599  if (protocol) {
6600  *protocol = 0;
6601  }
6602 
6603  /* Stop if we're a zombie or need a soft hangup */
6604  ast_channel_lock(chan);
6606  if (ast_channel_tech(chan)->transfer) {
6607  res = ast_channel_tech(chan)->transfer(chan, dest);
6608  if (!res)
6609  res = 1;
6610  } else
6611  res = 0;
6612  }
6613  ast_channel_unlock(chan);
6614 
6615  if (res <= 0) {
6616  return res;
6617  }
6618 
6619  for (;;) {
6620  struct ast_frame *fr;
6621 
6622  res = ast_waitfor(chan, -1);
6623 
6624  if (res < 0 || !(fr = ast_read(chan))) {
6625  res = -1;
6626  break;
6627  }
6628 
6630  enum ast_control_transfer *message = fr->data.ptr;
6631 
6632  if (*message == AST_TRANSFER_SUCCESS) {
6633  res = 1;
6634  } else {
6635  res = -1;
6636  /* Message can contain a protocol specific code
6637  AST_TRANSFER_SUCCESS indicates success
6638  Else, failure. Protocol will be set to the failure reason.
6639  SIP example, 0 is success, else error code 3xx-6xx */
6640  if (protocol) {
6641  *protocol = *message;
6642  }
6643  }
6644 
6645  ast_frfree(fr);
6646  break;
6647  }
6648 
6649  ast_frfree(fr);
6650  }
6651 
6652  return res;
6653 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
int(*const transfer)(struct ast_channel *chan, const char *newdest)
Blind transfer other side (see app_transfer.c and ast_transfer()
Definition: channel.h:784
#define ast_test_flag(p, flag)
Definition: utils.h:63
ast_control_transfer
static int transfer
Definition: chan_mgcp.c:194
struct ast_frame_subclass subclass
int ast_check_hangup(struct ast_channel *chan)
Checks to see if a channel is needing hang up.
Definition: channel.c:445
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4302
#define ast_channel_unlock(chan)
Definition: channel.h:2946
int ast_waitfor(struct ast_channel *c, int ms)
Wait for input on a channel.
Definition: channel.c:3171
#define ast_frfree(fr)
Data structure associated with a single frame of data.
union ast_frame::@263 data
enum ast_frame_type frametype
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)

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

References AST_TRANS_CAP_3_1K_AUDIO, AST_TRANS_CAP_DIGITAL, AST_TRANS_CAP_DIGITAL_W_TONES, AST_TRANS_CAP_RESTRICTED_DIGITAL, AST_TRANS_CAP_SPEECH, and AST_TRANS_CAP_VIDEO.

Referenced by cb_events(), and misdn_call().

679 {
680  switch (transfercapability) {
682  return "SPEECH";
684  return "DIGITAL";
686  return "RESTRICTED_DIGITAL";
688  return "3K1AUDIO";
690  return "DIGITAL_W_TONES";
691  case AST_TRANS_CAP_VIDEO:
692  return "VIDEO";
693  default:
694  return "UNKNOWN";
695  }
696 }
#define AST_TRANS_CAP_DIGITAL_W_TONES
Definition: transcap.h:39
#define AST_TRANS_CAP_3_1K_AUDIO
Definition: transcap.h:37
#define AST_TRANS_CAP_VIDEO
Definition: transcap.h:40
#define AST_TRANS_CAP_RESTRICTED_DIGITAL
Definition: transcap.h:36
#define AST_TRANS_CAP_SPEECH
Definition: transcap.h:34
#define AST_TRANS_CAP_DIGITAL
Definition: transcap.h:35

◆ ast_undestroyed_channels()

int ast_undestroyed_channels ( void  )
Returns
the number of channels not yet destroyed

Definition at line 504 of file channel.c.

References ast_atomic_fetchadd_int(), and chancount.

Referenced by wait_for_channels_to_die().

505 {
507 }
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:755
static int chancount
Definition: channel.c:93

◆ 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
Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 3171 of file channel.c.

References ast_waitfor_nandfds(), 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(), destroy_all_channels(), dictate_exec(), disa_exec(), disable_t38(), do_waiting(), echo_exec(), handle_recordfile(), handle_speechrecognize(), ices_exec(), isAnsweringMachine(), jack_exec(), launch_asyncagi(), measurenoise(), moh_channel_thread(), mp3_exec(), NBScat_exec(), read_mf_digits(), read_sf_digits(), receive_dtmf_digits(), receivefax_t38_init(), record_exec(), recordthread(), safe_sleep_conditional(), send_waveform_to_channel(), sendfax_t38_init(), sendurl_exec(), sms_exec(), speech_background(), stasis_app_exec(), stream_echo_perform(), transmit_audio(), transmit_t38(), wait_exec(), wait_for_hangup(), waitforring_exec(), and waitstream_core().

3172 {
3173  if (ms < 0) {
3174  do {
3175  ms = 100000;
3176  ast_waitfor_nandfds(&c, 1, NULL, 0, NULL, NULL, &ms);
3177  } while (!ms);
3178  } else {
3179  ast_waitfor_nandfds(&c, 1, NULL, 0, NULL, NULL, &ms);
3180  }
3181  return ms;
3182 }
static struct test_val c
#define NULL
Definition: resample.c:96
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:2997

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

References ast_waitfor_nandfds(), and NULL.

Referenced by autoservice_run(), dial_exec_full(), iax2_key_rotate(), misdn_write(), monitor_dial(), wait_for_answer(), and wait_for_winner().

3167 {
3168  return ast_waitfor_nandfds(c, n, NULL, 0, NULL, NULL, ms);
3169 }
static struct test_val c
#define NULL
Definition: resample.c:96
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:2997

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

References ast_waitfor_nandfds(), and NULL.

Referenced by dundi_lookup_internal(), dundi_precache_internal(), rfcomm_wait(), and softmix_mixing_loop().

2990 {
2991  int winner = -1;
2992  ast_waitfor_nandfds(NULL, 0, fds, n, exception, &winner, ms);
2993  return winner;
2994 }
#define NULL
Definition: resample.c:96
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:2997

◆ 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
chanan array of pointers to channels
nnumber of channels that are to be waited upon
fdsan array of fds to wait upon
nfdsthe number of fds to wait upon
exceptionexception flag
outfdfd that had activity on it
mshow long the wait was

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

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

Waits for activity on a group of channels.

Definition at line 2997 of file channel.c.

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(), chanlist::chan, 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(), find_cache(), generic_fax_exec(), run_agi(), and waitstream_core().

2999 {
3000  struct timeval start = { 0 , 0 };
3001  struct pollfd *pfds = NULL;
3002  int res;
3003  long rms;
3004  int x, y, max;
3005  int sz = nfds;
3006  struct timeval now = { 0, 0 };
3007  struct timeval whentohangup = { 0, 0 }, diff;
3008  struct ast_channel *winner = NULL;
3009  struct fdmap {
3010  int chan;
3011  int fdno;
3012  } *fdmap = NULL;
3013 
3014  if (outfd) {
3015  *outfd = -99999;
3016  }
3017  if (exception) {
3018  *exception = 0;
3019  }
3020 
3021  for (x = 0; x < n; x++) {
3022  ast_channel_lock(c[x]);
3023  if (!ast_tvzero(*ast_channel_whentohangup(c[x]))) {
3024  if (ast_tvzero(whentohangup))
3025  now = ast_tvnow();
3026  diff = ast_tvsub(*ast_channel_whentohangup(c[x]), now);
3027  if (diff.tv_sec < 0 || ast_tvzero(diff)) {
3028  ast_test_suite_event_notify("HANGUP_TIME", "Channel: %s", ast_channel_name(c[x]));
3029  /* Should already be hungup */
3031  ast_channel_unlock(c[x]);
3032  return c[x];
3033  }
3034  if (ast_tvzero(whentohangup) || ast_tvcmp(diff, whentohangup) < 0)
3035  whentohangup = diff;
3036  }
3037  sz += ast_channel_fd_count(c[x]);
3038  ast_channel_unlock(c[x]);
3039  }
3040 
3041  if (!sz) {
3042  return NULL;
3043  }
3044 
3045  pfds = ast_alloca(sizeof(*pfds) * sz);
3046  fdmap = ast_alloca(sizeof(*fdmap) * sz);
3047 
3048  /* Wait full interval */
3049  rms = *ms;
3050  /* INT_MAX, not LONG_MAX, because it matters on 64-bit */
3051  if (!ast_tvzero(whentohangup) && whentohangup.tv_sec < INT_MAX / 1000) {
3052  rms = whentohangup.tv_sec * 1000 + whentohangup.tv_usec / 1000; /* timeout in milliseconds */
3053  if (*ms >= 0 && *ms < rms) { /* original *ms still smaller */
3054  rms = *ms;
3055  }
3056  } else if (!ast_tvzero(whentohangup) && rms < 0) {
3057  /* Tiny corner case... call would need to last >24 days */
3058  rms = INT_MAX;
3059  }
3060  /*
3061  * Build the pollfd array, putting the channels' fds first,
3062  * followed by individual fds. Order is important because
3063  * individual fd's must have priority over channel fds.
3064  */
3065  max = 0;
3066  for (x = 0; x < n; x++) {
3067  ast_channel_lock(c[x]);
3068  for (y = 0; y < ast_channel_fd_count(c[x]); y++) {
3069  fdmap[max].fdno = y; /* fd y is linked to this pfds */
3070  fdmap[max].chan = x; /* channel x is linked to this pfds */
3071  max += ast_add_fd(&pfds[max], ast_channel_fd(c[x], y));
3072  }
3073  CHECK_BLOCKING(c[x]);
3074  ast_channel_unlock(c[x]);
3075  }
3076  /* Add the individual fds */
3077  for (x = 0; x < nfds; x++) {
3078  fdmap[max].chan = -1;
3079  max += ast_add_fd(&pfds[max], fds[x]);
3080  }
3081 
3082  if (*ms > 0) {
3083  start = ast_tvnow();
3084  }
3085 
3086  if (sizeof(int) == 4) { /* XXX fix timeout > 600000 on linux x86-32 */
3087  do {
3088  int kbrms = rms;
3089  if (kbrms > 600000) {
3090  kbrms = 600000;
3091  }
3092  res = ast_poll(pfds, max, kbrms);
3093  if (!res) {
3094  rms -= kbrms;
3095  }
3096  } while (!res && (rms > 0));
3097  } else {
3098  res = ast_poll(pfds, max, rms);
3099  }
3100  for (x = 0; x < n; x++) {
3101  ast_channel_lock(c[x]);
3103  ast_channel_unlock(c[x]);
3104  }
3105  if (res < 0) { /* Simulate a timeout if we were interrupted */
3106  if (errno != EINTR) {
3107  *ms = -1;
3108  }
3109  return NULL;
3110  }
3111  if (!ast_tvzero(whentohangup)) { /* if we have a timeout, check who expired */
3112  now = ast_tvnow();
3113  for (x = 0; x < n; x++) {
3114  if (!ast_tvzero(*ast_channel_whentohangup(c[x])) && ast_tvcmp(*ast_channel_whentohangup(c[x]), now) <= 0) {
3115  ast_test_suite_event_notify("HANGUP_TIME", "Channel: %s", ast_channel_name(c[x]));
3117  if (winner == NULL) {
3118  winner = c[x];
3119  }
3120  }
3121  }
3122  }
3123  if (res == 0) { /* no fd ready, reset timeout and done */
3124  *ms = 0; /* XXX use 0 since we may not have an exact timeout. */
3125  return winner;
3126  }
3127  /*
3128  * Then check if any channel or fd has a pending event.
3129  * Remember to check channels first and fds last, as they
3130  * must have priority on setting 'winner'
3131  */
3132  for (x = 0; x < max; x++) {
3133  res = pfds[x].revents;
3134  if (res == 0) {
3135  continue;
3136  }
3137  if (fdmap[x].chan >= 0) { /* this is a channel */
3138  winner = c[fdmap[x].chan]; /* override previous winners */
3139  ast_channel_lock(winner);
3140  if (res & POLLPRI) {
3142  } else {
3144  }
3145  ast_channel_fdno_set(winner, fdmap[x].fdno);
3146  ast_channel_unlock(winner);
3147  } else { /* this is an fd */
3148  if (outfd) {
3149  *outfd = pfds[x].fd;
3150  }
3151  if (exception) {
3152  *exception = (res & POLLPRI) ? -1 : 0;
3153  }
3154  winner = NULL;
3155  }
3156  }
3157  if (*ms > 0) {
3158  *ms -= ast_tvdiff_ms(ast_tvnow(), start);
3159  if (*ms < 0) {
3160  *ms = 0;
3161  }
3162  }
3163  return winner;
3164 }
void ast_channel_fdno_set(struct ast_channel *chan, int value)
#define ast_channel_lock(chan)
Definition: channel.h:2945
Main Channel structure associated with a channel.
#define ast_set_flag(p, flag)
Definition: utils.h:70
static int ast_add_fd(struct pollfd *pfd, int fd)
if fd is a valid descriptor, set *pfd with the descriptor
Definition: channel.h:2842
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:108
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:150
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:98
#define NULL
Definition: resample.c:96
struct timeval * ast_channel_whentohangup(struct ast_channel *chan)
#define ast_poll(a, b, c)
Definition: poll-compat.h:88
#define ast_test_suite_event_notify(s, f,...)
Definition: test.h:196
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: astmm.h:290
int ast_tvcmp(struct timeval _a, struct timeval _b)
Compres two struct timeval instances returning -1, 0, 1 if the first arg is smaller, equal or greater to the second.
Definition: time.h:128
int errno
#define ast_channel_unlock(chan)
Definition: channel.h:2946
#define ast_clear_flag(p, flag)
Definition: utils.h:77
#define CHECK_BLOCKING(c)
Set the blocking indication on the channel.
Definition: channel.h:2894
int ast_channel_fd(const struct ast_channel *chan, int which)
const char * ast_channel_name(const struct ast_channel *chan)
int ast_channel_fd_count(const struct ast_channel *chan)
Retrieve the number of file decriptor positions present on the channel.
void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
struct timeval ast_tvsub(struct timeval a, struct timeval b)
Returns the difference of two timevals a - b.
Definition: extconf.c:2298
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
#define max(a, b)
Definition: f2c.h:198

◆ ast_waitfordigit()

int ast_waitfordigit ( struct ast_channel c,
int  ms 
)

Waits for a digit.

Parameters
cchannel to wait for a digit on
mshow many milliseconds to wait (<0 for indefinite).
Returns
Returns <0 on error, 0 on no entry, and the digit on success.
Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 3184 of file channel.c.

References ast_waitfordigit_full(), and NULL.

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

3185 {
3186  return ast_waitfordigit_full(c, ms, NULL, -1, -1);
3187 }
#define NULL
Definition: resample.c:96
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:3248

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

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

3249 {
3250  struct timeval start = ast_tvnow();
3251  int ms;
3252 
3253  /* Stop if we're a zombie or need a soft hangup */
3255  return -1;
3256 
3257  /* Only look for the end of DTMF, don't bother with the beginning and don't emulate things */
3259 
3260  /* Wait for a digit, no more than timeout_ms milliseconds total.
3261  * Or, wait indefinitely if timeout_ms is <0.
3262  */
3263  while ((ms = ast_remaining_ms(start, timeout_ms))) {
3264  struct ast_channel *rchan;
3265  int outfd = -1;
3266 
3267  errno = 0;
3268  /* While ast_waitfor_nandfds tries to help by reducing the timeout by how much was waited,
3269  * it is unhelpful if it waited less than a millisecond.
3270  */
3271  rchan = ast_waitfor_nandfds(&c, 1, &cmdfd, (cmdfd > -1) ? 1 : 0, NULL, &outfd, &ms);
3272 
3273  if (!rchan && outfd < 0 && ms) {
3274  if (errno == 0 || errno == EINTR)
3275  continue;
3276  ast_log(LOG_WARNING, "Wait failed (%s)\n", strerror(errno));
3278  return -1;
3279  } else if (outfd > -1) {
3280  /* The FD we were watching has something waiting */
3281  ast_log(LOG_WARNING, "The FD we were waiting for has something waiting. Waitfordigit returning numeric 1\n");
3283  return 1;
3284  } else if (rchan) {
3285  int res;
3286  struct ast_frame *f = ast_read(c);
3287 
3288  if (!f) {
3290 
3291  return -1;
3292  }
3293 
3294  switch (f->frametype) {
3295  case AST_FRAME_DTMF_BEGIN:
3296  break;
3297  case AST_FRAME_DTMF_END:
3298  res = f->subclass.integer;
3299  if (!breakon || strchr(breakon, res)) {
3300  ast_frfree(f);
3302  return res;
3303  }
3304  break;
3305  case AST_FRAME_CONTROL:
3306  switch (f->subclass.integer) {
3307  case AST_CONTROL_HANGUP:
3308  ast_frfree(f);
3310  return -1;
3316  /* Fall-through and treat as if it were a DTMF signal. Items
3317  * that perform stream control will handle this. */
3318  res = f->subclass.integer;
3319  ast_frfree(f);
3321  return res;
3323  case AST_CONTROL_RINGING:
3324  case AST_CONTROL_ANSWER:
3325  case AST_CONTROL_SRCUPDATE:
3326  case AST_CONTROL_SRCCHANGE:
3330  case AST_CONTROL_HOLD:
3331  case AST_CONTROL_UNHOLD:
3332  case AST_CONTROL_FLASH:
3333  case -1:
3334  /* Unimportant */
3335  break;
3336  default:
3337  ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", f->subclass.integer);
3338  break;
3339  }
3340  break;
3341  case AST_FRAME_VOICE:
3342  /* Write audio if appropriate */
3343  if (audiofd > -1) {
3344  if (write(audiofd, f->data.ptr, f->datalen) < 0) {
3345  ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
3346  }
3347  }
3348  default:
3349  /* Ignore */
3350  break;
3351  }
3352  ast_frfree(f);
3353  }
3354  }
3355 
3357 
3358  return 0; /* Time is up */
3359 }
Main Channel structure associated with a channel.
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define LOG_WARNING
Definition: logger.h:274
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:150
#define NULL
Definition: resample.c:96
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:2997
struct ast_frame_subclass subclass
int ast_check_hangup(struct ast_channel *chan)
Checks to see if a channel is needing hang up.
Definition: channel.c:445
#define ast_log
Definition: astobj2.c:42
void ast_channel_clear_flag(struct ast_channel *chan, unsigned int flag)
Definition: channel.c:11235
void ast_channel_set_flag(struct ast_channel *chan, unsigned int flag)
Set a flag on a channel.
Definition: channel.c:11228
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
Definition: main/utils.c:2033
int errno
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4302
#define ast_frfree(fr)
Data structure associated with a single frame of data.
union ast_frame::@263 data
enum ast_frame_type frametype
struct ast_flags * ast_channel_flags(struct ast_channel *chan)

◆ 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.
Examples:
/usr/src/asterisk-18.5.0/main/app.c.

Definition at line 5189 of file channel.c.

References ast_write_stream().

Referenced by adsi_careful_send(), ast_prod(), ast_readaudio_callback(), ast_readvideo_callback(), AST_TEST_DEFINE(), ast_write_video(), audiosocket_run(), conf_queue_dtmf(), conf_run(), dictate_exec(), echo_exec(), fax_gateway_detect_v21(), fax_generator_generate(), gen_generate(), generic_fax_exec(), handle_jack_audio(), iax2_key_rotate(), jb_get_and_deliver(), linear_generator(), milliwatt_generate(), misdn_write(), moh_files_generator(), moh_generate(), mp3_exec(), NBScat_exec(), playtones_generator(), send_waveform_to_channel(), silence_generator_generate(), sms_generate(), spandsp_fax_gw_t30_gen(), spy_generate(), t38_tx_packet_handler(), tonepair_generator(), and wait_for_answer().

5190 {
5191  return ast_write_stream(chan, -1, fr);
5192 }
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:5194

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

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_insmpl(), ast_channel_lock, ast_channel_monitor(), ast_channel_name(), ast_channel_nativeformats(), ast_channel_outsmpl(), ast_channel_outsmpl_set(), ast_channel_rawwriteformat(), ast_channel_softhangup_internal_flag_add(), ast_channel_tech(), 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_sample_rate(), 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_log, AST_MEDIA_TYPE_IMAGE, AST_MEDIA_TYPE_UNKNOWN, AST_MONITOR_RUNNING, ast_opt_generic_plc, ast_seekstream(), 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(), ast_writestream(), calc_monitor_jump(), 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, LOG_WARNING, chanlist::next, NULL, ast_frame::ptr, ast_frame::samples, SEEK_FORCECUR, send_dtmf_begin_event(), send_dtmf_end_event(), ast_channel_tech::send_html, ast_channel_tech::send_text, ast_frame::src, 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_write(), bridge_channel_handle_write(), and stream_echo_write().

5195 {
5196  struct ast_stream *stream = NULL, *default_stream = NULL;
5197  int res = -1;
5198  struct ast_frame *f = NULL;
5199  int count = 0;
5200  int hooked = 0;
5201 
5202  /*Deadlock avoidance*/
5203  while(ast_channel_trylock(chan)) {
5204  /*cannot goto done since the channel is not locked*/
5205  if(count++ > 10) {
5206  ast_debug(1, "Deadlock avoided for write to channel '%s'\n", ast_channel_name(chan));
5207  return 0;
5208  }
5209  usleep(1);
5210  }
5211 
5212  /* Stop if we're a zombie or need a soft hangup */
5214  goto done;
5215  }
5216 
5217  if (stream_num >= 0) {
5218  /* If we were told to write to an explicit stream then allow this frame through, no matter
5219  * if the type is expected or not (a framehook could change)
5220  */
5222  goto done;
5223  }
5225  default_stream = ast_channel_get_default_stream(chan, ast_stream_get_type(stream));
5226  } else if (fr->frametype == AST_FRAME_VOICE || fr->frametype == AST_FRAME_VIDEO || fr->frametype == AST_FRAME_MODEM) {
5227  /* If we haven't been told of a stream then we need to figure out which once we need */
5229 
5230  /* Some frame types have a fixed media type */
5231  if (fr->frametype == AST_FRAME_VOICE || fr->frametype == AST_FRAME_VIDEO) {
5232  type = ast_format_get_type(fr->subclass.format);
5233  } else if (fr->frametype == AST_FRAME_MODEM) {
5234  type = AST_MEDIA_TYPE_IMAGE;
5235  }
5236 
5237  /* No stream was specified, so use the default one */
5238  stream = default_stream = ast_channel_get_default_stream(chan, type);
5239  }
5240 
5241  /* Perform the framehook write event here. After the frame enters the framehook list
5242  * there is no telling what will happen, how awesome is that!!! */
5243  if ((stream == default_stream) && !(fr = ast_framehook_list_write_event(ast_channel_framehooks(chan), fr))) {
5244  res = 0;
5245  goto done;
5246  }
5247 
5248  if (ast_channel_generatordata(chan) && (fr->frametype != AST_FRAME_RTCP) && (!fr->src || strcasecmp(fr->src, "ast_prod"))) {
5251  } else {
5252  if (fr->frametype == AST_FRAME_DTMF_END) {
5253  /* There is a generator running while we're in the middle of a digit.
5254  * It's probably inband DTMF, so go ahead and pass it so it can
5255  * stop the generator */
5256  ast_channel_unlock(chan);
5257  res = ast_senddigit_end(chan, fr->subclass.integer, fr->len);
5258  ast_channel_lock(chan);
5259  } else if (fr->frametype == AST_FRAME_CONTROL
5260  && fr->subclass.integer == AST_CONTROL_UNHOLD) {
5261  /*
5262  * This is a side case where Echo is basically being called
5263  * and the person put themselves on hold and took themselves
5264  * off hold.
5265  */
5266  indicate_data_internal(chan, fr->subclass.integer, fr->data.ptr,
5267  fr->datalen);
5268  }
5269  res = 0; /* XXX explain, why 0 ? */
5270  goto done;
5271  }
5272  }
5273  /* High bit prints debugging */
5274  if (ast_channel_fout(chan) & DEBUGCHAN_FLAG)
5275  ast_frame_dump(ast_channel_name(chan), fr, ">>");
5276  switch (fr->frametype) {
5277  case AST_FRAME_CONTROL:
5278  indicate_data_internal(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
5279  res = 0;
5280  break;
5281  case AST_FRAME_DTMF_BEGIN:
5282  if (ast_channel_audiohooks(chan)) {
5283  struct ast_frame *old_frame = fr;
5285  if (old_frame != fr)
5286  f = fr;
5287  }
5288  send_dtmf_begin_event(chan, DTMF_SENT, fr->subclass.integer);
5289  ast_channel_unlock(chan);
5290  res = ast_senddigit_begin(chan, fr->subclass.integer);
5291  ast_channel_lock(chan);
5292  break;
5293  case AST_FRAME_DTMF_END:
5294  if (ast_channel_audiohooks(chan)) {
5295  struct ast_frame *new_frame = fr;
5296 
5298  if (new_frame != fr) {
5299  ast_frfree(new_frame);
5300  }
5301  }
5302  send_dtmf_end_event(chan, DTMF_SENT, fr->subclass.integer, fr->len);
5303  ast_channel_unlock(chan);
5304  res = ast_senddigit_end(chan, fr->subclass.integer, fr->len);
5305  ast_channel_lock(chan);
5306  break;
5307  case AST_FRAME_TEXT:
5308  CHECK_BLOCKING(chan);
5309  if (ast_format_cmp(fr->subclass.format, ast_format_t140) == AST_FORMAT_CMP_EQUAL) {
5310  res = (ast_channel_tech(chan)->write_text == NULL) ? 0 :
5311  ast_channel_tech(chan)->write_text(chan, fr);
5312  } else {
5313  res = (ast_channel_tech(chan)->send_text == NULL) ? 0 :
5314  ast_channel_tech(chan)->send_text(chan, (char *) fr->data.ptr);
5315  }
5317  break;
5318  case AST_FRAME_HTML:
5319  CHECK_BLOCKING(chan);
5320  res = (ast_channel_tech(chan)->send_html == NULL) ? 0 :
5321  ast_channel_tech(chan)->send_html(chan, fr->subclass.integer, (char *) fr->data.ptr, fr->datalen);
5323  break;
5324  case AST_FRAME_VIDEO:
5325  /* XXX Handle translation of video codecs one day XXX */
5326  CHECK_BLOCKING(chan);
5327  if (ast_channel_tech(chan)->write_stream) {
5328  if (stream) {
5329  res = ast_channel_tech(chan)->write_stream(chan, ast_stream_get_position(stream), fr);
5330  } else {
5331  res = 0;
5332  }
5333  } else if ((stream == default_stream) && ast_channel_tech(chan)->write_video) {
5334  res = ast_channel_tech(chan)->write_video(chan, fr);
5335  } else {
5336  res = 0;
5337  }
5339  break;
5340  case AST_FRAME_MODEM:
5341  CHECK_BLOCKING(chan);
5342  res = tech_write(chan, stream, default_stream, fr);
5344  break;
5345  case AST_FRAME_VOICE:
5346  if (ast_opt_generic_plc && ast_format_cmp(fr->subclass.format, ast_format_slin) == AST_FORMAT_CMP_EQUAL) {
5347  apply_plc(chan, fr);
5348  }
5349 
5350  f = fr;
5351 
5352  /*
5353  * Send frame to audiohooks if present, if frametype is linear (else, later as per
5354  * previous behavior)
5355  */
5356  if ((stream == default_stream) && ast_channel_audiohooks(chan)) {
5357  if (ast_format_cache_is_slinear(fr->subclass.format)) {
5358  hooked = 1;
5360  }
5361  }
5362 
5363  /* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */
5364  if ((stream == default_stream) && ast_format_cmp(fr->subclass.format, ast_channel_rawwriteformat(chan)) != AST_FORMAT_CMP_EQUAL) {
5365  if (ast_format_cmp(ast_channel_writeformat(chan), fr->subclass.format) != AST_FORMAT_CMP_EQUAL) {
5366  struct ast_str *codec_buf = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
5367 
5368  /*
5369  * We are not setup to write this frame. Things may have changed
5370  * on the peer side of the world and we try to adjust the format to
5371  * make it compatible again. However, bad things can happen if we
5372  * cannot setup a new translation path. Problems range from no
5373  * audio, one-way audio, to garbled audio. The best we can do is
5374  * request the call to hangup since we could not make it compatible.
5375  *
5376  * Being continuously spammed by this message likely indicates a
5377  * problem with the peer because it cannot make up its mind about
5378  * which format to use.
5379  */
5380  ast_debug(1, "Channel %s changing write format from %s to %s, native formats %s\n",
5381  ast_channel_name(chan),
5383  ast_format_get_name(fr->subclass.format),
5385  if (ast_set_write_format(chan, fr->subclass.format)) {
5386  /* Could not handle the new write format. Induce a hangup. */
5387  break;
5388  }
5389  }
5390 
5391  if (ast_channel_writetrans(chan)) {
5392  struct ast_frame *trans_frame = ast_translate(ast_channel_writetrans(chan), f, 0);
5393  if (trans_frame != f && f != fr) {
5394  /*
5395  * If translate gives us a new frame and so did the audio
5396  * hook then we need to free the one from the audio hook.
5397  */
5398  ast_frfree(f);
5399  }
5400  f = trans_frame;
5401  }
5402  }
5403 
5404  if (!f) {
5405  res = 0;
5406  break;
5407  }
5408 
5409  if ((stream == default_stream) && ast_channel_audiohooks(chan) && !hooked) {
5410  struct ast_frame *prev = NULL, *new_frame, *cur, *dup;
5411  int freeoldlist = 0;
5412 
5413  if (f != fr) {
5414  freeoldlist = 1;
5415  }
5416 
5417  /* Since ast_audiohook_write may return a new frame, and the cur frame is
5418  * an item in a list of frames, create a new list adding each cur frame back to it
5419  * regardless if the cur frame changes or not. */
5420  for (cur = f; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
5422 
5423  /* if this frame is different than cur, preserve the end of the list,
5424  * free the old frames, and set cur to be the new frame */
5425  if (new_frame != cur) {
5426 
5427  /* doing an ast_frisolate here seems silly, but we are not guaranteed the new_frame
5428  * isn't part of local storage, meaning if ast_audiohook_write is called multiple
5429  * times it may override the previous frame we got from it unless we dup it */
5430  if ((dup = ast_frisolate(new_frame))) {
5432  if (freeoldlist) {
5433  AST_LIST_NEXT(cur, frame_list) = NULL;
5434  ast_frfree(cur);
5435  }
5436  if (new_frame != dup) {
5437  ast_frfree(new_frame);
5438  }
5439  cur = dup;
5440  }
5441  }
5442 
5443  /* now, regardless if cur is new or not, add it to the new list,
5444  * if the new list has not started, cur will become the first item. */
5445  if (prev) {
5446  AST_LIST_NEXT(prev, frame_list) = cur;
5447  } else {
5448  f = cur; /* set f to be the beginning of our new list */
5449  }
5450  prev = cur;
5451  }
5452  }
5453 
5454  /* If Monitor is running on this channel, then we have to write frames out there too */
5455  /* the translator on chan->writetrans may have returned multiple frames
5456  from the single frame we passed in; if so, feed each one of them to the
5457  monitor */
5458  if ((stream == default_stream) && ast_channel_monitor(chan) && ast_channel_monitor(chan)->write_stream) {
5459  struct ast_frame *cur;
5460 
5461  for (cur = f; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
5462  /* XXX must explain this code */
5463 #ifndef MONITOR_CONSTANT_DELAY
5464  int jump = ast_channel_insmpl(chan) - ast_channel_outsmpl(chan) - 4 * cur->samples;
5465  if (jump >= 0) {
5469  if (ast_seekstream(ast_channel_monitor(chan)->write_stream, jump, SEEK_FORCECUR) == -1) {
5470  ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n");
5471  }
5473  } else {
5475  }
5476 #else
5477  int jump = calc_monitor_jump((ast_channel_insmpl(chan) - ast_channel_outsmpl(chan)),
5480  if (jump - MONITOR_DELAY >= 0) {
5481  if (ast_seekstream(ast_channel_monitor(chan)->write_stream, jump - cur->samples, SEEK_FORCECUR) == -1) {
5482  ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n");
5483  }
5485  } else {
5487  }
5488 #endif
5490  if (ast_writestream(ast_channel_monitor(chan)->write_stream, cur) < 0)
5491  ast_log(LOG_WARNING, "Failed to write data to channel monitor write stream\n");
5492  }
5493  }
5494  }
5495 
5496  /* the translator on chan->writetrans may have returned multiple frames
5497  from the single frame we passed in; if so, feed each one of them to the
5498  channel, freeing each one after it has been written */
5499  CHECK_BLOCKING(chan);
5500  if ((f != fr) && AST_LIST_NEXT(f, frame_list)) {
5501  struct ast_frame *cur, *next = NULL;
5502  unsigned int skip = 0;
5503 
5504  cur = f;
5505  while (cur) {
5506  next = AST_LIST_NEXT(cur, frame_list);
5507  AST_LIST_NEXT(cur, frame_list) = NULL;
5508  if (!skip) {
5509  res = tech_write(chan, stream, default_stream, cur);
5510  if (res < 0) {
5512  skip = 1;
5513  } else if (next) {
5514  /* don't do this for the last frame in the list,
5515  as the code outside the loop will do it once
5516  */
5518  }
5519  }
5520  ast_frfree(cur);
5521  cur = next;
5522  }
5523 
5524  /* reset f so the code below doesn't attempt to free it */
5525  f = NULL;
5526  } else {
5527  res = tech_write(chan, stream, default_stream, f);
5528  }
5530  break;
5531  case AST_FRAME_NULL:
5532  case AST_FRAME_IAX:
5533  /* Ignore these */
5534  res = 0;
5535  break;
5536  case AST_FRAME_RTCP:
5537  /* RTCP information is on a per-stream basis and only available on multistream capable channels */
5538  CHECK_BLOCKING(chan);
5539  if (ast_channel_tech(chan)->write_stream && stream) {
5540  res = ast_channel_tech(chan)->write_stream(chan, ast_stream_get_position(stream), fr);
5541  } else {
5542  res = 0;
5543  }
5545  break;
5546  default:
5547  /* At this point, fr is the incoming frame and f is NULL. Channels do
5548  * not expect to get NULL as a frame pointer and will segfault. Hence,
5549  * we output the original frame passed in. */
5550  CHECK_BLOCKING(chan);
5551  res = ast_channel_tech(chan)->write(chan, fr);
5553  break;
5554  }
5555 
5556  if (f && f != fr)
5557  ast_frfree(f);
5558 
5559  /* Consider a write failure to force a soft hangup */
5560  if (res < 0) {
5562  } else {
5564  }
5565 done:
5567  /* The list gets recreated if audiohooks are added again later */
5570  }
5571  ast_channel_unlock(chan);
5572  return res;
5573 }
static const char type[]
Definition: chan_ooh323.c:109
#define ast_channel_lock(chan)
Definition: channel.h:2945
enum ast_media_type ast_format_get_type(const struct ast_format *format)
Get the media type of a format.
Definition: format.c:354
void * ast_channel_generatordata(const struct ast_channel *chan)
int(*const write_video)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format.
Definition: channel.h:787
struct ast_stream_topology * ast_channel_get_stream_topology(const struct ast_channel *chan)
Retrieve the topology of streams on a channel.
#define DEBUGCHAN_FLAG
Definition: channel.h:858
static int calc_monitor_jump(int samples, int sample_rate, int seek_rate)
calculates the number of samples to jump forward with in a monitor stream.
Definition: channel.c:3516
int(*const write)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format (see frame.h)
Definition: channel.h:751
#define ast_test_flag(p, flag)
Definition: utils.h:63
static void send_dtmf_begin_event(struct ast_channel *chan, enum DtmfDirection direction, const char digit)
Definition: channel.c:3378
unsigned int ast_channel_fout(const struct ast_channel *chan)
void ast_audiohook_detach_list(struct ast_audiohook_list *audiohook_list)
Detach audiohooks from list and destroy said list.
Definition: audiohook.c:594
int ast_audiohook_write_list_empty(struct ast_audiohook_list *audiohook_list)
Determine if a audiohook_list is empty or not.
Definition: audiohook.c:1112
enum ast_media_type ast_stream_get_type(const struct ast_stream *stream)
Get the media type of a stream.
Definition: stream.c:316
struct ast_framehook_list * ast_channel_framehooks(const struct ast_channel *chan)
#define LOG_WARNING
Definition: logger.h:274
unsigned long ast_channel_insmpl(const struct ast_channel *chan)
#define AST_FORMAT_CAP_NAMES_LEN
Definition: format_cap.h:326
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
Definition: linkedlists.h:438
static void write_stream(struct ogg_vorbis_desc *s, FILE *f)
Write out any pending encoded data.
void ast_channel_audiohooks_set(struct ast_channel *chan, struct ast_audiohook_list *value)
void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
Definition: main/frame.c:731
int ast_senddigit_begin(struct ast_channel *chan, char digit)
Send a DTMF digit to a channel.
Definition: channel.c:4919
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:565
#define ast_str_alloca(init_len)
Definition: strings.h:800
const char * ast_format_get_name(const struct ast_format *format)
Get the name associated with a format.
Definition: format.c:334
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:788
#define NULL
Definition: resample.c:96
const char * data
struct ast_frame_subclass subclass
int done
Definition: test_amihooks.c:48
static int indicate_data_internal(struct ast_channel *chan, int _condition, const void *data, size_t datalen)
Definition: channel.c:4515
int ast_check_hangup(struct ast_channel *chan)
Checks to see if a channel is needing hang up.
Definition: channel.c:445
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
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
int(*const send_html)(struct ast_channel *chan, int subclass, const char *data, int len)
Send HTML data.
Definition: channel.h:763
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_trans_pvt * ast_channel_writetrans(const struct ast_channel *chan)
int(*const write_text)(struct ast_channel *chan, struct ast_frame *frame)
Write a text frame, in standard format.
Definition: channel.h:790
static int tech_write(struct ast_channel *chan, struct ast_stream *stream, struct ast_stream *default_stream, struct ast_frame *frame)
Definition: channel.c:5177
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition: channel.c:4969
int(*const send_text)(struct ast_channel *chan, const char *text)
Display or transmit text.
Definition: channel.h:757
#define ast_opt_generic_plc
Definition: options.h:134
static void apply_plc(struct ast_channel *chan, struct ast_frame *frame)
Definition: channel.c:5151
int ast_format_cache_is_slinear(struct ast_format *format)
Determines if a format is one of the cached slin formats.
Definition: format_cache.c:542
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:1127
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:754
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
void ast_channel_fout_set(struct ast_channel *chan, unsigned int value)
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:736
struct ast_frame * ast_framehook_list_write_event(struct ast_framehook_list *framehooks, struct ast_frame *frame)
This is used by the channel API push a frame write event to a channel&#39;s framehook list...
Definition: framehook.c:313
int ast_seekstream(struct ast_filestream *fs, off_t sample_offset, int whence)
Seeks into stream.
Definition: file.c:1038
#define ast_channel_unlock(chan)
Definition: channel.h:2946
#define SEEK_FORCECUR
Definition: file.h:51
#define FRAMECOUNT_INC(x)
Definition: channel.h:861
#define ast_frisolate(fr)
Makes a frame independent of any static storage.
void ast_deactivate_generator(struct ast_channel *chan)
Definition: channel.c:2902
int ast_stream_topology_get_count(const struct ast_stream_topology *topology)
Get the number of streams in a topology.
Definition: stream.c:765
#define ast_clear_flag(p, flag)
Definition: utils.h:77
#define CHECK_BLOCKING(c)
Set the blocking indication on the channel.
Definition: channel.h:2894
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
static void send_dtmf_end_event(struct ast_channel *chan, enum DtmfDirection direction, const char digit, long duration_ms)
Definition: channel.c:3394
const char * ast_channel_name(const struct ast_channel *chan)
int ast_writestream(struct ast_filestream *fs, struct ast_frame *f)
Writes a frame to a stream.
Definition: file.c:209
struct ast_frame * next
unsigned int ast_format_get_sample_rate(const struct ast_format *format)
Get the sample rate of a media format.
Definition: format.c:379
#define ast_frfree(fr)
Data structure associated with a single frame of data.
void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
unsigned long ast_channel_outsmpl(const struct ast_channel *chan)
ast_media_type
Types of media.
Definition: codec.h:30
#define ast_channel_trylock(chan)
Definition: channel.h:2947
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
struct ast_format * format
struct ast_audiohook_list * ast_channel_audiohooks(const struct ast_channel *chan)
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_format * ast_format_t140
Built-in cached t140 format.
Definition: format_cache.c:236
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
Definition: format_cache.c:41
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
Definition: channel.c:5890
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
struct ast_channel_monitor * ast_channel_monitor(const struct ast_channel *chan)
struct ast_format * ast_channel_rawwriteformat(struct ast_channel *chan)
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
void ast_channel_outsmpl_set(struct ast_channel *chan, unsigned long value)

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

References ast_channel_tech(), and ast_write().

5063 {
5064  int res;
5065  if (!ast_channel_tech(chan)->write_video)
5066  return 0;
5067  res = ast_write(chan, fr);
5068  if (!res)
5069  res = 1;
5070  return res;
5071 }
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:5189
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [1/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() [2/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( language  )

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [3/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( musicclass  )

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [4/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( latest_musicclass  )

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [5/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( accountcode  )

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [6/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( peeraccount  )

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [7/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( userfield  )

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [8/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( call_forward  )

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [9/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( uniqueid  )

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [10/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( linkedid  )

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [11/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( parkinglot  )

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [12/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( hangupsource  )

◆ DECLARE_STRINGFIELD_SETTERS_FOR() [13/13]

DECLARE_STRINGFIELD_SETTERS_FOR ( dialcontext  )

Variable Documentation

◆ ast_kill_tech

const struct ast_channel_tech ast_kill_tech

Kill the channel channel driver technology descriptor.

Kill the channel channel driver technology descriptor.

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

Note
Used by DTMF atxfer and zombie channels.

Definition at line 434 of file channel.c.

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

Referenced by ast_channel_stream_topology_changed_externally().

◆ global_fin

unsigned long global_fin

The current value of the debug flags is stored in the two variables global_fin and global_fout (declared in main/channel.c)

Definition at line 95 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 95 of file channel.c.

Referenced by __ast_channel_alloc_ap(), and handle_core_set_debug_channel().