Asterisk - The Open Source Telephony Project  21.4.1
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"

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_tech
 Structure to describe a channel "technology", ie a channel driver See for examples: More...
 
struct  ast_datastore_list
 
struct  ast_generator
 
struct  ast_group_info
 channel group info More...
 
struct  ast_hangup_handler
 
struct  ast_hangup_handler_list
 
struct  ast_party_caller
 Caller Party information. More...
 
struct  ast_party_connected_line
 Connected Line/Party information. More...
 
struct  ast_party_dialed
 Dialed/Called Party information. More...
 
struct  ast_party_id
 Information needed to identify an endpoint in a call. More...
 
struct  ast_party_name
 Information needed to specify a name in a call. More...
 
struct  ast_party_number
 Information needed to specify a number in a call. More...
 
struct  ast_party_redirecting
 Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call diversion or transfer was invoked. More...
 
struct  ast_party_redirecting_reason
 Redirecting reason information. More...
 
struct  ast_party_subaddress
 Information needed to specify a subaddress in a call. More...
 
struct  ast_readq_list
 
struct  ast_set_party_caller
 Indicate what information in ast_party_caller should be set. More...
 
struct  ast_set_party_connected_line
 Indicate what information in ast_party_connected_line should be set. More...
 
struct  ast_set_party_id
 Indicate what information in ast_party_id should be set. More...
 
struct  ast_set_party_redirecting
 Indicate what information in ast_party_redirecting should be set. More...
 
struct  outgoing_helper
 

Macros

#define AST_AGENT_FD   (AST_MAX_FDS-3)
 
#define AST_ALERT_FD   (AST_MAX_FDS-1)
 
#define AST_BRIDGE_DTMF_CHANNEL_0   (1 << 0)
 Report DTMF on channel 0.
 
#define AST_BRIDGE_DTMF_CHANNEL_1   (1 << 1)
 Report DTMF on channel 1.
 
#define AST_CHAN_WRITE_INFO_T_VERSION   1
 ast_chan_write_info_t version. Must be incremented if structure is changed
 
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag, ...)
 Create a channel structure. 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.
 
#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
 
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.
 
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.
 

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 cause) 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)
 Clear a flag on a channel. More...
 
void ast_channel_clear_softhangup (struct ast_channel *chan, int flag)
 Clear a set of softhangup flags from a channel. More...
 
int ast_channel_cmpwhentohangup_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_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.
 
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_lastcontext (const struct ast_channel *chan)
 
const char * ast_channel_lastexten (const struct ast_channel *chan)
 
const char * ast_channel_latest_musicclass (const struct ast_channel *chan)
 
const char * ast_channel_linkedid (const struct ast_channel *chan)
 
int ast_channel_make_compatible (struct ast_channel *chan, struct ast_channel *peer)
 Make the frame formats of two channels compatible. 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)
 
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_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)
 
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
 
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.
 
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.
 
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.
 
int ast_prod (struct ast_channel *chan)
 Send empty audio to prime a channel driver.
 
int ast_queue_answer (struct ast_channel *chan, const struct ast_stream_topology *topology)
 Queue an ANSWER control frame with topology. 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 cause)
 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 cause)
 Softly hangup up a channel (no channel lock) More...
 
const char * ast_state2str (enum ast_channel_state 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 **c, 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.
 
unsigned long global_fin
 
unsigned long global_fout
 

Detailed Description

General Asterisk PBX channel definitions.

See also:

Definition in file channel.h.

Macro Definition Documentation

#define AST_AGENT_FD   (AST_MAX_FDS-3)

used by agents for pass through

Definition at line 202 of file channel.h.

#define AST_ALERT_FD   (AST_MAX_FDS-1)

used for alertpipe

Definition at line 200 of file channel.h.

Referenced by __ast_channel_alloc_ap().

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

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

Referenced by ast_channel_yank(), ast_iax2_new(), ast_pbx_outgoing_exten_predial(), ast_unreal_new_channels(), audiosocket_request(), console_new(), handle_exec(), multicast_rtp_request(), stasis_app_control_snoop(), unicast_rtp_request(), and unistim_new().

#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__)
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:954

Definition at line 1262 of file channel.h.

#define ast_channel_cleanup (   c)    ({ ao2_cleanup(c); (struct ast_channel *) (NULL); })
#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 4948 of file channel.h.

#define AST_CHANNEL_NAME   80
#define ast_channel_ref (   c)    ({ ao2_ref(c, +1); (c); })
#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 2958 of file channel.h.

Referenced by __ast_channel_alloc_ap(), acf_odbc_write(), action_add_agi_cmd(), action_redirect(), action_status(), 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_manager_hangup_helper(), ast_parse_device_state(), ast_pickup_call(), ast_pickup_find_by_group(), ast_rtp_instance_set_stats_vars(), ast_str_substitute_variables_full2(), ast_unreal_channel_push_to_bridge(), ast_unreal_hangup(), ast_unreal_indicate(), ast_unreal_lock_all(), ast_unreal_queryoption(), ast_unreal_setoption(), bridge_agent_hold_push(), bridge_exec(), channel_do_masquerade(), handle_cli_agi_add_cmd(), handle_eval_function(), handle_redirect(), handle_show_chanvar(), handle_show_hangup_all(), handle_show_hangup_channel(), handle_showchan(), jingle_action_session_accept(), jingle_action_session_info(), jingle_action_session_terminate(), jingle_interpret_content(), jingle_outgoing_hook(), jingle_queue_hangup_with_cause(), local_call(), make_email_file(), manager_mute_mixmonitor(), pbx_substitute_variables_helper_full_location(), pickup_by_channel(), pickup_by_exten(), pickup_by_group(), pickup_by_mark(), pickup_by_part(), rtp_check_timeout(), stasis_app_channel_unreal_set_internal(), and unreal_queue_frame().

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

Referenced by acf_odbc_write(), ast_add_extension2_lockopt(), ast_cel_fabricate_channel_from_event(), ast_str_substitute_variables_full2(), handle_eval_function(), make_email_file(), and pbx_substitute_variables_helper_full_location().

#define AST_EXTENDED_FDS   12

the start of extended file descriptor positions

Definition at line 195 of file channel.h.

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

#define AST_FEATURE_DTMF_MASK
Value:
(AST_FEATURE_REDIRECT | AST_FEATURE_DISCONNECT |\
AST_FEATURE_ATXFER | AST_FEATURE_AUTOMON | AST_FEATURE_PARKCALL | AST_FEATURE_AUTOMIXMON)

Definition at line 1072 of file channel.h.

#define AST_GENERATOR_FD   (AST_MAX_FDS-4)

used by generator

Definition at line 203 of file channel.h.

Referenced by __ast_read(), and channel_do_masquerade().

#define AST_JITTERBUFFER_FD   (AST_MAX_FDS-5)

used by generator

Definition at line 204 of file channel.h.

Referenced by __ast_read(), and ast_jb_create_framehook().

#define AST_MAX_ACCOUNT_CODE   80

Max length of an account code

Definition at line 170 of file channel.h.

#define AST_MAX_CONTEXT   80

Max length of a context

Definition at line 135 of file channel.h.

Referenced by feature_attended_transfer(), handle_call_forward(), handle_show_hint(), handle_show_hints(), iax2_exec(), and run_externnotify().

#define AST_MAX_EXTENSION   80
#define AST_MAX_FDS   11

original maximum number of file descriptors

Definition at line 194 of file channel.h.

#define AST_MAX_PUBLIC_UNIQUEID   149

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

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

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

Definition at line 147 of file channel.h.

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

#define AST_MAX_USER_FIELD   256

Max length of the channel user field

Definition at line 174 of file channel.h.

Referenced by ast_rtp_instance_set_stats_vars(), and ast_variable_list_join().

#define AST_NUM_CHANNEL_BUCKETS   1567

The number of buckets to store channels or channel information

Definition at line 155 of file channel.h.

Referenced by ast_channels_init(), and ast_stasis_channels_init().

#define AST_TIMING_FD   (AST_MAX_FDS-2)

used for timingfd

Definition at line 201 of file channel.h.

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

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

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

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

Referenced by __ast_read(), and ast_write_stream().

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

Definition at line 4038 of file channel.h.

#define MAX_LANGUAGE   40

Max length of the language setting

Definition at line 172 of file channel.h.

#define MAX_MUSICCLASS   80

Max length of the music class setting

Definition at line 173 of file channel.h.

Typedef Documentation

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

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

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

Enumeration Type Documentation

anonymous enum

ast_channel_tech Properties

Enumerator
AST_CHAN_TP_WANTSJITTER 

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

AST_CHAN_TP_CREATESJITTER 

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

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

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

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

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

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

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

Definition at line 242 of file channel.h.

242  {
243  AST_PARTY_CHAR_SET_UNKNOWN = 0,
244  AST_PARTY_CHAR_SET_ISO8859_1 = 1,
245  AST_PARTY_CHAR_SET_WITHDRAWN = 2,/* ITU withdrew this enum value. */
246  AST_PARTY_CHAR_SET_ISO8859_2 = 3,
247  AST_PARTY_CHAR_SET_ISO8859_3 = 4,
248  AST_PARTY_CHAR_SET_ISO8859_4 = 5,
249  AST_PARTY_CHAR_SET_ISO8859_5 = 6,
250  AST_PARTY_CHAR_SET_ISO8859_7 = 7,
251  AST_PARTY_CHAR_SET_ISO10646_BMPSTRING = 8,
252  AST_PARTY_CHAR_SET_ISO10646_UTF_8STRING = 9,
253 };

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

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

Function Documentation

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

References 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_frisolate, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_HEAD_NOLOCK, AST_LIST_INSERT_HEAD, AST_LIST_REMOVE_HEAD, ast_queue_frame_head(), ast_raw_answer(), ast_read(), ast_remaining_ms(), AST_STATE_RING, AST_STATE_RINGING, ast_tvnow(), ast_waitfor(), ast_frame::frametype, ast_frame_subclass::integer, and ast_frame::subclass.

Referenced by ast_answer().

2696 {
2697  int res = 0;
2698  enum ast_channel_state old_state;
2699  SCOPE_TRACE(1, "%s\n", ast_channel_name(chan));
2700 
2701  old_state = ast_channel_state(chan);
2702  if ((res = ast_raw_answer(chan))) {
2703  return res;
2704  }
2705 
2706  switch (old_state) {
2707  case AST_STATE_RINGING:
2708  case AST_STATE_RING:
2709  /* wait for media to start flowing, but don't wait any longer
2710  * than 'delay' or 500 milliseconds, whichever is longer
2711  */
2712  do {
2713  AST_LIST_HEAD_NOLOCK(, ast_frame) frames;
2714  struct ast_frame *cur;
2715  struct ast_frame *new_frame;
2716  int timeout_ms = MAX(delay, 500);
2717  unsigned int done = 0;
2718  struct timeval start;
2719 
2720  AST_LIST_HEAD_INIT_NOLOCK(&frames);
2721 
2722  start = ast_tvnow();
2723  for (;;) {
2724  int ms = ast_remaining_ms(start, timeout_ms);
2725  ms = ast_waitfor(chan, ms);
2726  if (ms < 0) {
2727  ast_log(LOG_WARNING, "Error condition occurred when polling channel %s for a voice frame: %s\n", ast_channel_name(chan), strerror(errno));
2728  res = -1;
2729  break;
2730  }
2731  if (ms == 0) {
2732  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));
2733  break;
2734  }
2735  cur = ast_read(chan);
2736  if (!cur || ((cur->frametype == AST_FRAME_CONTROL) &&
2737  (cur->subclass.integer == AST_CONTROL_HANGUP))) {
2738  if (cur) {
2739  ast_frfree(cur);
2740  }
2741  res = -1;
2742  ast_debug(2, "Hangup of channel %s detected in answer routine\n", ast_channel_name(chan));
2743  break;
2744  }
2745 
2746  if ((new_frame = ast_frisolate(cur)) != cur) {
2747  ast_frfree(cur);
2748  }
2749 
2750  AST_LIST_INSERT_HEAD(&frames, new_frame, frame_list);
2751 
2752  /* if a specific delay period was requested, continue
2753  * until that delay has passed. don't stop just because
2754  * incoming media has arrived.
2755  */
2756  if (delay) {
2757  continue;
2758  }
2759 
2760  switch (new_frame->frametype) {
2761  /* all of these frametypes qualify as 'media' */
2762  case AST_FRAME_VOICE:
2763  case AST_FRAME_VIDEO:
2764  case AST_FRAME_TEXT:
2765  case AST_FRAME_TEXT_DATA:
2766  case AST_FRAME_DTMF_BEGIN:
2767  case AST_FRAME_DTMF_END:
2768  case AST_FRAME_IMAGE:
2769  case AST_FRAME_HTML:
2770  case AST_FRAME_MODEM:
2771  case AST_FRAME_RTCP:
2772  done = 1;
2773  break;
2774  case AST_FRAME_CONTROL:
2775  case AST_FRAME_IAX:
2778  case AST_FRAME_NULL:
2779  case AST_FRAME_CNG:
2780  break;
2781  }
2782 
2783  if (done) {
2784  break;
2785  }
2786  }
2787 
2788  ast_channel_lock(chan);
2789  while ((cur = AST_LIST_REMOVE_HEAD(&frames, frame_list))) {
2790  if (res == 0) {
2791  ast_queue_frame_head(chan, cur);
2792  }
2793  ast_frfree(cur);
2794  }
2795  ast_channel_unlock(chan);
2796  } while (0);
2797  break;
2798  default:
2799  break;
2800  }
2801 
2802  return res;
2803 }
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:159
struct ast_frame_subclass subclass
#define ast_debug(level,...)
Log a DEBUG message.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:833
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
Definition: linkedlists.h:225
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
Definition: utils.c:2281
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4257
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: linkedlists.h:711
#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:2690
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
Definition: linkedlists.h:681
int ast_waitfor(struct ast_channel *c, int ms)
Wait for input on a channel.
Definition: channel.c:3162
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's frame queue.
Definition: channel.c:1144
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 954 of file channel.c.

References __ast_channel_alloc_ap().

961 {
962  va_list ap;
963  struct ast_channel *result;
964 
965  va_start(ap, name_fmt);
966  result = __ast_channel_alloc_ap(needqueue, state, cid_num, cid_name, acctcode, exten, context,
967  assignedids, requestor, amaflag, endpoint, file, line, function, name_fmt, ap);
968  va_end(ap);
969 
970  return result;
971 }
Main Channel structure associated with a channel.
char context[AST_MAX_CONTEXT]
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:733
char exten[AST_MAX_EXTENSION]
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 5976 of file channel.c.

References ast_call(), ast_call_forward(), ast_channel_datastore_inherit(), ast_channel_hangupcause_hash_set(), ast_channel_inherit_variables(), ast_channel_lock_both, ast_channel_req_accountcodes(), AST_CHANNEL_REQUESTOR_BRIDGE_PEER, ast_channel_set_connected_line(), ast_channel_stage_snapshot(), ast_channel_stage_snapshot_done(), 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_hangup(), ast_party_connected_line_set_init(), ast_read(), ast_remaining_ms(), ast_request(), ast_set_callerid(), ast_set_variables(), AST_STATE_UP, ast_tvnow(), ast_waitfor(), ast_frame::data, ast_frame::datalen, ast_frame::frametype, ast_party_connected_line::id, ast_frame_subclass::integer, ast_party_id::name, ast_party_id::number, ast_party_name::presentation, ast_party_number::presentation, ast_party_name::str, ast_party_number::str, ast_frame::subclass, ast_party_name::valid, and ast_party_number::valid.

Referenced by ast_request_and_dial().

5977 {
5978  int dummy_outstate;
5979  int cause = 0;
5980  struct ast_channel *chan;
5981  int res = 0;
5982  int last_subclass = 0;
5983  struct ast_party_connected_line connected;
5984 
5985  if (outstate)
5986  *outstate = 0;
5987  else
5988  outstate = &dummy_outstate; /* make outstate always a valid pointer */
5989 
5990  chan = ast_request(type, cap, assignedids, requestor, addr, &cause);
5991  if (!chan) {
5992  ast_log(LOG_NOTICE, "Unable to request channel %s/%s\n", type, addr);
5993  handle_cause(cause, outstate);
5994  return NULL;
5995  }
5996 
5997  if (oh) {
5998  if (oh->vars) {
5999  ast_channel_lock(chan);
6000  ast_set_variables(chan, oh->vars);
6001  ast_channel_unlock(chan);
6002  }
6003  if (!ast_strlen_zero(oh->cid_num) && !ast_strlen_zero(oh->cid_name)) {
6004  /*
6005  * Use the oh values instead of the function parameters for the
6006  * outgoing CallerID.
6007  */
6008  cid_num = oh->cid_num;
6009  cid_name = oh->cid_name;
6010  }
6011  if (oh->parent_channel) {
6012  /* Safely inherit variables and datastores from the parent channel. */
6013  ast_channel_lock_both(oh->parent_channel, chan);
6014  ast_channel_inherit_variables(oh->parent_channel, chan);
6015  ast_channel_datastore_inherit(oh->parent_channel, chan);
6016  ast_max_forwards_decrement(chan);
6017  ast_channel_unlock(oh->parent_channel);
6018  ast_channel_unlock(chan);
6019  }
6020  if (!ast_strlen_zero(oh->account)) {
6021  ast_channel_lock(chan);
6023  ast_channel_accountcode_set(chan, oh->account);
6024  ast_channel_peeraccount_set(chan, oh->account);
6026  ast_channel_unlock(chan);
6027  }
6028  }
6029 
6030  /*
6031  * It seems strange to set the CallerID on an outgoing call leg
6032  * to whom we are calling, but this function's callers are doing
6033  * various Originate methods. This call leg goes to the local
6034  * user. Once the local user answers, the dialplan needs to be
6035  * able to access the CallerID from the CALLERID function as if
6036  * the local user had placed this call.
6037  */
6038  ast_set_callerid(chan, cid_num, cid_name, cid_num);
6039 
6040  ast_channel_lock(chan);
6041  ast_set_flag(ast_channel_flags(chan), AST_FLAG_ORIGINATED);
6042  ast_channel_unlock(chan);
6043  ast_party_connected_line_set_init(&connected, ast_channel_connected(chan));
6044  if (cid_num) {
6045  connected.id.number.valid = 1;
6046  connected.id.number.str = (char *) cid_num;
6047  connected.id.number.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
6048  }
6049  if (cid_name) {
6050  connected.id.name.valid = 1;
6051  connected.id.name.str = (char *) cid_name;
6052  connected.id.name.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
6053  }
6054  ast_channel_set_connected_line(chan, &connected, NULL);
6055  if (requestor) {
6056  ast_channel_lock_both(chan, (struct ast_channel *) requestor);
6058  ast_channel_unlock(chan);
6059  ast_channel_unlock((struct ast_channel *) requestor);
6060  }
6061 
6062  if (ast_call(chan, addr, 0)) { /* ast_call failed... */
6063  ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, addr);
6064  } else {
6065  struct timeval start = ast_tvnow();
6066  res = 1; /* mark success in case chan->_state is already AST_STATE_UP */
6067  while (timeout && ast_channel_state(chan) != AST_STATE_UP) {
6068  struct ast_frame *f;
6069  int ms = ast_remaining_ms(start, timeout);
6070 
6071  res = ast_waitfor(chan, ms);
6072  if (res == 0) { /* timeout, treat it like ringing */
6073  *outstate = AST_CONTROL_RINGING;
6074  break;
6075  }
6076  if (res < 0) /* error or done */
6077  break;
6078  if (!ast_strlen_zero(ast_channel_call_forward(chan))) {
6079  if (!(chan = ast_call_forward(NULL, chan, NULL, cap, oh, outstate))) {
6080  return NULL;
6081  }
6082  continue;
6083  }
6084 
6085  f = ast_read(chan);
6086  if (!f) {
6087  *outstate = AST_CONTROL_HANGUP;
6088  res = 0;
6089  break;
6090  }
6091  if (f->frametype == AST_FRAME_CONTROL) {
6092  switch (f->subclass.integer) {
6093  case AST_CONTROL_RINGING: /* record but keep going */
6094  *outstate = f->subclass.integer;
6095  break;
6096 
6097  case AST_CONTROL_BUSY:
6098  *outstate = f->subclass.integer;
6099  timeout = 0;
6100  break;
6101 
6103  *outstate = AST_CONTROL_CONGESTION;
6104  timeout = 0;
6105  break;
6106 
6108  *outstate = f->subclass.integer;
6109  timeout = 0;
6110  break;
6111 
6112  case AST_CONTROL_ANSWER:
6113  *outstate = f->subclass.integer;
6114  timeout = 0; /* trick to force exit from the while() */
6115  break;
6116 
6118  ast_channel_hangupcause_hash_set(chan, f->data.ptr, f->datalen);
6119  break;
6120 
6121  case AST_CONTROL_PROGRESS:
6122  if (oh && oh->connect_on_early_media) {
6123  *outstate = f->subclass.integer;
6124  timeout = 0; /* trick to force exit from the while() */
6125  break;
6126  }
6127  /* Fallthrough */
6128  /* Ignore these */
6130  case AST_CONTROL_HOLD:
6131  case AST_CONTROL_UNHOLD:
6132  case AST_CONTROL_VIDUPDATE:
6133  case AST_CONTROL_SRCUPDATE:
6134  case AST_CONTROL_SRCCHANGE:
6137  case AST_CONTROL_CC:
6138  case -1: /* Ignore -- just stopping indications */
6139  break;
6140 
6141  default:
6142  ast_log(LOG_NOTICE, "Don't know what to do with control frame %d\n", f->subclass.integer);
6143  }
6144  last_subclass = f->subclass.integer;
6145  }
6146  ast_frfree(f);
6147  }
6148  }
6149 
6150  /* Final fixups */
6151  if (oh) {
6152  if (!ast_strlen_zero(oh->context))
6153  ast_channel_context_set(chan, oh->context);
6154  if (!ast_strlen_zero(oh->exten))
6155  ast_channel_exten_set(chan, oh->exten);
6156  if (oh->priority)
6157  ast_channel_priority_set(chan, oh->priority);
6158  }
6159  if (ast_channel_state(chan) == AST_STATE_UP)
6160  *outstate = AST_CONTROL_ANSWER;
6161 
6162  if (res <= 0) {
6163  ast_channel_lock(chan);
6164  if (AST_CONTROL_RINGING == last_subclass) {
6165  ast_channel_hangupcause_set(chan, AST_CAUSE_NO_ANSWER);
6166  }
6167  ast_channel_unlock(chan);
6168  ast_hangup(chan);
6169  chan = NULL;
6170  }
6171  return chan;
6172 }
Main Channel structure associated with a channel.
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:8308
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:159
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:6771
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:2368
struct ast_channel * ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, struct ast_format_cap *cap, struct outgoing_helper *oh, int *outstate)
Forwards a call to a new channel specified by the original channel's call_forward str...
Definition: channel.c:5898
int ast_call(struct ast_channel *chan, const char *addr, int timeout)
Make a call.
Definition: channel.c:6461
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
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:6434
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
Definition: utils.c:2281
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:7334
Connected Line/Party information.
Definition: channel.h:456
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4257
union ast_frame::@224 data
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:4346
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition: channel.h:2929
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:6354
int ast_waitfor(struct ast_channel *c, int ms)
Wait for input on a channel.
Definition: channel.c:3162
void ast_hangup(struct ast_channel *chan)
Hangup a channel.
Definition: channel.c:2541
Data structure associated with a single frame of data.
enum ast_frame_type frametype
void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars)
adds a list of channel variables to a channel
Definition: channel.c:8115
int ast_activate_generator ( struct ast_channel chan,
struct ast_generator gen,
void *  params 
)

Activate a given generator

Definition at line 2951 of file channel.c.

References ast_prod(), ast_settimeout(), ast_channel::generatordata, and ast_generator::release.

Referenced by ast_channel_start_silence_generator(), ast_linear_stream(), ast_playtones_start(), ast_tonepair_start(), and spandsp_fax_gateway_start().

2952 {
2953  int res = 0;
2954  void *generatordata = NULL;
2955 
2956  ast_channel_lock(chan);
2957  if (ast_channel_generatordata(chan)) {
2958  struct ast_generator *generator_old = ast_channel_generator(chan);
2959 
2960  if (generator_old && generator_old->release) {
2961  generator_old->release(chan, ast_channel_generatordata(chan));
2962  }
2963  }
2964  if (gen->alloc && !(generatordata = gen->alloc(chan, params))) {
2965  res = -1;
2966  }
2967  ast_channel_generatordata_set(chan, generatordata);
2968  if (!res) {
2969  ast_settimeout(chan, 50, generator_force, chan);
2970  ast_channel_generator_set(chan, gen);
2971  }
2972  ast_channel_unlock(chan);
2973 
2974  ast_prod(chan);
2975 
2976  return res;
2977 }
void(* release)(struct ast_channel *chan, void *data)
Definition: channel.h:228
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:3180
int ast_prod(struct ast_channel *chan)
Send empty audio to prime a channel driver.
Definition: channel.c:5000
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(), 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
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 2819 of file channel.h.

Referenced by ast_waitfor_nandfds().

2820 {
2821  pfd->fd = fd;
2822  pfd->events = POLLIN | POLLPRI;
2823  return fd >= 0;
2824 }
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 2805 of file channel.c.

References __ast_answer().

Referenced by agent_login_exec(), alarmreceiver_exec(), ast_auto_answer(), ast_bridge_add_channel(), ast_do_pickup(), ast_pickup_call(), conf_exec(), confbridge_exec(), count_exec(), dial_exec_full(), leave_voicemail(), local_call(), minivm_accmess_exec(), receivefax_exec(), sendfax_exec(), setup_privacy_args(), and speech_background().

2806 {
2807  SCOPE_TRACE(1, "%s\n", ast_channel_name(chan));
2808  return __ast_answer(chan, 0);
2809 }
int __ast_answer(struct ast_channel *chan, unsigned int delay)
Answer a channel, with a selectable delay before returning.
Definition: channel.c:2695
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 2811 of file channel.c.

References ast_answer(), and AST_STATE_UP.

2812 {
2813  if (ast_channel_state(chan) == AST_STATE_UP) {
2814  /* Already answered */
2815  return 0;
2816  }
2817  return ast_answer(chan);
2818 }
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition: channel.c:2805
ast_channel_state
ast_channel states
Definition: channelstate.h:35
void ast_autoservice_chan_hangup_peer ( struct ast_channel chan,
struct ast_channel peer 
)

Put chan into autoservice while hanging up peer.

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

Definition at line 342 of file autoservice.c.

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

Referenced by dial_exec_full().

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:2541
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, and AST_LIST_UNLOCK.

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:40
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:140
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
int ast_autoservice_start ( struct ast_channel chan)

Automatically service a channel for us...

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

Definition at line 200 of file autoservice.c.

References ast_calloc, ast_debug, AST_FLAG_END_DTMF_ONLY, AST_LIST_EMPTY, AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_REMOVE, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_thread_is_user_interface(), and asent::use_count.

Referenced by acf_odbc_write(), ast_app_exec_sub(), ast_audiosocket_connect(), ast_autoservice_chan_hangup_peer(), ast_dtmf_stream(), ast_get_enum(), ast_get_srv(), ast_get_txt(), ast_mf_stream(), ast_sf_stream(), begin_dial_prerun(), confbridge_exec(), dial_exec_full(), join_conference_bridge(), lua_autoservice_start(), lua_get_variable_value(), lua_pbx_exec(), lua_set_variable(), lua_set_variable_value(), push_announcer(), and ring_one().

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);
234  as->orig_end_dtmf_flag = ast_test_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY) ? 1 : 0;
235  if (!as->orig_end_dtmf_flag)
236  ast_set_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY);
237  ast_channel_unlock(chan);
238 
240 
241  if (AST_LIST_EMPTY(&aslist) && asthread != AST_PTHREADT_NULL) {
242  ast_cond_signal(&as_cond);
243  }
244 
245  AST_LIST_INSERT_HEAD(&aslist, as, list);
246 
247  if (asthread == AST_PTHREADT_NULL) { /* need start the thread */
248  if (ast_pthread_create_background(&asthread, NULL, autoservice_run, NULL)) {
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);
254  asthread = AST_PTHREADT_NULL;
255  res = -1;
256  } else {
257  pthread_kill(asthread, SIGURG);
258  }
259  }
260 
262 
263  return res;
264 }
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:40
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:140
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
Definition: linkedlists.h:450
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
Definition: linkedlists.h:856
int ast_thread_is_user_interface(void)
Indicates whether the current thread is a user interface.
Definition: utils.c:3248
#define ast_debug(level,...)
Log a DEBUG message.
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:491
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: linkedlists.h:711
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
int ast_autoservice_stop ( struct ast_channel chan)

Stop servicing a channel for us...

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

Definition at line 266 of file autoservice.c.

References ast_debug, AST_FLAG_END_DTMF_ONLY, 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_queue_frame_head(), ast_thread_is_user_interface(), asent::deferred_frames, ast_frame::frametype, and asent::use_count.

Referenced by acf_odbc_write(), ast_app_exec_sub(), ast_audiosocket_connect(), ast_autoservice_chan_hangup_peer(), ast_dtmf_stream(), ast_get_enum(), ast_get_srv(), ast_get_txt(), ast_hangup(), ast_mf_stream(), ast_sf_stream(), begin_dial_prerun(), confbridge_exec(), dial_exec_full(), hangup_playback(), join_conference_bridge(), lua_autoservice_stop(), lua_get_variable_value(), lua_pbx_exec(), lua_set_variable(), lua_set_variable_value(), and ring_one().

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 
320  if (!ast_channel_softhangup_internal_flag(chan)) {
321  res = 0;
322  }
323 
324  ast_channel_lock(chan);
325  if (!as->orig_end_dtmf_flag) {
326  ast_clear_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY);
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_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:40
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:140
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:615
int ast_thread_is_user_interface(void)
Indicates whether the current thread is a user interface.
Definition: utils.c:3248
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:557
#define ast_debug(level,...)
Log a DEBUG message.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:833
unsigned int use_count
Definition: autoservice.c:59
struct asent::@309 deferred_frames
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:529
enum ast_frame_type frametype
int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to the head of a channel's frame queue.
Definition: channel.c:1144
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 6461 of file channel.c.

References ast_check_hangup(), AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, and ast_channel_tech::call.

Referenced by __ast_request_and_dial(), ast_call_forward(), attended_transfer_bridge(), begin_dial_channel(), dial_exec_full(), do_forward(), feature_attended_transfer(), ring_entry(), and wait_for_answer().

6462 {
6463  /* Place an outgoing call, but don't wait any longer than timeout ms before returning.
6464  If the remote end does not answer within the timeout, then do NOT hang up, but
6465  return anyway. */
6466  int res = -1;
6467  /* Stop if we're a zombie or need a soft hangup */
6468  ast_channel_lock(chan);
6469  if (!ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) {
6470  if (ast_channel_tech(chan)->call)
6471  res = ast_channel_tech(chan)->call(chan, addr, timeout);
6472  ast_set_flag(ast_channel_flags(chan), AST_FLAG_OUTGOING);
6473  }
6474  ast_channel_unlock(chan);
6475  return res;
6476 }
int(*const call)(struct ast_channel *chan, const char *addr, int timeout)
Make a call.
Definition: channel.h:701
int ast_check_hangup(struct ast_channel *chan)
Checks to see if a channel is needing hang up.
Definition: channel.c:445
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
struct ast_channel* ast_call_forward ( struct ast_channel caller,
struct ast_channel orig,
int *  timeout,
struct ast_format_cap cap,
struct outgoing_helper oh,
int *  outstate 
)

Forwards a call to a new channel specified by the original channel's call_forward str. If possible, the new forwarded channel is created and returned while the original one is terminated.

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

Definition at line 5898 of file channel.c.

References ast_call(), ast_channel_lock_both, AST_CHANNEL_NAME, ast_channel_req_accountcodes(), AST_CHANNEL_REQUESTOR_REPLACEMENT, ast_channel_set_flag(), ast_channel_stage_snapshot(), ast_channel_stage_snapshot_done(), ast_copy_string(), AST_FLAG_ORIGINATED, ast_hangup(), ast_party_connected_line_copy(), ast_party_redirecting_copy(), ast_request(), ast_set_variables(), ast_channel::data, pbx_builtin_getvar_helper(), pbx_builtin_setvar_helper(), and S_OR.

Referenced by __ast_request_and_dial().

5899 {
5900  char tmpchan[256];
5901  char forwarder[AST_CHANNEL_NAME];
5902  struct ast_channel *new_chan = NULL;
5903  char *data, *type;
5904  int cause = 0;
5905  int res;
5906 
5907  /* gather data and request the new forward channel */
5908  ast_copy_string(tmpchan, ast_channel_call_forward(orig), sizeof(tmpchan));
5909  ast_copy_string(forwarder, ast_channel_name(orig), sizeof(forwarder));
5910  if ((data = strchr(tmpchan, '/'))) {
5911  *data++ = '\0';
5912  type = tmpchan;
5913  } else {
5914  const char *forward_context;
5915  ast_channel_lock(orig);
5916  forward_context = pbx_builtin_getvar_helper(orig, "FORWARD_CONTEXT");
5917  snprintf(tmpchan, sizeof(tmpchan), "%s@%s", ast_channel_call_forward(orig), S_OR(forward_context, ast_channel_context(orig)));
5918  ast_channel_unlock(orig);
5919  data = tmpchan;
5920  type = "Local";
5921  }
5922  if (!(new_chan = ast_request(type, cap, NULL, orig, data, &cause))) {
5923  ast_log(LOG_NOTICE, "Unable to create channel for call forward to '%s/%s' (cause = %d)\n", type, data, cause);
5924  handle_cause(cause, outstate);
5925  ast_hangup(orig);
5926  return NULL;
5927  }
5928 
5929  /* Copy/inherit important information into new channel */
5930  if (oh) {
5931  if (oh->vars) {
5932  ast_channel_lock(new_chan);
5933  ast_set_variables(new_chan, oh->vars);
5934  ast_channel_unlock(new_chan);
5935  }
5936  if (oh->parent_channel) {
5937  call_forward_inherit(new_chan, oh->parent_channel, orig);
5938  }
5939  if (!ast_strlen_zero(oh->account)) {
5940  ast_channel_lock(new_chan);
5941  ast_channel_stage_snapshot(new_chan);
5942  ast_channel_accountcode_set(new_chan, oh->account);
5943  ast_channel_peeraccount_set(new_chan, oh->account);
5945  ast_channel_unlock(new_chan);
5946  }
5947  } else if (caller) { /* no outgoing helper so use caller if available */
5948  call_forward_inherit(new_chan, caller, orig);
5949  }
5950 
5951  ast_channel_lock_both(orig, new_chan);
5953  pbx_builtin_setvar_helper(new_chan, "FORWARDERNAME", forwarder);
5954  ast_party_connected_line_copy(ast_channel_connected(new_chan), ast_channel_connected(orig));
5955  ast_party_redirecting_copy(ast_channel_redirecting(new_chan), ast_channel_redirecting(orig));
5957  ast_channel_unlock(new_chan);
5958  ast_channel_unlock(orig);
5959 
5960  /* call new channel */
5961  res = ast_call(new_chan, data, 0);
5962  if (timeout) {
5963  *timeout = res;
5964  }
5965  if (res) {
5966  ast_log(LOG_NOTICE, "Unable to call forward to channel %s/%s\n", type, (char *)data);
5967  ast_hangup(orig);
5968  ast_hangup(new_chan);
5969  return NULL;
5970  }
5971  ast_hangup(orig);
5972 
5973  return new_chan;
5974 }
Main Channel structure associated with a channel.
const char * data
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
int ast_call(struct ast_channel *chan, const char *addr, int timeout)
Make a call.
Definition: channel.c:6461
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
void ast_channel_set_flag(struct ast_channel *chan, unsigned int flag)
Set a flag on a channel.
Definition: channel.c:11027
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:6434
#define AST_CHANNEL_NAME
Definition: channel.h:171
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
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:2929
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:6354
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:80
void ast_hangup(struct ast_channel *chan)
Hangup a channel.
Definition: channel.c:2541
void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars)
adds a list of channel variables to a channel
Definition: channel.c:8115
const char* ast_cause2str ( int  cause)

Gives the string form of a given cause code.

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

Gives the string form of a given cause code.

Definition at line 612 of file channel.c.

Referenced by channel_state_change(), dial_exec_full(), and hangupcause_read().

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

References __ast_change_name_nolink(), ao2_link, and ao2_unlink.

6760 {
6761  /* We must re-link, as the hash value will change here. */
6762  ao2_lock(channels);
6763  ast_channel_lock(chan);
6764  ao2_unlink(channels, chan);
6765  __ast_change_name_nolink(chan, newname);
6766  ao2_link(channels, chan);
6767  ast_channel_unlock(chan);
6768  ao2_unlock(channels);
6769 }
#define ao2_unlink(container, obj)
Remove an object from a container.
Definition: astobj2.h:1578
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:6742
#define ao2_link(container, obj)
Add an object to a container.
Definition: astobj2.h:1532
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 4373 of file channel.c.

Referenced by ast_cdr_format_var().

4374 {
4375  switch (flag) {
4376  case AST_AMA_OMIT:
4377  return "OMIT";
4378  case AST_AMA_BILLING:
4379  return "BILLING";
4380  case AST_AMA_DOCUMENTATION:
4381  return "DOCUMENTATION";
4382  default:
4383  return "Unknown";
4384  }
4385 }
void ast_channel_amaflags_set ( struct ast_channel chan,
enum ama_flags  value 
)
Precondition
chan is locked

Definition at line 409 of file channel_internal_api.c.

References ast_channel::amaflags, and ast_channel_publish_snapshot().

Referenced by __ast_channel_alloc_ap(), ast_cel_fabricate_channel_from_event(), and ast_iax2_new().

410 {
411  if (chan->amaflags == value) {
412  return;
413  }
414  chan->amaflags = value;
416 }
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.
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 10564 of file channel.c.

References ao2_ref, ast_bridge_peer(), and ast_channel_get_bridge().

Referenced by ast_rtp_instance_set_stats_vars(), ast_set_hangupsource(), ast_unreal_queryoption(), channel_do_masquerade(), fax_detect_framehook(), fax_gateway_framehook(), and spandsp_fax_gateway_start().

10565 {
10566  struct ast_channel *peer;
10567  struct ast_bridge *bridge;
10568 
10569  /* Get the bridge the channel is in. */
10570  ast_channel_lock(chan);
10571  bridge = ast_channel_get_bridge(chan);
10572  ast_channel_unlock(chan);
10573  if (!bridge) {
10574  return NULL;
10575  }
10576 
10577  peer = ast_bridge_peer(bridge, chan);
10578  ao2_ref(bridge, -1);
10579  return peer;
10580 }
Main Channel structure associated with a channel.
struct ast_channel * ast_bridge_peer(struct ast_bridge *bridge, struct ast_channel *chan)
Get the channel's bridge peer only if the bridge is two-party.
Definition: bridge.c:4075
struct ast_bridge * ast_channel_get_bridge(const struct ast_channel *chan)
Get the bridge associated with a channel.
Definition: channel.c:10534
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
Structure that contains information about a bridge.
Definition: bridge.h:349
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.

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(), find_by_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
void ast_channel_callgroup_set ( struct ast_channel chan,
ast_group_t  value 
)
Precondition
chan is locked

Definition at line 1063 of file channel_internal_api.c.

References ast_channel::callgroup.

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

1064 {
1065  chan->callgroup = value;
1066 }
ast_group_t callgroup
void ast_channel_callid_set ( struct ast_channel chan,
ast_callid  value 
)
Precondition
chan is locked

Definition at line 782 of file channel_internal_api.c.

References ast_callid_strnprint(), 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(), and jingle_new().

783 {
784  char call_identifier_from[AST_CALLID_BUFFER_LENGTH];
785  char call_identifier_to[AST_CALLID_BUFFER_LENGTH];
786  call_identifier_from[0] = '\0';
787  ast_callid_strnprint(call_identifier_to, sizeof(call_identifier_to), callid);
788  if (chan->callid) {
789  ast_callid_strnprint(call_identifier_from, sizeof(call_identifier_from), chan->callid);
790  ast_debug(3, "Channel Call ID changing from %s to %s\n", call_identifier_from, call_identifier_to);
791  }
792 
793  chan->callid = callid;
794 
795  ast_test_suite_event_notify("CallIDChange",
796  "State: CallIDChange\r\n"
797  "Channel: %s\r\n"
798  "CallID: %s\r\n"
799  "PriorCallID: %s",
800  ast_channel_name(chan),
801  call_identifier_to,
802  call_identifier_from);
803 }
ast_callid callid
Definition: bridge.h:361
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_test_suite_event_notify(s, f,...)
Definition: test.h:189
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:2288
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 10451 of file channel.c.

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

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

10453 {
10454  struct ast_cc_config_params *cc_params;
10455  struct ast_datastore *cc_datastore;
10456 
10457  if (!(cc_params = ast_cc_config_params_init())) {
10458  return -1;
10459  }
10460 
10461  if (!(cc_datastore = ast_datastore_alloc(&cc_channel_datastore_info, NULL))) {
10462  ast_cc_config_params_destroy(cc_params);
10463  return -1;
10464  }
10465 
10466  if (base_params) {
10467  ast_cc_copy_config_params(cc_params, base_params);
10468  }
10469  cc_datastore->data = cc_params;
10470  ast_channel_datastore_add(chan, cc_datastore);
10471  return 0;
10472 }
void ast_cc_config_params_destroy(struct ast_cc_config_params *params)
Free memory from CCSS configuration params.
Definition: ccss.c:692
Structure for a data store object.
Definition: datastore.h:64
#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:854
void * data
Definition: datastore.h:66
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition: channel.c:2385
void ast_channel_clear_flag ( struct ast_channel chan,
unsigned int  flag 
)

Clear a flag on a channel.

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

Definition at line 11034 of file channel.c.

Referenced by action_redirect(), ast_bridge_setup_after_goto(), ast_channel_undefer_dtmf(), ast_waitfordigit_full(), dial_exec_full(), and waitstream_core().

11035 {
11036  ast_channel_lock(chan);
11037  ast_clear_flag(ast_channel_flags(chan), flag);
11038  ast_channel_unlock(chan);
11039 }
void ast_channel_clear_softhangup ( struct ast_channel chan,
int  flag 
)

Clear a set of softhangup flags from a channel.

Never clear a softhangup flag from a channel directly. Instead, use this function. This ensures that all aspects of the softhangup process are aborted.

Parameters
chanthe channel to clear the flag on
flagthe flag or flags to clear

Definition at line 2432 of file channel.c.

References AST_CONTROL_END_OF_Q, AST_FRAME_CONTROL, 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(), collect_digits(), and stasis_app_exec().

2433 {
2434  ast_channel_lock(chan);
2435 
2436  ast_channel_softhangup_internal_flag_clear(chan, flag);
2437 
2438  if (!ast_channel_softhangup_internal_flag(chan)) {
2439  struct ast_frame *fr;
2440 
2441  /* If we have completely cleared the softhangup flag,
2442  * then we need to fully abort the hangup process. This requires
2443  * pulling the END_OF_Q frame out of the channel frame queue if it
2444  * still happens to be there. */
2445 
2446  fr = AST_LIST_LAST(ast_channel_readq(chan));
2447  if (fr && fr->frametype == AST_FRAME_CONTROL &&
2449  AST_LIST_REMOVE(ast_channel_readq(chan), fr, frame_list);
2450  ast_frfree(fr);
2451  }
2452  }
2453 
2454  ast_channel_unlock(chan);
2455 }
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
Definition: linkedlists.h:856
struct ast_frame_subclass subclass
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.
Definition: linkedlists.h:429
Data structure associated with a single frame of data.
enum ast_frame_type frametype
int ast_channel_cmpwhentohangup_tv ( struct ast_channel chan,
struct timeval  offset 
)

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

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

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

Definition at line 523 of file channel.c.

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

524 {
525  struct timeval whentohangup;
526 
527  if (ast_tvzero(*ast_channel_whentohangup(chan)))
528  return ast_tvzero(offset) ? 0 : -1;
529 
530  if (ast_tvzero(offset))
531  return 1;
532 
533  whentohangup = ast_tvadd(offset, ast_tvnow());
534 
535  return ast_tvdiff_ms(whentohangup, *ast_channel_whentohangup(chan));
536 }
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:117
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:159
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:107
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
Definition: extconf.c:2282
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 10338 of file channel.c.

References ast_app_run_sub(), 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_frame::data, ast_frame::datalen, pbx_builtin_getvar_helper(), and S_OR.

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

10339 {
10340  const char *sub;
10341  const char *sub_args;
10342  int retval;
10343 
10344  ast_channel_lock(sub_chan);
10345  sub = pbx_builtin_getvar_helper(sub_chan, "CONNECTED_LINE_SEND_SUB");
10346  sub = ast_strdupa(S_OR(sub, ""));
10347  sub_args = pbx_builtin_getvar_helper(sub_chan, "CONNECTED_LINE_SEND_SUB_ARGS");
10348  sub_args = ast_strdupa(S_OR(sub_args, ""));
10349 
10350  if (ast_strlen_zero(sub)) {
10351  ast_channel_unlock(sub_chan);
10352  return -1;
10353  }
10354 
10355  if (is_frame) {
10356  const struct ast_frame *frame = connected_info;
10357 
10358  ast_connected_line_parse_data(frame->data.ptr, frame->datalen, ast_channel_connected(sub_chan));
10359  } else {
10360  const struct ast_party_connected_line *connected = connected_info;
10361 
10362  ast_party_connected_line_copy(ast_channel_connected(sub_chan), connected);
10363  }
10364  ast_channel_unlock(sub_chan);
10365 
10366  channel_set_intercept_mode(1);
10367  retval = ast_app_run_sub(autoservice_chan, sub_chan, sub, sub_args, 0);
10368  channel_set_intercept_mode(0);
10369  if (!retval) {
10370  struct ast_party_connected_line saved_connected;
10371 
10372  ast_party_connected_line_init(&saved_connected);
10373  ast_channel_lock(sub_chan);
10374  ast_party_connected_line_copy(&saved_connected, ast_channel_connected(sub_chan));
10375  ast_channel_unlock(sub_chan);
10376  ast_channel_update_connected_line(sub_chan, &saved_connected, NULL);
10377  ast_party_connected_line_free(&saved_connected);
10378  }
10379 
10380  return retval;
10381 }
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:8785
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
Definition: channel.c:2022
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition: channel.c:2072
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
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:456
int ast_app_run_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_location, const char *sub_args, int ignore_hangup)
Run a subroutine on a channel, placing an optional second channel into autoservice.
Definition: main/app.c:328
union ast_frame::@224 data
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:80
Data structure associated with a single frame of data.
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:9093
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 2385 of file channel.c.

References AST_LIST_INSERT_HEAD.

Referenced by 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(), audiohook_volume_get(), authenticate_reply(), command_prestart_queue_command(), dial_exec_full(), find_or_create_details(), lua_get_state(), raise_exception(), save_dialstring(), set_timeout(), setup_async_playback_datastore(), speech_create(), stasis_app_channel_set_stasis_end_published(), t38_attach_framehook(), and unicast_rtp_request().

2386 {
2387  int res = 0;
2388 
2389  AST_LIST_INSERT_HEAD(ast_channel_datastores(chan), datastore, entry);
2390 
2391  return res;
2392 }
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: linkedlists.h:711
Definition: search.h:40
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 2399 of file channel.c.

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

Referenced by 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_set_cc_interfaces_chanvar(), async_play_sound_ready(), audiohook_volume_callback(), audiohook_volume_get(), bridge_timeout(), chan_rtp_get_rtp_peer(), command_prestart_get_container(), command_prestart_queue_command(), conf_find_bridge_profile(), conf_find_user_profile(), conf_set_menu_to_user(), dial_exec_full(), find_details(), find_speech(), fixup_callback(), get_agi_cmd(), get_park_common_datastore_copy(), lua_get_state(), mute_mixmonitor_instance(), raise_exception(), restore_dialstring(), set_interval_hook(), setup_async_playback_datastore(), stasis_app_channel_is_internal(), stasis_app_channel_is_stasis_end_published(), t38_attach_framehook(), and wait_for_initiator().

2400 {
2401  struct ast_datastore *datastore = NULL;
2402 
2403  if (info == NULL)
2404  return NULL;
2405 
2406  AST_LIST_TRAVERSE(ast_channel_datastores(chan), datastore, entry) {
2407  if (datastore->info != info) {
2408  continue;
2409  }
2410 
2411  if (uid == NULL) {
2412  /* matched by type only */
2413  break;
2414  }
2415 
2416  if ((datastore->uid != NULL) && !strcasecmp(uid, datastore->uid)) {
2417  /* Matched by type AND uid */
2418  break;
2419  }
2420  }
2421 
2422  return datastore;
2423 }
Structure for a data store object.
Definition: datastore.h:64
const char * uid
Definition: datastore.h:65
const struct ast_datastore_info * info
Definition: datastore.h:67
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
Definition: search.h:40
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 2368 of file channel.c.

References AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_datastore::data, ast_datastore_info::duplicate, ast_datastore::info, ast_datastore::inheritance, and ast_datastore::uid.

Referenced by __ast_request_and_dial(), ast_ari_channels_dial(), ast_unreal_call_setup(), begin_dial_prerun(), dial_exec_full(), do_forward(), ring_entry(), and wait_for_answer().

2369 {
2370  struct ast_datastore *datastore = NULL, *datastore2;
2371 
2372  AST_LIST_TRAVERSE(ast_channel_datastores(from), datastore, entry) {
2373  if (datastore->inheritance > 0) {
2374  datastore2 = ast_datastore_alloc(datastore->info, datastore->uid);
2375  if (datastore2) {
2376  datastore2->data = datastore->info->duplicate ? datastore->info->duplicate(datastore->data) : NULL;
2377  datastore2->inheritance = datastore->inheritance == DATASTORE_INHERIT_FOREVER ? DATASTORE_INHERIT_FOREVER : datastore->inheritance - 1;
2378  AST_LIST_INSERT_TAIL(ast_channel_datastores(to), datastore2, entry);
2379  }
2380  }
2381  }
2382  return 0;
2383 }
void *(* duplicate)(void *data)
Definition: datastore.h:33
Structure for a data store object.
Definition: datastore.h:64
const char * uid
Definition: datastore.h:65
const struct ast_datastore_info * info
Definition: datastore.h:67
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:731
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
unsigned int inheritance
Definition: datastore.h:69
void * data
Definition: datastore.h:66
Definition: search.h:40
int ast_channel_datastore_remove ( struct ast_channel chan,
struct ast_datastore datastore 
)

Remove a datastore from a channel.

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

Definition at line 2394 of file channel.c.

References AST_LIST_REMOVE.

Referenced by ast_channel_unsuppress(), ast_do_pickup(), ast_jb_create_framehook(), bridge_timeout(), fixup_callback(), and lua_get_state().

2395 {
2396  return AST_LIST_REMOVE(ast_channel_datastores(chan), datastore, entry) ? 0 : -1;
2397 }
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
Definition: linkedlists.h:856
Definition: search.h:40
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_FLAG_DEFER_DTMF.

1258 {
1259  int pre = 0;
1260 
1261  if (chan) {
1262  ast_channel_lock(chan);
1263  pre = ast_test_flag(ast_channel_flags(chan), AST_FLAG_DEFER_DTMF);
1264  ast_set_flag(ast_channel_flags(chan), AST_FLAG_DEFER_DTMF);
1265  ast_channel_unlock(chan);
1266  }
1267  return pre;
1268 }
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 1278 of file channel_internal_api.c.

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

Referenced by ast_channel_hangupcause_hash_set().

1279 {
1280  struct ast_control_pvt_cause_code *ao2_cause_code;
1281  ao2_find(chan->dialed_causes, cause_code->chan_name, OBJ_KEY | OBJ_UNLINK | OBJ_NODATA);
1282  ao2_cause_code = ao2_alloc(datalen, NULL);
1283 
1284  if (ao2_cause_code) {
1285  memcpy(ao2_cause_code, cause_code, datalen);
1286  ao2_link(chan->dialed_causes, ao2_cause_code);
1287  ao2_ref(ao2_cause_code, -1);
1288  return 0;
1289  } else {
1290  return -1;
1291  }
1292 }
char chan_name[AST_CHANNEL_NAME]
#define OBJ_KEY
Definition: astobj2.h:1151
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
struct ao2_container * dialed_causes
#define ao2_link(container, obj)
Add an object to a container.
Definition: astobj2.h:1532
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 1260 of file channel_internal_api.c.

References ao2_callback, ast_str_create, and ast_channel::dialed_causes.

1261 {
1262  struct ast_str *chanlist = ast_str_create(128);
1263 
1264  if (!chanlist) {
1265  return NULL;
1266  }
1267 
1268  ao2_callback(chan->dialed_causes, 0, collect_names_cb, &chanlist);
1269 
1270  return chanlist;
1271 }
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container, as described below.
Definition: astobj2.h:1693
List of channel drivers.
Definition: app_dial.c:797
struct ao2_container * dialed_causes
Support for dynamic strings.
Definition: strings.h:623
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition: strings.h:659
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 1294 of file channel_internal_api.c.

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

1295 {
1297 }
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container, as described below.
Definition: astobj2.h:1693
struct ao2_container * dialed_causes
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 1273 of file channel_internal_api.c.

References ast_channel::dialed_causes, and OBJ_KEY.

Referenced by hangupcause_read().

1274 {
1275  return ao2_find(chan->dialed_causes, chan_name, OBJ_KEY);
1276 }
#define OBJ_KEY
Definition: astobj2.h:1151
struct ao2_container * dialed_causes
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 7412 of file channel.c.

References ast_channel_tech::early_bridge.

Referenced by dial_exec_full().

7413 {
7414  /* Make sure we can early bridge, if not error out */
7415  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)))
7416  return -1;
7417 
7418  return ast_channel_tech(c0)->early_bridge(c0, c1);
7419 }
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
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:768
void ast_channel_end_dtmf ( struct ast_channel chan,
char  digit,
struct timeval  start,
const char *  why 
)

Simulate a DTMF end on a broken bridge channel.

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

Definition at line 10869 of file channel.c.

References AST_FLAG_ZOMBIE, ast_senddigit_end(), AST_SOFTHANGUP_ASYNCGOTO, ast_tvdiff_ms(), ast_tvnow(), and option_dtmfminduration.

Referenced by channel_do_masquerade().

10870 {
10871  int dead;
10872  long duration;
10873 
10874  ast_channel_lock(chan);
10875  dead = ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE)
10876  || (ast_channel_softhangup_internal_flag(chan)
10878  ast_channel_unlock(chan);
10879  if (dead) {
10880  /* Channel is a zombie or a real hangup. */
10881  return;
10882  }
10883 
10884  duration = ast_tvdiff_ms(ast_tvnow(), start);
10885  if (duration < option_dtmfminduration) {
10886  duration = option_dtmfminduration;
10887  }
10888  ast_senddigit_end(chan, digit, duration);
10889  ast_log(LOG_DTMF, "DTMF end '%c' simulated on %s due to %s, duration %ld ms\n",
10890  digit, ast_channel_name(chan), why, duration);
10891 }
unsigned int option_dtmfminduration
Definition: options.c:83
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:159
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:107
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition: channel.c:4924
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 1185 of file channel_internal_api.c.

References AST_EXTENDED_FDS, AST_VECTOR_REPLACE, and ast_channel::fds.

1186 {
1187  int pos = AST_EXTENDED_FDS;
1188 
1189  while (ast_channel_fd_isset(chan, pos)) {
1190  pos += 1;
1191  }
1192 
1193  AST_VECTOR_REPLACE(&chan->fds, pos, value);
1194 
1195  return pos;
1196 }
struct ast_channel::@335 fds
#define AST_EXTENDED_FDS
Definition: channel.h:195
#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_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 1180 of file channel_internal_api.c.

References AST_VECTOR_SIZE, and ast_channel::fds.

Referenced by ast_waitfor_nandfds(), and channel_do_masquerade().

1181 {
1182  return AST_VECTOR_SIZE(&chan->fds);
1183 }
struct ast_channel::@335 fds
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:609
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 10951 of file channel.c.

10952 {
10953  return channel_feature_hooks_set_full(chan, features, 0);
10954 }
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 10903 of file channel.c.

References ast_channel_datastore_find(), and ast_datastore::data.

10904 {
10905  struct ast_datastore *datastore;
10906 
10907  datastore = ast_channel_datastore_find(chan, &bridge_features_info, NULL);
10908  if (!datastore) {
10909  return NULL;
10910  }
10911  return datastore->data;
10912 }
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:2399
Structure for a data store object.
Definition: datastore.h:64
void * data
Definition: datastore.h:66
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 10956 of file channel.c.

10957 {
10958  return channel_feature_hooks_set_full(chan, features, 1);
10959 }
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 1497 of file channel_internal_api.c.

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

Referenced by ast_endpoint_add_channel().

1499 {
1500  ast_assert(chan != NULL);
1501  ast_assert(endpoint != NULL);
1502 
1503  chan->endpoint_forward =
1505  ast_endpoint_topic(endpoint));
1506  if (!chan->endpoint_forward) {
1507  return -1;
1508  }
1509 
1510  return 0;
1511 }
struct stasis_topic * ast_endpoint_topic(struct ast_endpoint *endpoint)
Returns the topic for a specific endpoint.
struct stasis_topic * ast_channel_topic(struct ast_channel *chan)
A topic which publishes the events for a particular channel.
struct stasis_forward * endpoint_forward
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
struct varshead* ast_channel_get_ari_vars ( struct ast_channel chan)

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

Since
14.2.0 The returned variable list is an AO2 object, so ao2_cleanup() to free it.
Parameters
chanChannel to get variables for.
Returns
List of channel variables.
Return values
NULLon error

Definition at line 7988 of file channel.c.

Referenced by ast_channel_snapshot_create().

7989 {
7990  return channel_get_external_vars(&ari_vars, chan);
7991 }
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 10534 of file channel.c.

References ao2_ref.

Referenced by ast_bridge_add_channel(), ast_bridge_transfer_acquire_bridge(), ast_channel_bridge_peer(), get_transfer_parties(), and handle_showchan().

10535 {
10536  struct ast_bridge *bridge;
10537 
10538  bridge = ast_channel_internal_bridge(chan);
10539  if (bridge) {
10540  ao2_ref(bridge, +1);
10541  }
10542  return bridge;
10543 }
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
Structure that contains information about a bridge.
Definition: bridge.h:349
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 10582 of file channel.c.

References ao2_ref.

Referenced by ast_bridge_add_channel(), ast_bridge_notify_masquerade(), ast_bridge_transfer_attended(), ast_bridge_transfer_blind(), bridge_move(), dial_bridge_after_cb(), hold(), play_sound(), ringing(), set_interval_hook(), and unhold().

10583 {
10584  struct ast_bridge_channel *bridge_channel;
10585 
10586  bridge_channel = ast_channel_internal_bridge_channel(chan);
10587  if (bridge_channel) {
10588  ao2_ref(bridge_channel, +1);
10589  }
10590  return bridge_channel;
10591 }
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
Structure that contains information regarding a channel in a bridge.
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_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 }
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
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_redirect(), action_status(), 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(), ast_manager_hangup_helper(), find_control(), handle_cli_agi_add_cmd(), handle_redirect(), handle_show_chanvar(), handle_show_hangup_channel(), handle_showchan(), manager_mute_mixmonitor(), moh_channel_thread(), rtp_check_timeout(), stasis_app_bridge_moh_channel(), stasis_app_bridge_moh_stop(), and stasis_app_bridge_playback_channel_find().

1455 {
1456  return ast_channel_get_by_name_prefix(name, 0);
1457 }
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
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_callback(), and OBJ_KEY.

Referenced by action_bridge(), ast_channel_get_by_name(), ast_parse_device_state(), and bridge_exec().

1435 {
1436  struct ast_channel *chan;
1437  char *l_name = (char *) name;
1438 
1439  if (ast_strlen_zero(l_name)) {
1440  /* We didn't have a name to search for so quit. */
1441  return NULL;
1442  }
1443 
1444  chan = ast_channel_callback(ast_channel_by_name_cb, l_name, &name_len,
1445  (name_len == 0) /* optimize if it is a complete name match */ ? OBJ_KEY : 0);
1446  if (chan) {
1447  return chan;
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:1151
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
const ast_string_field name
int ast_channel_get_cc_agent_type ( struct ast_channel chan,
char *  agent_type,
size_t  size 
)

Find the appropriate CC agent type to use given a channel.

Since
1.8

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

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

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

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

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

Definition at line 10513 of file channel.c.

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

10514 {
10515  int len = size;
10516  char *slash;
10517 
10518  if (!ast_channel_queryoption(chan, AST_OPTION_CC_AGENT_TYPE, agent_type, &len, 0)) {
10519  return 0;
10520  }
10521 
10522  ast_copy_string(agent_type, ast_channel_name(chan), size);
10523  if ((slash = strchr(agent_type, '/'))) {
10524  *slash = '\0';
10525  }
10526  return 0;
10527 }
#define AST_OPTION_CC_AGENT_TYPE
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:7442
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
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 10474 of file channel.c.

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

Referenced by ast_cc_call_failed(), ast_cc_call_init(), ast_queue_cc_frame(), ast_unreal_call_setup(), and ast_unreal_new_channels().

10475 {
10476  struct ast_datastore *cc_datastore;
10477 
10478  if (!(cc_datastore = ast_channel_datastore_find(chan, &cc_channel_datastore_info, NULL))) {
10479  /* If we can't find the datastore, it almost definitely means that the channel type being
10480  * used has not had its driver modified to parse CC config parameters. The best action
10481  * to take here is to create the parameters on the spot with the defaults set.
10482  */
10483  if (ast_channel_cc_params_init(chan, NULL)) {
10484  return NULL;
10485  }
10486  if (!(cc_datastore = ast_channel_datastore_find(chan, &cc_channel_datastore_info, NULL))) {
10487  /* Should be impossible */
10488  return NULL;
10489  }
10490  }
10491 
10492  ast_assert(cc_datastore->data != NULL);
10493  return cc_datastore->data;
10494 }
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:2399
Structure for a data store object.
Definition: datastore.h:64
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:10451
void * data
Definition: datastore.h:66
struct ast_stream* ast_channel_get_default_stream ( struct ast_channel chan,
enum ast_media_type  type 
)

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

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

Definition at line 1605 of file channel_internal_api.c.

References ast_channel::default_streams, and ast_stream::type.

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

1607 {
1608  ast_assert(chan != NULL);
1609  ast_assert(type < AST_MEDIA_TYPE_END);
1610 
1611  return chan->default_streams[type];
1612 }
struct ast_stream * default_streams[AST_MEDIA_TYPE_END]
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 10496 of file channel.c.

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

Referenced by ast_cc_call_failed(), ast_cc_is_recall(), ast_queue_cc_frame(), chan_pjsip_indicate(), dial_exec_full(), and sig_pri_call().

10497 {
10498  int len = name_buffer_length;
10499  char *dash;
10500  if (!ast_channel_queryoption(chan, AST_OPTION_DEVICE_NAME, device_name, &len, 0)) {
10501  return 0;
10502  }
10503 
10504  /* Dang. Do it the old-fashioned way */
10505  ast_copy_string(device_name, ast_channel_name(chan), name_buffer_length);
10506  if ((dash = strrchr(device_name, '-'))) {
10507  *dash = '\0';
10508  }
10509 
10510  return 0;
10511 }
#define AST_OPTION_DEVICE_NAME
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:7442
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
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 2830 of file channel.c.

References ast_channel_get_duration_ms().

2831 {
2832  return (ast_channel_get_duration_ms(chan) / 1000);
2833 }
int64_t ast_channel_get_duration_ms(struct ast_channel *chan)
Obtain how long it's been, in milliseconds, since the channel was created.
Definition: channel.c:2820
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 2820 of file channel.c.

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

Referenced by ast_channel_get_duration().

2821 {
2822  ast_assert(NULL != chan);
2823 
2824  if (ast_tvzero(ast_channel_creationtime(chan))) {
2825  return 0;
2826  }
2827  return ast_tvdiff_ms(ast_tvnow(), ast_channel_creationtime(chan));
2828 }
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:117
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:159
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:107
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 10333 of file channel.c.

References ast_threadstorage_get_ptr().

Referenced by run_agi().

10334 {
10335  return ast_threadstorage_get_ptr(&in_intercept_routine) ? 1 : 0;
10336 }
void * ast_threadstorage_get_ptr(struct ast_threadstorage *ts)
Retrieve a raw pointer from threadstorage.
struct varshead* ast_channel_get_manager_vars ( struct ast_channel chan)

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

Since
12 The returned variable list is an AO2 object, so ao2_cleanup() to free it.
Parameters
chanChannel to get variables for.
Returns
List of channel variables.
Return values
NULLon error

Definition at line 7983 of file channel.c.

Referenced by ast_channel_snapshot_create().

7984 {
7985  return channel_get_external_vars(&ami_vars, chan);
7986 }
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 1569 of file channel_internal_api.c.

References ast_channel::stream_topology.

Referenced by __ast_read(), ast_bridge_channel_stream_map(), ast_channel_request_stream_topology_change(), ast_unreal_indicate(), ast_write_stream(), dial_exec_full(), do_forward(), handle_showchan(), map_source_to_destinations(), native_rtp_bridge_join(), sfu_topologies_on_join(), and softmix_bridge_stream_topology_changed().

1571 {
1572  ast_assert(chan != NULL);
1573 
1574  return chan->stream_topology;
1575 }
struct ast_stream_topology * stream_topology
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 657 of file channel_internal_api.c.

References ast_channel::stream_topology_change_source.

658 {
659  return chan->stream_topology_change_source;
660 }
void * stream_topology_change_source
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 2850 of file channel.h.

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

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

2851 {
2853  int datalen = sizeof(state);
2854 
2855  ast_channel_queryoption(chan, AST_OPTION_T38_STATE, &state, &datalen, 0);
2856 
2857  return state;
2858 }
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:7442
ast_t38_state
Possible T38 states on channels.
Definition: channel.h:878
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 2845 of file channel.c.

References ast_channel_get_up_time_ms().

Referenced by chan_pjsip_read_stream().

2846 {
2847  return (ast_channel_get_up_time_ms(chan) / 1000);
2848 }
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:2835
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 2835 of file channel.c.

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

Referenced by ast_channel_get_up_time().

2836 {
2837  ast_assert(NULL != chan);
2838 
2839  if (ast_tvzero(ast_channel_answertime(chan))) {
2840  return 0;
2841  }
2842  return ast_tvdiff_ms(ast_tvnow(), ast_channel_answertime(chan));
2843 }
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:117
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:159
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:107
struct varshead* ast_channel_get_vars ( struct ast_channel chan)

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

Since
12 The returned variable list is an AO2 object, so ao2_cleanup() to free it.
Parameters
chanChannel to get variables for
Returns
List of channel variables.
Return values
NULLon error

Definition at line 7911 of file channel.c.

References ao2_ref, AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, RAII_VAR, and varshead_dtor().

7912 {
7913  RAII_VAR(struct varshead *, ret, NULL, ao2_cleanup);
7914  struct ast_var_t *cv;
7915 
7916  ret = ao2_alloc(sizeof(*ret), varshead_dtor);
7917 
7918  if (!ret) {
7919  return NULL;
7920  }
7921 
7922  AST_LIST_TRAVERSE(ast_channel_varshead(chan), cv, entries) {
7923  struct ast_var_t *var = ast_var_assign(ast_var_name(cv), ast_var_value(cv));
7924 
7925  if (!var) {
7926  return NULL;
7927  }
7928 
7929  AST_LIST_INSERT_TAIL(ret, var, entries);
7930  }
7931 
7932  ao2_ref(ret, +1);
7933  return ret;
7934 }
static void varshead_dtor(void *obj)
Destructor for lists of variables.
Definition: channel.c:7901
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:731
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
#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:941
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 4346 of file channel.c.

References ast_channel_dialed_causes_add(), ast_func_write(), ast_control_pvt_cause_code::chan_name, ast_control_pvt_cause_code::code, and ast_control_pvt_cause_code::emulate_sip_cause.

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

4347 {
4348  char causevar[256];
4349 
4350  if (ast_channel_dialed_causes_add(chan, cause_code, datalen)) {
4351  ast_log(LOG_WARNING, "Unable to store hangup cause for %s on %s\n", cause_code->chan_name, ast_channel_name(chan));
4352  }
4353 
4354  if (cause_code->emulate_sip_cause) {
4355  snprintf(causevar, sizeof(causevar), "HASH(SIP_CAUSE,%s)", cause_code->chan_name);
4356  ast_func_write(chan, causevar, cause_code->code);
4357  }
4358 }
char chan_name[AST_CHANNEL_NAME]
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.
int ast_func_write(struct ast_channel *chan, const char *function, const char *value)
executes a write operation on a function
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 7860 of file channel.c.

7861 {
7862  return channel_has_external_vars(&ari_vars);
7863 }
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 2518 of file channel.c.

References ast_audiohook_write_list_empty(), and ast_framehook_list_contains_no_active().

2519 {
2520  return !ast_audiohook_write_list_empty(ast_channel_audiohooks(chan))
2521  || !ast_framehook_list_contains_no_active(ast_channel_framehooks(chan));
2522 }
int ast_audiohook_write_list_empty(struct ast_audiohook_list *audiohook_list)
Determine if a audiohook_list is empty or not.
Definition: audiohook.c:1071
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
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 2524 of file channel.c.

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

2525 {
2526  return !ast_audiohook_write_list_empty(ast_channel_audiohooks(chan))
2527  || !ast_framehook_list_contains_no_active_of_type(ast_channel_framehooks(chan), AST_FRAME_VOICE);
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:1071
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
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 7855 of file channel.c.

Referenced by ast_channel_publish_varset().

7856 {
7857  return channel_has_external_vars(&ami_vars);
7858 }
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 6771 of file channel.c.

References ast_channel_publish_varset(), ast_debug, AST_LIST_INSERT_TAIL, and AST_LIST_TRAVERSE.

Referenced by __ast_request_and_dial(), ast_ari_channels_dial(), begin_dial_prerun(), dial_exec_full(), do_forward(), ring_entry(), and wait_for_answer().

6772 {
6773  struct ast_var_t *current;
6774  struct ast_var_t *newvar;
6775  const char *varname;
6776  int vartype;
6777 
6778  AST_LIST_TRAVERSE(ast_channel_varshead((struct ast_channel *) parent), current, entries) {
6779  varname = ast_var_full_name(current);
6780  if (!varname) {
6781  continue;
6782  }
6783 
6784  vartype = 0;
6785  if (varname[0] == '_') {
6786  vartype = 1;
6787  if (varname[1] == '_') {
6788  vartype = 2;
6789  }
6790  }
6791 
6792  switch (vartype) {
6793  case 1:
6794  newvar = ast_var_assign(&varname[1], ast_var_value(current));
6795  break;
6796  case 2:
6797  newvar = ast_var_assign(varname, ast_var_value(current));
6798  break;
6799  default:
6800  continue;
6801  }
6802  if (newvar) {
6803  ast_debug(1, "Inheriting variable %s from %s to %s.\n",
6804  ast_var_full_name(newvar), ast_channel_name(parent),
6805  ast_channel_name(child));
6806  AST_LIST_INSERT_TAIL(ast_channel_varshead(child), newvar, entries);
6807  ast_channel_publish_varset(child, ast_var_full_name(newvar),
6808  ast_var_value(newvar));
6809  }
6810  }
6811 }
Main Channel structure associated with a channel.
#define ast_debug(level,...)
Log a DEBUG message.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:731
void ast_channel_publish_varset(struct ast_channel *chan, const char *variable, const char *value)
Publish a ast_channel_publish_varset for a channel.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
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 1140 of file channel_internal_api.c.

Referenced by channel_do_masquerade().

1141 {
1142  ast_alertpipe_swap(chan1->alertpipe, chan2->alertpipe);
1143 }
void ast_channel_internal_bridge_set ( struct ast_channel chan,
struct ast_bridge value 
)
Precondition
chan is locked

Definition at line 1229 of file channel_internal_api.c.

References ast_channel_publish_snapshot(), AST_CHANNEL_SNAPSHOT_INVALIDATE_BRIDGE, ast_channel_snapshot_invalidate_segment(), and ast_channel::bridge.

1230 {
1231  chan->bridge = value;
1234 }
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_bridge * bridge
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.
void ast_channel_internal_copy_linkedid ( struct ast_channel dest,
struct ast_channel source 
)

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

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

Definition at line 1390 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.

1391 {
1392  if (dest->linkedid.creation_time == source->linkedid.creation_time
1393  && dest->linkedid.creation_unique == source->linkedid.creation_unique
1394  && !strcmp(dest->linkedid.unique_id, source->linkedid.unique_id)) {
1395  return;
1396  }
1397  dest->linkedid = source->linkedid;
1400 }
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.
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 1373 of file channel_internal_api.c.

References ast_channel_id::creation_time, ast_channel_id::creation_unique, and ast_channel::linkedid.

1374 {
1375  ast_assert(a->linkedid.creation_time != 0);
1376  ast_assert(b->linkedid.creation_time != 0);
1377 
1379  return a;
1380  }
1382  return b;
1383  }
1385  return a;
1386  }
1387  return b;
1388 }
struct ast_channel_id linkedid
void ast_channel_internal_set_fake_ids ( struct ast_channel chan,
const char *  uniqueid,
const char *  linkedid 
)

Set uniqueid and linkedid string value only (not time)

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

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

1452 {
1453  ast_copy_string(chan->uniqueid.unique_id, uniqueid, sizeof(chan->uniqueid.unique_id));
1454  ast_copy_string(chan->linkedid.unique_id, linkedid, sizeof(chan->linkedid.unique_id));
1455 }
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:425
struct ast_channel_id uniqueid
void ast_channel_internal_swap_endpoint_forward ( struct ast_channel a,
struct ast_channel b 
)

Swap endpoint_forward between two channels.

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

Definition at line 1433 of file channel_internal_api.c.

References ast_channel::endpoint_forward.

Referenced by channel_do_masquerade().

1434 {
1435  struct stasis_forward *temp;
1436 
1437  temp = a->endpoint_forward;
1439  b->endpoint_forward = temp;
1440 }
struct stasis_forward * endpoint_forward
Forwarding information.
Definition: stasis.c:1531
void ast_channel_internal_swap_snapshots ( struct ast_channel a,
struct ast_channel b 
)

Swap snapshots beteween two channels.

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

Definition at line 1442 of file channel_internal_api.c.

References ast_channel::snapshot.

Referenced by channel_do_masquerade().

1443 {
1444  struct ast_channel_snapshot *snapshot;
1445 
1446  snapshot = a->snapshot;
1447  a->snapshot = b->snapshot;
1448  b->snapshot = snapshot;
1449 }
Structure representing a snapshot of channel state.
struct ast_channel_snapshot * snapshot
void ast_channel_internal_swap_topics ( struct ast_channel a,
struct ast_channel b 
)

Swap topics beteween two channels.

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

Definition at line 1419 of file channel_internal_api.c.

References ast_channel::channel_forward, and ast_channel::topic.

Referenced by channel_do_masquerade().

1420 {
1421  struct stasis_topic *topic;
1422  struct stasis_forward *forward;
1423 
1424  topic = a->topic;
1425  a->topic = b->topic;
1426  b->topic = topic;
1427 
1428  forward = a->channel_forward;
1430  b->channel_forward = forward;
1431 }
struct stasis_forward * channel_forward
struct stasis_topic * topic
Forwarding information.
Definition: stasis.c:1531
void ast_channel_internal_swap_uniqueid_and_linkedid ( struct ast_channel a,
struct ast_channel b 
)

Swap uniqueid and linkedid beteween two channels.

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

Definition at line 1402 of file channel_internal_api.c.

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

Referenced by channel_do_masquerade().

1403 {
1404  struct ast_channel_id temp;
1405 
1406  /* This operation is used as part of masquerading and so does not invalidate the peer
1407  * segment. This is due to the masquerade process invalidating all segments.
1408  */
1409 
1410  temp = a->uniqueid;
1411  a->uniqueid = b->uniqueid;
1412  b->uniqueid = temp;
1413 
1414  temp = a->linkedid;
1415  a->linkedid = b->linkedid;
1416  b->linkedid = temp;
1417 }
struct ast_channel_id linkedid
Channel UniqueId structure.
struct ast_channel_id uniqueid
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 10545 of file channel.c.

Referenced by __ast_read(), action_redirect(), ast_async_goto(), ast_audiohook_attach(), ast_audiohook_remove(), ast_framehook_attach(), ast_framehook_detach(), ast_framehook_list_fixup(), audio_audiohook_write_list(), chan_pjsip_read_stream(), chan_pjsip_set_rtp_peer(), dtmf_audiohook_write_list(), set_timeout(), wait_for_bridged(), and wait_for_unbridged().

10546 {
10547  return ast_channel_internal_bridge(chan) != NULL;
10548 }
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 10550 of file channel.c.

References ast_channel_unbridged(), and AST_SOFTHANGUP_ASYNCGOTO.

Referenced by ast_indicate_data().

10551 {
10552  int hangup_flags = ast_channel_softhangup_internal_flag(chan);
10553  int hangup_test = hangup_flags & AST_SOFTHANGUP_ASYNCGOTO;
10554  int unbridge = ast_channel_unbridged(chan);
10555 
10556  /* This function should only return true if either the unbridged flag or
10557  * the ASYNCGOTO soft hangup flag is set and when no other soft hangup
10558  * flags are set. Any other soft hangup flags being set should make it
10559  * return false.
10560  */
10561  return ((hangup_test || unbridge) && (hangup_test == hangup_flags));
10562 }
int ast_channel_unbridged(struct ast_channel *chan)
This function will check if the bridge needs to be re-evaluated due to external changes.
int ast_channel_is_multistream ( struct ast_channel chan)

Determine if a channel is multi-stream capable.

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

Definition at line 1629 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_request_stream_topology_change(), ast_channel_set_stream_topology(), ast_channel_stream_topology_changed(), ast_channel_stream_topology_changed_externally(), ast_unreal_indicate(), and ast_unreal_new_channels().

1630 {
1631  return (chan && chan->tech && chan->tech->read_stream && chan->tech->write_stream);
1632 }
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:747
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:753
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 1031 of file channel_internal_api.c.

References ast_channel_is_t38_active_nolock().

1032 {
1033  int res;
1034 
1035  ast_channel_lock(chan);
1037  ast_channel_unlock(chan);
1038  return res;
1039 }
int ast_channel_is_t38_active_nolock(struct ast_channel *chan)
ast_channel_is_t38_active variant. Use this if the channel is already locked prior to calling...
int ast_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 1026 of file channel_internal_api.c.

References ast_channel::is_t38_active.

Referenced by ast_channel_is_t38_active().

1027 {
1028  return chan->is_t38_active;
1029 }
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 ao2_iterator_init(), and ast_calloc.

Referenced by action_status(), ast_manager_hangup_helper(), and handle_show_hangup_all().

1409 {
1410  struct ast_channel_iterator *i;
1411 
1412  if (!(i = ast_calloc(1, sizeof(*i)))) {
1413  return NULL;
1414  }
1415 
1416  i->simple_iterator = ao2_iterator_init(channels, 0);
1417  i->active_iterator = &i->simple_iterator;
1418 
1419  return i;
1420 }
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:202
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
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_calloc, ast_channel_callback(), and OBJ_MULTIPLE.

Referenced by 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 
1378  i->active_iterator = (void *) ast_channel_callback(ast_channel_by_exten_cb,
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 }
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_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
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_calloc, ast_channel_callback(), OBJ_KEY, and OBJ_MULTIPLE.

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 
1397  i->active_iterator = (void *) ast_channel_callback(ast_channel_by_name_cb,
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:1151
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_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
struct ast_channel_iterator* ast_channel_iterator_destroy ( struct ast_channel_iterator i)

Destroy a channel iterator.

Parameters
ithe itereator to destroy

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

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

Definition at line 1360 of file channel.c.

References ao2_iterator_destroy().

Referenced by action_status(), ast_manager_hangup_helper(), handle_show_hangup_all(), and pickup_by_exten().

1361 {
1362  ao2_iterator_destroy(i->active_iterator);
1363  ast_free(i);
1364 
1365  return NULL;
1366 }
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
struct ast_channel* ast_channel_iterator_next ( struct ast_channel_iterator i)

Get the next channel for a channel iterator.

Parameters
ithe channel iterator that was created using one of the channel_iterator_xxx_new() functions.

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

Return values
thenext channel that matches the parameters used when the iterator was created.
NULLif no more channels match the iterator parameters.
Since
1.8

Definition at line 1422 of file channel.c.

Referenced by action_status(), ast_manager_hangup_helper(), handle_show_hangup_all(), and pickup_by_exten().

1423 {
1424  return ao2_iterator_next(i->active_iterator);
1425 }
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 6720 of file channel.c.

References ast_channel_make_compatible_helper().

Referenced by dial_exec_full(), do_forward(), fax_detect_framehook(), and fax_gateway_framehook().

6721 {
6722  /*
6723  * Set up translation from the peer to the chan first in case we
6724  * need to hear any in-band tones and the other direction fails.
6725  */
6726  if (ast_channel_make_compatible_helper(peer, chan)) {
6727  return -1;
6728  }
6729 
6730  /* Set up translation from the chan to the peer */
6731  if (ast_channel_make_compatible_helper(chan, peer)) {
6732  return -1;
6733  }
6734 
6735  return 0;
6736 }
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:6641
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 10666 of file channel.c.

References ast_channel_lock_both, ast_channel_masquerade_type(), ast_channel_publish_blob(), AST_FLAG_ZOMBIE, ast_json_pack(), ast_json_unref(), channel_do_masquerade(), channel_move_lock, lock, RAII_VAR, and SCOPED_MUTEX.

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

10667 {
10668  RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
10670 
10671  if (dest == source) {
10672  ast_log(LOG_WARNING, "Can't move channel '%s' into itself!\n",
10673  ast_channel_name(dest));
10674  return -1;
10675  }
10676 
10677  ast_channel_lock_both(dest, source);
10678 
10679  if (ast_test_flag(ast_channel_flags(dest), AST_FLAG_ZOMBIE)
10680  || ast_test_flag(ast_channel_flags(source), AST_FLAG_ZOMBIE)) {
10681  /* Zombies! Run! */
10682  ast_log(LOG_WARNING,
10683  "Can't move channel. One or both is dead (%s <-- %s)\n",
10684  ast_channel_name(dest), ast_channel_name(source));
10685  ast_channel_unlock(source);
10686  ast_channel_unlock(dest);
10687  return -1;
10688  }
10689 
10690  ast_channel_masq_set(dest, source);
10691  ast_channel_masqr_set(source, dest);
10692 
10693  blob = ast_json_pack("{s: s}",
10694  "newchanneluniqueid", ast_channel_uniqueid(dest));
10696 
10697  ast_channel_unlock(dest);
10698  ast_channel_unlock(source);
10699 
10700  channel_do_masquerade(dest, source);
10701  return 0;
10702 }
static ast_mutex_t channel_move_lock
Definition: channel.c:10664
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:612
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
ast_mutex_t lock
#define SCOPED_MUTEX(varname, lock)
scoped lock specialization for mutexes
Definition: lock.h:589
static void channel_do_masquerade(struct ast_channel *original, struct ast_channel *clonechan)
Masquerade a channel.
Definition: channel.c:6857
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition: channel.h:2929
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_masquerade_type(void)
Message type for when a channel is being masqueraded.
#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:941
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 6839 of file channel.c.

6840 {
6841  char *dash;
6842 
6843  /* Truncate after the dash */
6844  dash = strrchr(channel_name, '-');
6845  if (dash) {
6846  *dash = '\0';
6847  }
6848 }
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
void ast_channel_pickupgroup_set ( struct ast_channel chan,
ast_group_t  value 
)
Precondition
chan is locked

Definition at line 1071 of file channel_internal_api.c.

References ast_channel::pickupgroup.

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

1072 {
1073  chan->pickupgroup = value;
1074 }
ast_group_t pickupgroup
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 7442 of file channel.c.

References ast_channel_tech::queryoption.

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

7443 {
7444  int res;
7445 
7446  ast_channel_lock(chan);
7447  if (!ast_channel_tech(chan)->queryoption) {
7448  errno = ENOSYS;
7449  ast_channel_unlock(chan);
7450  return -1;
7451  }
7452 
7453  if (block)
7454  ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n");
7455 
7456  res = ast_channel_tech(chan)->queryoption(chan, option, data, datalen);
7457  ast_channel_unlock(chan);
7458 
7459  return res;
7460 }
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
int(*const queryoption)(struct ast_channel *chan, int option, void *data, int *datalen)
Query a given option. Called with chan locked.
Definition: channel.h:780
void ast_channel_queue_connected_line_update ( struct ast_channel chan,
const struct ast_party_connected_line connected,
const struct ast_set_party_connected_line update 
)

Queue a connected line update frame on a channel.

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

Definition at line 9106 of file channel.c.

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

Referenced by ast_do_pickup().

9107 {
9108  unsigned char data[1024]; /* This should be large enough */
9109  size_t datalen;
9110 
9111  datalen = ast_connected_line_build_data(data, sizeof(data), connected, update);
9112  if (datalen == (size_t) -1) {
9113  return;
9114  }
9115 
9116  ast_queue_control_data(chan, AST_CONTROL_CONNECTED_LINE, data, datalen);
9117 }
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:8697
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
void ast_channel_queue_redirecting_update ( struct ast_channel chan,
const struct ast_party_redirecting redirecting,
const struct ast_set_party_redirecting update 
)

Queue a redirecting update frame on a channel.

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

Definition at line 10297 of file channel.c.

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

10298 {
10299  unsigned char data[1024]; /* This should be large enough */
10300  size_t datalen;
10301 
10302  datalen = ast_redirecting_build_data(data, sizeof(data), redirecting, update);
10303  if (datalen == (size_t) -1) {
10304  return;
10305  }
10306 
10307  ast_queue_control_data(chan, AST_CONTROL_REDIRECTING, data, datalen);
10308 }
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:9268
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
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 5826 of file channel.c.

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

5827 {
5828  switch (reason) /* the following appear to be the only ones actually returned by request_and_dial */
5829  {
5830  case 0:
5831  return "Call Failure (not BUSY, and not NO_ANSWER, maybe Circuit busy or down?)";
5832  case AST_CONTROL_HANGUP:
5833  return "Hangup";
5834  case AST_CONTROL_RING:
5835  return "Local Ring";
5836  case AST_CONTROL_RINGING:
5837  return "Remote end Ringing";
5838  case AST_CONTROL_ANSWER:
5839  return "Remote end has Answered";
5840  case AST_CONTROL_BUSY:
5841  return "Remote end is Busy";
5843  return "Congestion (circuits busy)";
5844  default:
5845  return "Unknown Reason!!";
5846  }
5847 }
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 10383 of file channel.c.

References ast_app_run_sub(), ast_channel_update_redirecting(), ast_party_redirecting_copy(), ast_party_redirecting_free(), ast_party_redirecting_init(), ast_redirecting_parse_data(), ast_strdupa, ast_frame::data, ast_frame::datalen, pbx_builtin_getvar_helper(), and S_OR.

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

10384 {
10385  const char *sub;
10386  const char *sub_args;
10387  int retval;
10388 
10389  ast_channel_lock(sub_chan);
10390  sub = pbx_builtin_getvar_helper(sub_chan, "REDIRECTING_SEND_SUB");
10391  sub = ast_strdupa(S_OR(sub, ""));
10392  sub_args = pbx_builtin_getvar_helper(sub_chan, "REDIRECTING_SEND_SUB_ARGS");
10393  sub_args = ast_strdupa(S_OR(sub_args, ""));
10394 
10395  if (ast_strlen_zero(sub)) {
10396  ast_channel_unlock(sub_chan);
10397  return -1;
10398  }
10399 
10400  if (is_frame) {
10401  const struct ast_frame *frame = redirecting_info;
10402 
10403  ast_redirecting_parse_data(frame->data.ptr, frame->datalen, ast_channel_redirecting(sub_chan));
10404  } else {
10405  const struct ast_party_redirecting *redirecting = redirecting_info;
10406 
10407  ast_party_redirecting_copy(ast_channel_redirecting(sub_chan), redirecting);
10408  }
10409  ast_channel_unlock(sub_chan);
10410 
10411  channel_set_intercept_mode(1);
10412  retval = ast_app_run_sub(autoservice_chan, sub_chan, sub, sub_args, 0);
10413  channel_set_intercept_mode(0);
10414  if (!retval) {
10415  struct ast_party_redirecting saved_redirecting;
10416 
10417  ast_party_redirecting_init(&saved_redirecting);
10418  ast_channel_lock(sub_chan);
10419  ast_party_redirecting_copy(&saved_redirecting, ast_channel_redirecting(sub_chan));
10420  ast_channel_unlock(sub_chan);
10421  ast_channel_update_redirecting(sub_chan, &saved_redirecting, NULL);
10422  ast_party_redirecting_free(&saved_redirecting);
10423  }
10424 
10425  return retval;
10426 }
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_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
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:9479
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:522
int ast_app_run_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_location, const char *sub_args, int ignore_hangup)
Run a subroutine on a channel, placing an optional second channel into autoservice.
Definition: main/app.c:328
union ast_frame::@224 data
void ast_party_redirecting_copy(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src)
Copy the source redirecting information to the destination redirecting.
Definition: channel.c: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:10284
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:80
Data structure associated with a single frame of data.
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_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and chanlist::tech.

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

540 {
541  struct chanlist *chan;
542 
544 
545  AST_RWLIST_TRAVERSE(&backends, chan, list) {
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;
558  AST_RWLIST_INSERT_HEAD(&backends, chan, list);
559 
560  ast_debug(5, "Registered handler for '%s' (%s)\n", chan->tech->type, chan->tech->description);
561 
562  ast_verb(5, "Registered channel type '%s' (%s)\n", chan->tech->type, chan->tech->description);
563 
565 
566  return 0;
567 }
const char * tech
Definition: app_dial.c:803
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:52
the list of registered channel types
Definition: channel.c:121
List of channel drivers.
Definition: app_dial.c:797
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
struct ast_channel* ast_channel_release ( struct ast_channel chan)

Unlink and release reference to a channel.

This function will unlink the channel from the global channels container if it is still there and also release the current reference to the channel.

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

Definition at line 1584 of file channel.c.

References ao2_unlink, and ast_channel_unref.

Referenced by ast_iax2_new(), and ast_unreal_new_channels().

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:2958
#define ao2_unlink(container, obj)
Remove an object from a container.
Definition: astobj2.h:1578
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:124
void ast_channel_req_accountcodes ( struct ast_channel chan,
const struct ast_channel requestor,
enum ast_channel_requestor_relationship  relationship 
)

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

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

Definition at line 6434 of file channel.c.

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

6435 {
6436  channel_req_accountcodes(chan, requestor, relationship, 0);
6437 }
void ast_channel_req_accountcodes_precious ( struct ast_channel chan,
const struct ast_channel requestor,
enum ast_channel_requestor_relationship  relationship 
)

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

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

Definition at line 6439 of file channel.c.

Referenced by ring_entry().

6440 {
6441  channel_req_accountcodes(chan, requestor, relationship, 1);
6442 }
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 10966 of file channel.c.

References ast_channel_get_stream_topology(), ast_channel_is_multistream(), AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE, ast_debug, ast_str_tmp, ast_stream_topology_equal(), ast_stream_topology_to_str(), and ast_channel_tech::indicate.

Referenced by native_rtp_bridge_join(), and sfu_topologies_on_join().

10968 {
10969  int res;
10970 
10971  ast_assert(chan != NULL);
10972  ast_assert(topology != NULL);
10973 
10974  ast_channel_lock(chan);
10975  if (!ast_channel_is_multistream(chan) || !ast_channel_tech(chan)->indicate) {
10976  ast_channel_unlock(chan);
10977  return -1;
10978  }
10979 
10981  ast_debug(2, "%s: Topologies already match. Current: %s Requested: %s\n",
10982  ast_channel_name(chan),
10984  ast_str_tmp(256, ast_stream_topology_to_str(topology, &STR_TMP)));
10985  ast_channel_unlock(chan);
10986  return 0;
10987  }
10988 
10989  ast_channel_internal_set_stream_topology_change_source(chan, change_source);
10990 
10991  res = ast_channel_tech(chan)->indicate(chan, AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE, topology, sizeof(topology));
10992  ast_channel_unlock(chan);
10993  return res;
10994 }
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.
#define ast_str_tmp(init_len, __expr)
Provides a temporary ast_str and returns a copy of its buffer.
Definition: strings.h:1189
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
#define ast_debug(level,...)
Log a DEBUG message.
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
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
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:771
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 6628 of file channel.c.

References ast_channel_tech::send_html.

Referenced by ast_channel_sendurl().

6629 {
6630  if (ast_channel_tech(chan)->send_html)
6631  return ast_channel_tech(chan)->send_html(chan, subclass, data, datalen);
6632  return -1;
6633 }
int(*const send_html)(struct ast_channel *chan, int subclass, const char *data, int len)
Send HTML data.
Definition: channel.h:762
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
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 6635 of file channel.c.

References ast_channel_sendhtml(), and AST_HTML_URL.

Referenced by dial_exec_full().

6636 {
6637  return ast_channel_sendhtml(chan, AST_HTML_URL, url, strlen(url) + 1);
6638 }
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:6628
#define AST_HTML_URL
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 7892 of file channel.c.

7893 {
7894  channel_set_external_vars(&ari_vars, varc, vars);
7895 }
void ast_channel_set_caller ( struct ast_channel chan,
const struct ast_party_caller caller,
const struct ast_set_party_caller update 
)

Set the caller id information in the Asterisk channel.

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

Definition at line 7359 of file channel.c.

References AST_CHANNEL_SNAPSHOT_INVALIDATE_CALLER, ast_channel_snapshot_invalidate_segment(), and ast_party_caller_set().

7360 {
7361  if (ast_channel_caller(chan) == caller) {
7362  /* Don't set to self */
7363  return;
7364  }
7365 
7366  ast_channel_lock(chan);
7367  ast_party_caller_set(ast_channel_caller(chan), caller, update);
7369  ast_channel_unlock(chan);
7370 }
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.
void ast_channel_set_caller_event ( struct ast_channel chan,
const struct ast_party_caller caller,
const struct ast_set_party_caller update 
)

Set the caller id information in the Asterisk channel and generate an AMI event if the caller id name or number changed.

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

Definition at line 7372 of file channel.c.

References ast_channel_publish_snapshot(), AST_CHANNEL_SNAPSHOT_INVALIDATE_CALLER, ast_channel_snapshot_invalidate_segment(), and ast_party_caller_set().

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

7373 {
7374  if (ast_channel_caller(chan) == caller) {
7375  /* Don't set to self */
7376  return;
7377  }
7378 
7379  ast_channel_lock(chan);
7380  ast_party_caller_set(ast_channel_caller(chan), caller, update);
7383  ast_channel_unlock(chan);
7384 }
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.
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.
void ast_channel_set_connected_line ( struct ast_channel chan,
const struct ast_party_connected_line connected,
const struct ast_set_party_connected_line update 
)

Set the connected line information in the Asterisk channel.

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

Definition at line 8308 of file channel.c.

References ast_channel_publish_snapshot(), AST_CHANNEL_SNAPSHOT_INVALIDATE_CONNECTED, ast_channel_snapshot_invalidate_segment(), and ast_party_connected_line_set().

Referenced by __ast_request_and_dial(), and dial_exec_full().

8309 {
8310  if (ast_channel_connected(chan) == connected) {
8311  /* Don't set to self */
8312  return;
8313  }
8314 
8315  ast_channel_lock(chan);
8316  ast_party_connected_line_set(ast_channel_connected(chan), connected, update);
8319  ast_channel_unlock(chan);
8320 }
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_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
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.
void ast_channel_set_fd ( struct ast_channel chan,
int  which,
int  fd 
)

Set the file descriptor on the channel

Definition at line 2426 of file channel.c.

Referenced by __ast_channel_alloc_ap(), ast_jb_create_framehook(), audiosocket_request(), channel_do_masquerade(), check_for_rtp_changes(), jingle_enable_video(), jingle_new(), sco_accept(), stasis_app_control_snoop(), and unicast_rtp_request().

2427 {
2428  ast_channel_internal_fd_set(chan, which, fd);
2429  return;
2430 }
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 11027 of file channel.c.

Referenced by ast_call_forward(), ast_waitfordigit_full(), dial_exec_full(), and waitstream_core().

11028 {
11029  ast_channel_lock(chan);
11030  ast_set_flag(ast_channel_flags(chan), flag);
11031  ast_channel_unlock(chan);
11032 }
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 1046 of file channel_internal_api.c.

References ast_channel_set_is_t38_active_nolock().

1047 {
1048  ast_channel_lock(chan);
1049  ast_channel_set_is_t38_active_nolock(chan, is_t38_active);
1050  ast_channel_unlock(chan);
1051 }
void ast_channel_set_is_t38_active_nolock(struct ast_channel *chan, int is_t38_active)
Variant of ast_channel_set_is_t38_active. Use this if the channel is already locked prior to calling...
void ast_channel_set_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 1041 of file channel_internal_api.c.

References ast_channel::is_t38_active.

Referenced by ast_channel_set_is_t38_active(), and indicate_data_internal().

1042 {
1043  chan->is_t38_active = !!is_t38_active;
1044 }
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 7887 of file channel.c.

7888 {
7889  channel_set_external_vars(&ami_vars, varc, vars);
7890 }
void ast_channel_set_redirecting ( struct ast_channel chan,
const struct ast_party_redirecting redirecting,
const struct ast_set_party_redirecting update 
)

Set the redirecting id information in the Asterisk channel.

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

Definition at line 9119 of file channel.c.

References ast_channel_publish_snapshot(), AST_CHANNEL_SNAPSHOT_INVALIDATE_CALLER, ast_channel_snapshot_invalidate_segment(), and ast_party_redirecting_set().

9120 {
9121  if (ast_channel_redirecting(chan) == redirecting) {
9122  /* Don't set to self */
9123  return;
9124  }
9125 
9126  ast_channel_lock(chan);
9127  ast_party_redirecting_set(ast_channel_redirecting(chan), redirecting, update);
9130  ast_channel_unlock(chan);
9131 }
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
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.
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 1577 of file channel_internal_api.c.

References ast_channel_is_multistream(), ast_str_tmp, ast_stream_topology_alloc(), and ast_stream_topology_to_str().

Referenced by ast_unreal_indicate(), ast_unreal_new_channels(), and chan_pjsip_new().

1579 {
1580  struct ast_stream_topology *new_topology;
1581  SCOPE_ENTER(1, "%s: %s\n", ast_channel_name(chan),
1582  ast_str_tmp(256, ast_stream_topology_to_str(topology, &STR_TMP)));
1583 
1584  ast_assert(chan != NULL);
1585 
1586  /* A non-MULTISTREAM channel can't manipulate topology directly */
1587  ast_assert(ast_channel_is_multistream(chan));
1588 
1589  /* Unless the channel is being destroyed, we always want a topology on
1590  * it even if its empty.
1591  */
1592  if (!topology) {
1593  new_topology = ast_stream_topology_alloc();
1594  } else {
1595  new_topology = topology;
1596  }
1597 
1598  if (new_topology) {
1599  ast_channel_internal_set_stream_topology(chan, new_topology);
1600  }
1601 
1602  SCOPE_EXIT_RTN_VALUE(new_topology, "Used %s topology\n", topology ? "provided" : "empty");
1603 }
int ast_channel_is_multistream(struct ast_channel *chan)
Determine if a channel is multi-stream capable.
#define ast_str_tmp(init_len, __expr)
Provides a temporary ast_str and returns a copy of its buffer.
Definition: strings.h:1189
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
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 1019 of file channel_internal_api.c.

References ast_channel_set_unbridged_nolock().

Referenced by ast_bridge_setup_after_goto(), and t38_change_state().

1020 {
1021  ast_channel_lock(chan);
1022  ast_channel_set_unbridged_nolock(chan, value);
1023  ast_channel_unlock(chan);
1024 }
void ast_channel_set_unbridged_nolock(struct ast_channel *chan, int value)
Variant of ast_channel_set_unbridged. Use this if the channel is already locked prior to calling...
void ast_channel_set_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 1013 of file channel_internal_api.c.

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

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

1014 {
1015  chan->unbridged = !!value;
1017 }
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
Definition: channel.c:1139
struct ast_frame ast_null_frame
Definition: main/frame.c:79
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 7422 of file channel.c.

References ast_channel_tech::setoption.

Referenced by dial_exec_full(), and vm_forwardoptions().

7423 {
7424  int res;
7425 
7426  ast_channel_lock(chan);
7427  if (!ast_channel_tech(chan)->setoption) {
7428  errno = ENOSYS;
7429  ast_channel_unlock(chan);
7430  return -1;
7431  }
7432 
7433  if (block)
7434  ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n");
7435 
7436  res = ast_channel_tech(chan)->setoption(chan, option, data, datalen);
7437  ast_channel_unlock(chan);
7438 
7439  return res;
7440 }
int(*const setoption)(struct ast_channel *chan, int option, void *data, int datalen)
Set a given option. Called with chan locked.
Definition: channel.h:777
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
void ast_channel_setwhentohangup_tv ( struct ast_channel chan,
struct timeval  offset 
)

Set when to hang a channel up.

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

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

Precondition
chan is locked
Since
1.6.1

Set when to hang a channel up.

Definition at line 510 of file channel.c.

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

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:117
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:159
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to a channel's frame queue.
Definition: channel.c:1139
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
Definition: extconf.c:2282
struct ast_frame ast_null_frame
Definition: main/frame.c:79
void ast_channel_softhangup_withcause_locked ( struct ast_channel chan,
int  causecode 
)

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

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

Definition at line 468 of file channel.c.

References ast_debug, AST_SOFTHANGUP_EXPLICIT, and ast_softhangup_nolock().

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

Starts a silence generator on the given channel.

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

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

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

Definition at line 8164 of file channel.c.

References ao2_bump, ast_activate_generator(), ast_calloc, ast_debug, ast_format_slin, and ast_set_write_format().

Referenced by __ast_play_and_record(), and safe_sleep_conditional().

8165 {
8166  struct ast_silence_generator *state;
8167 
8168  if (!(state = ast_calloc(1, sizeof(*state)))) {
8169  return NULL;
8170  }
8171 
8172  state->old_write_format = ao2_bump(ast_channel_writeformat(chan));
8173 
8174  if (ast_set_write_format(chan, ast_format_slin) < 0) {
8175  ast_log(LOG_ERROR, "Could not set write format to SLINEAR\n");
8176  ast_free(state);
8177  return NULL;
8178  }
8179 
8180  ast_activate_generator(chan, &silence_generator, state);
8181 
8182  ast_debug(1, "Started silence generator on '%s'\n", ast_channel_name(chan));
8183 
8184  return state;
8185 }
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition: astobj2.h:480
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
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:5803
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
Definition: channel.c:2951
void ast_channel_stop_silence_generator ( struct ast_channel chan,
struct ast_silence_generator state 
)

Stops a previously-started silence generator on the given channel.

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

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

Definition at line 8210 of file channel.c.

References ast_debug, and ast_set_write_format().

Referenced by __ast_play_and_record(), control_silence_stop_now(), and safe_sleep_conditional().

8211 {
8212  if (!state) {
8213  return;
8214  }
8215 
8216  if (deactivate_silence_generator(chan)) {
8217  ast_debug(1, "Stopped silence generator on '%s'\n", ast_channel_name(chan));
8218  if (ast_set_write_format(chan, state->old_write_format) < 0) {
8219  ast_log(LOG_ERROR, "Could not return write format to its original state\n");
8220  }
8221  }
8222  ao2_cleanup(state->old_write_format);
8223  ast_free(state);
8224 }
#define ast_debug(level,...)
Log a DEBUG message.
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
Definition: channel.c:5803
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 10996 of file channel.c.

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

Referenced by __ast_read().

10997 {
10998  ast_assert(chan != NULL);
10999  ast_assert(topology != NULL);
11000 
11001  if (!ast_channel_is_multistream(chan) || !ast_channel_tech(chan)->indicate) {
11002  return -1;
11003  }
11004 
11005  return ast_channel_tech(chan)->indicate(chan, AST_CONTROL_STREAM_TOPOLOGY_CHANGED, topology, sizeof(topology));
11006 }
int ast_channel_is_multistream(struct ast_channel *chan)
Determine if a channel is multi-stream capable.
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
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:771
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 11008 of file channel.c.

References ast_channel_is_multistream(), AST_CONTROL_STREAM_TOPOLOGY_CHANGED, AST_FRAME_CONTROL, ast_queue_frame(), and ast_stream_topology_changed_external.

11009 {
11010  int res;
11011  struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_STREAM_TOPOLOGY_CHANGED };
11012 
11013  ast_assert(chan != NULL);
11014 
11015  if (!ast_channel_is_multistream(chan)) {
11016  return -1;
11017  }
11018 
11019  ast_channel_lock(chan);
11020  ast_channel_internal_set_stream_topology_change_source(chan, (void *)&ast_stream_topology_changed_external);
11021  res = ast_queue_frame(chan, &f);
11022  ast_channel_unlock(chan);
11023 
11024  return res;
11025 }
int ast_channel_is_multistream(struct ast_channel *chan)
Determine if a channel is multi-stream capable.
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to a channel's frame queue.
Definition: channel.c: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:221
Data structure associated with a single frame of data.
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 4360 of file channel.c.

Referenced by build_user(), and set_config().

4361 {
4362  if (!strcasecmp(flag, "default"))
4363  return DEFAULT_AMA_FLAGS;
4364  if (!strcasecmp(flag, "omit"))
4365  return AST_AMA_OMIT;
4366  if (!strcasecmp(flag, "billing"))
4367  return AST_AMA_BILLING;
4368  if (!strcasecmp(flag, "documentation"))
4369  return AST_AMA_DOCUMENTATION;
4370  return AST_AMA_NONE;
4371 }
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 6623 of file channel.c.

Referenced by dial_exec_full().

6624 {
6625  return (ast_channel_tech(chan)->send_html) ? 1 : 0;
6626 }
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
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 10777 of file channel.c.

References ao2_ref, ast_channel_datastore_add(), ast_channel_datastore_find(), ast_framehook_attach(), ast_framehook_detach(), ast_datastore::data, ast_framehook_interface::data, and ast_framehook_interface::version.

10778 {
10779  struct suppress_data *suppress;
10780  const struct ast_datastore_info *datastore_info = NULL;
10781  struct ast_datastore *datastore = NULL;
10782  struct ast_framehook_interface interface = {
10783  .version = AST_FRAMEHOOK_INTERFACE_VERSION,
10784  .event_cb = suppress_framehook_event_cb,
10785  .destroy_cb = suppress_framehook_destroy_cb,
10786  .chan_fixup_cb = suppress_framehook_fixup_cb,
10787  };
10788  int framehook_id;
10789 
10790  if (!(datastore_info = suppress_get_datastore_information(frametype))) {
10791  ast_log(LOG_WARNING, "Attempted to suppress an unsupported frame type (%u).\n", frametype);
10792  return -1;
10793  }
10794 
10795  if ((datastore = ast_channel_datastore_find(chan, datastore_info, NULL))) {
10796  suppress = datastore->data;
10797  suppress->direction |= direction;
10798  return 0;
10799  }
10800 
10801  if (!(suppress = ao2_alloc(sizeof(*suppress), NULL))) {
10802  ast_log(LOG_WARNING, "Failed to allocate data while attempting to suppress a stream.\n");
10803  return -1;
10804  }
10805 
10806  suppress->frametype = frametype;
10807  suppress->direction |= direction;
10808 
10809  interface.data = suppress;
10810 
10811  framehook_id = ast_framehook_attach(chan, &interface);
10812  if (framehook_id < 0) {
10813  /* Hook attach failed. Get rid of the evidence. */
10814  ast_log(LOG_WARNING, "Failed to attach framehook while attempting to suppress a stream.\n");
10815  ao2_ref(suppress, -1);
10816  return -1;
10817  }
10818 
10819  /* One ref for the framehook */
10820  ao2_ref(suppress, +1);
10821 
10822  suppress->framehook_id = framehook_id;
10823 
10824  if (!(datastore = ast_datastore_alloc(datastore_info, NULL))) {
10825  ast_log(LOG_WARNING, "Failed to allocate datastore while attempting to suppress a stream.\n");
10826  ast_framehook_detach(chan, framehook_id);
10827  ao2_ref(suppress, -1);
10828  return -1;
10829  }
10830 
10831  /* the ref provided by the allocation is taken by the datastore */
10832  datastore->data = suppress;
10833 
10834  ast_channel_datastore_add(chan, datastore);
10835 
10836  return 0;
10837 }
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:2399
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
Structure for a data store object.
Definition: datastore.h:64
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
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
void * data
Definition: datastore.h:66
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition: channel.c:2385
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 1488 of file channel_internal_api.c.

References ast_channel_topic_all(), and ast_channel::topic.

Referenced by ast_ari_bridges_record(), ast_channel_forward_endpoint(), ast_channel_publish_blob(), ast_channel_publish_cached_blob(), ast_channel_publish_final_snapshot(), ast_channel_publish_snapshot(), ast_multi_object_blob_single_channel_publish(), forwards_create_channel(), local_optimization_finished_cb(), local_optimization_started_cb(), manager_mute_mixmonitor(), report_fax_status(), report_receive_fax_status(), report_send_fax_status(), and stasis_app_control_publish().

1489 {
1490  if (!chan) {
1491  return ast_channel_topic_all();
1492  }
1493 
1494  return chan->topic;
1495 }
struct stasis_topic * ast_channel_topic_all(void)
A topic which publishes the events for all channels.
struct stasis_topic * topic
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 1004 of file channel_internal_api.c.

References ast_channel_unbridged_nolock().

Referenced by ast_channel_is_leaving_bridge().

1005 {
1006  int res;
1007  ast_channel_lock(chan);
1008  res = ast_channel_unbridged_nolock(chan);
1009  ast_channel_unlock(chan);
1010  return res;
1011 }
int ast_channel_unbridged_nolock(struct ast_channel *chan)
ast_channel_unbridged variant. Use this if the channel is already locked prior to calling...
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 999 of file channel_internal_api.c.

References ast_channel::unbridged.

Referenced by ast_channel_unbridged().

1000 {
1001  return chan->unbridged;
1002 }
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.

1272 {
1273  if (chan) {
1275  }
1276 }
void ast_channel_clear_flag(struct ast_channel *chan, unsigned int flag)
Clear a flag on a channel.
Definition: channel.c:11034
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 10529 of file channel.c.

References ao2_unlink.

10530 {
10531  ao2_unlink(channels, chan);
10532 }
#define ao2_unlink(container, obj)
Remove an object from a container.
Definition: astobj2.h:1578
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:124
void ast_channel_unregister ( const struct ast_channel_tech tech)

Unregister a channel technology.

Parameters
techStructure defining channel technology or "type" that was previously registered

Unregister a channel technology.

Definition at line 570 of file channel.c.

References ast_debug, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and chanlist::tech.

Referenced by load_module(), and unload_module().

571 {
572  struct chanlist *chan;
573 
574  ast_debug(5, "Unregistering channel type '%s'\n", tech->type);
575 
577 
578  AST_RWLIST_TRAVERSE_SAFE_BEGIN(&backends, chan, list) {
579  if (chan->tech == tech) {
581  ast_free(chan);
582  ast_verb(5, "Unregistered channel type '%s'\n", tech->type);
583  break;
584  }
585  }
587 
589 }
const char * tech
Definition: app_dial.c:803
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:52
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:615
the list of registered channel types
Definition: channel.c:121
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:557
List of channel drivers.
Definition: app_dial.c:797
#define ast_debug(level,...)
Log a DEBUG message.
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
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 10839 of file channel.c.

References ast_channel_datastore_find(), ast_channel_datastore_remove(), ast_datastore_free(), ast_framehook_detach(), and ast_datastore::data.

10840 {
10841  const struct ast_datastore_info *datastore_info = NULL;
10842  struct ast_datastore *datastore = NULL;
10843  struct suppress_data *suppress;
10844 
10845  if (!(datastore_info = suppress_get_datastore_information(frametype))) {
10846  ast_log(LOG_WARNING, "Attempted to unsuppress an unsupported frame type (%u).\n", frametype);
10847  return -1;
10848  }
10849 
10850  if (!(datastore = ast_channel_datastore_find(chan, datastore_info, NULL))) {
10851  /* Nothing to do! */
10852  return 0;
10853  }
10854 
10855  suppress = datastore->data;
10856 
10857  suppress->direction &= ~(direction);
10858 
10859  if (suppress->direction == 0) {
10860  /* Nothing left to suppress. Bye! */
10861  ast_framehook_detach(chan, suppress->framehook_id);
10862  ast_channel_datastore_remove(chan, datastore);
10863  ast_datastore_free(datastore);
10864  }
10865 
10866  return 0;
10867 }
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:2399
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
Structure for a data store object.
Definition: datastore.h:64
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:2394
void * data
Definition: datastore.h:66
void ast_channel_update_connected_line ( struct ast_channel chan,
const struct ast_party_connected_line connected,
const struct ast_set_party_connected_line update 
)

Indicate that the connected line information has changed.

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

Definition at line 9093 of file channel.c.

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

Referenced by ast_channel_connected_line_sub(), ast_do_pickup(), and wait_for_answer().

9094 {
9095  unsigned char data[1024]; /* This should be large enough */
9096  size_t datalen;
9097 
9098  datalen = ast_connected_line_build_data(data, sizeof(data), connected, update);
9099  if (datalen == (size_t) -1) {
9100  return;
9101  }
9102 
9103  ast_indicate_data(chan, AST_CONTROL_CONNECTED_LINE, data, datalen);
9104 }
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:4653
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:8697
void ast_channel_update_redirecting ( struct ast_channel chan,
const struct ast_party_redirecting redirecting,
const struct ast_set_party_redirecting update 
)

Indicate that the redirecting id has changed.

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

Definition at line 10284 of file channel.c.

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

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

10285 {
10286  unsigned char data[1024]; /* This should be large enough */
10287  size_t datalen;
10288 
10289  datalen = ast_redirecting_build_data(data, sizeof(data), redirecting, update);
10290  if (datalen == (size_t) -1) {
10291  return;
10292  }
10293 
10294  ast_indicate_data(chan, AST_CONTROL_REDIRECTING, data, datalen);
10295 }
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:4653
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:9268
void ast_channel_whentohangup_set ( struct ast_channel chan,
struct timeval *  value 
)
Precondition
chan is locked

Definition at line 953 of file channel_internal_api.c.

References ast_channel::whentohangup.

Referenced by ast_channel_setwhentohangup_tv(), and dial_exec_full().

954 {
955  chan->whentohangup = *value;
956 }
struct timeval whentohangup
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 10593 of file channel.c.

References ast_channel::accountcode, ast_channel::amaflags, ao2_bump, ast_channel_alloc, ast_channel_move(), AST_FLAG_IN_AUTOLOOP, ast_hangup(), AST_STATE_DOWN, ast_strdupa, ast_channel::context, ast_channel::exten, ast_channel::name, ast_channel::priority, ast_channel::readformat, and ast_channel::writeformat.

Referenced by ast_async_goto(), and ast_bridge_add_channel().

10594 {
10595  struct ast_channel *yanked_chan;
10596  struct {
10597  char *accountcode;
10598  char *exten;
10599  char *context;
10600  char *name;
10601  int amaflags;
10602  int priority;
10603  struct ast_format *readformat;
10604  struct ast_format *writeformat;
10605  } my_vars = { 0, };
10606 
10607  ast_channel_lock(yankee);
10608  my_vars.accountcode = ast_strdupa(ast_channel_accountcode(yankee));
10609  my_vars.exten = ast_strdupa(ast_channel_exten(yankee));
10610  my_vars.context = ast_strdupa(ast_channel_context(yankee));
10611  my_vars.name = ast_strdupa(ast_channel_name(yankee));
10612  my_vars.amaflags = ast_channel_amaflags(yankee);
10613  my_vars.priority = ast_channel_priority(yankee);
10614  /* The priority as returned by ast_channel_yank is where the channel
10615  * should go if the dialplan is executed on it. If the channel is
10616  * already executing dialplan then the priority currently set is
10617  * where it is currently. We increment it so it becomes where it should
10618  * execute.
10619  */
10620  if (ast_test_flag(ast_channel_flags(yankee), AST_FLAG_IN_AUTOLOOP)) {
10621  my_vars.priority++;
10622  }
10623  my_vars.writeformat = ao2_bump(ast_channel_writeformat(yankee));
10624  my_vars.readformat = ao2_bump(ast_channel_readformat(yankee));
10625  ast_channel_unlock(yankee);
10626 
10627  /* Do not hold any channel locks while calling channel_alloc() since the function
10628  * locks the channel container when linking the new channel in. */
10629  if (!(yanked_chan = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, my_vars.accountcode,
10630  my_vars.exten, my_vars.context, NULL, yankee, my_vars.amaflags,
10631  "Surrogate/%s", my_vars.name))) {
10632  ao2_cleanup(my_vars.writeformat);
10633  ao2_cleanup(my_vars.readformat);
10634  return NULL;
10635  }
10636 
10637  /* Make formats okay */
10638  ast_channel_set_readformat(yanked_chan, my_vars.readformat);
10639  ast_channel_set_writeformat(yanked_chan, my_vars.writeformat);
10640  ao2_cleanup(my_vars.readformat);
10641  ao2_cleanup(my_vars.writeformat);
10642  ast_channel_priority_set(yanked_chan, my_vars.priority);
10643 
10644  ast_channel_unlock(yanked_chan);
10645 
10646  if (ast_channel_move(yanked_chan, yankee)) {
10647  ast_hangup(yanked_chan);
10648  return NULL;
10649  }
10650 
10651  return yanked_chan;
10652 }
Main Channel structure associated with a channel.
char context[AST_MAX_CONTEXT]
Definition of a media format.
Definition: format.c:43
struct ast_format * writeformat
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition: astobj2.h:480
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
struct ast_format * readformat
const ast_string_field name
void ast_hangup(struct ast_channel *chan)
Hangup a channel.
Definition: channel.c:2541
const ast_string_field accountcode
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:10666
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
Definition: channel.h:1258
char exten[AST_MAX_EXTENSION]
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_debug, AST_SOFTHANGUP_TIMEOUT, ast_test_suite_event_notify, ast_tvdiff_ms(), ast_tvnow(), and ast_tvzero().

Referenced by __ast_pbx_run(), __ast_read(), agent_request_exec(), app_exec(), ast_bridge_setup_after_goto(), ast_call(), ast_indicate_data(), ast_raw_answer_with_stream_topology(), ast_recvtext(), ast_sendtext_data(), ast_transfer_protocol(), ast_unreal_fixup(), ast_waitfordigit_full(), ast_write_stream(), confbridge_exec(), dahdi_setoption(), depart_channel(), dial_exec_full(), fax_gateway_framehook(), join_conference_bridge(), lua_check_hangup(), run_agi(), set_config(), stasis_app_exec(), and transfer_target_framehook_cb().

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));
455  ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_TIMEOUT); /* record event */
456  return 1;
457 }
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:117
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:159
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:107
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_test_suite_event_notify(s, f,...)
Definition: test.h:189
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 8697 of file channel.c.

References ast_party_connected_line::id, ast_set_party_connected_line::id, ast_party_id_ies::name, ast_party_connected_line::priv, ast_set_party_connected_line::priv, ast_party_connected_line::source, and ast_party_name_ies::str.

Referenced by ast_channel_queue_connected_line_update(), and ast_channel_update_connected_line().

8698 {
8699  int32_t value;
8700  size_t pos = 0;
8701  int res;
8702 
8703  static const struct ast_party_id_ies ies = {
8704  .name.str = AST_CONNECTED_LINE_NAME,
8705  .name.char_set = AST_CONNECTED_LINE_NAME_CHAR_SET,
8706  .name.presentation = AST_CONNECTED_LINE_NAME_PRESENTATION,
8707  .name.valid = AST_CONNECTED_LINE_NAME_VALID,
8708 
8709  .number.str = AST_CONNECTED_LINE_NUMBER,
8710  .number.plan = AST_CONNECTED_LINE_NUMBER_PLAN,
8711  .number.presentation = AST_CONNECTED_LINE_NUMBER_PRESENTATION,
8712  .number.valid = AST_CONNECTED_LINE_NUMBER_VALID,
8713 
8714  .subaddress.str = AST_CONNECTED_LINE_SUBADDRESS,
8715  .subaddress.type = AST_CONNECTED_LINE_SUBADDRESS_TYPE,
8716  .subaddress.odd_even_indicator = AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN,
8717  .subaddress.valid = AST_CONNECTED_LINE_SUBADDRESS_VALID,
8718 
8719  .tag = AST_CONNECTED_LINE_TAG,
8720  .combined_presentation = AST_CONNECTED_LINE_ID_PRESENTATION,
8721  };
8722 
8723  static const struct ast_party_id_ies priv_ies = {
8724  .name.str = AST_CONNECTED_LINE_PRIV_NAME,
8725  .name.char_set = AST_CONNECTED_LINE_PRIV_NAME_CHAR_SET,
8726  .name.presentation = AST_CONNECTED_LINE_PRIV_NAME_PRESENTATION,
8727  .name.valid = AST_CONNECTED_LINE_PRIV_NAME_VALID,
8728 
8729  .number.str = AST_CONNECTED_LINE_PRIV_NUMBER,
8730  .number.plan = AST_CONNECTED_LINE_PRIV_NUMBER_PLAN,
8731  .number.presentation = AST_CONNECTED_LINE_PRIV_NUMBER_PRESENTATION,
8732  .number.valid = AST_CONNECTED_LINE_PRIV_NUMBER_VALID,
8733 
8734  .subaddress.str = AST_CONNECTED_LINE_PRIV_SUBADDRESS,
8735  .subaddress.type = AST_CONNECTED_LINE_PRIV_SUBADDRESS_TYPE,
8736  .subaddress.odd_even_indicator = AST_CONNECTED_LINE_PRIV_SUBADDRESS_ODD_EVEN,
8737  .subaddress.valid = AST_CONNECTED_LINE_PRIV_SUBADDRESS_VALID,
8738 
8739  .tag = AST_CONNECTED_LINE_PRIV_TAG,
8740  .combined_presentation = 0,/* Not sent. */
8741  };
8742 
8743  /*
8744  * The size of integer values must be fixed in case the frame is
8745  * shipped to another machine.
8746  */
8747 
8748  /* Connected line frame version */
8749  if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8750  ast_log(LOG_WARNING, "No space left for connected line frame version\n");
8751  return -1;
8752  }
8753  data[pos++] = AST_CONNECTED_LINE_VERSION;
8754  data[pos++] = 1;
8755  data[pos++] = 2;/* Version 1 did not have a version ie */
8756 
8757  res = party_id_build_data(data + pos, datalen - pos, &connected->id,
8758  "connected line", &ies, update ? &update->id : NULL);
8759  if (res < 0) {
8760  return -1;
8761  }
8762  pos += res;
8763 
8764  res = party_id_build_data(data + pos, datalen - pos, &connected->priv,
8765  "connected line priv", &priv_ies, update ? &update->priv : NULL);
8766  if (res < 0) {
8767  return -1;
8768  }
8769  pos += res;
8770 
8771  /* Connected line source */
8772  if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) {
8773  ast_log(LOG_WARNING, "No space left for connected line source\n");
8774  return -1;
8775  }
8776  data[pos++] = AST_CONNECTED_LINE_SOURCE;
8777  data[pos++] = sizeof(value);
8778  value = htonl(connected->source);
8779  memcpy(data + pos, &value, sizeof(value));
8780  pos += sizeof(value);
8781 
8782  return pos;
8783 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:458
struct ast_party_name_ies name
Subscriber name ies.
Definition: channel.c:8548
struct ast_set_party_id priv
Definition: channel.h:495
int source
Information about the source of an update.
Definition: channel.h:482
struct ast_set_party_id id
Definition: channel.h:491
struct ast_party_id priv
Private connected party ID.
Definition: channel.h:468
int str
Subscriber name ie.
Definition: channel.c:8325
void ast_connected_line_copy_from_caller ( struct ast_party_connected_line dest,
const struct ast_party_caller src 
)

Copy the caller information to the connected line information.

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

Definition at line 8293 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 agent_request_exec(), ast_ari_channels_dial(), ast_do_pickup(), ast_unreal_call_setup(), begin_dial_prerun(), dial_exec_full(), do_forward(), ring_entry(), and wait_for_answer().

8294 {
8295  ast_party_id_copy(&dest->id, &src->id);
8296  ast_party_id_copy(&dest->ani, &src->ani);
8297  dest->ani2 = src->ani2;
8298 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:458
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:475
struct ast_party_id id
Caller party ID.
Definition: channel.h:420
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:427
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:465
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:433
void ast_connected_line_copy_to_caller ( struct ast_party_caller dest,
const struct ast_party_connected_line src 
)

Copy the connected line information to the caller information.

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

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

8301 {
8302  ast_party_id_copy(&dest->id, &src->id);
8303  ast_party_id_copy(&dest->ani, &src->ani);
8304 
8305  dest->ani2 = src->ani2;
8306 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:458
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:475
struct ast_party_id id
Caller party ID.
Definition: channel.h:420
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:427
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:465
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:433
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 8785 of file channel.c.

References ast_debug, ast_malloc, ast_party_name::char_set, ast_party_id_ies::combined_presentation, ast_party_connected_line::id, 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, and ast_party_subaddress::valid.

Referenced by __ast_read(), ast_channel_connected_line_sub(), and wait_for_answer().

8786 {
8787  size_t pos;
8788  unsigned char ie_len;
8789  unsigned char ie_id;
8790  int32_t value;
8791  int frame_version = 1;
8792  int combined_presentation = 0;
8793  int got_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
8794 
8795  for (pos = 0; pos < datalen; pos += ie_len) {
8796  if (datalen < pos + sizeof(ie_id) + sizeof(ie_len)) {
8797  ast_log(LOG_WARNING, "Invalid connected line update\n");
8798  return -1;
8799  }
8800  ie_id = data[pos++];
8801  ie_len = data[pos++];
8802  if (datalen < pos + ie_len) {
8803  ast_log(LOG_WARNING, "Invalid connected line update\n");
8804  return -1;
8805  }
8806 
8807  switch (ie_id) {
8808 /* Connected line party frame version */
8809  case AST_CONNECTED_LINE_VERSION:
8810  if (ie_len != 1) {
8811  ast_log(LOG_WARNING, "Invalid connected line frame version (%u)\n",
8812  (unsigned) ie_len);
8813  break;
8814  }
8815  frame_version = data[pos];
8816  break;
8817 /* Connected line party id name */
8818  case AST_CONNECTED_LINE_NAME:
8819  ast_free(connected->id.name.str);
8820  connected->id.name.str = ast_malloc(ie_len + 1);
8821  if (connected->id.name.str) {
8822  memcpy(connected->id.name.str, data + pos, ie_len);
8823  connected->id.name.str[ie_len] = 0;
8824  }
8825  break;
8826  case AST_CONNECTED_LINE_NAME_CHAR_SET:
8827  if (ie_len != 1) {
8828  ast_log(LOG_WARNING, "Invalid connected line name char set (%u)\n",
8829  (unsigned) ie_len);
8830  break;
8831  }
8832  connected->id.name.char_set = data[pos];
8833  break;
8834  case AST_CONNECTED_LINE_NAME_PRESENTATION:
8835  if (ie_len != 1) {
8836  ast_log(LOG_WARNING, "Invalid connected line name presentation (%u)\n",
8837  (unsigned) ie_len);
8838  break;
8839  }
8840  connected->id.name.presentation = data[pos];
8841  break;
8842  case AST_CONNECTED_LINE_NAME_VALID:
8843  if (ie_len != 1) {
8844  ast_log(LOG_WARNING, "Invalid connected line name valid (%u)\n",
8845  (unsigned) ie_len);
8846  break;
8847  }
8848  connected->id.name.valid = data[pos];
8849  break;
8850 /* Connected line party id number */
8851  case AST_CONNECTED_LINE_NUMBER:
8852  ast_free(connected->id.number.str);
8853  connected->id.number.str = ast_malloc(ie_len + 1);
8854  if (connected->id.number.str) {
8855  memcpy(connected->id.number.str, data + pos, ie_len);
8856  connected->id.number.str[ie_len] = 0;
8857  }
8858  break;
8859  case AST_CONNECTED_LINE_NUMBER_PLAN:
8860  if (ie_len != 1) {
8861  ast_log(LOG_WARNING, "Invalid connected line numbering plan (%u)\n",
8862  (unsigned) ie_len);
8863  break;
8864  }
8865  connected->id.number.plan = data[pos];
8866  break;
8867  case AST_CONNECTED_LINE_NUMBER_PRESENTATION:
8868  if (ie_len != 1) {
8869  ast_log(LOG_WARNING, "Invalid connected line number presentation (%u)\n",
8870  (unsigned) ie_len);
8871  break;
8872  }
8873  connected->id.number.presentation = data[pos];
8874  break;
8875  case AST_CONNECTED_LINE_NUMBER_VALID:
8876  if (ie_len != 1) {
8877  ast_log(LOG_WARNING, "Invalid connected line number valid (%u)\n",
8878  (unsigned) ie_len);
8879  break;
8880  }
8881  connected->id.number.valid = data[pos];
8882  break;
8883 /* Connected line party id subaddress */
8884  case AST_CONNECTED_LINE_SUBADDRESS:
8885  ast_free(connected->id.subaddress.str);
8886  connected->id.subaddress.str = ast_malloc(ie_len + 1);
8887  if (connected->id.subaddress.str) {
8888  memcpy(connected->id.subaddress.str, data + pos, ie_len);
8889  connected->id.subaddress.str[ie_len] = 0;
8890  }
8891  break;
8892  case AST_CONNECTED_LINE_SUBADDRESS_TYPE:
8893  if (ie_len != 1) {
8894  ast_log(LOG_WARNING, "Invalid connected line type of subaddress (%u)\n",
8895  (unsigned) ie_len);
8896  break;
8897  }
8898  connected->id.subaddress.type = data[pos];
8899  break;
8900  case AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN:
8901  if (ie_len != 1) {
8902  ast_log(LOG_WARNING,
8903  "Invalid connected line subaddress odd-even indicator (%u)\n",
8904  (unsigned) ie_len);
8905  break;
8906  }
8907  connected->id.subaddress.odd_even_indicator = data[pos];
8908  break;
8909  case AST_CONNECTED_LINE_SUBADDRESS_VALID:
8910  if (ie_len != 1) {
8911  ast_log(LOG_WARNING, "Invalid connected line subaddress valid (%u)\n",
8912  (unsigned) ie_len);
8913  break;
8914  }
8915  connected->id.subaddress.valid = data[pos];
8916  break;
8917 /* Connected line party tag */
8918  case AST_CONNECTED_LINE_TAG:
8919  ast_free(connected->id.tag);
8920  connected->id.tag = ast_malloc(ie_len + 1);
8921  if (connected->id.tag) {
8922  memcpy(connected->id.tag, data + pos, ie_len);
8923  connected->id.tag[ie_len] = 0;
8924  }
8925  break;
8926 /* Connected line party id combined presentation */
8927  case AST_CONNECTED_LINE_ID_PRESENTATION:
8928  if (ie_len != 1) {
8929  ast_log(LOG_WARNING, "Invalid connected line combined presentation (%u)\n",
8930  (unsigned) ie_len);
8931  break;
8932  }
8933  combined_presentation = data[pos];
8934  got_combined_presentation = 1;
8935  break;
8936 /* Private connected line party id name */
8937  case AST_CONNECTED_LINE_PRIV_NAME:
8938  ast_free(connected->priv.name.str);
8939  connected->priv.name.str = ast_malloc(ie_len + 1);
8940  if (connected->priv.name.str) {
8941  memcpy(connected->priv.name.str, data + pos, ie_len);
8942  connected->priv.name.str[ie_len] = 0;
8943  }
8944  break;
8945  case AST_CONNECTED_LINE_PRIV_NAME_CHAR_SET:
8946  if (ie_len != 1) {
8947  ast_log(LOG_WARNING, "Invalid connected line private name char set (%u)\n",
8948  (unsigned) ie_len);
8949  break;
8950  }
8951  connected->priv.name.char_set = data[pos];
8952  break;
8953  case AST_CONNECTED_LINE_PRIV_NAME_PRESENTATION:
8954  if (ie_len != 1) {
8955  ast_log(LOG_WARNING, "Invalid connected line private name presentation (%u)\n",
8956  (unsigned) ie_len);
8957  break;
8958  }
8959  connected->priv.name.presentation = data[pos];
8960  break;
8961  case AST_CONNECTED_LINE_PRIV_NAME_VALID:
8962  if (ie_len != 1) {
8963  ast_log(LOG_WARNING, "Invalid connected line private name valid (%u)\n",
8964  (unsigned) ie_len);
8965  break;
8966  }
8967  connected->priv.name.valid = data[pos];
8968  break;
8969 /* Private connected line party id number */
8970  case AST_CONNECTED_LINE_PRIV_NUMBER:
8971  ast_free(connected->priv.number.str);
8972  connected->priv.number.str = ast_malloc(ie_len + 1);
8973  if (connected->priv.number.str) {
8974  memcpy(connected->priv.number.str, data + pos, ie_len);
8975  connected->priv.number.str[ie_len] = 0;
8976  }
8977  break;
8978  case AST_CONNECTED_LINE_PRIV_NUMBER_PLAN:
8979  if (ie_len != 1) {
8980  ast_log(LOG_WARNING, "Invalid connected line private numbering plan (%u)\n",
8981  (unsigned) ie_len);
8982  break;
8983  }
8984  connected->priv.number.plan = data[pos];
8985  break;
8986  case AST_CONNECTED_LINE_PRIV_NUMBER_PRESENTATION:
8987  if (ie_len != 1) {
8988  ast_log(LOG_WARNING, "Invalid connected line private number presentation (%u)\n",
8989  (unsigned) ie_len);
8990  break;
8991  }
8992  connected->priv.number.presentation = data[pos];
8993  break;
8994  case AST_CONNECTED_LINE_PRIV_NUMBER_VALID:
8995  if (ie_len != 1) {
8996  ast_log(LOG_WARNING, "Invalid connected line private number valid (%u)\n",
8997  (unsigned) ie_len);
8998  break;
8999  }
9000  connected->priv.number.valid = data[pos];
9001  break;
9002 /* Private connected line party id subaddress */
9003  case AST_CONNECTED_LINE_PRIV_SUBADDRESS:
9004  ast_free(connected->priv.subaddress.str);
9005  connected->priv.subaddress.str = ast_malloc(ie_len + 1);
9006  if (connected->priv.subaddress.str) {
9007  memcpy(connected->priv.subaddress.str, data + pos, ie_len);
9008  connected->priv.subaddress.str[ie_len] = 0;
9009  }
9010  break;
9011  case AST_CONNECTED_LINE_PRIV_SUBADDRESS_TYPE:
9012  if (ie_len != 1) {
9013  ast_log(LOG_WARNING, "Invalid connected line private type of subaddress (%u)\n",
9014  (unsigned) ie_len);
9015  break;
9016  }
9017  connected->priv.subaddress.type = data[pos];
9018  break;
9019  case AST_CONNECTED_LINE_PRIV_SUBADDRESS_ODD_EVEN:
9020  if (ie_len != 1) {
9021  ast_log(LOG_WARNING,
9022  "Invalid connected line private subaddress odd-even indicator (%u)\n",
9023  (unsigned) ie_len);
9024  break;
9025  }
9026  connected->priv.subaddress.odd_even_indicator = data[pos];
9027  break;
9028  case AST_CONNECTED_LINE_PRIV_SUBADDRESS_VALID:
9029  if (ie_len != 1) {
9030  ast_log(LOG_WARNING, "Invalid connected line private subaddress valid (%u)\n",
9031  (unsigned) ie_len);
9032  break;
9033  }
9034  connected->priv.subaddress.valid = data[pos];
9035  break;
9036 /* Private connected line party tag */
9037  case AST_CONNECTED_LINE_PRIV_TAG:
9038  ast_free(connected->priv.tag);
9039  connected->priv.tag = ast_malloc(ie_len + 1);
9040  if (connected->priv.tag) {
9041  memcpy(connected->priv.tag, data + pos, ie_len);
9042  connected->priv.tag[ie_len] = 0;
9043  }
9044  break;
9045 /* Connected line party source */
9046  case AST_CONNECTED_LINE_SOURCE:
9047  if (ie_len != sizeof(value)) {
9048  ast_log(LOG_WARNING, "Invalid connected line source (%u)\n",
9049  (unsigned) ie_len);
9050  break;
9051  }
9052  memcpy(&value, data + pos, sizeof(value));
9053  connected->source = ntohl(value);
9054  break;
9055 /* Connected line party unknown element */
9056  default:
9057  ast_debug(1, "Unknown connected line element: %u (%u)\n",
9058  (unsigned) ie_id, (unsigned) ie_len);
9059  break;
9060  }
9061  }
9062 
9063  switch (frame_version) {
9064  case 1:
9065  /*
9066  * The other end is an earlier version that we need to adjust
9067  * for compatibility.
9068  */
9069  connected->id.name.valid = 1;
9070  connected->id.name.char_set = AST_PARTY_CHAR_SET_ISO8859_1;
9071  connected->id.number.valid = 1;
9072  if (got_combined_presentation) {
9075  }
9076  break;
9077  case 2:
9078  /* The other end is at the same level as we are. */
9079  break;
9080  default:
9081  /*
9082  * The other end is newer than we are.
9083  * We need to assume that they are compatible with us.
9084  */
9085  ast_debug(1, "Connected line frame has newer version: %u\n",
9086  (unsigned) frame_version);
9087  break;
9088  }
9089 
9090  return 0;
9091 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:277
char * str
Subscriber phone number (Malloced)
Definition: channel.h:291
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:295
struct ast_party_id id
Connected party ID.
Definition: channel.h:458
struct ast_party_name name
Subscriber name.
Definition: channel.h:340
int char_set
Character set the name is using.
Definition: channel.h:272
char * str
Subscriber name (Malloced)
Definition: channel.h:264
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:328
char * str
Malloced subaddress string.
Definition: channel.h:313
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:326
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:191
#define ast_debug(level,...)
Log a DEBUG message.
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:344
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:293
int source
Information about the source of an update.
Definition: channel.h:482
int combined_presentation
Combined name and number presentation ie.
Definition: channel.c:8559
char * tag
User-set "tag".
Definition: channel.h:354
int type
Q.931 subaddress type.
Definition: channel.h:320
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:279
struct ast_party_id priv
Private connected party ID.
Definition: channel.h:468
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:297
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:342
void ast_deactivate_generator ( struct ast_channel chan)

Deactivate an active generator

Definition at line 2893 of file channel.c.

References ast_timer_set_rate(), and should_trigger_dtmf_emulating().

Referenced by __ast_read(), ast_openstream_full(), ast_playtones_stop(), ast_tonepair_stop(), ast_write_stream(), and dial_exec_full().

2894 {
2895  ast_channel_lock(chan);
2896  deactivate_generator_nolock(chan);
2897  if (should_trigger_dtmf_emulating(chan)) {
2898  /* if in the middle of dtmf emulation keep 50 tick per sec timer on rolling */
2899  ast_timer_set_rate(ast_channel_timer(chan), 50);
2900  }
2901  ast_channel_unlock(chan);
2902 }
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:2855
int ast_timer_set_rate(const struct ast_timer *handle, unsigned int rate)
Set the timing tick rate.
Definition: timing.c:166
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_UNLOCK, and chanlist::tech.

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

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:803
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:78
the list of registered channel types
Definition: channel.c:121
List of channel drivers.
Definition: app_dial.c:797
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
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 7675 of file channel.c.

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_container_alloc_hash, ao2_container_count(), ao2_link, ao2_ref, ast_skip_blanks(), ast_str_hash(), ast_strdupa, ast_strip(), ast_trim_blanks(), namedgroup_member::hash, namedgroup_member::name, namedgroup_cmp_cb(), namedgroup_hash_cb(), OBJ_NODATA, OBJ_POINTER, and OBJ_UNLINK.

7676 {
7677  struct ao2_container *namedgroups;
7678  char *piece;
7679  char *c;
7680 
7681  if (!s) {
7682  return NULL;
7683  }
7684 
7685  /*! \brief Remove leading and trailing whitespace */
7687  if (ast_strlen_zero(c)) {
7688  return NULL;
7689  }
7690 
7693  if (!namedgroups) {
7694  return NULL;
7695  }
7696 
7697  while ((piece = strsep(&c, ","))) {
7698  struct namedgroup_member *member;
7699  size_t len;
7700 
7701  /* remove leading/trailing whitespace */
7702  piece = ast_strip(piece);
7703 
7704  len = strlen(piece);
7705  if (!len) {
7706  continue;
7707  }
7708 
7709  member = ao2_alloc_options(sizeof(*member) + len, NULL, AO2_ALLOC_OPT_LOCK_NOLOCK);
7710  if (!member) {
7711  ao2_ref(namedgroups, -1);
7712  return NULL;
7713  }
7714  strcpy(member->name, piece);/* Safe */
7715  member->hash = ast_str_hash(member->name);
7716 
7717  /* every group name may exist only once, delete duplicates */
7718  ao2_find(namedgroups, member, OBJ_POINTER | OBJ_UNLINK | OBJ_NODATA);
7719  ao2_link(namedgroups, member);
7720  ao2_ref(member, -1);
7721  }
7722 
7723  if (!ao2_container_count(namedgroups)) {
7724  /* There were no group names specified. */
7725  ao2_ref(namedgroups, -1);
7726  namedgroups = NULL;
7727  }
7728 
7729  return (struct ast_namedgroups *) namedgroups;
7730 }
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
#define OBJ_POINTER
Definition: astobj2.h:1150
Named group member structure.
Definition: channel.c:7651
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Definition: strings.h:223
unsigned int hash
Definition: channel.c:7653
static int namedgroup_hash_cb(const void *obj, const int flags)
Hashing function used for named group container.
Definition: channel.c:7668
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
Definition: astobj2.h:1303
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
Definition: strings.h:161
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
Definition: strings.h:186
static int namedgroup_cmp_cb(void *obj, void *arg, int flags)
Comparison function used for named group container.
Definition: channel.c:7659
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:1259
#define ao2_link(container, obj)
Add an object to a container.
Definition: astobj2.h:1532
void ast_hangup ( struct ast_channel chan)

Hang up a channel.

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

Hang up a channel.

Definition at line 2541 of file channel.c.

References ao2_ref, ao2_unlink, ast_autoservice_stop(), ast_cc_offer(), ast_channel_unref, ast_closestream(), ast_debug, AST_FLAG_BLOCKING, AST_FLAG_ZOMBIE, ast_get_tid(), ast_pbx_hangup_handler_run(), ast_sched_context_destroy(), ast_channel_tech::hangup, and ast_generator::release.

Referenced by __analog_handle_event(), __ast_pbx_run(), __ast_request_and_dial(), answer_exec_run(), 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_unreal_hangup(), attended_transfer_bridge(), begin_dial_channel(), build_conf(), chan_pjsip_new(), conf_free(), console_new(), destroy_conference_bridge(), dial_exec_full(), do_forward(), do_hang(), feature_attended_transfer(), handle_call_forward(), handle_exec(), handle_frame(), handle_timeout_trip(), hangup_playback(), hangupcalls(), jingle_action_session_initiate(), local_call(), moh_channel_thread(), monitor_dial(), pbx_outgoing_exec(), push_announcer(), snoop_stasis_thread(), stasis_app_control_snoop(), unistim_new(), and wait_for_answer().

2542 {
2543  /* Be NULL safe for RAII_VAR() usage. */
2544  if (!chan) {
2545  return;
2546  }
2547 
2548  ast_debug(1, "Channel %p '%s' hanging up. Refs: %d\n", chan, ast_channel_name(chan),
2549  ao2_ref(chan, 0));
2550 
2551  ast_autoservice_stop(chan);
2552 
2553  ast_channel_lock(chan);
2554 
2555  while (ast_channel_masq(chan) || ast_channel_masqr(chan)) {
2556  CHANNEL_DEADLOCK_AVOIDANCE(chan);
2557  }
2558 
2559  /* Mark as a zombie so a masquerade cannot be setup on this channel. */
2560  ast_set_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE);
2561 
2562  ast_channel_unlock(chan);
2563 
2564  /*
2565  * XXX if running the hangup handlers here causes problems
2566  * because the handlers take too long to execute, we could move
2567  * the meat of this function into another thread. A thread
2568  * where channels go to die.
2569  *
2570  * If this is done, ast_autoservice_chan_hangup_peer() will no
2571  * longer be needed.
2572  */
2574  ao2_unlink(channels, chan);
2575  ast_channel_lock(chan);
2576 
2577  destroy_hooks(chan);
2578 
2579  free_translation(chan);
2580  /* Close audio stream */
2581  if (ast_channel_stream(chan)) {
2582  ast_closestream(ast_channel_stream(chan));
2583  ast_channel_stream_set(chan, NULL);
2584  }
2585  /* Close video stream */
2586  if (ast_channel_vstream(chan)) {
2587  ast_closestream(ast_channel_vstream(chan));
2588  ast_channel_vstream_set(chan, NULL);
2589  }
2590  if (ast_channel_sched(chan)) {
2591  ast_sched_context_destroy(ast_channel_sched(chan));
2592  ast_channel_sched_set(chan, NULL);
2593  }
2594 
2595  if (ast_channel_generatordata(chan)) { /* Clear any tone stuff remaining */
2596  if (ast_channel_generator(chan) && ast_channel_generator(chan)->release) {
2597  ast_channel_generator(chan)->release(chan, ast_channel_generatordata(chan));
2598  }
2599  }
2600  ast_channel_generatordata_set(chan, NULL);
2601  ast_channel_generator_set(chan, NULL);
2602 
2603  if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING)) {
2604  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",
2605  ast_get_tid(), ast_channel_name(chan), ast_channel_blocker_tid(chan),
2606  ast_channel_blockproc(chan));
2607  ast_assert(0);
2608  }
2609 
2610  if (ast_channel_tech(chan)->hangup) {
2611  ast_channel_tech(chan)->hangup(chan);
2612  }
2613 
2614  ast_channel_unlock(chan);
2615 
2616  ast_cc_offer(chan);
2617 
2618  ast_channel_unref(chan);
2619 }
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2958
int(*const hangup)(struct ast_channel *chan)
Hangup (and possibly destroy) the channel.
Definition: channel.h:704
int ast_get_tid(void)
Get current thread ID.
Definition: utils.c:2752
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
void(* release)(struct ast_channel *chan, void *data)
Definition: channel.h:228
#define ast_debug(level,...)
Log a DEBUG message.
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:266
int ast_cc_offer(struct ast_channel *caller_chan)
Offer CC to a caller.
Definition: ccss.c:3716
#define ao2_unlink(container, obj)
Remove an object from a container.
Definition: astobj2.h:1578
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:124
int ast_closestream(struct ast_filestream *f)
Closes a stream.
Definition: file.c:1111
int ast_pbx_hangup_handler_run(struct ast_channel *chan)
Run all hangup handlers on the channel.
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
Definition: sched.c:271
int ast_indicate ( struct ast_channel chan,
int  condition 
)

Indicates condition of channel.

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

Definition at line 4277 of file channel.c.

References ast_indicate_data().

Referenced by __ast_play_and_record(), 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(), channel_do_masquerade(), cli_console_answer(), dial_exec_full(), do_forward(), handle_frame(), indicate_congestion(), monitor_dial(), queue_exec(), rna(), say_periodic_announcement(), softmix_bridge_join(), and wait_for_answer().

4278 {
4279  return ast_indicate_data(chan, condition, NULL, 0);
4280 }
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:4653
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 4653 of file channel.c.

References ast_channel_is_leaving_bridge(), 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_frame::data, ast_frame::datalen, ast_frame::frametype, indicate_data_internal(), ast_frame_subclass::integer, and ast_frame::subclass.

Referenced by __ast_read(), ast_channel_update_connected_line(), ast_channel_update_redirecting(), ast_handle_cc_control_frame(), ast_indicate(), channel_do_masquerade(), dial_exec_full(), fax_gateway_indicate_t38(), generic_fax_exec(), handle_frame(), and wait_for_answer().

4654 {
4655  int res;
4656  /* this frame is used by framehooks. if it is set, we must free it at the end of this function */
4657  struct ast_frame *awesome_frame = NULL;
4658 
4659  ast_channel_lock(chan);
4660 
4661  /* Don't bother if the channel is about to go away, anyway. */
4662  if ((ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE)
4663  || (ast_check_hangup(chan) && !ast_channel_is_leaving_bridge(chan)))
4664  && _condition != AST_CONTROL_MASQUERADE_NOTIFY) {
4665  res = -1;
4666  goto indicate_cleanup;
4667  }
4668 
4669  if (!ast_framehook_list_is_empty(ast_channel_framehooks(chan))) {
4670  /* Do framehooks now, do it, go, go now */
4671  struct ast_frame frame = {
4673  .subclass.integer = _condition,
4674  .data.ptr = (void *) data, /* this cast from const is only okay because we do the ast_frdup below */
4675  .datalen = datalen
4676  };
4677 
4678  /* we have now committed to freeing this frame */
4679  awesome_frame = ast_frdup(&frame);
4680 
4681  /* who knows what we will get back! the anticipation is killing me. */
4682  awesome_frame = ast_framehook_list_write_event(ast_channel_framehooks(chan),
4683  awesome_frame);
4684  if (!awesome_frame
4685  || awesome_frame->frametype != AST_FRAME_CONTROL) {
4686  res = 0;
4687  goto indicate_cleanup;
4688  }
4689 
4690  _condition = awesome_frame->subclass.integer;
4691  data = awesome_frame->data.ptr;
4692  datalen = awesome_frame->datalen;
4693  }
4694 
4695  res = indicate_data_internal(chan, _condition, data, datalen);
4696 
4697 indicate_cleanup:
4698  ast_channel_unlock(chan);
4699  if (awesome_frame) {
4700  ast_frfree(awesome_frame);
4701  }
4702 
4703  return res;
4704 }
#define ast_frdup(fr)
Copies a frame.
int ast_framehook_list_is_empty(struct ast_framehook_list *framehooks)
Determine if an framehook list is empty or not.
Definition: framehook.c:274
struct ast_frame_subclass subclass
static int indicate_data_internal(struct ast_channel *chan, int _condition, const void *data, size_t datalen)
Definition: channel.c:4470
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's framehook list...
Definition: framehook.c:313
union ast_frame::@224 data
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:10550
Data structure associated with a single frame of data.
enum ast_frame_type frametype
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(), 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
void ast_party_caller_copy ( struct ast_party_caller dest,
const struct ast_party_caller src 
)

Copy the source caller information to the destination caller.

Since
1.8
Parameters
destDestination caller
srcSource caller

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

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:420
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:427
struct ast_party_id priv
Private caller party ID.
Definition: channel.h:430
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:433
void ast_party_caller_free ( struct ast_party_caller doomed)

Destroy the caller party contents.

Since
1.8
Parameters
doomedThe caller party to destroy.

Definition at line 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(), 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:420
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:427
struct ast_party_id priv
Private caller party ID.
Definition: channel.h:430
void ast_party_caller_init ( struct ast_party_caller init)

Initialize the given caller structure.

Since
1.8
Parameters
initCaller structure to initialize.

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

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:420
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:427
struct ast_party_id priv
Private caller party ID.
Definition: channel.h:430
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:433
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition: channel.c:1757
void ast_party_caller_set ( struct ast_party_caller dest,
const struct ast_party_caller src,
const struct ast_set_party_caller update 
)

Set the caller information based on another caller source.

Since
1.8

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

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

Definition at line 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, ast_party_caller::priv, and ast_set_party_caller::priv.

Referenced by ast_channel_set_caller(), and ast_channel_set_caller_event().

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:444
struct ast_party_id id
Caller party ID.
Definition: channel.h:420
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:427
struct ast_party_id priv
Private caller party ID.
Definition: channel.h:430
struct ast_set_party_id id
Definition: channel.h:442
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:433
struct ast_set_party_id priv
Definition: channel.h:446
void ast_party_caller_set_init ( struct ast_party_caller init,
const struct ast_party_caller guide 
)

Initialize the given caller structure using the given guide for a set update operation.

Since
1.8

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

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

Definition at line 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 dial_exec_full(), do_forward(), 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:420
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:427
struct ast_party_id priv
Private caller party ID.
Definition: channel.h:430
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:433
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
void ast_party_connected_line_collect_caller ( struct ast_party_connected_line connected,
struct ast_party_caller caller 
)

Collect the caller party information into a connected line structure.

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

Definition at line 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:458
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:475
struct ast_party_id id
Caller party ID.
Definition: channel.h:420
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:427
struct ast_party_id priv
Private caller party ID.
Definition: channel.h:430
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:465
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:433
int source
Information about the source of an update.
Definition: channel.h:482
struct ast_party_id priv
Private connected party ID.
Definition: channel.h:468
void ast_party_connected_line_copy ( struct ast_party_connected_line dest,
const struct ast_party_connected_line src 
)

Copy the source connected line information to the destination connected line.

Since
1.8
Parameters
destDestination connected line
srcSource connected line

Definition at line 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(), ast_call_forward(), ast_channel_connected_line_sub(), ast_do_pickup(), attended_transfer_properties_alloc(), dial_exec_full(), do_forward(), 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:458
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:475
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:465
int source
Information about the source of an update.
Definition: channel.h:482
struct ast_party_id priv
Private connected party ID.
Definition: channel.h:468
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.

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(), agent_request_exec(), ast_channel_connected_line_sub(), ast_channel_destructor(), ast_do_pickup(), ast_dummy_channel_destructor(), and wait_for_answer().

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:458
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:465
struct ast_party_id priv
Private connected party ID.
Definition: channel.h:468
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.

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(), agent_request_exec(), ast_channel_connected_line_sub(), ast_do_pickup(), and do_forward().

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:458
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:475
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:465
int source
Information about the source of an update.
Definition: channel.h:482
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:468
void ast_party_connected_line_set ( struct ast_party_connected_line dest,
const struct ast_party_connected_line src,
const struct ast_set_party_connected_line update 
)

Set the connected line information based on another connected line source.

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

Definition at line 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, ast_party_connected_line::priv, ast_set_party_connected_line::priv, and ast_party_connected_line::source.

Referenced by ast_channel_set_connected_line(), and wait_for_answer().

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:458
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:475
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:465
struct ast_set_party_id priv
Definition: channel.h:495
int source
Information about the source of an update.
Definition: channel.h:482
struct ast_set_party_id id
Definition: channel.h:491
struct ast_set_party_id ani
Definition: channel.h:493
struct ast_party_id priv
Private connected party ID.
Definition: channel.h:468
void ast_party_connected_line_set_init ( struct ast_party_connected_line init,
const struct ast_party_connected_line guide 
)

Initialize the given connected line structure using the given guide for a set update operation.

Since
1.8

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

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

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

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:458
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:475
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:465
int source
Information about the source of an update.
Definition: channel.h:482
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:468
void ast_party_dialed_copy ( struct ast_party_dialed dest,
const struct ast_party_dialed src 
)

Copy the source dialed party information to the destination dialed party.

Since
1.8
Parameters
destDestination dialed party
srcSource dialed party

Definition at line 1936 of file channel.c.

References 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 }
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:388
char * str
Subscriber phone number (Malloced)
Definition: channel.h:386
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
void ast_party_subaddress_copy(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src)
Copy the source party subaddress information to the destination party subaddress. ...
Definition: channel.c:1705
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition: channel.h:391
int transit_network_select
Transit Network Select.
Definition: channel.h:397
struct ast_party_dialed::@206 number
Dialed/Called number.
void ast_party_dialed_free ( struct ast_party_dialed doomed)

Destroy the dialed party contents.

Since
1.8
Parameters
doomedThe dialed party to destroy.

Definition at line 1971 of file channel.c.

References ast_party_subaddress_free(), ast_party_dialed::number, ast_party_dialed::str, and ast_party_dialed::subaddress.

Referenced by ast_channel_destructor(), and ast_dummy_channel_destructor().

1972 {
1973  ast_free(doomed->number.str);
1974  doomed->number.str = NULL;
1976 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:386
void ast_party_subaddress_free(struct ast_party_subaddress *doomed)
Destroy the party subaddress contents.
Definition: channel.c:1744
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition: channel.h:391
struct ast_party_dialed::@206 number
Dialed/Called number.
void ast_party_dialed_init ( struct ast_party_dialed init)

Initialize the given dialed structure.

Since
1.8
Parameters
initDialed structure to initialize.

Definition at line 1928 of file channel.c.

References ast_party_subaddress_init(), ast_party_dialed::number, ast_party_dialed::plan, ast_party_dialed::str, ast_party_dialed::subaddress, and ast_party_dialed::transit_network_select.

Referenced by __ast_channel_alloc_ap().

1929 {
1930  init->number.str = NULL;
1931  init->number.plan = 0;/* Unknown */
1933  init->transit_network_select = 0;
1934 }
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:388
char * str
Subscriber phone number (Malloced)
Definition: channel.h:386
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:391
int transit_network_select
Transit Network Select.
Definition: channel.h:397
struct ast_party_dialed::@206 number
Dialed/Called number.
void ast_party_dialed_set ( struct ast_party_dialed dest,
const struct ast_party_dialed src 
)

Set the dialed information based on another dialed source.

Since
1.8

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

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

Definition at line 1958 of file channel.c.

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

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 }
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:388
char * str
Subscriber phone number (Malloced)
Definition: channel.h:386
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:241
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition: channel.h:391
int transit_network_select
Transit Network Select.
Definition: channel.h:397
struct ast_party_dialed::@206 number
Dialed/Called number.
void ast_party_dialed_set_init ( struct ast_party_dialed init,
const struct ast_party_dialed guide 
)

Initialize the given dialed structure using the given guide for a set update operation.

Since
1.8

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

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

Definition at line 1950 of file channel.c.

References ast_party_subaddress_set_init(), ast_party_dialed::number, ast_party_dialed::plan, ast_party_dialed::str, ast_party_dialed::subaddress, and ast_party_dialed::transit_network_select.

1951 {
1952  init->number.str = NULL;
1953  init->number.plan = guide->number.plan;
1956 }
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:388
char * str
Subscriber phone number (Malloced)
Definition: channel.h:386
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:391
int transit_network_select
Transit Network Select.
Definition: channel.h:397
struct ast_party_dialed::@206 number
Dialed/Called number.
void ast_party_id_copy ( struct ast_party_id dest,
const struct ast_party_id src 
)

Copy the source party id information to the destination party id.

Since
1.8
Parameters
destDestination party id
srcSource party id

Definition at line 1765 of file channel.c.

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

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:340
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
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:344
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
char * tag
User-set "tag".
Definition: channel.h:354
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:342
void ast_party_id_free ( struct ast_party_id doomed)

Destroy the party id contents.

Since
1.8
Parameters
doomedThe party id to destroy.

Definition at line 1811 of file channel.c.

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

Referenced by ast_party_caller_free(), ast_party_connected_line_free(), ast_party_id_reset(), and ast_party_redirecting_free().

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:340
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:344
char * tag
User-set "tag".
Definition: channel.h:354
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:342
void ast_party_id_init ( struct ast_party_id init)

Initialize the given party id structure.

Since
1.8
Parameters
initParty id structure to initialize.

Definition at line 1757 of file channel.c.

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

Referenced by ast_party_caller_init(), ast_party_connected_line_init(), ast_party_id_reset(), ast_party_redirecting_init(), and dial_exec_full().

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:340
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:344
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:354
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:342
void ast_party_id_invalidate ( struct ast_party_id id)

Invalidate all components of the given party id.

Since
11.0
Parameters
idThe party id to invalidate.

Definition at line 1889 of file channel.c.

1890 {
1891  id->name.valid = 0;
1892  id->number.valid = 0;
1893  id->subaddress.valid = 0;
1894 }
struct ast_party_id ast_party_id_merge ( struct ast_party_id base,
struct ast_party_id overlay 
)

Merge a given party id into another given party id.

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_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:338
struct ast_party_name name
Subscriber name.
Definition: channel.h:340
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:328
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:344
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:279
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:297
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:342
void ast_party_id_merge_copy ( struct ast_party_id dest,
struct ast_party_id base,
struct ast_party_id overlay 
)

Copy a merge of a given party id into another given party id to a given destination party id.

Since
11.0

Each party id component of the party id 'base' is overwritten by components of the party id 'overlay' if the 'overlay' component is marked as valid. However the component 'tag' of the 'base' party id remains untouched. The result is copied into the given party id 'dest'.

Note
The resulting merged party id is a real copy and has to be freed.
Parameters
destThe resulting merged party id.
baseThe party id which is merged.
overlayThe party id which is used to merge into.

Definition at line 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:338
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 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_party_id::name, ast_party_id::number, ast_party_name::valid, and ast_party_number::valid.

Referenced by ast_json_party_id(), ast_str_retrieve_variable(), and queue_exec().

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) {
1883  return AST_PRES_NUMBER_NOT_AVAILABLE;
1884  }
1885 
1886  return number_value | number_screening;
1887 }
struct ast_party_name name
Subscriber name.
Definition: channel.h:340
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:279
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:297
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:342
void ast_party_id_reset ( struct ast_party_id id)

Destroy and initialize the given party id structure.

Since
11.0
Parameters
idThe party id to reset.

Definition at line 1896 of file channel.c.

References ast_party_id_free(), and ast_party_id_init().

Referenced by ast_do_pickup(), and channel_do_masquerade().

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
void ast_party_id_set ( struct ast_party_id dest,
const struct ast_party_id src,
const struct ast_set_party_id update 
)

Set the source party id information into the destination party id.

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

Definition at line 1788 of file channel.c.

References 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:340
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
unsigned char subaddress
Definition: channel.h:367
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:344
unsigned char number
Definition: channel.h:365
char * tag
User-set "tag".
Definition: channel.h:354
unsigned char name
Definition: channel.h:363
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:342
void ast_party_id_set_init ( struct ast_party_id init,
const struct ast_party_id guide 
)

Initialize the given party id structure using the given guide for a set update operation.

Since
1.8

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

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

Definition at line 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, 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:340
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:344
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:354
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:342
void ast_party_name_copy ( struct ast_party_name dest,
const struct ast_party_name src 
)

Copy the source party name information to the destination party name.

Since
1.8
Parameters
destDestination party name
srcSource party name

Definition at line 1599 of file channel.c.

References 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:277
int char_set
Character set the name is using.
Definition: channel.h:272
char * str
Subscriber name (Malloced)
Definition: channel.h:264
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:279
void ast_party_name_free ( struct ast_party_name doomed)

Destroy the party name contents.

Since
1.8
Parameters
doomedThe party name to destroy.

Definition at line 1638 of file channel.c.

References ast_party_name::str.

Referenced by ast_party_id_free().

1639 {
1640  ast_free(doomed->str);
1641  doomed->str = NULL;
1642 }
char * str
Subscriber name (Malloced)
Definition: channel.h:264
void ast_party_name_init ( struct ast_party_name init)

Initialize the given name structure.

Since
1.8
Parameters
initName structure to initialize.

Definition at line 1591 of file channel.c.

References ast_party_name::char_set, ast_party_name::presentation, ast_party_name::str, and ast_party_name::valid.

Referenced by ast_party_id_init().

1592 {
1593  init->str = NULL;
1594  init->char_set = AST_PARTY_CHAR_SET_ISO8859_1;
1595  init->presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
1596  init->valid = 0;
1597 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:277
int char_set
Character set the name is using.
Definition: channel.h:272
char * str
Subscriber name (Malloced)
Definition: channel.h:264
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:279
void ast_party_name_set ( struct ast_party_name dest,
const struct ast_party_name src 
)

Set the source party name information into the destination party name.

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

Definition at line 1621 of file channel.c.

References 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:277
int char_set
Character set the name is using.
Definition: channel.h:272
char * str
Subscriber name (Malloced)
Definition: channel.h:264
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:279
void ast_party_name_set_init ( struct ast_party_name init,
const struct ast_party_name guide 
)

Initialize the given party name structure using the given guide for a set update operation.

Since
1.8

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

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

Definition at line 1613 of file channel.c.

References ast_party_name::char_set, ast_party_name::presentation, ast_party_name::str, and ast_party_name::valid.

Referenced by ast_party_id_set_init().

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:277
int char_set
Character set the name is using.
Definition: channel.h:272
char * str
Subscriber name (Malloced)
Definition: channel.h:264
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:279
void ast_party_number_copy ( struct ast_party_number dest,
const struct ast_party_number src 
)

Copy the source party number information to the destination party number.

Since
1.8
Parameters
destDestination party number
srcSource party number

Definition at line 1652 of file channel.c.

References 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:291
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:295
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:293
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:297
void ast_party_number_free ( struct ast_party_number doomed)

Destroy the party number contents.

Since
1.8
Parameters
doomedThe party number to destroy.

Definition at line 1691 of file channel.c.

References ast_party_number::str.

Referenced by ast_party_id_free(), do_forward(), and wait_for_answer().

1692 {
1693  ast_free(doomed->str);
1694  doomed->str = NULL;
1695 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:291
void ast_party_number_init ( struct ast_party_number init)

Initialize the given number structure.

Since
1.8
Parameters
initNumber structure to initialize.

Definition at line 1644 of file channel.c.

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

Referenced by ast_party_id_init(), do_forward(), and wait_for_answer().

1645 {
1646  init->str = NULL;
1647  init->plan = 0;/* Unknown */
1648  init->presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
1649  init->valid = 0;
1650 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:291
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:295
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:293
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:297
void ast_party_number_set ( struct ast_party_number dest,
const struct ast_party_number src 
)

Set the source party number information into the destination party number.

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

Definition at line 1674 of file channel.c.

References 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:291
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:295
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:293
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:297
void ast_party_number_set_init ( struct ast_party_number init,
const struct ast_party_number guide 
)

Initialize the given party number structure using the given guide for a set update operation.

Since
1.8

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

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

Definition at line 1666 of file channel.c.

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

Referenced by ast_party_id_set_init().

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:291
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:295
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:293
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:297
void ast_party_redirecting_copy ( struct ast_party_redirecting dest,
const struct ast_party_redirecting src 
)

Copy the source redirecting information to the destination redirecting.

Since
1.8
Parameters
destDestination redirecting
srcSource redirecting

Definition at line 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_sub(), ast_unreal_call_setup(), begin_dial_prerun(), dial_exec_full(), do_forward(), 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:539
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:533
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:527
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:536
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:524
struct ast_party_redirecting_reason orig_reason
Reason for the redirection by the original party.
Definition: channel.h:545
struct ast_party_redirecting_reason reason
Reason for the redirection.
Definition: channel.h:542
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:548
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:530
void ast_party_redirecting_free ( struct ast_party_redirecting doomed)

Destroy the redirecting information contents.

Since
1.8
Parameters
doomedThe redirecting information to destroy.

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_sub(), ast_dummy_channel_destructor(), do_forward(), 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:539
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:533
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:527
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:536
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:524
struct ast_party_redirecting_reason orig_reason
Reason for the redirection by the original party.
Definition: channel.h:545
struct ast_party_redirecting_reason reason
Reason for the redirection.
Definition: channel.h:542
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:530
void ast_party_redirecting_init ( struct ast_party_redirecting init)

Initialize the given redirecting structure.

Since
1.8
Parameters
initRedirecting structure to initialize.

Definition at line 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_sub(), do_forward(), 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:539
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:533
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:527
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:536
struct ast_party_id orig
Who originally redirected the call (Sent to the party the call is redirected toward) ...
Definition: channel.h:524
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:545
struct ast_party_redirecting_reason reason
Reason for the redirection.
Definition: channel.h:542
int count
Number of times the call was redirected.
Definition: channel.h:548
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:530
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition: channel.c:1757
void ast_party_redirecting_reason_copy ( struct ast_party_redirecting_reason dest,
const struct ast_party_redirecting_reason src 
)

Copy the source redirecting reason information to the destination redirecting reason.

Parameters
destDestination redirecting reason
srcSource redirecting reason

Definition at line 2085 of file channel.c.

References 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:241
int code
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:510
char * str
a string value for the redirecting reason
Definition: channel.h:507
void ast_party_redirecting_reason_free ( struct ast_party_redirecting_reason doomed)

Destroy the redirecting reason contents.

Parameters
doomedThe redirecting reason to destroy.

Definition at line 2116 of file channel.c.

References 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:507
void ast_party_redirecting_reason_init ( struct ast_party_redirecting_reason init)

Initialize the given redirecting reason structure.

Parameters
initRedirecting reason structure to initialize

Definition at line 2079 of file channel.c.

References ast_party_redirecting_reason::code, and ast_party_redirecting_reason::str.

Referenced by ast_party_redirecting_init().

2080 {
2081  init->str = NULL;
2082  init->code = AST_REDIRECTING_REASON_UNKNOWN;
2083 }
int code
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:510
char * str
a string value for the redirecting reason
Definition: channel.h:507
void ast_party_redirecting_reason_set ( struct ast_party_redirecting_reason dest,
const struct ast_party_redirecting_reason src 
)

Set the redirecting reason information based on another redirecting reason source.

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

Parameters
destThe redirecting reason one wishes to update
srcThe new redirecting reason values to update the dest

Definition at line 2102 of file channel.c.

References 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:241
int code
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:510
char * str
a string value for the redirecting reason
Definition: channel.h:507
void ast_party_redirecting_reason_set_init ( struct ast_party_redirecting_reason init,
const struct ast_party_redirecting_reason guide 
)

Initialize the given redirecting reason structure using the given guide for a set update operation.

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

Parameters
initRedirecting reason structure to initialize.
guideSource redirecting reason to use as a guide in initializing.

Definition at line 2096 of file channel.c.

References ast_party_redirecting_reason::code, and ast_party_redirecting_reason::str.

Referenced by ast_party_redirecting_set_init().

2097 {
2098  init->str = NULL;
2099  init->code = guide->code;
2100 }
int code
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:510
char * str
a string value for the redirecting reason
Definition: channel.h:507
void ast_party_redirecting_set ( struct ast_party_redirecting dest,
const struct ast_party_redirecting src,
const struct ast_set_party_redirecting update 
)

Set the redirecting information based on another redirecting source.

Since
1.8

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

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

Definition at line 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, 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:539
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:533
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:527
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:536
struct ast_set_party_id priv_orig
Definition: channel.h:563
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:559
struct ast_party_id orig
Who originally redirected the call (Sent to the party the call is redirected toward) ...
Definition: channel.h:524
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:545
struct ast_set_party_id priv_from
Definition: channel.h:565
struct ast_party_redirecting_reason reason
Reason for the redirection.
Definition: channel.h:542
struct ast_set_party_id orig
Definition: channel.h:557
struct ast_set_party_id to
Definition: channel.h:561
int count
Number of times the call was redirected.
Definition: channel.h:548
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:530
struct ast_set_party_id priv_to
Definition: channel.h:567
void ast_party_redirecting_set_init ( struct ast_party_redirecting init,
const struct ast_party_redirecting guide 
)

Initialize the given redirecting id structure using the given guide for a set update operation.

Since
1.8

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

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

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

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:539
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:533
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:527
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:536
struct ast_party_id orig
Who originally redirected the call (Sent to the party the call is redirected toward) ...
Definition: channel.h:524
struct ast_party_redirecting_reason orig_reason
Reason for the redirection by the original party.
Definition: channel.h:545
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:542
int count
Number of times the call was redirected.
Definition: channel.h:548
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:530
void ast_party_subaddress_copy ( struct ast_party_subaddress dest,
const struct ast_party_subaddress src 
)

Copy the source party subaddress information to the destination party subaddress.

Since
1.8
Parameters
destDestination party subaddress
srcSource party subaddress

Definition at line 1705 of file channel.c.

References 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:328
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
char * str
Malloced subaddress string.
Definition: channel.h:313
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:326
int type
Q.931 subaddress type.
Definition: channel.h:320
void ast_party_subaddress_free ( struct ast_party_subaddress doomed)

Destroy the party subaddress contents.

Since
1.8
Parameters
doomedThe party subaddress to destroy.

Definition at line 1744 of file channel.c.

References 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:313
void ast_party_subaddress_init ( struct ast_party_subaddress init)

Initialize the given subaddress structure.

Since
1.8
Parameters
initSubaddress structure to initialize.

Definition at line 1697 of file channel.c.

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

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

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:328
char * str
Malloced subaddress string.
Definition: channel.h:313
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:326
int type
Q.931 subaddress type.
Definition: channel.h:320
void ast_party_subaddress_set ( struct ast_party_subaddress dest,
const struct ast_party_subaddress src 
)

Set the source party subaddress information into the destination party subaddress.

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

Definition at line 1727 of file channel.c.

References 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:328
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
char * str
Malloced subaddress string.
Definition: channel.h:313
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:326
int type
Q.931 subaddress type.
Definition: channel.h:320
void ast_party_subaddress_set_init ( struct ast_party_subaddress init,
const struct ast_party_subaddress guide 
)

Initialize the given party subaddress structure using the given guide for a set update operation.

Since
1.8

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

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

Definition at line 1719 of file channel.c.

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

Referenced by ast_party_dialed_set_init(), and ast_party_id_set_init().

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:328
char * str
Malloced subaddress string.
Definition: channel.h:313
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:326
int type
Q.931 subaddress type.
Definition: channel.h:320
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 6444 of file channel.c.

References ast_app_exec_sub(), and ast_channel_tech::pre_call.

Referenced by begin_dial_prerun(), dial_exec_full(), and ring_entry().

6445 {
6446  int (*pre_call)(struct ast_channel *chan, const char *sub_args);
6447 
6448  ast_channel_lock(chan);
6449  pre_call = ast_channel_tech(chan)->pre_call;
6450  if (pre_call) {
6451  int res;
6452 
6453  res = pre_call(chan, sub_args);
6454  ast_channel_unlock(chan);
6455  return res;
6456  }
6457  ast_channel_unlock(chan);
6458  return ast_app_exec_sub(NULL, chan, sub_args, 0);
6459 }
Main Channel structure associated with a channel.
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
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:841
int ast_app_exec_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_args, int ignore_hangup)
Run a subroutine on a channel, placing an optional second channel into autoservice.
Definition: main/app.c:297
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 8031 of file channel.c.

8032 {
8033  unsigned int i;
8034  int first = 1;
8035  char num[3];
8036 
8037  buf[0] = '\0';
8038 
8039  if (!group) /* Return empty string if no group */
8040  return buf;
8041 
8042  for (i = 0; i <= 63; i++) { /* Max group is 63 */
8043  if (group & ((ast_group_t) 1 << i)) {
8044  if (!first) {
8045  strncat(buf, ", ", buflen - strlen(buf) - 1);
8046  } else {
8047  first = 0;
8048  }
8049  snprintf(num, sizeof(num), "%u", i);
8050  strncat(buf, num, buflen - strlen(buf) - 1);
8051  }
8052  }
8053  return buf;
8054 }
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's frame queue.
Definition: channel.c:1139
Data structure associated with a single frame of data.
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(), ast_do_pickup(), audiosocket_call(), chan_pjsip_incoming_response(), cli_console_answer(), jingle_action_session_accept(), jingle_action_session_info(), jingle_outgoing_hook(), pbx_outgoing_state_callback(), rtp_call(), and stasis_app_control_queue_control().

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's frame queue.
Definition: channel.c:1139
Data structure associated with a single frame of 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(), ast_channel_queue_connected_line_update(), ast_channel_queue_redirecting_update(), chan_pjsip_incoming_response_update_cause(), fax_gateway_indicate_t38(), jingle_action_session_terminate(), queue_read_action_payload(), t38_change_state(), t38_framehook(), t38_interpret_parameters(), 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's frame queue.
Definition: channel.c:1139
union ast_frame::@224 data
Data structure associated with a single frame of data.
int ast_queue_frame ( struct ast_channel chan,
struct ast_frame f 
)

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

Parameters
chanthe channel to queue the frame(s) on
fthe frame(s) to queue. Note that the frame(s) will be duplicated by this function. It is the responsibility of the caller to handle freeing the memory associated with the frame(s) being passed if necessary.
Return values
0success
non-zerofailure

Definition at line 1139 of file channel.c.

Referenced by __ast_read(), 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(), channel_do_masquerade(), cli_console_sendtext(), iax2_queue_frame(), set_interval_hook(), sig_pri_dial_complete(), stream_monitor(), and unreal_queue_frame().

1140 {
1141  return __ast_queue_frame(chan, fin, 0, NULL);
1142 }
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.

Referenced by __ast_answer(), __ast_read(), ast_autoservice_stop(), and safe_sleep_conditional().

1145 {
1146  return __ast_queue_frame(chan, fin, 1, NULL);
1147 }
int ast_queue_hangup ( struct ast_channel chan)

Queue a hangup frame.

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

Queue a hangup frame.

Definition at line 1150 of file channel.c.

References ast_channel_hangup_request_type(), ast_channel_publish_blob(), AST_CONTROL_HANGUP, AST_FRAME_CONTROL, ast_queue_frame(), and AST_SOFTHANGUP_DEV.

Referenced by ast_app_exec_sub(), ast_unreal_fixup(), chan_pjsip_session_end(), and iax2_queue_hangup().

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);
1157  ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_DEV);
1159 
1160  res = ast_queue_frame(chan, &f);
1161  ast_channel_unlock(chan);
1162  return res;
1163 }
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to a channel's frame queue.
Definition: channel.c:1139
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.
struct stasis_message_type * ast_channel_hangup_request_type(void)
Message type for when a hangup is requested on a channel.
int ast_queue_hangup_with_cause ( struct ast_channel chan,
int  cause 
)

Queue a hangup frame with hangupcause set.

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

Queue a hangup frame with hangupcause set.

Definition at line 1166 of file channel.c.

References ast_channel_hangup_request_type(), ast_channel_publish_blob(), AST_CONTROL_HANGUP, AST_FRAME_CONTROL, ast_json_pack(), ast_json_unref(), ast_queue_frame(), AST_SOFTHANGUP_DEV, ast_frame::data, and RAII_VAR.

Referenced by __analog_handle_event(), ast_unreal_hangup(), chan_pjsip_session_end(), jingle_action_session_terminate(), and jingle_queue_hangup_with_cause().

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 
1176  /* Yeah, let's not change a lock-critical value without locking */
1177  ast_channel_lock(chan);
1178  ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_DEV);
1179  if (cause < 0) {
1180  f.data.uint32 = ast_channel_hangupcause(chan);
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 }
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:612
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to a channel's frame queue.
Definition: channel.c:1139
union ast_frame::@224 data
Data structure associated with a single frame of data.
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.
#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:941
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_publish_blob(), AST_CONTROL_HOLD, AST_FRAME_CONTROL, ast_json_pack(), ast_json_unref(), ast_queue_frame(), ast_frame::data, and ast_frame::datalen.

Referenced by __analog_handle_event(), iax2_queue_hold(), and jingle_action_session_info().

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.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:612
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to a channel's frame queue.
Definition: channel.c:1139
union ast_frame::@224 data
Data structure associated with a single frame of data.
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.
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_publish_blob(), ast_channel_unhold_type(), AST_CONTROL_UNHOLD, AST_FRAME_CONTROL, and ast_queue_frame().

Referenced by __analog_handle_event(), iax2_queue_unhold(), and jingle_action_session_info().

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 }
struct stasis_message_type * ast_channel_unhold_type(void)
Message type for when a channel is removed from hold.
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to a channel's frame queue.
Definition: channel.c:1139
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.
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 2690 of file channel.c.

References ast_raw_answer_with_stream_topology().

Referenced by __ast_answer().

2691 {
2692  return ast_raw_answer_with_stream_topology(chan, NULL);
2693 }
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:2639
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 2639 of file channel.c.

References ast_channel_tech::answer, ast_channel_tech::answer_with_stream_topology, ast_check_hangup(), AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, ast_indicate(), ast_setstate(), AST_STATE_RING, AST_STATE_RINGING, and AST_STATE_UP.

Referenced by ast_raw_answer().

2640 {
2641  int res = 0;
2642  SCOPE_TRACE(1, "%s\n", ast_channel_name(chan));
2643 
2644  ast_channel_lock(chan);
2645 
2646  /* You can't answer an outbound call */
2647  if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_OUTGOING)) {
2648  ast_channel_unlock(chan);
2649  return 0;
2650  }
2651 
2652  /* Stop if we're a zombie or need a soft hangup */
2653  if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
2654  ast_channel_unlock(chan);
2655  return -1;
2656  }
2657 
2658  /*
2659  * Mark when incoming channel answered so we can know how
2660  * long the channel has been up.
2661  */
2662  set_channel_answer_time(chan);
2663 
2664  ast_channel_unlock(chan);
2665 
2666  switch (ast_channel_state(chan)) {
2667  case AST_STATE_RINGING:
2668  case AST_STATE_RING:
2669  ast_channel_lock(chan);
2670  if (ast_channel_tech(chan)->answer_with_stream_topology) {
2671  res = ast_channel_tech(chan)->answer_with_stream_topology(chan, topology);
2672 
2673  } else if (ast_channel_tech(chan)->answer) {
2674  res = ast_channel_tech(chan)->answer(chan);
2675  }
2676  ast_setstate(chan, AST_STATE_UP);
2677  ast_channel_unlock(chan);
2678  break;
2679  case AST_STATE_UP:
2680  break;
2681  default:
2682  break;
2683  }
2684 
2685  ast_indicate(chan, -1);
2686 
2687  return res;
2688 }
int(*const answer_with_stream_topology)(struct ast_channel *chan, struct ast_stream_topology *topology)
Answer the channel with topology.
Definition: channel.h:720
int(*const answer)(struct ast_channel *chan)
Answer the channel.
Definition: channel.h:707
ast_channel_state
ast_channel states
Definition: channelstate.h:35
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4277
int ast_check_hangup(struct ast_channel *chan)
Checks to see if a channel is needing hang up.
Definition: channel.c:445
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
int ast_setstate(struct ast_channel *chan, enum ast_channel_state state)
Change the state of a channel.
Definition: channel.c:7386
struct ast_frame* ast_read ( struct ast_channel chan)

Reads a frame.

Parameters
chanchannel to read a frame from
Returns
Returns a frame, or NULL on error. If it returns NULL, you best just stop reading frames and assume the channel has been disconnected.
Note
This function will filter frames received from the channel so that only frames from the default stream for each media type are returned. All other media frames from other streams will be absorbed internally and a NULL frame returned instead.

Definition at line 4257 of file channel.c.

References __ast_read().

Referenced by __ast_answer(), __ast_play_and_record(), __ast_request_and_dial(), ast_recvtext(), ast_tonepair(), ast_transfer_protocol(), ast_waitfordigit_full(), dial_exec_full(), generic_fax_exec(), moh_channel_thread(), monitor_dial(), read_mf_digits(), read_sf_digits(), receive_dtmf_digits(), run_agi(), safe_sleep_conditional(), speech_background(), stasis_app_exec(), wait_for_answer(), and waitstream_core().

4258 {
4259  return __ast_read(chan, 0, 1);
4260 }
static struct ast_frame * __ast_read(struct ast_channel *chan, int dropaudio, int dropnondefault)
Definition: channel.c:3525
struct ast_frame* ast_read_noaudio ( struct ast_channel chan)

Reads a frame, returning AST_FRAME_NULL frame if audio.

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

Definition at line 4267 of file channel.c.

References __ast_read().

Referenced by ast_control_tone().

4268 {
4269  return __ast_read(chan, 1, 1);
4270 }
static struct ast_frame * __ast_read(struct ast_channel *chan, int dropaudio, int dropnondefault)
Definition: channel.c:3525
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 4262 of file channel.c.

References __ast_read().

4263 {
4264  return __ast_read(chan, 0, 0);
4265 }
static struct ast_frame * __ast_read(struct ast_channel *chan, int dropaudio, int dropnondefault)
Definition: channel.c:3525
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 4272 of file channel.c.

References __ast_read().

4273 {
4274  return __ast_read(chan, 1, 0);
4275 }
static struct ast_frame * __ast_read(struct ast_channel *chan, int dropaudio, int dropnondefault)
Definition: channel.c:3525
int ast_readstring ( struct ast_channel c,
char *  s,
int  len,
int  timeout,
int  rtimeout,
char *  enders 
)

Reads multiple digits.

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

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

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

Definition at line 6558 of file channel.c.

Referenced by ast_app_getdata_terminator(), and forward_message().

6559 {
6560  return ast_readstring_full(c, s, len, timeout, ftimeout, enders, -1, -1);
6561 }
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 4706 of file channel.c.

References ast_recvtext().

4707 {
4708  int c;
4709  char *buf = ast_recvtext(chan, timeout);
4710  if (buf == NULL)
4711  return -1; /* error or timeout */
4712  c = *(unsigned char *)buf;
4713  ast_free(buf);
4714  return c;
4715 }
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:4717
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 4717 of file channel.c.

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

Referenced by ast_recvchar().

4718 {
4719  int res;
4720  char *buf = NULL;
4721  struct timeval start = ast_tvnow();
4722  int ms;
4723 
4724  while ((ms = ast_remaining_ms(start, timeout))) {
4725  struct ast_frame *f;
4726 
4727  if (ast_check_hangup(chan)) {
4728  break;
4729  }
4730  res = ast_waitfor(chan, ms);
4731  if (res <= 0) {/* timeout or error */
4732  break;
4733  }
4734  f = ast_read(chan);
4735  if (f == NULL) {
4736  break; /* no frame */
4737  }
4739  ast_frfree(f);
4740  break;
4741  } else if (f->frametype == AST_FRAME_TEXT) { /* what we want */
4742  buf = ast_strndup((char *) f->data.ptr, f->datalen); /* dup and break */
4743  ast_frfree(f);
4744  break;
4745  }
4746  ast_frfree(f);
4747  }
4748  return buf;
4749 }
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:159
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: utils.c:2281
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4257
#define ast_strndup(str, len)
A wrapper for strndup()
Definition: astmm.h:256
union ast_frame::@224 data
int ast_waitfor(struct ast_channel *c, int ms)
Wait for input on a channel.
Definition: channel.c:3162
Data structure associated with a single frame of data.
enum ast_frame_type frametype
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 9268 of file channel.c.

References ast_party_redirecting::count, ast_party_redirecting::from, ast_set_party_redirecting::from, ast_party_id_ies::name, 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_name_ies::str, ast_party_redirecting::to, and ast_set_party_redirecting::to.

Referenced by ast_channel_queue_redirecting_update(), and ast_channel_update_redirecting().

9269 {
9270  int32_t value;
9271  size_t pos = 0;
9272  int res;
9273 
9274  static const struct ast_party_id_ies orig_ies = {
9275  .name.str = AST_REDIRECTING_ORIG_NAME,
9276  .name.char_set = AST_REDIRECTING_ORIG_NAME_CHAR_SET,
9277  .name.presentation = AST_REDIRECTING_ORIG_NAME_PRESENTATION,
9278  .name.valid = AST_REDIRECTING_ORIG_NAME_VALID,
9279 
9280  .number.str = AST_REDIRECTING_ORIG_NUMBER,
9281  .number.plan = AST_REDIRECTING_ORIG_NUMBER_PLAN,
9282  .number.presentation = AST_REDIRECTING_ORIG_NUMBER_PRESENTATION,
9283  .number.valid = AST_REDIRECTING_ORIG_NUMBER_VALID,
9284 
9285  .subaddress.str = AST_REDIRECTING_ORIG_SUBADDRESS,
9286  .subaddress.type = AST_REDIRECTING_ORIG_SUBADDRESS_TYPE,
9287  .subaddress.odd_even_indicator = AST_REDIRECTING_ORIG_SUBADDRESS_ODD_EVEN,
9288  .subaddress.valid = AST_REDIRECTING_ORIG_SUBADDRESS_VALID,
9289 
9290  .tag = AST_REDIRECTING_ORIG_TAG,
9291  .combined_presentation = 0,/* Not sent. */
9292  };
9293  static const struct ast_party_id_ies from_ies = {
9294  .name.str = AST_REDIRECTING_FROM_NAME,
9295  .name.char_set = AST_REDIRECTING_FROM_NAME_CHAR_SET,
9296  .name.presentation = AST_REDIRECTING_FROM_NAME_PRESENTATION,
9297  .name.valid = AST_REDIRECTING_FROM_NAME_VALID,
9298 
9299  .number.str = AST_REDIRECTING_FROM_NUMBER,
9300  .number.plan = AST_REDIRECTING_FROM_NUMBER_PLAN,
9301  .number.presentation = AST_REDIRECTING_FROM_NUMBER_PRESENTATION,
9302  .number.valid = AST_REDIRECTING_FROM_NUMBER_VALID,
9303 
9304  .subaddress.str = AST_REDIRECTING_FROM_SUBADDRESS,
9305  .subaddress.type = AST_REDIRECTING_FROM_SUBADDRESS_TYPE,
9306  .subaddress.odd_even_indicator = AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN,
9307  .subaddress.valid = AST_REDIRECTING_FROM_SUBADDRESS_VALID,
9308 
9309  .tag = AST_REDIRECTING_FROM_TAG,
9310  .combined_presentation = AST_REDIRECTING_FROM_ID_PRESENTATION,
9311  };
9312  static const struct ast_party_id_ies to_ies = {
9313  .name.str = AST_REDIRECTING_TO_NAME,
9314  .name.char_set = AST_REDIRECTING_TO_NAME_CHAR_SET,
9315  .name.presentation = AST_REDIRECTING_TO_NAME_PRESENTATION,
9316  .name.valid = AST_REDIRECTING_TO_NAME_VALID,
9317 
9318  .number.str = AST_REDIRECTING_TO_NUMBER,
9319  .number.plan = AST_REDIRECTING_TO_NUMBER_PLAN,
9320  .number.presentation = AST_REDIRECTING_TO_NUMBER_PRESENTATION,
9321  .number.valid = AST_REDIRECTING_TO_NUMBER_VALID,
9322 
9323  .subaddress.str = AST_REDIRECTING_TO_SUBADDRESS,
9324  .subaddress.type = AST_REDIRECTING_TO_SUBADDRESS_TYPE,
9325  .subaddress.odd_even_indicator = AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN,
9326  .subaddress.valid = AST_REDIRECTING_TO_SUBADDRESS_VALID,
9327 
9328  .tag = AST_REDIRECTING_TO_TAG,
9329  .combined_presentation = AST_REDIRECTING_TO_ID_PRESENTATION,
9330  };
9331  static const struct ast_party_id_ies priv_orig_ies = {
9332  .name.str = AST_REDIRECTING_PRIV_ORIG_NAME,
9333  .name.char_set = AST_REDIRECTING_PRIV_ORIG_NAME_CHAR_SET,
9334  .name.presentation = AST_REDIRECTING_PRIV_ORIG_NAME_PRESENTATION,
9335  .name.valid = AST_REDIRECTING_PRIV_ORIG_NAME_VALID,
9336 
9337  .number.str = AST_REDIRECTING_PRIV_ORIG_NUMBER,
9338  .number.plan = AST_REDIRECTING_PRIV_ORIG_NUMBER_PLAN,
9339  .number.presentation = AST_REDIRECTING_PRIV_ORIG_NUMBER_PRESENTATION,
9340  .number.valid = AST_REDIRECTING_PRIV_ORIG_NUMBER_VALID,
9341 
9342  .subaddress.str = AST_REDIRECTING_PRIV_ORIG_SUBADDRESS,
9343  .subaddress.type = AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_TYPE,
9344  .subaddress.odd_even_indicator = AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_ODD_EVEN,
9345  .subaddress.valid = AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_VALID,
9346 
9347  .tag = AST_REDIRECTING_PRIV_ORIG_TAG,
9348  .combined_presentation = 0,/* Not sent. */
9349  };
9350  static const struct ast_party_id_ies priv_from_ies = {
9351  .name.str = AST_REDIRECTING_PRIV_FROM_NAME,
9352  .name.char_set = AST_REDIRECTING_PRIV_FROM_NAME_CHAR_SET,
9353  .name.presentation = AST_REDIRECTING_PRIV_FROM_NAME_PRESENTATION,
9354  .name.valid = AST_REDIRECTING_PRIV_FROM_NAME_VALID,
9355 
9356  .number.str = AST_REDIRECTING_PRIV_FROM_NUMBER,
9357  .number.plan = AST_REDIRECTING_PRIV_FROM_NUMBER_PLAN,
9358  .number.presentation = AST_REDIRECTING_PRIV_FROM_NUMBER_PRESENTATION,
9359  .number.valid = AST_REDIRECTING_PRIV_FROM_NUMBER_VALID,
9360 
9361  .subaddress.str = AST_REDIRECTING_PRIV_FROM_SUBADDRESS,
9362  .subaddress.type = AST_REDIRECTING_PRIV_FROM_SUBADDRESS_TYPE,
9363  .subaddress.odd_even_indicator = AST_REDIRECTING_PRIV_FROM_SUBADDRESS_ODD_EVEN,
9364  .subaddress.valid = AST_REDIRECTING_PRIV_FROM_SUBADDRESS_VALID,
9365 
9366  .tag = AST_REDIRECTING_PRIV_FROM_TAG,
9367  .combined_presentation = 0,/* Not sent. */
9368  };
9369  static const struct ast_party_id_ies priv_to_ies = {
9370  .name.str = AST_REDIRECTING_PRIV_TO_NAME,
9371  .name.char_set = AST_REDIRECTING_PRIV_TO_NAME_CHAR_SET,
9372  .name.presentation = AST_REDIRECTING_PRIV_TO_NAME_PRESENTATION,
9373  .name.valid = AST_REDIRECTING_PRIV_TO_NAME_VALID,
9374 
9375  .number.str = AST_REDIRECTING_PRIV_TO_NUMBER,
9376  .number.plan = AST_REDIRECTING_PRIV_TO_NUMBER_PLAN,
9377  .number.presentation = AST_REDIRECTING_PRIV_TO_NUMBER_PRESENTATION,
9378  .number.valid = AST_REDIRECTING_PRIV_TO_NUMBER_VALID,
9379 
9380  .subaddress.str = AST_REDIRECTING_PRIV_TO_SUBADDRESS,
9381  .subaddress.type = AST_REDIRECTING_PRIV_TO_SUBADDRESS_TYPE,
9382  .subaddress.odd_even_indicator = AST_REDIRECTING_PRIV_TO_SUBADDRESS_ODD_EVEN,
9383  .subaddress.valid = AST_REDIRECTING_PRIV_TO_SUBADDRESS_VALID,
9384 
9385  .tag = AST_REDIRECTING_PRIV_TO_TAG,
9386  .combined_presentation = 0,/* Not sent. */
9387  };
9388  static const struct ast_party_redirecting_reason_ies reason_ies = {
9389  .code = AST_REDIRECTING_REASON_CODE,
9390  .str = AST_REDIRECTING_REASON_STR,
9391  };
9392 
9393  static const struct ast_party_redirecting_reason_ies orig_reason_ies = {
9394  .code = AST_REDIRECTING_ORIG_REASON_CODE,
9395  .str = AST_REDIRECTING_ORIG_REASON_STR,
9396  };
9397 
9398  /* Redirecting frame version */
9399  if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
9400  ast_log(LOG_WARNING, "No space left for redirecting frame version\n");
9401  return -1;
9402  }
9403  data[pos++] = AST_REDIRECTING_VERSION;
9404  data[pos++] = 1;
9405  data[pos++] = 2;/* Version 1 did not have a version ie */
9406 
9407  res = party_id_build_data(data + pos, datalen - pos, &redirecting->orig,
9408  "redirecting-orig", &orig_ies, update ? &update->orig : NULL);
9409  if (res < 0) {
9410  return -1;
9411  }
9412  pos += res;
9413 
9414  res = party_id_build_data(data + pos, datalen - pos, &redirecting->from,
9415  "redirecting-from", &from_ies, update ? &update->from : NULL);
9416  if (res < 0) {
9417  return -1;
9418  }
9419  pos += res;
9420 
9421  res = party_id_build_data(data + pos, datalen - pos, &redirecting->to,
9422  "redirecting-to", &to_ies, update ? &update->to : NULL);
9423  if (res < 0) {
9424  return -1;
9425  }
9426  pos += res;
9427 
9428  res = party_id_build_data(data + pos, datalen - pos, &redirecting->priv_orig,
9429  "redirecting-priv-orig", &priv_orig_ies, update ? &update->priv_orig : NULL);
9430  if (res < 0) {
9431  return -1;
9432  }
9433  pos += res;
9434 
9435  res = party_id_build_data(data + pos, datalen - pos, &redirecting->priv_from,
9436  "redirecting-priv-from", &priv_from_ies, update ? &update->priv_from : NULL);
9437  if (res < 0) {
9438  return -1;
9439  }
9440  pos += res;
9441 
9442  res = party_id_build_data(data + pos, datalen - pos, &redirecting->priv_to,
9443  "redirecting-priv-to", &priv_to_ies, update ? &update->priv_to : NULL);
9444  if (res < 0) {
9445  return -1;
9446  }
9447  pos += res;
9448 
9449  /* Redirecting reason */
9450  res = redirecting_reason_build_data(data + pos, datalen - pos, &redirecting->reason,
9451  "redirecting-reason", &reason_ies);
9452  if (res < 0) {
9453  return -1;
9454  }
9455  pos += res;
9456 
9457  /* Redirecting original reason */
9458  res = redirecting_reason_build_data(data + pos, datalen - pos, &redirecting->orig_reason,
9459  "redirecting-orig-reason", &orig_reason_ies);
9460  if (res < 0) {
9461  return -1;
9462  }
9463  pos += res;
9464 
9465  /* Redirecting count */
9466  if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) {
9467  ast_log(LOG_WARNING, "No space left for redirecting count\n");
9468  return -1;
9469  }
9470  data[pos++] = AST_REDIRECTING_COUNT;
9471  data[pos++] = sizeof(value);
9472  value = htonl(redirecting->count);
9473  memcpy(data + pos, &value, sizeof(value));
9474  pos += sizeof(value);
9475 
9476  return pos;
9477 }
struct ast_party_id priv_to
Call is redirecting to a new party (Sent to the caller) - private representation. ...
Definition: channel.h:539
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:533
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:527
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:536
struct ast_set_party_id priv_orig
Definition: channel.h:563
struct ast_party_name_ies name
Subscriber name ies.
Definition: channel.c:8548
struct ast_set_party_id from
Definition: channel.h:559
struct ast_party_id orig
Who originally redirected the call (Sent to the party the call is redirected toward) ...
Definition: channel.h:524
struct ast_party_redirecting_reason orig_reason
Reason for the redirection by the original party.
Definition: channel.h:545
struct ast_set_party_id priv_from
Definition: channel.h:565
struct ast_party_redirecting_reason reason
Reason for the redirection.
Definition: channel.h:542
struct ast_set_party_id orig
Definition: channel.h:557
struct ast_set_party_id to
Definition: channel.h:561
int count
Number of times the call was redirected.
Definition: channel.h:548
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:530
struct ast_set_party_id priv_to
Definition: channel.h:567
int str
Subscriber name ie.
Definition: channel.c:8325
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 9479 of file channel.c.

References ast_debug, ast_malloc, ast_party_name::char_set, ast_party_redirecting_reason::code, ast_party_redirecting::count, ast_party_redirecting::from, 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, and ast_party_subaddress::valid.

Referenced by ast_channel_redirecting_sub().

9480 {
9481  size_t pos;
9482  unsigned char ie_len;
9483  unsigned char ie_id;
9484  int32_t value;
9485  int frame_version = 1;
9486  int from_combined_presentation = 0;
9487  int got_from_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
9488  int to_combined_presentation = 0;
9489  int got_to_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
9490 
9491  for (pos = 0; pos < datalen; pos += ie_len) {
9492  if (datalen < pos + sizeof(ie_id) + sizeof(ie_len)) {
9493  ast_log(LOG_WARNING, "Invalid redirecting update\n");
9494  return -1;
9495  }
9496  ie_id = data[pos++];
9497  ie_len = data[pos++];
9498  if (datalen < pos + ie_len) {
9499  ast_log(LOG_WARNING, "Invalid redirecting update\n");
9500  return -1;
9501  }
9502 
9503  switch (ie_id) {
9504 /* Redirecting frame version */
9505  case AST_REDIRECTING_VERSION:
9506  if (ie_len != 1) {
9507  ast_log(LOG_WARNING, "Invalid redirecting frame version (%u)\n",
9508  (unsigned) ie_len);
9509  break;
9510  }
9511  frame_version = data[pos];
9512  break;
9513 /* Redirecting-orig party id name */
9514  case AST_REDIRECTING_ORIG_NAME:
9515  ast_free(redirecting->orig.name.str);
9516  redirecting->orig.name.str = ast_malloc(ie_len + 1);
9517  if (redirecting->orig.name.str) {
9518  memcpy(redirecting->orig.name.str, data + pos, ie_len);
9519  redirecting->orig.name.str[ie_len] = 0;
9520  }
9521  break;
9522  case AST_REDIRECTING_ORIG_NAME_CHAR_SET:
9523  if (ie_len != 1) {
9524  ast_log(LOG_WARNING, "Invalid redirecting-orig name char set (%u)\n",
9525  (unsigned) ie_len);
9526  break;
9527  }
9528  redirecting->orig.name.char_set = data[pos];
9529  break;
9530  case AST_REDIRECTING_ORIG_NAME_PRESENTATION:
9531  if (ie_len != 1) {
9532  ast_log(LOG_WARNING, "Invalid redirecting-orig name presentation (%u)\n",
9533  (unsigned) ie_len);
9534  break;
9535  }
9536  redirecting->orig.name.presentation = data[pos];
9537  break;
9538  case AST_REDIRECTING_ORIG_NAME_VALID:
9539  if (ie_len != 1) {
9540  ast_log(LOG_WARNING, "Invalid redirecting-orig name valid (%u)\n",
9541  (unsigned) ie_len);
9542  break;
9543  }
9544  redirecting->orig.name.valid = data[pos];
9545  break;
9546 /* Redirecting-orig party id number */
9547  case AST_REDIRECTING_ORIG_NUMBER:
9548  ast_free(redirecting->orig.number.str);
9549  redirecting->orig.number.str = ast_malloc(ie_len + 1);
9550  if (redirecting->orig.number.str) {
9551  memcpy(redirecting->orig.number.str, data + pos, ie_len);
9552  redirecting->orig.number.str[ie_len] = 0;
9553  }
9554  break;
9555  case AST_REDIRECTING_ORIG_NUMBER_PLAN:
9556  if (ie_len != 1) {
9557  ast_log(LOG_WARNING, "Invalid redirecting-orig numbering plan (%u)\n",
9558  (unsigned) ie_len);
9559  break;
9560  }
9561  redirecting->orig.number.plan = data[pos];
9562  break;
9563  case AST_REDIRECTING_ORIG_NUMBER_PRESENTATION:
9564  if (ie_len != 1) {
9565  ast_log(LOG_WARNING, "Invalid redirecting-orig number presentation (%u)\n",
9566  (unsigned) ie_len);
9567  break;
9568  }
9569  redirecting->orig.number.presentation = data[pos];
9570  break;
9571  case AST_REDIRECTING_ORIG_NUMBER_VALID:
9572  if (ie_len != 1) {
9573  ast_log(LOG_WARNING, "Invalid redirecting-orig number valid (%u)\n",
9574  (unsigned) ie_len);
9575  break;
9576  }
9577  redirecting->orig.number.valid = data[pos];
9578  break;
9579 /* Redirecting-orig party id subaddress */
9580  case AST_REDIRECTING_ORIG_SUBADDRESS:
9581  ast_free(redirecting->orig.subaddress.str);
9582  redirecting->orig.subaddress.str = ast_malloc(ie_len + 1);
9583  if (redirecting->orig.subaddress.str) {
9584  memcpy(redirecting->orig.subaddress.str, data + pos, ie_len);
9585  redirecting->orig.subaddress.str[ie_len] = 0;
9586  }
9587  break;
9588  case AST_REDIRECTING_ORIG_SUBADDRESS_TYPE:
9589  if (ie_len != 1) {
9590  ast_log(LOG_WARNING, "Invalid redirecting-orig type of subaddress (%u)\n",
9591  (unsigned) ie_len);
9592  break;
9593  }
9594  redirecting->orig.subaddress.type = data[pos];
9595  break;
9596  case AST_REDIRECTING_ORIG_SUBADDRESS_ODD_EVEN:
9597  if (ie_len != 1) {
9598  ast_log(LOG_WARNING,
9599  "Invalid redirecting-orig subaddress odd-even indicator (%u)\n",
9600  (unsigned) ie_len);
9601  break;
9602  }
9603  redirecting->orig.subaddress.odd_even_indicator = data[pos];
9604  break;
9605  case AST_REDIRECTING_ORIG_SUBADDRESS_VALID:
9606  if (ie_len != 1) {
9607  ast_log(LOG_WARNING, "Invalid redirecting-orig subaddress valid (%u)\n",
9608  (unsigned) ie_len);
9609  break;
9610  }
9611  redirecting->orig.subaddress.valid = data[pos];
9612  break;
9613 /* Redirecting-orig party id tag */
9614  case AST_REDIRECTING_ORIG_TAG:
9615  ast_free(redirecting->orig.tag);
9616  redirecting->orig.tag = ast_malloc(ie_len + 1);
9617  if (redirecting->orig.tag) {
9618  memcpy(redirecting->orig.tag, data + pos, ie_len);
9619  redirecting->orig.tag[ie_len] = 0;
9620  }
9621  break;
9622 /* Redirecting-from party id name */
9623  case AST_REDIRECTING_FROM_NAME:
9624  ast_free(redirecting->from.name.str);
9625  redirecting->from.name.str = ast_malloc(ie_len + 1);
9626  if (redirecting->from.name.str) {
9627  memcpy(redirecting->from.name.str, data + pos, ie_len);
9628  redirecting->from.name.str[ie_len] = 0;
9629  }
9630  break;
9631  case AST_REDIRECTING_FROM_NAME_CHAR_SET:
9632  if (ie_len != 1) {
9633  ast_log(LOG_WARNING, "Invalid redirecting-from name char set (%u)\n",
9634  (unsigned) ie_len);
9635  break;
9636  }
9637  redirecting->from.name.char_set = data[pos];
9638  break;
9639  case AST_REDIRECTING_FROM_NAME_PRESENTATION:
9640  if (ie_len != 1) {
9641  ast_log(LOG_WARNING, "Invalid redirecting-from name presentation (%u)\n",
9642  (unsigned) ie_len);
9643  break;
9644  }
9645  redirecting->from.name.presentation = data[pos];
9646  break;
9647  case AST_REDIRECTING_FROM_NAME_VALID:
9648  if (ie_len != 1) {
9649  ast_log(LOG_WARNING, "Invalid redirecting-from name valid (%u)\n",
9650  (unsigned) ie_len);
9651  break;
9652  }
9653  redirecting->from.name.valid = data[pos];
9654  break;
9655 /* Redirecting-from party id number */
9656  case AST_REDIRECTING_FROM_NUMBER:
9657  ast_free(redirecting->from.number.str);
9658  redirecting->from.number.str = ast_malloc(ie_len + 1);
9659  if (redirecting->from.number.str) {
9660  memcpy(redirecting->from.number.str, data + pos, ie_len);
9661  redirecting->from.number.str[ie_len] = 0;
9662  }
9663  break;
9664  case AST_REDIRECTING_FROM_NUMBER_PLAN:
9665  if (ie_len != 1) {
9666  ast_log(LOG_WARNING, "Invalid redirecting-from numbering plan (%u)\n",
9667  (unsigned) ie_len);
9668  break;
9669  }
9670  redirecting->from.number.plan = data[pos];
9671  break;
9672  case AST_REDIRECTING_FROM_NUMBER_PRESENTATION:
9673  if (ie_len != 1) {
9674  ast_log(LOG_WARNING, "Invalid redirecting-from number presentation (%u)\n",
9675  (unsigned) ie_len);
9676  break;
9677  }
9678  redirecting->from.number.presentation = data[pos];
9679  break;
9680  case AST_REDIRECTING_FROM_NUMBER_VALID:
9681  if (ie_len != 1) {
9682  ast_log(LOG_WARNING, "Invalid redirecting-from number valid (%u)\n",
9683  (unsigned) ie_len);
9684  break;
9685  }
9686  redirecting->from.number.valid = data[pos];
9687  break;
9688 /* Redirecting-from party id combined presentation */
9689  case AST_REDIRECTING_FROM_ID_PRESENTATION:
9690  if (ie_len != 1) {
9691  ast_log(LOG_WARNING, "Invalid redirecting-from combined presentation (%u)\n",
9692  (unsigned) ie_len);
9693  break;
9694  }
9695  from_combined_presentation = data[pos];
9696  got_from_combined_presentation = 1;
9697  break;
9698 /* Redirecting-from party id subaddress */
9699  case AST_REDIRECTING_FROM_SUBADDRESS:
9700  ast_free(redirecting->from.subaddress.str);
9701  redirecting->from.subaddress.str = ast_malloc(ie_len + 1);
9702  if (redirecting->from.subaddress.str) {
9703  memcpy(redirecting->from.subaddress.str, data + pos, ie_len);
9704  redirecting->from.subaddress.str[ie_len] = 0;
9705  }
9706  break;
9707  case AST_REDIRECTING_FROM_SUBADDRESS_TYPE:
9708  if (ie_len != 1) {
9709  ast_log(LOG_WARNING, "Invalid redirecting-from type of subaddress (%u)\n",
9710  (unsigned) ie_len);
9711  break;
9712  }
9713  redirecting->from.subaddress.type = data[pos];
9714  break;
9715  case AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN:
9716  if (ie_len != 1) {
9717  ast_log(LOG_WARNING,
9718  "Invalid redirecting-from subaddress odd-even indicator (%u)\n",
9719  (unsigned) ie_len);
9720  break;
9721  }
9722  redirecting->from.subaddress.odd_even_indicator = data[pos];
9723  break;
9724  case AST_REDIRECTING_FROM_SUBADDRESS_VALID:
9725  if (ie_len != 1) {
9726  ast_log(LOG_WARNING, "Invalid redirecting-from subaddress valid (%u)\n",
9727  (unsigned) ie_len);
9728  break;
9729  }
9730  redirecting->from.subaddress.valid = data[pos];
9731  break;
9732 /* Redirecting-from party id tag */
9733  case AST_REDIRECTING_FROM_TAG:
9734  ast_free(redirecting->from.tag);
9735  redirecting->from.tag = ast_malloc(ie_len + 1);
9736  if (redirecting->from.tag) {
9737  memcpy(redirecting->from.tag, data + pos, ie_len);
9738  redirecting->from.tag[ie_len] = 0;
9739  }
9740  break;
9741 /* Redirecting-to party id name */
9742  case AST_REDIRECTING_TO_NAME:
9743  ast_free(redirecting->to.name.str);
9744  redirecting->to.name.str = ast_malloc(ie_len + 1);
9745  if (redirecting->to.name.str) {
9746  memcpy(redirecting->to.name.str, data + pos, ie_len);
9747  redirecting->to.name.str[ie_len] = 0;
9748  }
9749  break;
9750  case AST_REDIRECTING_TO_NAME_CHAR_SET:
9751  if (ie_len != 1) {
9752  ast_log(LOG_WARNING, "Invalid redirecting-to name char set (%u)\n",
9753  (unsigned) ie_len);
9754  break;
9755  }
9756  redirecting->to.name.char_set = data[pos];
9757  break;
9758  case AST_REDIRECTING_TO_NAME_PRESENTATION:
9759  if (ie_len != 1) {
9760  ast_log(LOG_WARNING, "Invalid redirecting-to name presentation (%u)\n",
9761  (unsigned) ie_len);
9762  break;
9763  }
9764  redirecting->to.name.presentation = data[pos];
9765  break;
9766  case AST_REDIRECTING_TO_NAME_VALID:
9767  if (ie_len != 1) {
9768  ast_log(LOG_WARNING, "Invalid redirecting-to name valid (%u)\n",
9769  (unsigned) ie_len);
9770  break;
9771  }
9772  redirecting->to.name.valid = data[pos];
9773  break;
9774 /* Redirecting-to party id number */
9775  case AST_REDIRECTING_TO_NUMBER:
9776  ast_free(redirecting->to.number.str);
9777  redirecting->to.number.str = ast_malloc(ie_len + 1);
9778  if (redirecting->to.number.str) {
9779  memcpy(redirecting->to.number.str, data + pos, ie_len);
9780  redirecting->to.number.str[ie_len] = 0;
9781  }
9782  break;
9783  case AST_REDIRECTING_TO_NUMBER_PLAN:
9784  if (ie_len != 1) {
9785  ast_log(LOG_WARNING, "Invalid redirecting-to numbering plan (%u)\n",
9786  (unsigned) ie_len);
9787  break;
9788  }
9789  redirecting->to.number.plan = data[pos];
9790  break;
9791  case AST_REDIRECTING_TO_NUMBER_PRESENTATION:
9792  if (ie_len != 1) {
9793  ast_log(LOG_WARNING, "Invalid redirecting-to number presentation (%u)\n",
9794  (unsigned) ie_len);
9795  break;
9796  }
9797  redirecting->to.number.presentation = data[pos];
9798  break;
9799  case AST_REDIRECTING_TO_NUMBER_VALID:
9800  if (ie_len != 1) {
9801  ast_log(LOG_WARNING, "Invalid redirecting-to number valid (%u)\n",
9802  (unsigned) ie_len);
9803  break;
9804  }
9805  redirecting->to.number.valid = data[pos];
9806  break;
9807 /* Redirecting-to party id combined presentation */
9808  case AST_REDIRECTING_TO_ID_PRESENTATION:
9809  if (ie_len != 1) {
9810  ast_log(LOG_WARNING, "Invalid redirecting-to combined presentation (%u)\n",
9811  (unsigned) ie_len);
9812  break;
9813  }
9814  to_combined_presentation = data[pos];
9815  got_to_combined_presentation = 1;
9816  break;
9817 /* Redirecting-to party id subaddress */
9818  case AST_REDIRECTING_TO_SUBADDRESS:
9819  ast_free(redirecting->to.subaddress.str);
9820  redirecting->to.subaddress.str = ast_malloc(ie_len + 1);
9821  if (redirecting->to.subaddress.str) {
9822  memcpy(redirecting->to.subaddress.str, data + pos, ie_len);
9823  redirecting->to.subaddress.str[ie_len] = 0;
9824  }
9825  break;
9826  case AST_REDIRECTING_TO_SUBADDRESS_TYPE:
9827  if (ie_len != 1) {
9828  ast_log(LOG_WARNING, "Invalid redirecting-to type of subaddress (%u)\n",
9829  (unsigned) ie_len);
9830  break;
9831  }
9832  redirecting->to.subaddress.type = data[pos];
9833  break;
9834  case AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN:
9835  if (ie_len != 1) {
9836  ast_log(LOG_WARNING,
9837  "Invalid redirecting-to subaddress odd-even indicator (%u)\n",
9838  (unsigned) ie_len);
9839  break;
9840  }
9841  redirecting->to.subaddress.odd_even_indicator = data[pos];
9842  break;
9843  case AST_REDIRECTING_TO_SUBADDRESS_VALID:
9844  if (ie_len != 1) {
9845  ast_log(LOG_WARNING, "Invalid redirecting-to subaddress valid (%u)\n",
9846  (unsigned) ie_len);
9847  break;
9848  }
9849  redirecting->to.subaddress.valid = data[pos];
9850  break;
9851 /* Redirecting-to party id tag */
9852  case AST_REDIRECTING_TO_TAG:
9853  ast_free(redirecting->to.tag);
9854  redirecting->to.tag = ast_malloc(ie_len + 1);
9855  if (redirecting->to.tag) {
9856  memcpy(redirecting->to.tag, data + pos, ie_len);
9857  redirecting->to.tag[ie_len] = 0;
9858  }
9859  break;
9860 /* Private redirecting-orig party id name */
9861  case AST_REDIRECTING_PRIV_ORIG_NAME:
9862  ast_free(redirecting->priv_orig.name.str);
9863  redirecting->priv_orig.name.str = ast_malloc(ie_len + 1);
9864  if (redirecting->priv_orig.name.str) {
9865  memcpy(redirecting->priv_orig.name.str, data + pos, ie_len);
9866  redirecting->priv_orig.name.str[ie_len] = 0;
9867  }
9868  break;
9869  case AST_REDIRECTING_PRIV_ORIG_NAME_CHAR_SET:
9870  if (ie_len != 1) {
9871  ast_log(LOG_WARNING, "Invalid private redirecting-orig name char set (%u)\n",
9872  (unsigned) ie_len);
9873  break;
9874  }
9875  redirecting->priv_orig.name.char_set = data[pos];
9876  break;
9877  case AST_REDIRECTING_PRIV_ORIG_NAME_PRESENTATION:
9878  if (ie_len != 1) {
9879  ast_log(LOG_WARNING, "Invalid private redirecting-orig name presentation (%u)\n",
9880  (unsigned) ie_len);
9881  break;
9882  }
9883  redirecting->priv_orig.name.presentation = data[pos];
9884  break;
9885  case AST_REDIRECTING_PRIV_ORIG_NAME_VALID:
9886  if (ie_len != 1) {
9887  ast_log(LOG_WARNING, "Invalid private redirecting-orig name valid (%u)\n",
9888  (unsigned) ie_len);
9889  break;
9890  }
9891  redirecting->priv_orig.name.valid = data[pos];
9892  break;
9893 /* Private redirecting-orig party id number */
9894  case AST_REDIRECTING_PRIV_ORIG_NUMBER:
9895  ast_free(redirecting->priv_orig.number.str);
9896  redirecting->priv_orig.number.str = ast_malloc(ie_len + 1);
9897  if (redirecting->priv_orig.number.str) {
9898  memcpy(redirecting->priv_orig.number.str, data + pos, ie_len);
9899  redirecting->priv_orig.number.str[ie_len] = 0;
9900  }
9901  break;
9902  case AST_REDIRECTING_PRIV_ORIG_NUMBER_PLAN:
9903  if (ie_len != 1) {
9904  ast_log(LOG_WARNING, "Invalid private redirecting-orig numbering plan (%u)\n",
9905  (unsigned) ie_len);
9906  break;
9907  }
9908  redirecting->priv_orig.number.plan = data[pos];
9909  break;
9910  case AST_REDIRECTING_PRIV_ORIG_NUMBER_PRESENTATION:
9911  if (ie_len != 1) {
9912  ast_log(LOG_WARNING, "Invalid private redirecting-orig number presentation (%u)\n",
9913  (unsigned) ie_len);
9914  break;
9915  }
9916  redirecting->priv_orig.number.presentation = data[pos];
9917  break;
9918  case AST_REDIRECTING_PRIV_ORIG_NUMBER_VALID:
9919  if (ie_len != 1) {
9920  ast_log(LOG_WARNING, "Invalid private redirecting-orig number valid (%u)\n",
9921  (unsigned) ie_len);
9922  break;
9923  }
9924  redirecting->priv_orig.number.valid = data[pos];
9925  break;
9926 /* Private redirecting-orig party id subaddress */
9927  case AST_REDIRECTING_PRIV_ORIG_SUBADDRESS:
9928  ast_free(redirecting->priv_orig.subaddress.str);
9929  redirecting->priv_orig.subaddress.str = ast_malloc(ie_len + 1);
9930  if (redirecting->priv_orig.subaddress.str) {
9931  memcpy(redirecting->priv_orig.subaddress.str, data + pos, ie_len);
9932  redirecting->priv_orig.subaddress.str[ie_len] = 0;
9933  }
9934  break;
9935  case AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_TYPE:
9936  if (ie_len != 1) {
9937  ast_log(LOG_WARNING, "Invalid private redirecting-orig type of subaddress (%u)\n",
9938  (unsigned) ie_len);
9939  break;
9940  }
9941  redirecting->priv_orig.subaddress.type = data[pos];
9942  break;
9943  case AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_ODD_EVEN:
9944  if (ie_len != 1) {
9945  ast_log(LOG_WARNING,
9946  "Invalid private redirecting-orig subaddress odd-even indicator (%u)\n",
9947  (unsigned) ie_len);
9948  break;
9949  }
9950  redirecting->priv_orig.subaddress.odd_even_indicator = data[pos];
9951  break;
9952  case AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_VALID:
9953  if (ie_len != 1) {
9954  ast_log(LOG_WARNING, "Invalid private redirecting-orig subaddress valid (%u)\n",
9955  (unsigned) ie_len);
9956  break;
9957  }
9958  redirecting->priv_orig.subaddress.valid = data[pos];
9959  break;
9960 /* Private redirecting-orig party id tag */
9961  case AST_REDIRECTING_PRIV_ORIG_TAG:
9962  ast_free(redirecting->priv_orig.tag);
9963  redirecting->priv_orig.tag = ast_malloc(ie_len + 1);
9964  if (redirecting->priv_orig.tag) {
9965  memcpy(redirecting->priv_orig.tag, data + pos, ie_len);
9966  redirecting->priv_orig.tag[ie_len] = 0;
9967  }
9968  break;
9969 /* Private redirecting-from party id name */
9970  case AST_REDIRECTING_PRIV_FROM_NAME:
9971  ast_free(redirecting->priv_from.name.str);
9972  redirecting->priv_from.name.str = ast_malloc(ie_len + 1);
9973  if (redirecting->priv_from.name.str) {
9974  memcpy(redirecting->priv_from.name.str, data + pos, ie_len);
9975  redirecting->priv_from.name.str[ie_len] = 0;
9976  }
9977  break;
9978  case AST_REDIRECTING_PRIV_FROM_NAME_CHAR_SET:
9979  if (ie_len != 1) {
9980  ast_log(LOG_WARNING, "Invalid private redirecting-from name char set (%u)\n",
9981  (unsigned) ie_len);
9982  break;
9983  }
9984  redirecting->priv_from.name.char_set = data[pos];
9985  break;
9986  case AST_REDIRECTING_PRIV_FROM_NAME_PRESENTATION:
9987  if (ie_len != 1) {
9988  ast_log(LOG_WARNING, "Invalid private redirecting-from name presentation (%u)\n",
9989  (unsigned) ie_len);
9990  break;
9991  }
9992  redirecting->priv_from.name.presentation = data[pos];
9993  break;
9994  case AST_REDIRECTING_PRIV_FROM_NAME_VALID:
9995  if (ie_len != 1) {
9996  ast_log(LOG_WARNING, "Invalid private redirecting-from name valid (%u)\n",
9997  (unsigned) ie_len);
9998  break;
9999  }
10000  redirecting->priv_from.name.valid = data[pos];
10001  break;
10002 /* Private redirecting-from party id number */
10003  case AST_REDIRECTING_PRIV_FROM_NUMBER:
10004  ast_free(redirecting->priv_from.number.str);
10005  redirecting->priv_from.number.str = ast_malloc(ie_len + 1);
10006  if (redirecting->priv_from.number.str) {
10007  memcpy(redirecting->priv_from.number.str, data + pos, ie_len);
10008  redirecting->priv_from.number.str[ie_len] = 0;
10009  }
10010  break;
10011  case AST_REDIRECTING_PRIV_FROM_NUMBER_PLAN:
10012  if (ie_len != 1) {
10013  ast_log(LOG_WARNING, "Invalid private redirecting-from numbering plan (%u)\n",
10014  (unsigned) ie_len);
10015  break;
10016  }
10017  redirecting->priv_from.number.plan = data[pos];
10018  break;
10019  case AST_REDIRECTING_PRIV_FROM_NUMBER_PRESENTATION:
10020  if (ie_len != 1) {
10021  ast_log(LOG_WARNING, "Invalid private redirecting-from number presentation (%u)\n",
10022  (unsigned) ie_len);
10023  break;
10024  }
10025  redirecting->priv_from.number.presentation = data[pos];
10026  break;
10027  case AST_REDIRECTING_PRIV_FROM_NUMBER_VALID:
10028  if (ie_len != 1) {
10029  ast_log(LOG_WARNING, "Invalid private redirecting-from number valid (%u)\n",
10030  (unsigned) ie_len);
10031  break;
10032  }
10033  redirecting->priv_from.number.valid = data[pos];
10034  break;
10035 /* Private redirecting-from party id subaddress */
10036  case AST_REDIRECTING_PRIV_FROM_SUBADDRESS:
10037  ast_free(redirecting->priv_from.subaddress.str);
10038  redirecting->priv_from.subaddress.str = ast_malloc(ie_len + 1);
10039  if (redirecting->priv_from.subaddress.str) {
10040  memcpy(redirecting->priv_from.subaddress.str, data + pos, ie_len);
10041  redirecting->priv_from.subaddress.str[ie_len] = 0;
10042  }
10043  break;
10044  case AST_REDIRECTING_PRIV_FROM_SUBADDRESS_TYPE:
10045  if (ie_len != 1) {
10046  ast_log(LOG_WARNING, "Invalid private redirecting-from type of subaddress (%u)\n",
10047  (unsigned) ie_len);
10048  break;
10049  }
10050  redirecting->priv_from.subaddress.type = data[pos];
10051  break;
10052  case AST_REDIRECTING_PRIV_FROM_SUBADDRESS_ODD_EVEN:
10053  if (ie_len != 1) {
10054  ast_log(LOG_WARNING,
10055  "Invalid private redirecting-from subaddress odd-even indicator (%u)\n",
10056  (unsigned) ie_len);
10057  break;
10058  }
10059  redirecting->priv_from.subaddress.odd_even_indicator = data[pos];
10060  break;
10061  case AST_REDIRECTING_PRIV_FROM_SUBADDRESS_VALID:
10062  if (ie_len != 1) {
10063  ast_log(LOG_WARNING, "Invalid private redirecting-from subaddress valid (%u)\n",
10064  (unsigned) ie_len);
10065  break;
10066  }
10067  redirecting->priv_from.subaddress.valid = data[pos];
10068  break;
10069 /* Private redirecting-from party id tag */
10070  case AST_REDIRECTING_PRIV_FROM_TAG:
10071  ast_free(redirecting->priv_from.tag);
10072  redirecting->priv_from.tag = ast_malloc(ie_len + 1);
10073  if (redirecting->priv_from.tag) {
10074  memcpy(redirecting->priv_from.tag, data + pos, ie_len);
10075  redirecting->priv_from.tag[ie_len] = 0;
10076  }
10077  break;
10078 /* Private redirecting-to party id name */
10079  case AST_REDIRECTING_PRIV_TO_NAME:
10080  ast_free(redirecting->priv_to.name.str);
10081  redirecting->priv_to.name.str = ast_malloc(ie_len + 1);
10082  if (redirecting->priv_to.name.str) {
10083  memcpy(redirecting->priv_to.name.str, data + pos, ie_len);
10084  redirecting->priv_to.name.str[ie_len] = 0;
10085  }
10086  break;
10087  case AST_REDIRECTING_PRIV_TO_NAME_CHAR_SET:
10088  if (ie_len != 1) {
10089  ast_log(LOG_WARNING, "Invalid private redirecting-to name char set (%u)\n",
10090  (unsigned) ie_len);
10091  break;
10092  }
10093  redirecting->priv_to.name.char_set = data[pos];
10094  break;
10095  case AST_REDIRECTING_PRIV_TO_NAME_PRESENTATION:
10096  if (ie_len != 1) {
10097  ast_log(LOG_WARNING, "Invalid private redirecting-to name presentation (%u)\n",
10098  (unsigned) ie_len);
10099  break;
10100  }
10101  redirecting->priv_to.name.presentation = data[pos];
10102  break;
10103  case AST_REDIRECTING_PRIV_TO_NAME_VALID:
10104  if (ie_len != 1) {
10105  ast_log(LOG_WARNING, "Invalid private redirecting-to name valid (%u)\n",
10106  (unsigned) ie_len);
10107  break;
10108  }
10109  redirecting->priv_to.name.valid = data[pos];
10110  break;
10111 /* Private redirecting-to party id number */
10112  case AST_REDIRECTING_PRIV_TO_NUMBER:
10113  ast_free(redirecting->priv_to.number.str);
10114  redirecting->priv_to.number.str = ast_malloc(ie_len + 1);
10115  if (redirecting->priv_to.number.str) {
10116  memcpy(redirecting->priv_to.number.str, data + pos, ie_len);
10117  redirecting->priv_to.number.str[ie_len] = 0;
10118  }
10119  break;
10120  case AST_REDIRECTING_PRIV_TO_NUMBER_PLAN:
10121  if (ie_len != 1) {
10122  ast_log(LOG_WARNING, "Invalid private redirecting-to numbering plan (%u)\n",
10123  (unsigned) ie_len);
10124  break;
10125  }
10126  redirecting->priv_to.number.plan = data[pos];
10127  break;
10128  case AST_REDIRECTING_PRIV_TO_NUMBER_PRESENTATION:
10129  if (ie_len != 1) {
10130  ast_log(LOG_WARNING, "Invalid private redirecting-to number presentation (%u)\n",
10131  (unsigned) ie_len);
10132  break;
10133  }
10134  redirecting->priv_to.number.presentation = data[pos];
10135  break;
10136  case AST_REDIRECTING_PRIV_TO_NUMBER_VALID:
10137  if (ie_len != 1) {
10138  ast_log(LOG_WARNING, "Invalid private redirecting-to number valid (%u)\n",
10139  (unsigned) ie_len);
10140  break;
10141  }
10142  redirecting->priv_to.number.valid = data[pos];
10143  break;
10144 /* Private redirecting-to party id subaddress */
10145  case AST_REDIRECTING_PRIV_TO_SUBADDRESS:
10146  ast_free(redirecting->priv_to.subaddress.str);
10147  redirecting->priv_to.subaddress.str = ast_malloc(ie_len + 1);
10148  if (redirecting->priv_to.subaddress.str) {
10149  memcpy(redirecting->priv_to.subaddress.str, data + pos, ie_len);
10150  redirecting->priv_to.subaddress.str[ie_len] = 0;
10151  }
10152  break;
10153  case AST_REDIRECTING_PRIV_TO_SUBADDRESS_TYPE:
10154  if (ie_len != 1) {
10155  ast_log(LOG_WARNING, "Invalid private redirecting-to type of subaddress (%u)\n",
10156  (unsigned) ie_len);
10157  break;
10158  }
10159  redirecting->priv_to.subaddress.type = data[pos];
10160  break;
10161  case AST_REDIRECTING_PRIV_TO_SUBADDRESS_ODD_EVEN:
10162  if (ie_len != 1) {
10163  ast_log(LOG_WARNING,
10164  "Invalid private redirecting-to subaddress odd-even indicator (%u)\n",
10165  (unsigned) ie_len);
10166  break;
10167  }
10168  redirecting->priv_to.subaddress.odd_even_indicator = data[pos];
10169  break;
10170  case AST_REDIRECTING_PRIV_TO_SUBADDRESS_VALID:
10171  if (ie_len != 1) {
10172  ast_log(LOG_WARNING, "Invalid private redirecting-to subaddress valid (%u)\n",
10173  (unsigned) ie_len);
10174  break;
10175  }
10176  redirecting->priv_to.subaddress.valid = data[pos];
10177  break;
10178 /* Private redirecting-to party id tag */
10179  case AST_REDIRECTING_PRIV_TO_TAG:
10180  ast_free(redirecting->priv_to.tag);
10181  redirecting->priv_to.tag = ast_malloc(ie_len + 1);
10182  if (redirecting->priv_to.tag) {
10183  memcpy(redirecting->priv_to.tag, data + pos, ie_len);
10184  redirecting->priv_to.tag[ie_len] = 0;
10185  }
10186  break;
10187 /* Redirecting reason code */
10188  case AST_REDIRECTING_REASON_CODE:
10189  if (ie_len != sizeof(value)) {
10190  ast_log(LOG_WARNING, "Invalid redirecting reason (%u)\n",
10191  (unsigned) ie_len);
10192  break;
10193  }
10194  memcpy(&value, data + pos, sizeof(value));
10195  redirecting->reason.code = ntohl(value);
10196  break;
10197 /* Redirecting reason string */
10198  case AST_REDIRECTING_REASON_STR:
10199  ast_free(redirecting->reason.str);
10200  redirecting->reason.str = ast_malloc(ie_len + 1);
10201  if (redirecting->reason.str) {
10202  memcpy(redirecting->reason.str, data + pos, ie_len);
10203  redirecting->reason.str[ie_len] = 0;
10204  }
10205  break;
10206 /* Redirecting orig-reason code */
10207  case AST_REDIRECTING_ORIG_REASON_CODE:
10208  if (ie_len != sizeof(value)) {
10209  ast_log(LOG_WARNING, "Invalid redirecting original reason (%u)\n",
10210  (unsigned) ie_len);
10211  break;
10212  }
10213  memcpy(&value, data + pos, sizeof(value));
10214  redirecting->orig_reason.code = ntohl(value);
10215  break;
10216 /* Redirecting orig-reason string */
10217  case AST_REDIRECTING_ORIG_REASON_STR:
10218  ast_free(redirecting->orig_reason.str);
10219  redirecting->orig_reason.str = ast_malloc(ie_len + 1);
10220  if (redirecting->orig_reason.str) {
10221  memcpy(redirecting->orig_reason.str, data + pos, ie_len);
10222  redirecting->orig_reason.str[ie_len] = 0;
10223  }
10224  break;
10225 /* Redirecting count */
10226  case AST_REDIRECTING_COUNT:
10227  if (ie_len != sizeof(value)) {
10228  ast_log(LOG_WARNING, "Invalid redirecting count (%u)\n",
10229  (unsigned) ie_len);
10230  break;
10231  }
10232  memcpy(&value, data + pos, sizeof(value));
10233  redirecting->count = ntohl(value);
10234  break;
10235 /* Redirecting unknown element */
10236  default:
10237  ast_debug(1, "Unknown redirecting element: %u (%u)\n",
10238  (unsigned) ie_id, (unsigned) ie_len);
10239  break;
10240  }
10241  }
10242 
10243  switch (frame_version) {
10244  case 1:
10245  /*
10246  * The other end is an earlier version that we need to adjust
10247  * for compatibility.
10248  *
10249  * The earlier version did not have the orig party id or
10250  * orig_reason value.
10251  */
10252  redirecting->from.name.valid = 1;
10253  redirecting->from.name.char_set = AST_PARTY_CHAR_SET_ISO8859_1;
10254  redirecting->from.number.valid = 1;
10255  if (got_from_combined_presentation) {
10256  redirecting->from.name.presentation = from_combined_presentation;
10257  redirecting->from.number.presentation = from_combined_presentation;
10258  }
10259 
10260  redirecting->to.name.valid = 1;
10261  redirecting->to.name.char_set = AST_PARTY_CHAR_SET_ISO8859_1;
10262  redirecting->to.number.valid = 1;
10263  if (got_to_combined_presentation) {
10264  redirecting->to.name.presentation = to_combined_presentation;
10265  redirecting->to.number.presentation = to_combined_presentation;
10266  }
10267  break;
10268  case 2:
10269  /* The other end is at the same level as we are. */
10270  break;
10271  default:
10272  /*
10273  * The other end is newer than we are.
10274  * We need to assume that they are compatible with us.
10275  */
10276  ast_debug(1, "Redirecting frame has newer version: %u\n",
10277  (unsigned) frame_version);
10278  break;
10279  }
10280 
10281  return 0;
10282 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:277
char * str
Subscriber phone number (Malloced)
Definition: channel.h:291
struct ast_party_id priv_to
Call is redirecting to a new party (Sent to the caller) - private representation. ...
Definition: channel.h:539
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:295
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:533
struct ast_party_name name
Subscriber name.
Definition: channel.h:340
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:527
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:536
int char_set
Character set the name is using.
Definition: channel.h:272
char * str
Subscriber name (Malloced)
Definition: channel.h:264
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:328
char * str
Malloced subaddress string.
Definition: channel.h:313
int code
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:510
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:326
struct ast_party_id orig
Who originally redirected the call (Sent to the party the call is redirected toward) ...
Definition: channel.h:524
struct ast_party_redirecting_reason orig_reason
Reason for the redirection by the original party.
Definition: channel.h:545
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:191
#define ast_debug(level,...)
Log a DEBUG message.
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:344
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:293
char * str
a string value for the redirecting reason
Definition: channel.h:507
struct ast_party_redirecting_reason reason
Reason for the redirection.
Definition: channel.h:542
char * tag
User-set "tag".
Definition: channel.h:354
int type
Q.931 subaddress type.
Definition: channel.h:320
int count
Number of times the call was redirected.
Definition: channel.h:548
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:530
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:279
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:297
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:342
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 6354 of file channel.c.

Referenced by __ast_request_and_dial(), ast_ari_channels_create(), ast_call_forward(), attended_transfer_bridge(), begin_dial_prerun(), build_conf(), dial_transfer(), prepare_bridge_moh_channel(), ring_entry(), and wait_for_answer().

6355 {
6356  return request_channel(type, request_cap, NULL, assignedids, requestor, addr, cause);
6357 }
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 6174 of file channel.c.

References __ast_request_and_dial().

6175 {
6176  return __ast_request_and_dial(type, cap, assignedids, requestor, addr, timeout, outstate, cidnum, cidname, NULL);
6177 }
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:5976
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 6359 of file channel.c.

Referenced by dial_exec_full(), and do_forward().

6360 {
6361  return request_channel(type, NULL, topology, assignedids, requestor, addr, cause);
6362 }
int ast_safe_sleep ( struct ast_channel chan,
int  ms 
)

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

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

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

Returns
returns -1 on hangup, otherwise 0.

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

Definition at line 1574 of file channel.c.

References safe_sleep_conditional().

Referenced by alarmreceiver_exec(), ast_senddigit(), ast_senddigit_mf(), and send_tone_burst().

1575 {
1576  return safe_sleep_conditional(chan, ms, NULL, NULL, 1);
1577 }
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
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 safe_sleep_conditional().

1569 {
1570  return safe_sleep_conditional(chan, timeout_ms, cond, data, 1);
1571 }
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
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 safe_sleep_conditional().

1580 {
1581  return safe_sleep_conditional(chan, ms, NULL, NULL, 0);
1582 }
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
int ast_senddigit ( struct ast_channel chan,
char  digit,
unsigned int  duration 
)

Send a DTMF digit to a channel.

Parameters
chanchannel to act upon
digitthe DTMF digit to send, encoded in ASCII
durationthe duration of the digit ending in ms
Precondition
This must only be called by the channel's media handler thread.
Returns
0 on success, -1 on failure

Definition at line 4974 of file channel.c.

References AST_DEFAULT_EMULATE_DTMF_DURATION, ast_safe_sleep(), ast_senddigit_begin(), and ast_senddigit_end().

Referenced by dial_exec_full().

4975 {
4976  if (duration < AST_DEFAULT_EMULATE_DTMF_DURATION) {
4978  }
4979  if (ast_channel_tech(chan)->send_digit_begin) {
4980  ast_senddigit_begin(chan, digit);
4981  ast_safe_sleep(chan, duration);
4982  }
4983 
4984  return ast_senddigit_end(chan, digit, duration);
4985 }
#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:4874
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition: channel.c:4924
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
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 4874 of file channel.c.

References ast_debug, ast_playtones_start(), and ast_tvnow().

Referenced by ast_senddigit(), ast_senddigit_external(), and ast_write_stream().

4875 {
4876  /* Device does not support DTMF tones, lets fake
4877  * it by doing our own generation. */
4878  static const char * const dtmf_tones[] = {
4879  "941+1336", /* 0 */
4880  "697+1209", /* 1 */
4881  "697+1336", /* 2 */
4882  "697+1477", /* 3 */
4883  "770+1209", /* 4 */
4884  "770+1336", /* 5 */
4885  "770+1477", /* 6 */
4886  "852+1209", /* 7 */
4887  "852+1336", /* 8 */
4888  "852+1477", /* 9 */
4889  "697+1633", /* A */
4890  "770+1633", /* B */
4891  "852+1633", /* C */
4892  "941+1633", /* D */
4893  "941+1209", /* * */
4894  "941+1477" /* # */
4895  };
4896 
4897  if (!ast_channel_tech(chan)->send_digit_begin)
4898  return 0;
4899 
4900  ast_channel_lock(chan);
4901  ast_channel_sending_dtmf_digit_set(chan, digit);
4902  ast_channel_sending_dtmf_tv_set(chan, ast_tvnow());
4903  ast_channel_unlock(chan);
4904 
4905  if (!ast_channel_tech(chan)->send_digit_begin(chan, digit))
4906  return 0;
4907 
4908  if (digit >= '0' && digit <='9')
4909  ast_playtones_start(chan, 0, dtmf_tones[digit-'0'], 0);
4910  else if (digit >= 'A' && digit <= 'D')
4911  ast_playtones_start(chan, 0, dtmf_tones[digit-'A'+10], 0);
4912  else if (digit == '*')
4913  ast_playtones_start(chan, 0, dtmf_tones[14], 0);
4914  else if (digit == '#')
4915  ast_playtones_start(chan, 0, dtmf_tones[15], 0);
4916  else {
4917  /* not handled */
4918  ast_debug(1, "Unable to generate DTMF tone '%c' for '%s'\n", digit, ast_channel_name(chan));
4919  }
4920 
4921  return 0;
4922 }
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:159
#define ast_debug(level,...)
Log a DEBUG message.
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
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
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 4924 of file channel.c.

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

4925 {
4926  int res = -1;
4927 
4928  if (ast_channel_tech(chan)->send_digit_end)
4929  res = ast_channel_tech(chan)->send_digit_end(chan, digit, duration);
4930 
4931  ast_channel_lock(chan);
4932  if (ast_channel_sending_dtmf_digit(chan) == digit) {
4933  ast_channel_sending_dtmf_digit_set(chan, 0);
4934  }
4935  ast_channel_unlock(chan);
4936 
4937  if (res && ast_channel_generator(chan))
4938  ast_playtones_stop(chan);
4939 
4940  return 0;
4941 }
int(*const send_digit_end)(struct ast_channel *chan, char digit, unsigned int duration)
Stop sending a literal DTMF digit.
Definition: channel.h:690
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
Definition: indications.c:393
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
int ast_senddigit_external ( struct ast_channel chan,
char  digit,
unsigned int  duration 
)

Send a DTMF digit to a channel from an external thread.

Parameters
chanchannel to act upon
digitthe DTMF digit to send, encoded in ASCII
durationthe duration of the digit ending in ms
Precondition
This must only be called by threads that are not the channel's media handler thread.
Returns
0 on success, -1 on failure

Definition at line 4987 of file channel.c.

References AST_DEFAULT_EMULATE_DTMF_DURATION, ast_senddigit_begin(), and ast_senddigit_end().

4988 {
4989  if (duration < AST_DEFAULT_EMULATE_DTMF_DURATION) {
4991  }
4992  if (ast_channel_tech(chan)->send_digit_begin) {
4993  ast_senddigit_begin(chan, digit);
4994  usleep(duration * 1000);
4995  }
4996 
4997  return ast_senddigit_end(chan, digit, duration);
4998 }
#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:4874
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition: channel.c:4924
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
int ast_senddigit_mf ( struct ast_channel chan,
char  digit,
unsigned int  duration,
unsigned int  durationkp,
unsigned int  durationst,
int  is_external 
)

Send an MF digit to a channel.

Parameters
chanchannel to act upon
digitthe MF digit to send, encoded in ASCII
durationthe duration of a numeric digit ending in ms
durationkpthe duration of a KP digit ending in ms
durationstthe duration of a ST, STP, ST2P, or ST3P digit ending in ms
is_external1 if called by a thread that is not the channel's media handler thread, 0 if called by the channel's media handler thread.
Returns
0 on success, -1 on failure

Definition at line 4952 of file channel.c.

References ast_safe_sleep(), ast_senddigit_mf_begin(), ast_senddigit_mf_end(), and DEFAULT_EMULATE_MF_DURATION.

4954 {
4955  if (duration < DEFAULT_EMULATE_MF_DURATION) {
4956  duration = DEFAULT_EMULATE_MF_DURATION;
4957  }
4958  if (ast_channel_tech(chan)->send_digit_begin) {
4959  if (digit == '*') {
4960  duration = durationkp;
4961  } else if (digit == '#' || digit == 'A' || digit == 'B' || digit == 'C') {
4962  duration = durationst;
4963  }
4964  ast_senddigit_mf_begin(chan, digit);
4965  if (is_external) {
4966  usleep(duration * 1000);
4967  } else {
4968  ast_safe_sleep(chan, duration);
4969  }
4970  }
4971  return ast_senddigit_mf_end(chan);
4972 }
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait, look for hangups.
Definition: channel.c:1574
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
int ast_senddigit_mf_begin(struct ast_channel *chan, char digit)
Send an MF digit to a channel.
Definition: channel.c:4835
int ast_senddigit_mf_end(struct ast_channel *chan)
End sending an MF digit to a channel.
Definition: channel.c:4943
#define DEFAULT_EMULATE_MF_DURATION
Definition: channel.c:106
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 4835 of file channel.c.

References ast_playtones_start().

Referenced by ast_senddigit_mf().

4836 {
4837  static const char * const mf_tones[] = {
4838  "1300+1500", /* 0 */
4839  "700+900", /* 1 */
4840  "700+1100", /* 2 */
4841  "900+1100", /* 3 */
4842  "700+1300", /* 4 */
4843  "900+1300", /* 5 */
4844  "1100+1300", /* 6 */
4845  "700+1500", /* 7 */
4846  "900+1500", /* 8 */
4847  "1100+1500", /* 9 */
4848  "1100+1700", /* * (KP) */
4849  "1500+1700", /* # (ST) */
4850  "900+1700", /* A (STP) */
4851  "1300+1700", /* B (ST2P) */
4852  "700+1700" /* C (ST3P) */
4853  };
4854 
4855  if (digit >= '0' && digit <='9') {
4856  ast_playtones_start(chan, 0, mf_tones[digit-'0'], 0);
4857  } else if (digit == '*') {
4858  ast_playtones_start(chan, 0, mf_tones[10], 0);
4859  } else if (digit == '#') {
4860  ast_playtones_start(chan, 0, mf_tones[11], 0);
4861  } else if (digit == 'A') {
4862  ast_playtones_start(chan, 0, mf_tones[12], 0);
4863  } else if (digit == 'B') {
4864  ast_playtones_start(chan, 0, mf_tones[13], 0);
4865  } else if (digit == 'C') {
4866  ast_playtones_start(chan, 0, mf_tones[14], 0);
4867  } else {
4868  /* not handled */
4869  ast_log(LOG_WARNING, "Unable to generate MF tone '%c' for '%s'\n", digit, ast_channel_name(chan));
4870  }
4871  return 0;
4872 }
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
int ast_senddigit_mf_end ( struct ast_channel chan)

End sending an MF digit to a channel.

Parameters
chanchannel to act upon
Returns
Returns 0 on success, -1 on failure

Definition at line 4943 of file channel.c.

References ast_playtones_stop().

Referenced by ast_senddigit_mf().

4944 {
4945  if (ast_channel_generator(chan)) {
4946  ast_playtones_stop(chan);
4947  return 0;
4948  }
4949  return -1;
4950 }
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
Definition: indications.c:393
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 4809 of file channel.c.

References ast_msg_data_alloc(), and ast_sendtext_data().

Referenced by __ast_read().

4810 {
4811  struct ast_msg_data *msg;
4812  int rc;
4813  struct ast_msg_data_attribute attrs[] =
4814  {
4815  {
4816  .type = AST_MSG_DATA_ATTR_BODY,
4817  .value = (char *)text,
4818  }
4819  };
4820 
4821  if (ast_strlen_zero(text)) {
4822  return 0;
4823  }
4824 
4825  msg = ast_msg_data_alloc(AST_MSG_DATA_SOURCE_TYPE_UNKNOWN, attrs, ARRAY_LEN(attrs));
4826  if (!msg) {
4827  return -1;
4828  }
4829  rc = ast_sendtext_data(chan, msg);
4830  ast_free(msg);
4831 
4832  return rc;
4833 }
Structure used to transport a message through the frame core.
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.
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:4751
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 4751 of file channel.c.

References ast_begins_with(), AST_CHAN_TP_SEND_TEXT_DATA, ast_check_hangup(), ast_debug, AST_FLAG_BLOCKING, AST_FLAG_ZOMBIE, ast_format_cap_has_type(), ast_format_t140, AST_FRAME_TEXT, AST_MALLOCD_DATA, ast_msg_data_get_attribute(), ast_strdup, CHECK_BLOCKING, ast_frame::data, ast_frame::datalen, ast_frame_subclass::format, ast_frame::frametype, ast_frame::mallocd, S_OR, ast_channel_tech::send_text, ast_channel_tech::send_text_data, ast_frame::src, ast_frame::subclass, and ast_channel_tech::write_text.

Referenced by __ast_read(), and ast_sendtext().

4752 {
4753  int res = 0;
4754  const char *body = ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_BODY);
4755  const char *content_type = ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_CONTENT_TYPE);
4756 
4757  ast_channel_lock(chan);
4758  /* Stop if we're a zombie or need a soft hangup */
4759  if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
4760  ast_channel_unlock(chan);
4761  return -1;
4762  }
4763 
4764  CHECK_BLOCKING(chan);
4765  if (ast_channel_tech(chan)->write_text
4766  && (ast_strlen_zero(content_type) || ast_begins_with(content_type, "text/"))
4767  && (ast_format_cap_has_type(ast_channel_nativeformats(chan), AST_MEDIA_TYPE_TEXT))) {
4768  struct ast_frame f;
4769  /* T.140 payload does not include the null byte terminator */
4770  size_t body_len = strlen(body);
4771 
4772  /* Process as T.140 text (moved here from ast_sendtext() */
4773  memset(&f, 0, sizeof(f));
4774  f.src = "DIALPLAN";
4775  f.subclass.format = ast_format_t140;
4776  f.frametype = AST_FRAME_TEXT;
4777  f.datalen = body_len;
4778  f.mallocd = AST_MALLOCD_DATA;
4779  f.data.ptr = ast_strdup(body);
4780  if (f.data.ptr) {
4781  res = ast_channel_tech(chan)->write_text(chan, &f);
4782  } else {
4783  res = -1;
4784  }
4785  ast_frfree(&f);
4786  } else if ((ast_channel_tech(chan)->properties & AST_CHAN_TP_SEND_TEXT_DATA)
4787  && ast_channel_tech(chan)->send_text_data) {
4788  /* Send enhanced message to a channel driver that supports it */
4789  ast_debug(1, "Sending TEXT_DATA from '%s' to %s:%s %s\n",
4790  ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_FROM),
4791  ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_TO),
4792  ast_channel_name(chan), body);
4793  res = ast_channel_tech(chan)->send_text_data(chan, msg);
4794  } else if (ast_channel_tech(chan)->send_text
4795  && (ast_strlen_zero(content_type) || ast_begins_with(content_type, "text/"))) {
4796  /* Send the body of an enhanced message to a channel driver that supports only a char str */
4797  ast_debug(1, "Sending TEXT to %s: %s\n", ast_channel_name(chan), body);
4798  res = ast_channel_tech(chan)->send_text(chan, body);
4799  } else {
4800  ast_debug(1, "Channel technology does not support sending content type '%s' on channel '%s'\n",
4801  S_OR(content_type, "text/plain"), ast_channel_name(chan));
4802  res = -1;
4803  }
4804  ast_clear_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING);
4805  ast_channel_unlock(chan);
4806  return res;
4807 }
Channels have this property if they implement send_text_data.
Definition: channel.h:975
#define AST_MALLOCD_DATA
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
int ast_check_hangup(struct ast_channel *chan)
Checks to see if a channel is needing hang up.
Definition: channel.c:445
int(*const write_text)(struct ast_channel *chan, struct ast_frame *frame)
Write a text frame, in standard format.
Definition: channel.h:789
#define ast_debug(level,...)
Log a DEBUG message.
int(*const send_text)(struct ast_channel *chan, const char *text)
Display or transmit text.
Definition: channel.h:756
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
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.
#define CHECK_BLOCKING(c)
Set the blocking indication on the channel.
Definition: channel.h:2871
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:80
Data structure associated with a single frame of data.
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
Checks whether a string begins with another.
Definition: strings.h:97
int(*const send_text_data)(struct ast_channel *chan, struct ast_msg_data *data)
Display or transmit text with data.
Definition: channel.h:844
struct ast_format * ast_format_t140
Built-in cached t140 format.
Definition: format_cache.c:231
int ast_format_cap_has_type(const struct ast_format_cap *cap, enum ast_media_type type)
Find out if the capabilities structure has any formats of a specific type.
Definition: format_cap.c:613
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 7334 of file channel.c.

References ast_party_caller::ani, ast_channel_publish_snapshot(), ast_strdup, ast_party_caller::id, 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 __ast_request_and_dial(), and ring_entry().

7335 {
7336  ast_channel_lock(chan);
7337 
7338  if (cid_num) {
7339  ast_channel_caller(chan)->id.number.valid = 1;
7340  ast_free(ast_channel_caller(chan)->id.number.str);
7341  ast_channel_caller(chan)->id.number.str = ast_strdup(cid_num);
7342  }
7343  if (cid_name) {
7344  ast_channel_caller(chan)->id.name.valid = 1;
7345  ast_free(ast_channel_caller(chan)->id.name.str);
7346  ast_channel_caller(chan)->id.name.str = ast_strdup(cid_name);
7347  }
7348  if (cid_ani) {
7349  ast_channel_caller(chan)->ani.number.valid = 1;
7350  ast_free(ast_channel_caller(chan)->ani.number.str);
7351  ast_channel_caller(chan)->ani.number.str = ast_strdup(cid_ani);
7352  }
7353 
7355 
7356  ast_channel_unlock(chan);
7357 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:291
struct ast_party_name name
Subscriber name.
Definition: channel.h:340
char * str
Subscriber name (Malloced)
Definition: channel.h:264
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
Number structure.
Definition: app_followme.c:154
struct ast_party_id id
Caller party ID.
Definition: channel.h:420
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:427
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:279
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:297
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:342
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 2499 of file channel.c.

References ast_channel_bridge_peer(), ast_channel_cleanup, and RAII_VAR.

Referenced by chan_pjsip_session_end().

2500 {
2502 
2503  ast_channel_lock(chan);
2504  if (force || ast_strlen_zero(ast_channel_hangupsource(chan))) {
2505  ast_channel_hangupsource_set(chan, source);
2506  }
2507  ast_channel_unlock(chan);
2508 
2509  if (bridge) {
2510  ast_channel_lock(bridge);
2511  if (force || ast_strlen_zero(ast_channel_hangupsource(bridge))) {
2512  ast_channel_hangupsource_set(bridge, source);
2513  }
2514  ast_channel_unlock(bridge);
2515  }
2516 }
Main Channel structure associated with a channel.
#define ast_channel_cleanup(c)
Cleanup a channel reference.
Definition: channel.h:2969
struct ast_channel * ast_channel_bridge_peer(struct ast_channel *chan)
Get the channel's bridge peer only if the bridge is two-party.
Definition: channel.c:10564
#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:941
void ast_set_party_id_all ( struct ast_set_party_id update_id)

Set the update marker to update all information of a corresponding party id.

Since
11.0
Parameters
update_idThe update marker for a corresponding party id.

Definition at line 1750 of file channel.c.

References ast_set_party_id::name, ast_set_party_id::number, and ast_set_party_id::subaddress.

1751 {
1752  update_id->name = 1;
1753  update_id->number = 1;
1754  update_id->subaddress = 1;
1755 }
unsigned char subaddress
Definition: channel.h:367
unsigned char number
Definition: channel.h:365
unsigned char name
Definition: channel.h:363
int ast_set_read_format ( struct ast_channel chan,
struct ast_format format 
)

Sets read format on channel chan.

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

Definition at line 5762 of file channel.c.

References ast_format_cap_alloc, ast_format_cap_append, and AST_FORMAT_CAP_FLAG_DEFAULT.

Referenced by __ast_play_and_record(), alarmreceiver_exec(), ast_bridge_channel_restore_formats(), ast_channel_make_compatible_helper(), build_conf(), channel_do_masquerade(), fax_detect_framehook(), fax_gateway_framehook(), generic_fax_exec(), jingle_interpret_content(), jingle_read(), set_read_to_slin(), and speech_background().

5763 {
5765  int res;
5766 
5767  ast_assert(format != NULL);
5768 
5769  if (!cap) {
5770  return -1;
5771  }
5772  ast_format_cap_append(cap, format, 0);
5773 
5774  res = set_format(chan, cap, 0, 0);
5775 
5776  ao2_cleanup(cap);
5777  return res;
5778 }
#define ast_format_cap_append(cap, format, framing)
Add format capability to capabilities structure.
Definition: format_cap.h:99
#define ast_format_cap_alloc(flags)
Allocate a new ast_format_cap structure.
Definition: format_cap.h:49
Format capabilities structure, holds formats + preference order + etc.
Definition: format_cap.c:54
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 5780 of file channel.c.

5781 {
5782  return set_format(chan, cap, 0, 0);
5783 }
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 5488 of file channel.c.

References ast_debug, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_get_name(), ast_translator_build_path(), and ast_translator_free_path().

Referenced by __ast_read(), and chan_pjsip_read_stream().

5489 {
5490  struct ast_trans_pvt *trans_old;
5491  struct ast_trans_pvt *trans_new;
5492 
5493  if (ast_format_cmp(ast_channel_rawreadformat(chan), raw_format) == AST_FORMAT_CMP_EQUAL
5494  && ast_format_cmp(ast_channel_readformat(chan), core_format) == AST_FORMAT_CMP_EQUAL) {
5495  /* Nothing to setup */
5496  return 0;
5497  }
5498 
5499  ast_debug(1, "Channel %s setting read format path: %s -> %s\n",
5500  ast_channel_name(chan),
5501  ast_format_get_name(raw_format),
5502  ast_format_get_name(core_format));
5503 
5504  /* Setup new translation path. */
5505  if (ast_format_cmp(raw_format, core_format) != AST_FORMAT_CMP_EQUAL) {
5506  trans_new = ast_translator_build_path(core_format, raw_format);
5507  if (!trans_new) {
5508  return -1;
5509  }
5510  } else {
5511  /* No translation needed. */
5512  trans_new = NULL;
5513  }
5514  trans_old = ast_channel_readtrans(chan);
5515  if (trans_old) {
5516  ast_translator_free_path(trans_old);
5517  }
5518  ast_channel_readtrans_set(chan, trans_new);
5519  ast_channel_set_rawreadformat(chan, raw_format);
5520  ast_channel_set_readformat(chan, core_format);
5521  return 0;
5522 }
const char * ast_format_get_name(const struct ast_format *format)
Get the name associated with a format.
Definition: format.c:334
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:486
#define ast_debug(level,...)
Log a DEBUG message.
Default structure for translators, with the basic fields and buffers, all allocated as part of the sa...
Definition: translate.h:213
void ast_translator_free_path(struct ast_trans_pvt *tr)
Frees a translator path Frees the given translator path structure.
Definition: translate.c:476
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 8115 of file channel.c.

References ast_variable::name, ast_variable::next, pbx_builtin_setvar_helper(), and ast_variable::value.

Referenced by __ast_request_and_dial(), ast_ari_channels_create(), ast_call_forward(), and ast_pbx_outgoing_exten_predial().

8116 {
8117  struct ast_variable *cur;
8118 
8119  for (cur = vars; cur; cur = cur->next) {
8120  pbx_builtin_setvar_helper(chan, cur->name, cur->value);
8121  }
8122 }
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...
int ast_set_write_format ( struct ast_channel chan,
struct ast_format format 
)

Sets write format on channel chan.

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

Definition at line 5803 of file channel.c.

References ast_format_cap_alloc, ast_format_cap_append, and AST_FORMAT_CAP_FLAG_DEFAULT.

Referenced by 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(), build_conf(), channel_do_masquerade(), fax_gateway_framehook(), generic_fax_exec(), jingle_interpret_content(), and jingle_read().

5804 {
5806  int res;
5807 
5808  ast_assert(format != NULL);
5809 
5810  if (!cap) {
5811  return -1;
5812  }
5813  ast_format_cap_append(cap, format, 0);
5814 
5815  res = set_format(chan, cap, 1, 0);
5816 
5817  ao2_cleanup(cap);
5818  return res;
5819 }
#define ast_format_cap_append(cap, format, framing)
Add format capability to capabilities structure.
Definition: format_cap.h:99
#define ast_format_cap_alloc(flags)
Allocate a new ast_format_cap structure.
Definition: format_cap.h:49
Format capabilities structure, holds formats + preference order + etc.
Definition: format_cap.c:54
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 5821 of file channel.c.

Referenced by ast_openstream_full().

5822 {
5823  return set_format(chan, cap, 1, 0);
5824 }
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 5785 of file channel.c.

References ast_format_cap_alloc, ast_format_cap_append, and AST_FORMAT_CAP_FLAG_DEFAULT.

Referenced by softmix_bridge_unsuspend().

5786 {
5788  int res;
5789 
5790  ast_assert(format != NULL);
5791 
5792  if (!cap) {
5793  return -1;
5794  }
5795  ast_format_cap_append(cap, format, 0);
5796 
5797  res = set_format(chan, cap, 1, 1);
5798 
5799  ao2_cleanup(cap);
5800  return res;
5801 }
#define ast_format_cap_append(cap, format, framing)
Add format capability to capabilities structure.
Definition: format_cap.h:99
#define ast_format_cap_alloc(flags)
Allocate a new ast_format_cap structure.
Definition: format_cap.h:49
Format capabilities structure, holds formats + preference order + etc.
Definition: format_cap.c:54
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 5524 of file channel.c.

References ast_debug, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_get_name(), ast_translator_build_path(), and ast_translator_free_path().

Referenced by chan_pjsip_read_stream().

5525 {
5526  struct ast_trans_pvt *trans_old;
5527  struct ast_trans_pvt *trans_new;
5528 
5529  if (ast_format_cmp(ast_channel_rawwriteformat(chan), raw_format) == AST_FORMAT_CMP_EQUAL
5530  && ast_format_cmp(ast_channel_writeformat(chan), core_format) == AST_FORMAT_CMP_EQUAL) {
5531  /* Nothing to setup */
5532  return 0;
5533  }
5534 
5535  ast_debug(1, "Channel %s setting write format path: %s -> %s\n",
5536  ast_channel_name(chan),
5537  ast_format_get_name(core_format),
5538  ast_format_get_name(raw_format));
5539 
5540  /* Setup new translation path. */
5541  if (ast_format_cmp(raw_format, core_format) != AST_FORMAT_CMP_EQUAL) {
5542  trans_new = ast_translator_build_path(raw_format, core_format);
5543  if (!trans_new) {
5544  return -1;
5545  }
5546  } else {
5547  /* No translation needed. */
5548  trans_new = NULL;
5549  }
5550  trans_old = ast_channel_writetrans(chan);
5551  if (trans_old) {
5552  ast_translator_free_path(trans_old);
5553  }
5554  ast_channel_writetrans_set(chan, trans_new);
5555  ast_channel_set_rawwriteformat(chan, raw_format);
5556  ast_channel_set_writeformat(chan, core_format);
5557  return 0;
5558 }
const char * ast_format_get_name(const struct ast_format *format)
Get the name associated with a format.
Definition: format.c:334
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:486
#define ast_debug(level,...)
Log a DEBUG message.
Default structure for translators, with the basic fields and buffers, all allocated as part of the sa...
Definition: translate.h:213
void ast_translator_free_path(struct ast_trans_pvt *tr)
Frees a translator path Frees the given translator path structure.
Definition: translate.c:476
int ast_settimeout ( struct ast_channel c,
unsigned int  rate,
int(*)(const void *data)  func,
void *  data 
)

Enable or disable timer ticks for a channel.

Parameters
cchannel
ratenumber of timer ticks per second
funccallback function
data

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

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

Definition at line 3180 of file channel.c.

Referenced by ast_activate_generator().

3181 {
3182  return ast_settimeout_full(c, rate, func, data, 0);
3183 }
int ast_softhangup ( struct ast_channel chan,
int  cause 
)

Softly hangup up a channel.

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

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

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

Softly hangup up a channel.

Definition at line 2471 of file channel.c.

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

Referenced by __analog_handle_event(), __ast_pbx_run(), ast_ari_channels_hangup(), ast_bridge_transfer_attended(), ast_dial_join(), conf_free(), rtp_check_timeout(), and stasis_app_bridge_moh_stop().

2472 {
2473  RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
2474  int res;
2475 
2476  ast_channel_lock(chan);
2477  res = ast_softhangup_nolock(chan, cause);
2478  blob = ast_json_pack("{s: i, s: b}",
2479  "cause", cause,
2480  "soft", 1);
2482  ast_channel_unlock(chan);
2483 
2484  return res;
2485 }
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:612
int ast_softhangup_nolock(struct ast_channel *chan, int cause)
Softly hangup a channel, don't lock.
Definition: channel.c:2458
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
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.
#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:941
void ast_softhangup_all ( void  )

Soft hangup all active channels.

Since
13.3.0

Definition at line 493 of file channel.c.

References ao2_callback, OBJ_MULTIPLE, and OBJ_NODATA.

494 {
495  ao2_callback(channels, OBJ_NODATA | OBJ_MULTIPLE, ast_channel_softhangup_cb, NULL);
496 }
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container, as described below.
Definition: astobj2.h:1693
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:124
int ast_softhangup_nolock ( struct ast_channel chan,
int  cause 
)

Softly hangup up a channel (no channel lock)

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

Softly hangup up a channel (no channel lock)

Definition at line 2458 of file channel.c.

References ast_debug, AST_FLAG_BLOCKING, ast_null_frame, and ast_queue_frame().

Referenced by __analog_handle_event(), ast_async_goto(), ast_bridge_join(), ast_channel_softhangup_withcause_locked(), ast_pbx_h_exten_run(), ast_pbx_hangup_handler_run(), ast_softhangup(), and jingle_indicate().

2459 {
2460  ast_debug(1, "Soft-Hanging (%#04x) up channel '%s'\n", (unsigned)cause, ast_channel_name(chan));
2461  /* Inform channel driver that we need to be hung up, if it cares */
2462  ast_channel_softhangup_internal_flag_add(chan, cause);
2464  /* Interrupt any poll call or such */
2465  if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING))
2466  pthread_kill(ast_channel_blocker(chan), SIGURG);
2467  return 0;
2468 }
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to a channel's frame queue.
Definition: channel.c:1139
#define ast_debug(level,...)
Log a DEBUG message.
struct ast_frame ast_null_frame
Definition: main/frame.c:79
const char* ast_state2str ( enum ast_channel_state  state)

Gives the string form of a given channel state.

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

Definition at line 636 of file channel.c.

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

Referenced by ast_channel_snapshot_to_json(), ast_manager_build_channel_state_string_prefix(), and handle_showchan().

637 {
638  char *buf;
639 
640  switch (state) {
641  case AST_STATE_DOWN:
642  return "Down";
643  case AST_STATE_RESERVED:
644  return "Rsrvd";
645  case AST_STATE_OFFHOOK:
646  return "OffHook";
647  case AST_STATE_DIALING:
648  return "Dialing";
649  case AST_STATE_RING:
650  return "Ring";
651  case AST_STATE_RINGING:
652  return "Ringing";
653  case AST_STATE_UP:
654  return "Up";
655  case AST_STATE_BUSY:
656  return "Busy";
658  return "Dialing Offhook";
659  case AST_STATE_PRERING:
660  return "Pre-ring";
661  case AST_STATE_MUTE:
662  return "Mute";
663  default:
664  if (!(buf = ast_threadstorage_get(&state2str_threadbuf, STATE2STR_BUFSIZE)))
665  return "Unknown";
666  snprintf(buf, STATE2STR_BUFSIZE, "Unknown (%u)", state);
667  return buf;
668  }
669 }
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
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.

Referenced by dial_exec_full().

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

References ast_read(), ast_tonepair_start(), and ast_waitfor().

7601 {
7602  int res;
7603 
7604  if ((res = ast_tonepair_start(chan, freq1, freq2, duration, vol)))
7605  return res;
7606 
7607  /* Give us some wiggle room */
7608  while (ast_channel_generatordata(chan) && ast_waitfor(chan, 100) >= 0) {
7609  struct ast_frame *f = ast_read(chan);
7610  if (f)
7611  ast_frfree(f);
7612  else
7613  return -1;
7614  }
7615  return 0;
7616 }
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4257
int ast_waitfor(struct ast_channel *c, int ms)
Wait for input on a channel.
Definition: channel.c:3162
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:7582
int ast_tonepair_start ( struct ast_channel chan,
int  freq1,
int  freq2,
int  duration,
int  vol 
)

Start a tone going

Definition at line 7582 of file channel.c.

References ast_activate_generator().

Referenced by ast_tonepair().

7583 {
7584  struct tonepair_def d = { 0, };
7585 
7586  d.freq1 = freq1;
7587  d.freq2 = freq2;
7588  d.duration = duration;
7589  d.vol = (vol < 1) ? 8192 : vol; /* force invalid to 8192 */
7590  if (ast_activate_generator(chan, &tonepair, &d))
7591  return -1;
7592  return 0;
7593 }
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
Definition: channel.c:2951
void ast_tonepair_stop ( struct ast_channel chan)

Stop a tone from playing

Definition at line 7595 of file channel.c.

References ast_deactivate_generator().

7596 {
7598 }
void ast_deactivate_generator(struct ast_channel *chan)
Definition: channel.c:2893
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 6485 of file channel.c.

References ast_transfer_protocol().

6486 {
6487  int protocol;
6488  return ast_transfer_protocol(chan, dest, &protocol);
6489 }
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:6498
int ast_transfer_protocol ( struct ast_channel chan,
char *  dest,
int *  protocol 
)

Transfer a channel (if supported) receieve protocol result.

Return values
-1on error
0if not supported
1if supported and requested
Parameters
chanchannel to transfer
destdestination extension to transfer to
protocolprotocol is the protocol result SIP example, 0=success, 3xx-6xx is SIP error code

Transfer a channel (if supported) receieve protocol result.

Called by:

  • app_transfer
  • the manager interface

Definition at line 6498 of file channel.c.

References ast_check_hangup(), AST_CONTROL_TRANSFER, AST_FLAG_ZOMBIE, AST_FRAME_CONTROL, ast_read(), AST_TRANSFER_SUCCESS, ast_waitfor(), ast_frame::data, ast_frame::frametype, ast_frame_subclass::integer, ast_frame::subclass, and ast_channel_tech::transfer.

Referenced by ast_transfer().

6499 {
6500  int res = -1;
6501 
6502  if (protocol) {
6503  *protocol = 0;
6504  }
6505 
6506  /* Stop if we're a zombie or need a soft hangup */
6507  ast_channel_lock(chan);
6508  if (!ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) {
6509  if (ast_channel_tech(chan)->transfer) {
6510  res = ast_channel_tech(chan)->transfer(chan, dest);
6511  if (!res)
6512  res = 1;
6513  } else
6514  res = 0;
6515  }
6516  ast_channel_unlock(chan);
6517 
6518  if (res <= 0) {
6519  return res;
6520  }
6521 
6522  for (;;) {
6523  struct ast_frame *fr;
6524 
6525  res = ast_waitfor(chan, -1);
6526 
6527  if (res < 0 || !(fr = ast_read(chan))) {
6528  res = -1;
6529  break;
6530  }
6531 
6533  enum ast_control_transfer *message = fr->data.ptr;
6534 
6535  if (*message == AST_TRANSFER_SUCCESS) {
6536  res = 1;
6537  } else {
6538  res = -1;
6539  /* Message can contain a protocol specific code
6540  AST_TRANSFER_SUCCESS indicates success
6541  Else, failure. Protocol will be set to the failure reason.
6542  SIP example, 0 is success, else error code 3xx-6xx */
6543  if (protocol) {
6544  *protocol = *message;
6545  }
6546  }
6547 
6548  ast_frfree(fr);
6549  break;
6550  }
6551 
6552  ast_frfree(fr);
6553  }
6554 
6555  return res;
6556 }
int(*const transfer)(struct ast_channel *chan, const char *newdest)
Blind transfer other side (see app_transfer.c and ast_transfer()
Definition: channel.h:783
ast_control_transfer
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
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4257
union ast_frame::@224 data
int ast_waitfor(struct ast_channel *c, int ms)
Wait for input on a channel.
Definition: channel.c:3162
Data structure associated with a single frame of data.
enum ast_frame_type frametype
char* ast_transfercapability2str ( int  transfercapability) const

Gives the string form of a given transfer capability.

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

Definition at line 672 of file channel.c.

Referenced by sig_pri_call().

673 {
674  switch (transfercapability) {
675  case AST_TRANS_CAP_SPEECH:
676  return "SPEECH";
677  case AST_TRANS_CAP_DIGITAL:
678  return "DIGITAL";
679  case AST_TRANS_CAP_RESTRICTED_DIGITAL:
680  return "RESTRICTED_DIGITAL";
681  case AST_TRANS_CAP_3_1K_AUDIO:
682  return "3K1AUDIO";
683  case AST_TRANS_CAP_DIGITAL_W_TONES:
684  return "DIGITAL_W_TONES";
685  case AST_TRANS_CAP_VIDEO:
686  return "VIDEO";
687  default:
688  return "UNKNOWN";
689  }
690 }
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().

505 {
506  return ast_atomic_fetchadd_int(&chancount, 0);
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:757
int ast_waitfor ( struct ast_channel chan,
int  ms 
)

Wait for input on a channel.

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

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

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

Definition at line 3162 of file channel.c.

References ast_waitfor_nandfds().

Referenced by __ast_answer(), __ast_play_and_record(), __ast_request_and_dial(), ast_control_tone(), ast_recvtext(), ast_tonepair(), ast_transfer_protocol(), moh_channel_thread(), read_mf_digits(), read_sf_digits(), receive_dtmf_digits(), safe_sleep_conditional(), speech_background(), stasis_app_exec(), and waitstream_core().

3163 {
3164  if (ms < 0) {
3165  do {
3166  ms = 100000;
3167  ast_waitfor_nandfds(&c, 1, NULL, 0, NULL, NULL, &ms);
3168  } while (!ms);
3169  } else {
3170  ast_waitfor_nandfds(&c, 1, NULL, 0, NULL, NULL, &ms);
3171  }
3172  return ms;
3173 }
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:2988
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 3157 of file channel.c.

References ast_waitfor_nandfds().

Referenced by dial_exec_full(), monitor_dial(), and wait_for_answer().

3158 {
3159  return ast_waitfor_nandfds(c, n, NULL, 0, NULL, NULL, ms);
3160 }
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:2988
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 2980 of file channel.c.

References ast_waitfor_nandfds().

Referenced by rfcomm_wait(), and softmix_mixing_loop().

2981 {
2982  int winner = -1;
2983  ast_waitfor_nandfds(NULL, 0, fds, n, exception, &winner, ms);
2984  return winner;
2985 }
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:2988
struct ast_channel* ast_waitfor_nandfds ( struct ast_channel **  c,
int  n,
int *  fds,
int  nfds,
int *  exception,
int *  outfd,
int *  ms 
)

Waits for activity on a group of channels.

Parameters
can array of pointers to channels
nnumber of channels that are to be waited upon
fdsan array of fds to wait upon
nfdsthe number of fds to wait upon
exceptionexception flag
outfdfd that had activity on it
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 2988 of file channel.c.

References ast_add_fd(), ast_alloca, ast_channel_fd_count(), AST_FLAG_BLOCKING, AST_FLAG_EXCEPTION, AST_SOFTHANGUP_TIMEOUT, ast_test_suite_event_notify, ast_tvcmp(), ast_tvdiff_ms(), ast_tvnow(), ast_tvsub(), ast_tvzero(), and CHECK_BLOCKING.

Referenced by ast_waitfor(), ast_waitfor_n(), ast_waitfor_n_fd(), ast_waitfordigit_full(), generic_fax_exec(), run_agi(), and waitstream_core().

2990 {
2991  struct timeval start = { 0 , 0 };
2992  struct pollfd *pfds = NULL;
2993  int res;
2994  long rms;
2995  int x, y, max;
2996  int sz = nfds;
2997  struct timeval now = { 0, 0 };
2998  struct timeval whentohangup = { 0, 0 }, diff;
2999  struct ast_channel *winner = NULL;
3000  struct fdmap {
3001  int chan;
3002  int fdno;
3003  } *fdmap = NULL;
3004 
3005  if (outfd) {
3006  *outfd = -99999;
3007  }
3008  if (exception) {
3009  *exception = 0;
3010  }
3011 
3012  for (x = 0; x < n; x++) {
3013  ast_channel_lock(c[x]);
3014  if (!ast_tvzero(*ast_channel_whentohangup(c[x]))) {
3015  if (ast_tvzero(whentohangup))
3016  now = ast_tvnow();
3017  diff = ast_tvsub(*ast_channel_whentohangup(c[x]), now);
3018  if (diff.tv_sec < 0 || ast_tvzero(diff)) {
3019  ast_test_suite_event_notify("HANGUP_TIME", "Channel: %s", ast_channel_name(c[x]));
3020  /* Should already be hungup */
3021  ast_channel_softhangup_internal_flag_add(c[x], AST_SOFTHANGUP_TIMEOUT);
3022  ast_channel_unlock(c[x]);
3023  return c[x];
3024  }
3025  if (ast_tvzero(whentohangup) || ast_tvcmp(diff, whentohangup) < 0)
3026  whentohangup = diff;
3027  }
3028  sz += ast_channel_fd_count(c[x]);
3029  ast_channel_unlock(c[x]);
3030  }
3031 
3032  if (!sz) {
3033  return NULL;
3034  }
3035 
3036  pfds = ast_alloca(sizeof(*pfds) * sz);
3037  fdmap = ast_alloca(sizeof(*fdmap) * sz);
3038 
3039  /* Wait full interval */
3040  rms = *ms;
3041  /* INT_MAX, not LONG_MAX, because it matters on 64-bit */
3042  if (!ast_tvzero(whentohangup) && whentohangup.tv_sec < INT_MAX / 1000) {
3043  rms = whentohangup.tv_sec * 1000 + whentohangup.tv_usec / 1000; /* timeout in milliseconds */
3044  if (*ms >= 0 && *ms < rms) { /* original *ms still smaller */
3045  rms = *ms;
3046  }
3047  } else if (!ast_tvzero(whentohangup) && rms < 0) {
3048  /* Tiny corner case... call would need to last >24 days */
3049  rms = INT_MAX;
3050  }
3051  /*
3052  * Build the pollfd array, putting the channels' fds first,
3053  * followed by individual fds. Order is important because
3054  * individual fd's must have priority over channel fds.
3055  */
3056  max = 0;
3057  for (x = 0; x < n; x++) {
3058  ast_channel_lock(c[x]);
3059  for (y = 0; y < ast_channel_fd_count(c[x]); y++) {
3060  fdmap[max].fdno = y; /* fd y is linked to this pfds */
3061  fdmap[max].chan = x; /* channel x is linked to this pfds */
3062  max += ast_add_fd(&pfds[max], ast_channel_fd(c[x], y));
3063  }
3064  CHECK_BLOCKING(c[x]);
3065  ast_channel_unlock(c[x]);
3066  }
3067  /* Add the individual fds */
3068  for (x = 0; x < nfds; x++) {
3069  fdmap[max].chan = -1;
3070  max += ast_add_fd(&pfds[max], fds[x]);
3071  }
3072 
3073  if (*ms > 0) {
3074  start = ast_tvnow();
3075  }
3076 
3077  if (sizeof(int) == 4) { /* XXX fix timeout > 600000 on linux x86-32 */
3078  do {
3079  int kbrms = rms;
3080  if (kbrms > 600000) {
3081  kbrms = 600000;
3082  }
3083  res = ast_poll(pfds, max, kbrms);
3084  if (!res) {
3085  rms -= kbrms;
3086  }
3087  } while (!res && (rms > 0));
3088  } else {
3089  res = ast_poll(pfds, max, rms);
3090  }
3091  for (x = 0; x < n; x++) {
3092  ast_channel_lock(c[x]);
3093  ast_clear_flag(ast_channel_flags(c[x]), AST_FLAG_BLOCKING);
3094  ast_channel_unlock(c[x]);
3095  }
3096  if (res < 0) { /* Simulate a timeout if we were interrupted */
3097  if (errno != EINTR) {
3098  *ms = -1;
3099  }
3100  return NULL;
3101  }
3102  if (!ast_tvzero(whentohangup)) { /* if we have a timeout, check who expired */
3103  now = ast_tvnow();
3104  for (x = 0; x < n; x++) {
3105  if (!ast_tvzero(*ast_channel_whentohangup(c[x])) && ast_tvcmp(*ast_channel_whentohangup(c[x]), now) <= 0) {
3106  ast_test_suite_event_notify("HANGUP_TIME", "Channel: %s", ast_channel_name(c[x]));
3107  ast_channel_softhangup_internal_flag_add(c[x], AST_SOFTHANGUP_TIMEOUT);
3108  if (winner == NULL) {
3109  winner = c[x];
3110  }
3111  }
3112  }
3113  }
3114  if (res == 0) { /* no fd ready, reset timeout and done */
3115  *ms = 0; /* XXX use 0 since we may not have an exact timeout. */
3116  return winner;
3117  }
3118  /*
3119  * Then check if any channel or fd has a pending event.
3120  * Remember to check channels first and fds last, as they
3121  * must have priority on setting 'winner'
3122  */
3123  for (x = 0; x < max; x++) {
3124  res = pfds[x].revents;
3125  if (res == 0) {
3126  continue;
3127  }
3128  if (fdmap[x].chan >= 0) { /* this is a channel */
3129  winner = c[fdmap[x].chan]; /* override previous winners */
3130  ast_channel_lock(winner);
3131  if (res & POLLPRI) {
3132  ast_set_flag(ast_channel_flags(winner), AST_FLAG_EXCEPTION);
3133  } else {
3134  ast_clear_flag(ast_channel_flags(winner), AST_FLAG_EXCEPTION);
3135  }
3136  ast_channel_fdno_set(winner, fdmap[x].fdno);
3137  ast_channel_unlock(winner);
3138  } else { /* this is an fd */
3139  if (outfd) {
3140  *outfd = pfds[x].fd;
3141  }
3142  if (exception) {
3143  *exception = (res & POLLPRI) ? -1 : 0;
3144  }
3145  winner = NULL;
3146  }
3147  }
3148  if (*ms > 0) {
3149  *ms -= ast_tvdiff_ms(ast_tvnow(), start);
3150  if (*ms < 0) {
3151  *ms = 0;
3152  }
3153  }
3154  return winner;
3155 }
Main Channel structure associated with a channel.
static int ast_add_fd(struct pollfd *pfd, int fd)
if fd is a valid descriptor, set *pfd with the descriptor
Definition: channel.h:2819
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:117
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:159
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:107
#define ast_test_suite_event_notify(s, f,...)
Definition: test.h:189
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: astmm.h:288
int ast_tvcmp(struct timeval _a, struct timeval _b)
Compress two struct timeval instances returning -1, 0, 1 if the first arg is smaller, equal or greater to the second.
Definition: time.h:137
#define CHECK_BLOCKING(c)
Set the blocking indication on the channel.
Definition: channel.h:2871
int ast_channel_fd_count(const struct ast_channel *chan)
Retrieve the number of file decriptor positions present on the channel.
struct timeval ast_tvsub(struct timeval a, struct timeval b)
Returns the difference of two timevals a - b.
Definition: extconf.c:2297
int ast_waitfordigit ( struct ast_channel c,
int  ms 
)

Waits for a digit.

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

Definition at line 3175 of file channel.c.

References ast_waitfordigit_full().

Referenced by advanced_options(), ast_app_dtget(), ast_record_review(), collect_digits(), forward_message(), get_folder(), vm_forwardoptions(), vm_tempgreeting(), and wait_our_turn().

3176 {
3177  return ast_waitfordigit_full(c, ms, NULL, -1, -1);
3178 }
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:3239
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 3239 of file channel.c.

References ast_channel_clear_flag(), ast_channel_set_flag(), ast_check_hangup(), AST_CONTROL_ANSWER, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_FLASH, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_PROGRESS, AST_CONTROL_PVT_CAUSE_CODE, AST_CONTROL_REDIRECTING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_CONTROL_STREAM_FORWARD, AST_CONTROL_STREAM_RESTART, AST_CONTROL_STREAM_REVERSE, AST_CONTROL_STREAM_STOP, AST_CONTROL_STREAM_SUSPEND, AST_CONTROL_UNHOLD, AST_CONTROL_UPDATE_RTP_PEER, AST_FLAG_END_DTMF_ONLY, AST_FLAG_ZOMBIE, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_VOICE, ast_read(), ast_remaining_ms(), ast_tvnow(), ast_waitfor_nandfds(), ast_frame::data, ast_frame::datalen, ast_frame::frametype, ast_frame_subclass::integer, and ast_frame::subclass.

Referenced by ast_waitfordigit(), and handle_getoption().

3240 {
3241  struct timeval start = ast_tvnow();
3242  int ms;
3243 
3244  /* Stop if we're a zombie or need a soft hangup */
3245  if (ast_test_flag(ast_channel_flags(c), AST_FLAG_ZOMBIE) || ast_check_hangup(c))
3246  return -1;
3247 
3248  /* Only look for the end of DTMF, don't bother with the beginning and don't emulate things */
3250 
3251  /* Wait for a digit, no more than timeout_ms milliseconds total.
3252  * Or, wait indefinitely if timeout_ms is <0.
3253  */
3254  while ((ms = ast_remaining_ms(start, timeout_ms))) {
3255  struct ast_channel *rchan;
3256  int outfd = -1;
3257 
3258  errno = 0;
3259  /* While ast_waitfor_nandfds tries to help by reducing the timeout by how much was waited,
3260  * it is unhelpful if it waited less than a millisecond.
3261  */
3262  rchan = ast_waitfor_nandfds(&c, 1, &cmdfd, (cmdfd > -1) ? 1 : 0, NULL, &outfd, &ms);
3263 
3264  if (!rchan && outfd < 0 && ms) {
3265  if (errno == 0 || errno == EINTR)
3266  continue;
3267  ast_log(LOG_WARNING, "Wait failed (%s)\n", strerror(errno));
3269  return -1;
3270  } else if (outfd > -1) {
3271  /* The FD we were watching has something waiting */
3272  ast_log(LOG_WARNING, "The FD we were waiting for has something waiting. Waitfordigit returning numeric 1\n");
3274  return 1;
3275  } else if (rchan) {
3276  int res;
3277  struct ast_frame *f = ast_read(c);
3278 
3279  if (!f) {
3281 
3282  return -1;
3283  }
3284 
3285  switch (f->frametype) {
3286  case AST_FRAME_DTMF_BEGIN:
3287  break;
3288  case AST_FRAME_DTMF_END:
3289  res = f->subclass.integer;
3290  if (!breakon || strchr(breakon, res)) {
3291  ast_frfree(f);
3293  return res;
3294  }
3295  break;
3296  case AST_FRAME_CONTROL:
3297  switch (f->subclass.integer) {
3298  case AST_CONTROL_HANGUP:
3299  ast_frfree(f);
3301  return -1;
3307  /* Fall-through and treat as if it were a DTMF signal. Items
3308  * that perform stream control will handle this. */
3309  res = f->subclass.integer;
3310  ast_frfree(f);
3312  return res;
3314  case AST_CONTROL_PROGRESS:
3315  case AST_CONTROL_RINGING:
3316  case AST_CONTROL_ANSWER:
3317  case AST_CONTROL_SRCUPDATE:
3318  case AST_CONTROL_SRCCHANGE:
3322  case AST_CONTROL_HOLD:
3323  case AST_CONTROL_UNHOLD:
3324  case AST_CONTROL_FLASH:
3325  case -1:
3326  /* Unimportant */
3327  break;
3328  default:
3329  ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", f->subclass.integer);
3330  break;
3331  }
3332  break;
3333  case AST_FRAME_VOICE:
3334  /* Write audio if appropriate */
3335  if (audiofd > -1) {
3336  if (write(audiofd, f->data.ptr, f->datalen) < 0) {
3337  ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
3338  }
3339  }
3340  default:
3341  /* Ignore */
3342  break;
3343  }
3344  ast_frfree(f);
3345  }
3346  }
3347 
3349 
3350  return 0; /* Time is up */
3351 }
Main Channel structure associated with a channel.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:159
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:2988
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
void ast_channel_clear_flag(struct ast_channel *chan, unsigned int flag)
Clear a flag on a channel.
Definition: channel.c:11034
void ast_channel_set_flag(struct ast_channel *chan, unsigned int flag)
Set a flag on a channel.
Definition: channel.c:11027
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
Definition: utils.c:2281
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4257
union ast_frame::@224 data
Data structure associated with a single frame of data.
enum ast_frame_type frametype
int ast_write ( struct ast_channel chan,
struct ast_frame frame 
)

Write a frame to a channel This function writes the given frame to the indicated channel.

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

Definition at line 5144 of file channel.c.

References ast_write_stream().

Referenced by ast_prod(), ast_write_video(), fax_gateway_detect_v21(), generic_fax_exec(), handle_jack_audio(), sms_generate(), and spandsp_fax_gw_t30_gen().

5145 {
5146  return ast_write_stream(chan, -1, fr);
5147 }
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:5149
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 5149 of file channel.c.

References ast_audiohook_detach_list(), AST_AUDIOHOOK_DIRECTION_WRITE, ast_audiohook_write_list(), ast_audiohook_write_list_empty(), ast_channel_get_default_stream(), ast_channel_get_stream_topology(), ast_check_hangup(), AST_CONTROL_UNHOLD, ast_deactivate_generator(), ast_debug, AST_FLAG_BLOCKING, AST_FLAG_WRITE_INT, AST_FLAG_ZOMBIE, ast_format_cache_is_slinear(), ast_format_cap_get_names(), AST_FORMAT_CAP_NAMES_LEN, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_get_name(), ast_format_get_type(), ast_format_slin, ast_format_t140, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, ast_frame_dump(), AST_FRAME_HTML, AST_FRAME_IAX, AST_FRAME_MODEM, AST_FRAME_NULL, AST_FRAME_RTCP, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_framehook_list_write_event(), ast_frisolate, AST_LIST_NEXT, ast_senddigit_begin(), ast_senddigit_end(), ast_set_write_format(), AST_SOFTHANGUP_DEV, ast_stream_get_position(), ast_stream_get_type(), ast_stream_topology_get_count(), ast_stream_topology_get_stream(), ast_translate(), CHECK_BLOCKING, ast_frame::data, ast_frame::datalen, DEBUGCHAN_FLAG, ast_frame_subclass::format, ast_frame::frametype, indicate_data_internal(), ast_frame_subclass::integer, ast_frame::len, ast_channel_tech::send_html, ast_channel_tech::send_text, ast_frame::src, ast_frame::subclass, 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_write().

5150 {
5151  struct ast_stream *stream = NULL, *default_stream = NULL;
5152  int res = -1;
5153  struct ast_frame *f = NULL;
5154  int count = 0;
5155  int hooked = 0;
5156 
5157  /*Deadlock avoidance*/
5158  while(ast_channel_trylock(chan)) {
5159  /*cannot goto done since the channel is not locked*/
5160  if(count++ > 10) {
5161  ast_debug(1, "Deadlock avoided for write to channel '%s'\n", ast_channel_name(chan));
5162  return 0;
5163  }
5164  usleep(1);
5165  }
5166 
5167  /* Stop if we're a zombie or need a soft hangup */
5168  if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
5169  goto done;
5170  }
5171 
5172  if (stream_num >= 0) {
5173  /* If we were told to write to an explicit stream then allow this frame through, no matter
5174  * if the type is expected or not (a framehook could change)
5175  */
5177  goto done;
5178  }
5180  default_stream = ast_channel_get_default_stream(chan, ast_stream_get_type(stream));
5181  } else if (fr->frametype == AST_FRAME_VOICE || fr->frametype == AST_FRAME_VIDEO || fr->frametype == AST_FRAME_MODEM) {
5182  /* If we haven't been told of a stream then we need to figure out which once we need */
5183  enum ast_media_type type = AST_MEDIA_TYPE_UNKNOWN;
5184 
5185  /* Some frame types have a fixed media type */
5186  if (fr->frametype == AST_FRAME_VOICE || fr->frametype == AST_FRAME_VIDEO) {
5187  type = ast_format_get_type(fr->subclass.format);
5188  } else if (fr->frametype == AST_FRAME_MODEM) {
5189  type = AST_MEDIA_TYPE_IMAGE;
5190  }
5191 
5192  /* No stream was specified, so use the default one */
5193  stream = default_stream = ast_channel_get_default_stream(chan, type);
5194  }
5195 
5196  /* Perform the framehook write event here. After the frame enters the framehook list
5197  * there is no telling what will happen, how awesome is that!!! */
5198  if ((stream == default_stream) && !(fr = ast_framehook_list_write_event(ast_channel_framehooks(chan), fr))) {
5199  res = 0;
5200  goto done;
5201  }
5202 
5203  if (ast_channel_generatordata(chan) && (fr->frametype != AST_FRAME_RTCP) && (!fr->src || strcasecmp(fr->src, "ast_prod"))) {
5204  if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_WRITE_INT)) {
5206  } else {
5207  if (fr->frametype == AST_FRAME_DTMF_END) {
5208  /* There is a generator running while we're in the middle of a digit.
5209  * It's probably inband DTMF, so go ahead and pass it so it can
5210  * stop the generator */
5211  ast_channel_unlock(chan);
5212  res = ast_senddigit_end(chan, fr->subclass.integer, fr->len);
5213  ast_channel_lock(chan);
5214  } else if (fr->frametype == AST_FRAME_CONTROL
5215  && fr->subclass.integer == AST_CONTROL_UNHOLD) {
5216  /*
5217  * This is a side case where Echo is basically being called
5218  * and the person put themselves on hold and took themselves
5219  * off hold.
5220  */
5221  indicate_data_internal(chan, fr->subclass.integer, fr->data.ptr,
5222  fr->datalen);
5223  }
5224  res = 0; /* XXX explain, why 0 ? */
5225  goto done;
5226  }
5227  }
5228  /* High bit prints debugging */
5229  if (ast_channel_fout(chan) & DEBUGCHAN_FLAG)
5230  ast_frame_dump(ast_channel_name(chan), fr, ">>");
5231  switch (fr->frametype) {
5232  case AST_FRAME_CONTROL:
5233  indicate_data_internal(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
5234  res = 0;
5235  break;
5236  case AST_FRAME_DTMF_BEGIN:
5237  if (ast_channel_audiohooks(chan)) {
5238  struct ast_frame *old_frame = fr;
5239  fr = ast_audiohook_write_list(chan, ast_channel_audiohooks(chan), AST_AUDIOHOOK_DIRECTION_WRITE, fr);
5240  if (old_frame != fr)
5241  f = fr;
5242  }
5243  send_dtmf_begin_event(chan, DTMF_SENT, fr->subclass.integer);
5244  ast_channel_unlock(chan);
5245  res = ast_senddigit_begin(chan, fr->subclass.integer);
5246  ast_channel_lock(chan);
5247  break;
5248  case AST_FRAME_DTMF_END:
5249  if (ast_channel_audiohooks(chan)) {
5250  struct ast_frame *new_frame = fr;
5251 
5252  new_frame = ast_audiohook_write_list(chan, ast_channel_audiohooks(chan), AST_AUDIOHOOK_DIRECTION_WRITE, fr);
5253  if (new_frame != fr) {
5254  ast_frfree(new_frame);
5255  }
5256  }
5257  send_dtmf_end_event(chan, DTMF_SENT, fr->subclass.integer, fr->len);
5258  ast_channel_unlock(chan);
5259  res = ast_senddigit_end(chan, fr->subclass.integer, fr->len);
5260  ast_channel_lock(chan);
5261  break;
5262  case AST_FRAME_TEXT:
5263  CHECK_BLOCKING(chan);
5264  if (ast_format_cmp(fr->subclass.format, ast_format_t140) == AST_FORMAT_CMP_EQUAL) {
5265  res = (ast_channel_tech(chan)->write_text == NULL) ? 0 :
5266  ast_channel_tech(chan)->write_text(chan, fr);
5267  } else {
5268  res = (ast_channel_tech(chan)->send_text == NULL) ? 0 :
5269  ast_channel_tech(chan)->send_text(chan, (char *) fr->data.ptr);
5270  }
5271  ast_clear_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING);
5272  break;
5273  case AST_FRAME_HTML:
5274  CHECK_BLOCKING(chan);
5275  res = (ast_channel_tech(chan)->send_html == NULL) ? 0 :
5276  ast_channel_tech(chan)->send_html(chan, fr->subclass.integer, (char *) fr->data.ptr, fr->datalen);
5277  ast_clear_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING);
5278  break;
5279  case AST_FRAME_VIDEO:
5280  /* XXX Handle translation of video codecs one day XXX */
5281  CHECK_BLOCKING(chan);
5282  if (ast_channel_tech(chan)->write_stream) {
5283  if (stream) {
5284  res = ast_channel_tech(chan)->write_stream(chan, ast_stream_get_position(stream), fr);
5285  } else {
5286  res = 0;
5287  }
5288  } else if ((stream == default_stream) && ast_channel_tech(chan)->write_video) {
5289  res = ast_channel_tech(chan)->write_video(chan, fr);
5290  } else {
5291  res = 0;
5292  }
5293  ast_clear_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING);
5294  break;
5295  case AST_FRAME_MODEM:
5296  CHECK_BLOCKING(chan);
5297  res = tech_write(chan, stream, default_stream, fr);
5298  ast_clear_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING);
5299  break;
5300  case AST_FRAME_VOICE:
5301  if (ast_opt_generic_plc && ast_format_cmp(fr->subclass.format, ast_format_slin) == AST_FORMAT_CMP_EQUAL) {
5302  apply_plc(chan, fr);
5303  }
5304 
5305  f = fr;
5306 
5307  /*
5308  * Send frame to audiohooks if present, if frametype is linear (else, later as per
5309  * previous behavior)
5310  */
5311  if ((stream == default_stream) && ast_channel_audiohooks(chan)) {
5312  if (ast_format_cache_is_slinear(fr->subclass.format)) {
5313  hooked = 1;
5314  f = ast_audiohook_write_list(chan, ast_channel_audiohooks(chan), AST_AUDIOHOOK_DIRECTION_WRITE, fr);
5315  }
5316  }
5317 
5318  /* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */
5319  if ((stream == default_stream) && ast_format_cmp(fr->subclass.format, ast_channel_rawwriteformat(chan)) != AST_FORMAT_CMP_EQUAL) {
5320  if (ast_format_cmp(ast_channel_writeformat(chan), fr->subclass.format) != AST_FORMAT_CMP_EQUAL) {
5321  struct ast_str *codec_buf = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
5322 
5323  /*
5324  * We are not setup to write this frame. Things may have changed
5325  * on the peer side of the world and we try to adjust the format to
5326  * make it compatible again. However, bad things can happen if we
5327  * cannot setup a new translation path. Problems range from no
5328  * audio, one-way audio, to garbled audio. The best we can do is
5329  * request the call to hangup since we could not make it compatible.
5330  *
5331  * Being continuously spammed by this message likely indicates a
5332  * problem with the peer because it cannot make up its mind about
5333  * which format to use.
5334  */
5335  ast_debug(1, "Channel %s changing write format from %s to %s, native formats %s\n",
5336  ast_channel_name(chan),
5337  ast_format_get_name(ast_channel_writeformat(chan)),
5338  ast_format_get_name(fr->subclass.format),
5339  ast_format_cap_get_names(ast_channel_nativeformats(chan), &codec_buf));
5340  if (ast_set_write_format(chan, fr->subclass.format)) {
5341  /* Could not handle the new write format. Induce a hangup. */
5342  break;
5343  }
5344  }
5345 
5346  if (ast_channel_writetrans(chan)) {
5347  struct ast_frame *trans_frame = ast_translate(ast_channel_writetrans(chan), f, 0);
5348  if (trans_frame != f && f != fr) {
5349  /*
5350  * If translate gives us a new frame and so did the audio
5351  * hook then we need to free the one from the audio hook.
5352  */
5353  ast_frfree(f);
5354  }
5355  f = trans_frame;
5356  }
5357  }
5358 
5359  if (!f) {
5360  res = 0;
5361  break;
5362  }
5363 
5364  if ((stream == default_stream) && ast_channel_audiohooks(chan) && !hooked) {
5365  struct ast_frame *prev = NULL, *new_frame, *cur, *dup;
5366  int freeoldlist = 0;
5367 
5368  if (f != fr) {
5369  freeoldlist = 1;
5370  }
5371 
5372  /* Since ast_audiohook_write may return a new frame, and the cur frame is
5373  * an item in a list of frames, create a new list adding each cur frame back to it
5374  * regardless if the cur frame changes or not. */
5375  for (cur = f; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
5376  new_frame = ast_audiohook_write_list(chan, ast_channel_audiohooks(chan), AST_AUDIOHOOK_DIRECTION_WRITE, cur);
5377 
5378  /* if this frame is different than cur, preserve the end of the list,
5379  * free the old frames, and set cur to be the new frame */
5380  if (new_frame != cur) {
5381 
5382  /* doing an ast_frisolate here seems silly, but we are not guaranteed the new_frame
5383  * isn't part of local storage, meaning if ast_audiohook_write is called multiple
5384  * times it may override the previous frame we got from it unless we dup it */
5385  if ((dup = ast_frisolate(new_frame))) {
5387  if (freeoldlist) {
5388  AST_LIST_NEXT(cur, frame_list) = NULL;
5389  ast_frfree(cur);
5390  }
5391  if (new_frame != dup) {
5392  ast_frfree(new_frame);
5393  }
5394  cur = dup;
5395  }
5396  }
5397 
5398  /* now, regardless if cur is new or not, add it to the new list,
5399  * if the new list has not started, cur will become the first item. */
5400  if (prev) {
5401  AST_LIST_NEXT(prev, frame_list) = cur;
5402  } else {
5403  f = cur; /* set f to be the beginning of our new list */
5404  }
5405  prev = cur;
5406  }
5407  }
5408 
5409  /* the translator on chan->writetrans may have returned multiple frames
5410  from the single frame we passed in; if so, feed each one of them to the
5411  channel, freeing each one after it has been written */
5412  CHECK_BLOCKING(chan);
5413  if ((f != fr) && AST_LIST_NEXT(f, frame_list)) {
5414  struct ast_frame *cur, *next = NULL;
5415  unsigned int skip = 0;
5416 
5417  cur = f;
5418  while (cur) {
5419  next = AST_LIST_NEXT(cur, frame_list);
5420  AST_LIST_NEXT(cur, frame_list) = NULL;
5421  if (!skip) {
5422  res = tech_write(chan, stream, default_stream, cur);
5423  if (res < 0) {
5424  ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_DEV);
5425  skip = 1;
5426  } else if (next) {
5427  /* don't do this for the last frame in the list,
5428  as the code outside the loop will do it once
5429  */
5430  ast_channel_fout_set(chan, FRAMECOUNT_INC(ast_channel_fout(chan)));
5431  }
5432  }
5433  ast_frfree(cur);
5434  cur = next;
5435  }
5436 
5437  /* reset f so the code below doesn't attempt to free it */
5438  f = NULL;
5439  } else {
5440  res = tech_write(chan, stream, default_stream, f);
5441  }
5442  ast_clear_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING);
5443  break;
5444  case AST_FRAME_NULL:
5445  case AST_FRAME_IAX:
5446  /* Ignore these */
5447  res = 0;
5448  break;
5449  case AST_FRAME_RTCP:
5450  /* RTCP information is on a per-stream basis and only available on multistream capable channels */
5451  CHECK_BLOCKING(chan);
5452  if (ast_channel_tech(chan)->write_stream && stream) {
5453  res = ast_channel_tech(chan)->write_stream(chan, ast_stream_get_position(stream), fr);
5454  } else {
5455  res = 0;
5456  }
5457  ast_clear_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING);
5458  break;
5459  default:
5460  /* At this point, fr is the incoming frame and f is NULL. Channels do
5461  * not expect to get NULL as a frame pointer and will segfault. Hence,
5462  * we output the original frame passed in. */
5463  CHECK_BLOCKING(chan);
5464  res = ast_channel_tech(chan)->write(chan, fr);
5465  ast_clear_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING);
5466  break;
5467  }
5468 
5469  if (f && f != fr)
5470  ast_frfree(f);
5471 
5472  /* Consider a write failure to force a soft hangup */
5473  if (res < 0) {
5474  ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_DEV);
5475  } else {
5476  ast_channel_fout_set(chan, FRAMECOUNT_INC(ast_channel_fout(chan)));
5477  }
5478 done:
5479  if (ast_channel_audiohooks(chan) && ast_audiohook_write_list_empty(ast_channel_audiohooks(chan))) {
5480  /* The list gets recreated if audiohooks are added again later */
5481  ast_audiohook_detach_list(ast_channel_audiohooks(chan));
5482  ast_channel_audiohooks_set(chan, NULL);
5483  }
5484  ast_channel_unlock(chan);
5485  return res;
5486 }
enum ast_media_type ast_format_get_type(const struct ast_format *format)
Get the media type of a format.
Definition: format.c:354
int(*const write_video)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format.
Definition: channel.h:786
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:857
int(*const write)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format (see frame.h)
Definition: channel.h:750
void ast_audiohook_detach_list(struct ast_audiohook_list *audiohook_list)
Detach audiohooks from list and destroy said list.
Definition: audiohook.c:565
int ast_audiohook_write_list_empty(struct ast_audiohook_list *audiohook_list)
Determine if a audiohook_list is empty or not.
Definition: audiohook.c:1071
enum ast_media_type ast_stream_get_type(const struct ast_stream *stream)
Get the media type of a stream.
Definition: stream.c:316
#define AST_FORMAT_CAP_NAMES_LEN
Definition: format_cap.h:324
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
Definition: linkedlists.h:439
static void write_stream(struct ogg_vorbis_desc *s, FILE *f)
Write out any pending encoded data.
void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
Definition: main/frame.c:731
int ast_senddigit_begin(struct ast_channel *chan, char digit)
Send a DTMF digit to a channel.
Definition: channel.c:4874
struct ast_frame * ast_translate(struct ast_trans_pvt *tr, struct ast_frame *f, int consume)
translates one or more frames Apply an input frame into the translator and receive zero or one output...
Definition: translate.c:566
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
const char * data
static int indicate_data_internal(struct ast_channel *chan, int _condition, const void *data, size_t datalen)
Definition: channel.c:4470
int ast_check_hangup(struct ast_channel *chan)
Checks to see if a channel is needing hang up.
Definition: channel.c:445
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:762
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.
int(*const write_text)(struct ast_channel *chan, struct ast_frame *frame)
Write a text frame, in standard format.
Definition: channel.h:789
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition: channel.c:4924
#define ast_debug(level,...)
Log a DEBUG message.
int(*const send_text)(struct ast_channel *chan, const char *text)
Display or transmit text.
Definition: channel.h:756
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
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:534
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:1079
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:753
Support for dynamic strings.
Definition: strings.h:623
const char * ast_format_cap_get_names(const struct ast_format_cap *cap, struct ast_str **buf)
Get the names of codecs of a set of formats.
Definition: format_cap.c:734
struct ast_frame * ast_framehook_list_write_event(struct ast_framehook_list *framehooks, struct ast_frame *frame)
This is used by the channel API push a frame write event to a channel's framehook list...
Definition: framehook.c:313
#define ast_frisolate(fr)
Makes a frame independent of any static storage.
void ast_deactivate_generator(struct ast_channel *chan)
Definition: channel.c:2893
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 CHECK_BLOCKING(c)
Set the blocking indication on the channel.
Definition: channel.h:2871
Data structure associated with a single frame of data.
ast_media_type
Types of media.
Definition: codec.h:30
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:231
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:5803
int ast_write_text ( struct ast_channel chan,
struct ast_frame frame 
)

Write text frame to a channel This function writes the given frame to the indicated channel.

Parameters
chandestination channel of the frame
frameframe that will be written
Returns
It returns 1 on success, 0 if not implemented, and -1 on failure.
int ast_write_video ( struct ast_channel chan,
struct ast_frame frame 
)

Write video frame to a channel This function writes the given frame to the indicated channel.

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

Definition at line 5017 of file channel.c.

References ast_write().

5018 {
5019  int res;
5020  if (!ast_channel_tech(chan)->write_video)
5021  return 0;
5022  res = ast_write(chan, fr);
5023  if (!res)
5024  res = 1;
5025  return res;
5026 }
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
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:5144
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

Variable Documentation

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.

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