Asterisk - The Open Source Telephony Project GIT-master-4c84066
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions | Variables
channel.c File Reference

Channel Management. More...

#include "asterisk.h"
#include "asterisk/_private.h"
#include <sys/time.h>
#include <signal.h>
#include <math.h>
#include "asterisk/paths.h"
#include "asterisk/pbx.h"
#include "asterisk/frame.h"
#include "asterisk/mod_format.h"
#include "asterisk/sched.h"
#include "asterisk/channel.h"
#include "asterisk/cel.h"
#include "asterisk/musiconhold.h"
#include "asterisk/say.h"
#include "asterisk/file.h"
#include "asterisk/cli.h"
#include "asterisk/translate.h"
#include "asterisk/manager.h"
#include "asterisk/chanvars.h"
#include "asterisk/linkedlists.h"
#include "asterisk/indications.h"
#include "asterisk/causes.h"
#include "asterisk/callerid.h"
#include "asterisk/utils.h"
#include "asterisk/lock.h"
#include "asterisk/app.h"
#include "asterisk/transcap.h"
#include "asterisk/devicestate.h"
#include "asterisk/threadstorage.h"
#include "asterisk/slinfactory.h"
#include "asterisk/audiohook.h"
#include "asterisk/framehook.h"
#include "asterisk/timing.h"
#include "asterisk/autochan.h"
#include "asterisk/stringfields.h"
#include "asterisk/global_datastores.h"
#include "asterisk/channel_internal.h"
#include "asterisk/features.h"
#include "asterisk/bridge.h"
#include "asterisk/test.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/max_forwards.h"
#include "asterisk/stream.h"
#include "asterisk/message.h"
#include "asterisk/rtp_engine.h"
#include "channelstorage.h"
Include dependency graph for channel.c:

Go to the source code of this file.

Data Structures

struct  ast_party_id_ies
 
struct  ast_party_name_ies
 
struct  ast_party_number_ies
 
struct  ast_party_redirecting_reason_ies
 
struct  ast_party_subaddress_ies
 
struct  ast_silence_generator
 
struct  backends
 the list of registered channel types More...
 
struct  causes_map
 map AST_CAUSE's to readable string representations More...
 
struct  chanlist
 List of channel drivers. More...
 
struct  external_vars
 
struct  manager_channel_variable
 List of channel variables to append to all channel-related events. More...
 
struct  namedgroup_member
 Named group member structure. More...
 
struct  plc_ds
 
struct  set_format_access
 
struct  suppress_data
 
struct  tonepair_def
 
struct  tonepair_state
 

Macros

#define AST_DEFAULT_EMULATE_DTMF_DURATION   100
 
#define AST_MIN_DTMF_GAP   45
 
#define DEFAULT_AMA_FLAGS   AST_AMA_DOCUMENTATION
 
#define DEFAULT_EMULATE_MF_DURATION   55
 
#define FORMAT   "%-15.15s %-40.40s %-13.13s %-13.13s %-13.13s %-13.13s\n"
 
#define STATE2STR_BUFSIZE   32
 

Enumerations

enum  {
  AST_CONNECTED_LINE_NUMBER , AST_CONNECTED_LINE_NAME , AST_CONNECTED_LINE_NUMBER_PLAN , AST_CONNECTED_LINE_ID_PRESENTATION ,
  AST_CONNECTED_LINE_SOURCE , AST_CONNECTED_LINE_SUBADDRESS , AST_CONNECTED_LINE_SUBADDRESS_TYPE , AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN ,
  AST_CONNECTED_LINE_SUBADDRESS_VALID , AST_CONNECTED_LINE_TAG , AST_CONNECTED_LINE_VERSION , AST_CONNECTED_LINE_NAME_VALID ,
  AST_CONNECTED_LINE_NAME_CHAR_SET , AST_CONNECTED_LINE_NAME_PRESENTATION , AST_CONNECTED_LINE_NUMBER_VALID , AST_CONNECTED_LINE_NUMBER_PRESENTATION ,
  AST_CONNECTED_LINE_PRIV_NUMBER , AST_CONNECTED_LINE_PRIV_NUMBER_PLAN , AST_CONNECTED_LINE_PRIV_NUMBER_VALID , AST_CONNECTED_LINE_PRIV_NUMBER_PRESENTATION ,
  AST_CONNECTED_LINE_PRIV_NAME , AST_CONNECTED_LINE_PRIV_NAME_VALID , AST_CONNECTED_LINE_PRIV_NAME_CHAR_SET , AST_CONNECTED_LINE_PRIV_NAME_PRESENTATION ,
  AST_CONNECTED_LINE_PRIV_SUBADDRESS , AST_CONNECTED_LINE_PRIV_SUBADDRESS_TYPE , AST_CONNECTED_LINE_PRIV_SUBADDRESS_ODD_EVEN , AST_CONNECTED_LINE_PRIV_SUBADDRESS_VALID ,
  AST_CONNECTED_LINE_PRIV_TAG
}
 Element identifiers for connected line indication frame data. More...
 
enum  {
  AST_REDIRECTING_FROM_NUMBER , AST_REDIRECTING_FROM_NAME , AST_REDIRECTING_FROM_NUMBER_PLAN , AST_REDIRECTING_FROM_ID_PRESENTATION ,
  AST_REDIRECTING_TO_NUMBER , AST_REDIRECTING_TO_NAME , AST_REDIRECTING_TO_NUMBER_PLAN , AST_REDIRECTING_TO_ID_PRESENTATION ,
  AST_REDIRECTING_REASON_CODE , AST_REDIRECTING_COUNT , AST_REDIRECTING_FROM_SUBADDRESS , AST_REDIRECTING_FROM_SUBADDRESS_TYPE ,
  AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN , AST_REDIRECTING_FROM_SUBADDRESS_VALID , AST_REDIRECTING_TO_SUBADDRESS , AST_REDIRECTING_TO_SUBADDRESS_TYPE ,
  AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN , AST_REDIRECTING_TO_SUBADDRESS_VALID , AST_REDIRECTING_FROM_TAG , AST_REDIRECTING_TO_TAG ,
  AST_REDIRECTING_VERSION , AST_REDIRECTING_FROM_NAME_VALID , AST_REDIRECTING_FROM_NAME_CHAR_SET , AST_REDIRECTING_FROM_NAME_PRESENTATION ,
  AST_REDIRECTING_FROM_NUMBER_VALID , AST_REDIRECTING_FROM_NUMBER_PRESENTATION , AST_REDIRECTING_TO_NAME_VALID , AST_REDIRECTING_TO_NAME_CHAR_SET ,
  AST_REDIRECTING_TO_NAME_PRESENTATION , AST_REDIRECTING_TO_NUMBER_VALID , AST_REDIRECTING_TO_NUMBER_PRESENTATION , AST_REDIRECTING_ORIG_NUMBER ,
  AST_REDIRECTING_ORIG_NUMBER_VALID , AST_REDIRECTING_ORIG_NUMBER_PLAN , AST_REDIRECTING_ORIG_NUMBER_PRESENTATION , AST_REDIRECTING_ORIG_NAME ,
  AST_REDIRECTING_ORIG_NAME_VALID , AST_REDIRECTING_ORIG_NAME_CHAR_SET , AST_REDIRECTING_ORIG_NAME_PRESENTATION , AST_REDIRECTING_ORIG_SUBADDRESS ,
  AST_REDIRECTING_ORIG_SUBADDRESS_TYPE , AST_REDIRECTING_ORIG_SUBADDRESS_ODD_EVEN , AST_REDIRECTING_ORIG_SUBADDRESS_VALID , AST_REDIRECTING_ORIG_TAG ,
  AST_REDIRECTING_ORIG_REASON_CODE , AST_REDIRECTING_PRIV_TO_NUMBER , AST_REDIRECTING_PRIV_TO_NUMBER_PLAN , AST_REDIRECTING_PRIV_TO_NUMBER_VALID ,
  AST_REDIRECTING_PRIV_TO_NUMBER_PRESENTATION , AST_REDIRECTING_PRIV_TO_NAME , AST_REDIRECTING_PRIV_TO_NAME_VALID , AST_REDIRECTING_PRIV_TO_NAME_CHAR_SET ,
  AST_REDIRECTING_PRIV_TO_NAME_PRESENTATION , AST_REDIRECTING_PRIV_TO_SUBADDRESS , AST_REDIRECTING_PRIV_TO_SUBADDRESS_TYPE , AST_REDIRECTING_PRIV_TO_SUBADDRESS_ODD_EVEN ,
  AST_REDIRECTING_PRIV_TO_SUBADDRESS_VALID , AST_REDIRECTING_PRIV_TO_TAG , AST_REDIRECTING_PRIV_FROM_NUMBER , AST_REDIRECTING_PRIV_FROM_NUMBER_PLAN ,
  AST_REDIRECTING_PRIV_FROM_NUMBER_VALID , AST_REDIRECTING_PRIV_FROM_NUMBER_PRESENTATION , AST_REDIRECTING_PRIV_FROM_NAME , AST_REDIRECTING_PRIV_FROM_NAME_VALID ,
  AST_REDIRECTING_PRIV_FROM_NAME_CHAR_SET , AST_REDIRECTING_PRIV_FROM_NAME_PRESENTATION , AST_REDIRECTING_PRIV_FROM_SUBADDRESS , AST_REDIRECTING_PRIV_FROM_SUBADDRESS_TYPE ,
  AST_REDIRECTING_PRIV_FROM_SUBADDRESS_ODD_EVEN , AST_REDIRECTING_PRIV_FROM_SUBADDRESS_VALID , AST_REDIRECTING_PRIV_FROM_TAG , AST_REDIRECTING_PRIV_ORIG_NUMBER ,
  AST_REDIRECTING_PRIV_ORIG_NUMBER_VALID , AST_REDIRECTING_PRIV_ORIG_NUMBER_PLAN , AST_REDIRECTING_PRIV_ORIG_NUMBER_PRESENTATION , AST_REDIRECTING_PRIV_ORIG_NAME ,
  AST_REDIRECTING_PRIV_ORIG_NAME_VALID , AST_REDIRECTING_PRIV_ORIG_NAME_CHAR_SET , AST_REDIRECTING_PRIV_ORIG_NAME_PRESENTATION , AST_REDIRECTING_PRIV_ORIG_SUBADDRESS ,
  AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_TYPE , AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_ODD_EVEN , AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_VALID , AST_REDIRECTING_PRIV_ORIG_TAG ,
  AST_REDIRECTING_REASON_STR , AST_REDIRECTING_ORIG_REASON_STR
}
 Element identifiers for redirecting indication frame data. More...
 
enum  DtmfDirection { DTMF_RECEIVED , DTMF_SENT }
 

Functions

int __ast_answer (struct ast_channel *chan, unsigned int delay)
 Answer a channel, with a selectable delay before returning.
 
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 and linking the channel from the ao2_container. This should only be used when the channel has already been unlinked from the ao2_container.
 
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.
 
static struct ast_channel__ast_channel_alloc_ap (int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, enum ama_flags amaflag, struct ast_endpoint *endpoint, struct ast_channel_initializers *initializers, const char *file, int line, const char *function, const char *name_fmt, va_list ap)
 Create a new channel structure.
 
struct ast_channel__ast_channel_alloc_with_initializers (int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, enum ama_flags amaflag, struct ast_endpoint *endpoint, struct ast_channel_initializers *initializers, const char *file, int line, const char *function, const char *name_fmt,...)
 Create a channel structure.
 
struct ast_channel__ast_dummy_channel_alloc (const char *file, int line, const char *function)
 
static int __ast_queue_frame (struct ast_channel *chan, struct ast_frame *fin, int head, struct ast_frame *after)
 
static struct ast_frame__ast_read (struct ast_channel *chan, int dropaudio, int dropnondefault)
 
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 attempt to place a call on it.
 
static void adjust_frame_for_plc (struct ast_channel *chan, struct ast_frame *frame, struct ast_datastore *datastore)
 
static void apply_plc (struct ast_channel *chan, struct ast_frame *frame)
 
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
 
int ast_answer (struct ast_channel *chan)
 Answer a channel.
 
int ast_auto_answer (struct ast_channel *chan)
 Answer a channel, if it's not already answered.
 
int ast_call (struct ast_channel *chan, const char *addr, int timeout)
 Make a call.
 
struct ast_channelast_call_forward (struct ast_channel *caller, struct ast_channel *orig, int *timeout, struct ast_format_cap *cap, struct outgoing_helper *oh, int *outstate)
 Forwards a call to a new channel specified by the original channel's call_forward str. If possible, the new forwarded channel is created and returned while the original one is terminated.
 
const char * ast_cause2str (int cause)
 Gives the string form of a given hangup cause.
 
void ast_change_name (struct ast_channel *chan, const char *newname)
 Change channel name.
 
const char * ast_channel_amaflags2string (enum ama_flags flag)
 Convert the enum representation of an AMA flag to a string representation.
 
struct ast_channelast_channel_bridge_peer (struct ast_channel *chan)
 Get the channel's bridge peer only if the bridge is two-party.
 
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.
 
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.
 
void ast_channel_clear_flag (struct ast_channel *chan, unsigned int flag)
 Clear a flag on a channel.
 
void ast_channel_clear_softhangup (struct ast_channel *chan, int flag)
 Clear a set of softhangup flags from a channel.
 
void ast_channel_close_storage (void)
 
int ast_channel_cmpwhentohangup_tv (struct ast_channel *chan, struct timeval offset)
 Compare a offset with when to hangup channel.
 
int ast_channel_connected_line_sub (struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *connected_info, int is_frame)
 Run a connected line interception subroutine and update a channel's connected line information.
 
int ast_channel_datastore_add (struct ast_channel *chan, struct ast_datastore *datastore)
 Add a datastore to a channel.
 
struct ast_datastoreast_channel_datastore_find (struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
 Find a datastore on a channel.
 
int ast_channel_datastore_inherit (struct ast_channel *from, struct ast_channel *to)
 Inherit datastores from a parent to a child.
 
int ast_channel_datastore_remove (struct ast_channel *chan, struct ast_datastore *datastore)
 Remove a datastore from a channel.
 
int ast_channel_defer_dtmf (struct ast_channel *chan)
 Set defer DTMF flag on channel.
 
static void ast_channel_destructor (void *obj)
 Free a channel structure.
 
int ast_channel_early_bridge (struct ast_channel *c0, struct ast_channel *c1)
 Bridge two channels together (early)
 
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.
 
enum ast_channel_error ast_channel_errno (void)
 Get error code for latest channel operation.
 
int ast_channel_feature_hooks_append (struct ast_channel *chan, struct ast_bridge_features *features)
 Appends to the channel-attached features a channel has access to upon being bridged.
 
struct ast_bridge_featuresast_channel_feature_hooks_get (struct ast_channel *chan)
 Gets the channel-attached features a channel has access to upon being bridged.
 
int ast_channel_feature_hooks_replace (struct ast_channel *chan, struct ast_bridge_features *features)
 Sets the channel-attached features a channel has access to upon being bridged.
 
struct varsheadast_channel_get_ari_vars (struct ast_channel *chan)
 Gets the variables for a given channel, as specified by ast_channel_set_ari_vars().
 
struct ast_bridgeast_channel_get_bridge (const struct ast_channel *chan)
 Get the bridge associated with a channel.
 
struct ast_bridge_channelast_channel_get_bridge_channel (struct ast_channel *chan)
 Get a reference to the channel's bridge pointer.
 
struct ast_channelast_channel_get_by_exten (const char *exten, const char *context)
 Find a channel by extension and context.
 
struct ast_channelast_channel_get_by_name (const char *name)
 Find a channel by name or uniqueid.
 
struct ast_channelast_channel_get_by_name_prefix (const char *name, size_t name_len)
 Find a channel by a name prefix.
 
struct ast_channelast_channel_get_by_uniqueid (const char *uniqueid)
 Find a channel by a uniqueid.
 
int ast_channel_get_cc_agent_type (struct ast_channel *chan, char *agent_type, size_t size)
 Find the appropriate CC agent type to use given a channel.
 
struct ast_cc_config_paramsast_channel_get_cc_config_params (struct ast_channel *chan)
 Get the CCSS parameters from a channel.
 
const char * ast_channel_get_current_storage_driver_name (void)
 Get the name of the current channel storage driver.
 
int ast_channel_get_device_name (struct ast_channel *chan, char *device_name, size_t name_buffer_length)
 Get a device name given its channel structure.
 
int ast_channel_get_duration (struct ast_channel *chan)
 Obtain how long the channel since the channel was created.
 
int64_t ast_channel_get_duration_ms (struct ast_channel *chan)
 Obtain how long it's been, in milliseconds, since the channel was created.
 
int ast_channel_get_intercept_mode (void)
 Am I currently running an intercept dialplan routine.
 
struct varsheadast_channel_get_manager_vars (struct ast_channel *chan)
 Gets the variables for a given channel, as specified by ast_channel_set_manager_vars().
 
int ast_channel_get_up_time (struct ast_channel *chan)
 Obtain how long it has been since the channel was answered.
 
int64_t ast_channel_get_up_time_ms (struct ast_channel *chan)
 Obtain how long it has been since the channel was answered in ms.
 
struct varsheadast_channel_get_vars (struct ast_channel *chan)
 Gets the variables for a given channel, as set using pbx_builtin_setvar_helper().
 
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.
 
int ast_channel_has_ari_vars (void)
 Return whether or not any ARI variables have been set.
 
int ast_channel_has_audio_frame_or_monitor (struct ast_channel *chan)
 Check if the channel has active audiohooks, active framehooks, or a monitor.
 
int ast_channel_has_hook_requiring_audio (struct ast_channel *chan)
 Check if the channel has any active hooks that require audio.
 
int ast_channel_has_manager_vars (void)
 Return whether or not any manager variables have been set.
 
void ast_channel_inherit_variables (const struct ast_channel *parent, struct ast_channel *child)
 Inherits channel variable from parent to child channel.
 
int ast_channel_is_bridged (const struct ast_channel *chan)
 Determine if a channel is in a bridge.
 
int ast_channel_is_leaving_bridge (struct ast_channel *chan)
 Determine if a channel is leaving a bridge, but not hung up.
 
struct ast_channel_iteratorast_channel_iterator_all_new (void)
 Create a new channel iterator.
 
struct ast_channel_iteratorast_channel_iterator_by_exten_new (const char *exten, const char *context)
 Create a new channel iterator based on extension.
 
struct ast_channel_iteratorast_channel_iterator_by_name_new (const char *name, size_t name_len)
 Create a new channel iterator based on name.
 
struct ast_channel_iteratorast_channel_iterator_destroy (struct ast_channel_iterator *i)
 Destroy a channel iterator.
 
struct ast_channelast_channel_iterator_next (struct ast_channel_iterator *i)
 Get the next channel for a channel iterator.
 
int ast_channel_make_compatible (struct ast_channel *chan, struct ast_channel *peer)
 Make the frame formats of two channels compatible.
 
static int ast_channel_make_compatible_helper (struct ast_channel *from, struct ast_channel *to)
 Set up translation from one channel to another.
 
int ast_channel_move (struct ast_channel *dest, struct ast_channel *source)
 Move a channel from its current location to a new location.
 
void ast_channel_name_to_dial_string (char *channel_name)
 Removes the trailing identifiers from a channel name string.
 
int ast_channel_open_storage ()
 
int ast_channel_queryoption (struct ast_channel *chan, int option, void *data, int *datalen, int block)
 Checks the value of an option.
 
void ast_channel_queue_connected_line_update (struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
 Queue a connected line update frame on a channel.
 
void ast_channel_queue_redirecting_update (struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
 Queue a redirecting update frame on a channel.
 
const char * ast_channel_reason2str (int reason)
 return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument
 
int ast_channel_redirecting_sub (struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *redirecting_info, int is_frame)
 Run a redirecting interception subroutine and update a channel's redirecting information.
 
int ast_channel_register (const struct ast_channel_tech *tech)
 Register a new telephony channel in Asterisk.
 
struct ast_channelast_channel_release (struct ast_channel *chan)
 Unlink and release reference to a channel.
 
void ast_channel_req_accountcodes (struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship)
 Setup new channel accountcodes from the requestor channel after ast_request().
 
void ast_channel_req_accountcodes_precious (struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship)
 Setup new channel accountcodes from the requestor channel after ast_request().
 
int ast_channel_request_stream_topology_change (struct ast_channel *chan, struct ast_stream_topology *topology, void *change_source)
 Request that the stream topology of a channel change.
 
int ast_channel_sendhtml (struct ast_channel *chan, int subclass, const char *data, int datalen)
 Sends HTML on given channel Send HTML or URL on link.
 
int ast_channel_sendurl (struct ast_channel *chan, const char *url)
 Sends a URL on a given link Send URL on link.
 
void ast_channel_set_ari_vars (size_t varc, char **vars)
 Sets the variables to be stored in the ari_vars field of all snapshots.
 
void ast_channel_set_caller (struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update)
 Set the caller id information in the Asterisk channel.
 
void ast_channel_set_caller_event (struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update)
 Set the caller id information in the Asterisk channel and generate an AMI event if the caller id name or number changed.
 
void ast_channel_set_connected_line (struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
 Set the connected line information in the Asterisk channel.
 
void ast_channel_set_fd (struct ast_channel *chan, int which, int fd)
 
void ast_channel_set_flag (struct ast_channel *chan, unsigned int flag)
 Set a flag on a channel.
 
void ast_channel_set_manager_vars (size_t varc, char **vars)
 Sets the variables to be stored in the manager_vars field of all snapshots.
 
void ast_channel_set_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.
 
int ast_channel_setoption (struct ast_channel *chan, int option, void *data, int datalen, int block)
 Sets an option on a channel.
 
void ast_channel_setwhentohangup_tv (struct ast_channel *chan, struct timeval offset)
 Set when to hangup channel.
 
static int ast_channel_softhangup_cb (void *obj, void *arg, void *data, int flags)
 
void ast_channel_softhangup_withcause_locked (struct ast_channel *chan, int causecode)
 Lock the given channel, then request softhangup on the channel with the given causecode.
 
struct ast_silence_generatorast_channel_start_silence_generator (struct ast_channel *chan)
 Starts a silence generator on the given channel.
 
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.
 
int ast_channel_stream_topology_changed (struct ast_channel *chan, struct ast_stream_topology *topology)
 Provide notice to a channel that the stream topology has changed.
 
int ast_channel_stream_topology_changed_externally (struct ast_channel *chan)
 Provide notice from a channel that the topology has changed on it as a result of the remote party renegotiating.
 
enum ama_flags ast_channel_string2amaflag (const char *flag)
 Convert a string to a detail record AMA flag.
 
int ast_channel_supports_html (struct ast_channel *chan)
 Checks for HTML support on a channel.
 
int ast_channel_suppress (struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype)
 Suppress passing of a frame type on a channel.
 
void ast_channel_undefer_dtmf (struct ast_channel *chan)
 Unset defer DTMF flag on channel.
 
void ast_channel_unlink (struct ast_channel *chan)
 Remove a channel from the global channels container.
 
void ast_channel_unregister (const struct ast_channel_tech *tech)
 Unregister channel driver.
 
int ast_channel_unsuppress (struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype)
 Stop suppressing of a frame type on a channel.
 
void ast_channel_update_connected_line (struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
 Indicate that the connected line information has changed.
 
void ast_channel_update_redirecting (struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
 Indicate that the redirecting id has changed.
 
struct ast_channelast_channel_yank (struct ast_channel *yankee)
 Gain control of a channel in the system.
 
int ast_channels_init (void)
 
struct ast_variableast_channeltype_list (void)
 return an ast_variable list of channeltypes
 
int ast_check_hangup (struct ast_channel *chan)
 Checks to see if a channel is needing hang up.
 
int ast_check_hangup_locked (struct ast_channel *chan)
 
int ast_connected_line_build_data (unsigned char *data, size_t datalen, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
 Build the connected line information data frame.
 
void ast_connected_line_copy_from_caller (struct ast_party_connected_line *dest, const struct ast_party_caller *src)
 Copy the caller information to the connected line information.
 
void ast_connected_line_copy_to_caller (struct ast_party_caller *dest, const struct ast_party_connected_line *src)
 Copy the connected line information to the caller information.
 
int ast_connected_line_parse_data (const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected)
 Parse connected line indication frame data.
 
void ast_deactivate_generator (struct ast_channel *chan)
 
static void ast_dummy_channel_destructor (void *obj)
 Free a dummy channel structure.
 
const struct ast_channel_techast_get_channel_tech (const char *name)
 Get handle to channel driver based on name.
 
ast_group_t ast_get_group (const char *s)
 
struct ast_namedgroups * ast_get_namedgroups (const char *s)
 Create an ast_namedgroups set with group names from comma separated string.
 
void ast_hangup (struct ast_channel *chan)
 Hangup a channel.
 
int ast_indicate (struct ast_channel *chan, int condition)
 Indicates condition of channel.
 
int ast_indicate_data (struct ast_channel *chan, int _condition, const void *data, size_t datalen)
 Indicates condition of channel, with payload.
 
void ast_install_music_functions (int(*start_ptr)(struct ast_channel *, const char *, const char *), void(*stop_ptr)(struct ast_channel *), void(*cleanup_ptr)(struct ast_channel *))
 
int ast_is_deferrable_frame (const struct ast_frame *frame)
 Should we keep this frame for later?
 
void ast_moh_cleanup (struct ast_channel *chan)
 Clean up music on hold state on a given channel.
 
int ast_moh_start (struct ast_channel *chan, const char *mclass, const char *interpclass)
 Turn on music on hold on a given channel.
 
void ast_moh_stop (struct ast_channel *chan)
 Turn off music on hold on a given channel.
 
int ast_namedgroups_intersect (struct ast_namedgroups *a, struct ast_namedgroups *b)
 Return TRUE if group a and b contain at least one common groupname.
 
void ast_party_caller_copy (struct ast_party_caller *dest, const struct ast_party_caller *src)
 Copy the source caller information to the destination caller.
 
void ast_party_caller_free (struct ast_party_caller *doomed)
 Destroy the caller party contents.
 
void ast_party_caller_init (struct ast_party_caller *init)
 Initialize the given caller structure.
 
void ast_party_caller_set (struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update)
 Set the caller information based on another caller source.
 
void ast_party_caller_set_init (struct ast_party_caller *init, const struct ast_party_caller *guide)
 Initialize the given caller structure using the given guide for a set update operation.
 
void ast_party_connected_line_collect_caller (struct ast_party_connected_line *connected, struct ast_party_caller *caller)
 Collect the caller party information into a connected line structure.
 
void ast_party_connected_line_copy (struct ast_party_connected_line *dest, const struct ast_party_connected_line *src)
 Copy the source connected line information to the destination connected line.
 
void ast_party_connected_line_free (struct ast_party_connected_line *doomed)
 Destroy the connected line information contents.
 
void ast_party_connected_line_init (struct ast_party_connected_line *init)
 Initialize the given connected line structure.
 
void ast_party_connected_line_set (struct ast_party_connected_line *dest, const struct ast_party_connected_line *src, const struct ast_set_party_connected_line *update)
 Set the connected line information based on another connected line source.
 
void ast_party_connected_line_set_init (struct ast_party_connected_line *init, const struct ast_party_connected_line *guide)
 Initialize the given connected line structure using the given guide for a set update operation.
 
void ast_party_dialed_copy (struct ast_party_dialed *dest, const struct ast_party_dialed *src)
 Copy the source dialed party information to the destination dialed party.
 
void ast_party_dialed_free (struct ast_party_dialed *doomed)
 Destroy the dialed party contents.
 
void ast_party_dialed_init (struct ast_party_dialed *init)
 Initialize the given dialed structure.
 
void ast_party_dialed_set (struct ast_party_dialed *dest, const struct ast_party_dialed *src)
 Set the dialed information based on another dialed source.
 
void ast_party_dialed_set_init (struct ast_party_dialed *init, const struct ast_party_dialed *guide)
 Initialize the given dialed structure using the given guide for a set update operation.
 
void ast_party_id_copy (struct ast_party_id *dest, const struct ast_party_id *src)
 Copy the source party id information to the destination party id.
 
void ast_party_id_free (struct ast_party_id *doomed)
 Destroy the party id contents.
 
void ast_party_id_init (struct ast_party_id *init)
 Initialize the given party id structure.
 
void ast_party_id_invalidate (struct ast_party_id *id)
 Invalidate all components of the given party id.
 
struct ast_party_id ast_party_id_merge (struct ast_party_id *base, struct ast_party_id *overlay)
 Merge a given party id into another given party id.
 
void ast_party_id_merge_copy (struct ast_party_id *dest, struct ast_party_id *base, struct ast_party_id *overlay)
 Copy a merge of a given party id into another given party id to a given destination party id.
 
int ast_party_id_presentation (const struct ast_party_id *id)
 Determine the overall presentation value for the given party.
 
void ast_party_id_reset (struct ast_party_id *id)
 Destroy and initialize the given party id structure.
 
void ast_party_id_set (struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update)
 Set the source party id information into the destination party id.
 
void ast_party_id_set_init (struct ast_party_id *init, const struct ast_party_id *guide)
 Initialize the given party id structure using the given guide for a set update operation.
 
void ast_party_name_copy (struct ast_party_name *dest, const struct ast_party_name *src)
 Copy the source party name information to the destination party name.
 
void ast_party_name_free (struct ast_party_name *doomed)
 Destroy the party name contents.
 
void ast_party_name_init (struct ast_party_name *init)
 Initialize the given name structure.
 
void ast_party_name_set (struct ast_party_name *dest, const struct ast_party_name *src)
 Set the source party name information into the destination party name.
 
void ast_party_name_set_init (struct ast_party_name *init, const struct ast_party_name *guide)
 Initialize the given party name structure using the given guide for a set update operation.
 
void ast_party_number_copy (struct ast_party_number *dest, const struct ast_party_number *src)
 Copy the source party number information to the destination party number.
 
void ast_party_number_free (struct ast_party_number *doomed)
 Destroy the party number contents.
 
void ast_party_number_init (struct ast_party_number *init)
 Initialize the given number structure.
 
void ast_party_number_set (struct ast_party_number *dest, const struct ast_party_number *src)
 Set the source party number information into the destination party number.
 
void ast_party_number_set_init (struct ast_party_number *init, const struct ast_party_number *guide)
 Initialize the given party number structure using the given guide for a set update operation.
 
void ast_party_redirecting_copy (struct ast_party_redirecting *dest, const struct ast_party_redirecting *src)
 Copy the source redirecting information to the destination redirecting.
 
void ast_party_redirecting_free (struct ast_party_redirecting *doomed)
 Destroy the redirecting information contents.
 
void ast_party_redirecting_init (struct ast_party_redirecting *init)
 Initialize the given redirecting structure.
 
void ast_party_redirecting_reason_copy (struct ast_party_redirecting_reason *dest, const struct ast_party_redirecting_reason *src)
 Copy the source redirecting reason information to the destination redirecting reason.
 
void ast_party_redirecting_reason_free (struct ast_party_redirecting_reason *doomed)
 Destroy the redirecting reason contents.
 
void ast_party_redirecting_reason_init (struct ast_party_redirecting_reason *init)
 Initialize the given redirecting reason structure.
 
void ast_party_redirecting_reason_set (struct ast_party_redirecting_reason *dest, const struct ast_party_redirecting_reason *src)
 Set the redirecting reason information based on another redirecting reason source.
 
void ast_party_redirecting_reason_set_init (struct ast_party_redirecting_reason *init, const struct ast_party_redirecting_reason *guide)
 Initialize the given redirecting reason structure using the given guide for a set update operation.
 
void ast_party_redirecting_set (struct ast_party_redirecting *dest, const struct ast_party_redirecting *src, const struct ast_set_party_redirecting *update)
 Set the redirecting information based on another redirecting source.
 
void ast_party_redirecting_set_init (struct ast_party_redirecting *init, const struct ast_party_redirecting *guide)
 Initialize the given redirecting id structure using the given guide for a set update operation.
 
void ast_party_subaddress_copy (struct ast_party_subaddress *dest, const struct ast_party_subaddress *src)
 Copy the source party subaddress information to the destination party subaddress.
 
void ast_party_subaddress_free (struct ast_party_subaddress *doomed)
 Destroy the party subaddress contents.
 
void ast_party_subaddress_init (struct ast_party_subaddress *init)
 Initialize the given subaddress structure.
 
void ast_party_subaddress_set (struct ast_party_subaddress *dest, const struct ast_party_subaddress *src)
 Set the source party subaddress information into the destination party subaddress.
 
void ast_party_subaddress_set_init (struct ast_party_subaddress *init, const struct ast_party_subaddress *guide)
 Initialize the given party subaddress structure using the given guide for a set update operation.
 
int ast_pre_call (struct ast_channel *chan, const char *sub_args)
 Execute a Gosub call on the channel before a call is placed.
 
char * ast_print_group (char *buf, int buflen, ast_group_t group)
 Print call group and pickup group —.
 
char * ast_print_namedgroups (struct ast_str **buf, struct ast_namedgroups *group)
 Print named call groups and named pickup groups.
 
int ast_prod (struct ast_channel *chan)
 Send empty audio to prime a channel driver.
 
int ast_queue_answer (struct ast_channel *chan, const struct ast_stream_topology *topology)
 Queue an ANSWER control frame with topology.
 
int ast_queue_control (struct ast_channel *chan, enum ast_control_frame_type control)
 Queue a control frame.
 
int ast_queue_control_data (struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen)
 Queue a control frame with payload.
 
int ast_queue_frame (struct ast_channel *chan, struct ast_frame *fin)
 Queue one or more frames to a channel's frame queue.
 
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.
 
int ast_queue_hangup (struct ast_channel *chan)
 Queue a hangup frame for channel.
 
int ast_queue_hangup_with_cause (struct ast_channel *chan, int cause)
 Queue a hangup frame for channel.
 
int ast_queue_hold (struct ast_channel *chan, const char *musicclass)
 Queue a hold frame.
 
int ast_queue_unhold (struct ast_channel *chan)
 Queue an unhold frame.
 
int ast_raw_answer (struct ast_channel *chan)
 Answer a channel.
 
int ast_raw_answer_with_stream_topology (struct ast_channel *chan, struct ast_stream_topology *topology)
 Answer a channel passing in a stream topology.
 
struct ast_frameast_read (struct ast_channel *chan)
 Reads a frame.
 
static void ast_read_generator_actions (struct ast_channel *chan, struct ast_frame *f)
 
struct ast_frameast_read_noaudio (struct ast_channel *chan)
 Reads a frame, returning AST_FRAME_NULL frame if audio.
 
struct ast_frameast_read_stream (struct ast_channel *chan)
 Reads a frame, but does not filter to just the default streams.
 
struct ast_frameast_read_stream_noaudio (struct ast_channel *chan)
 Reads a frame, but does not filter to just the default streams, returning AST_FRAME_NULL frame if audio.
 
int ast_readstring (struct ast_channel *c, char *s, int len, int timeout, int ftimeout, char *enders)
 Reads multiple digits.
 
int ast_readstring_full (struct ast_channel *c, char *s, int len, int timeout, int ftimeout, char *enders, int audiofd, int ctrlfd)
 
int ast_recvchar (struct ast_channel *chan, int timeout)
 Receives a text character from a channel.
 
char * ast_recvtext (struct ast_channel *chan, int timeout)
 Receives a text string from a channel Read a string of text from a channel.
 
int ast_redirecting_build_data (unsigned char *data, size_t datalen, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
 Build the redirecting id data frame.
 
int ast_redirecting_parse_data (const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting)
 Parse redirecting indication frame data.
 
struct ast_namedgroups * ast_ref_namedgroups (struct ast_namedgroups *groups)
 
struct ast_channelast_request (const char *type, struct ast_format_cap *request_cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
 Requests a channel.
 
struct ast_channelast_request_and_dial (const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int timeout, int *outstate, const char *cidnum, const char *cidname)
 Request a channel of a given type, with data as optional information used by the low level module and attempt to place a call on it.
 
struct ast_channelast_request_with_stream_topology (const char *type, struct ast_stream_topology *topology, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
 Requests a channel (specifying stream topology)
 
int ast_safe_sleep (struct ast_channel *chan, int ms)
 Wait, look for hangups.
 
int ast_safe_sleep_conditional (struct ast_channel *chan, int timeout_ms, int(*cond)(void *), void *data)
 Wait for a specified amount of time, looking for hangups and a condition argument.
 
int ast_safe_sleep_without_silence (struct ast_channel *chan, int ms)
 Wait for a specified amount of time, looking for hangups, and do not generate silence.
 
int ast_say_character_str (struct ast_channel *chan, const char *str, const char *ints, const char *lang, enum ast_say_case_sensitivity sensitivity)
 function to pronounce character and phonetic strings
 
int ast_say_digit_str (struct ast_channel *chan, const char *str, const char *ints, const char *lang)
 says digits of a string
 
int ast_say_digits (struct ast_channel *chan, int num, const char *ints, const char *lang)
 says digits
 
int ast_say_digits_full (struct ast_channel *chan, int num, const char *ints, const char *lang, int audiofd, int ctrlfd)
 Same as ast_say_digits() with audiofd for received audio and returns 1 on ctrlfd being readable.
 
int ast_say_enumeration (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options)
 says an enumeration
 
int ast_say_money_str (struct ast_channel *chan, const char *str, const char *ints, const char *lang)
 function to pronounce monetary amounts
 
int ast_say_number (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options)
 says a number
 
int ast_say_ordinal (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options)
 says an ordinal number
 
int ast_say_phonetic_str (struct ast_channel *chan, const char *str, const char *ints, const char *lang)
 
int ast_senddigit (struct ast_channel *chan, char digit, unsigned int duration)
 Send a DTMF digit to a channel.
 
int ast_senddigit_begin (struct ast_channel *chan, char digit)
 Send a DTMF digit to a channel.
 
int ast_senddigit_end (struct ast_channel *chan, char digit, unsigned int duration)
 Send a DTMF digit to a channel.
 
int ast_senddigit_external (struct ast_channel *chan, char digit, unsigned int duration)
 Send a DTMF digit to a channel from an external thread.
 
int ast_senddigit_mf (struct ast_channel *chan, char digit, unsigned int duration, unsigned int durationkp, unsigned int durationst, int is_external)
 Send an MF digit to a channel.
 
int ast_senddigit_mf_begin (struct ast_channel *chan, char digit)
 Send an MF digit to a channel.
 
int ast_senddigit_mf_end (struct ast_channel *chan)
 End sending an MF digit to a channel.
 
int ast_sendtext (struct ast_channel *chan, const char *text)
 Sends text to a channel.
 
int ast_sendtext_data (struct ast_channel *chan, struct ast_msg_data *msg)
 Sends text to a channel in an ast_msg_data structure wrapper with ast_sendtext as fallback.
 
void ast_set_callerid (struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani)
 Set caller ID number, name and ANI and generate AMI event.
 
void ast_set_hangupsource (struct ast_channel *chan, const char *source, int force)
 Set the source of the hangup in this channel and it's bridge.
 
void ast_set_party_id_all (struct ast_set_party_id *update_id)
 Set the update marker to update all information of a corresponding party id.
 
int ast_set_read_format (struct ast_channel *chan, struct ast_format *format)
 Sets read format on channel chan.
 
int ast_set_read_format_from_cap (struct ast_channel *chan, struct ast_format_cap *cap)
 Sets read format on channel chan from capabilities Set read format for channel to whichever component of "format" is best.
 
int ast_set_read_format_path (struct ast_channel *chan, struct ast_format *raw_format, struct ast_format *core_format)
 Set specific read path on channel.
 
void ast_set_variables (struct ast_channel *chan, struct ast_variable *vars)
 adds a list of channel variables to a channel
 
int ast_set_write_format (struct ast_channel *chan, struct ast_format *format)
 Sets write format on channel chan.
 
int ast_set_write_format_from_cap (struct ast_channel *chan, struct ast_format_cap *cap)
 Sets write format on channel chan Set write format for channel to whichever component of "format" is best.
 
int ast_set_write_format_interleaved_stereo (struct ast_channel *chan, struct ast_format *format)
 Sets write format for a channel. All internal data will than be handled in an interleaved format. (needed by binaural opus)
 
int ast_set_write_format_path (struct ast_channel *chan, struct ast_format *core_format, struct ast_format *raw_format)
 Set specific write path on channel.
 
int ast_setstate (struct ast_channel *chan, enum ast_channel_state state)
 Change the state of a channel.
 
int ast_settimeout (struct ast_channel *c, unsigned int rate, int(*func)(const void *data), void *data)
 Enable or disable timer ticks for a channel.
 
int ast_settimeout_full (struct ast_channel *c, unsigned int rate, int(*func)(const void *data), void *data, unsigned int is_ao2_obj)
 
int ast_softhangup (struct ast_channel *chan, int cause)
 Softly hangup a channel, lock.
 
void ast_softhangup_all (void)
 Soft hangup all active channels.
 
int ast_softhangup_nolock (struct ast_channel *chan, int cause)
 Softly hangup a channel, don't lock.
 
const char * ast_state2str (enum ast_channel_state state)
 Gives the string form of a given channel state.
 
int ast_str2cause (const char *name)
 Convert a symbolic hangup cause to number.
 
 AST_THREADSTORAGE_CUSTOM_SCOPE (state2str_threadbuf, NULL, ast_free_ptr, static)
 
 AST_THREADSTORAGE_RAW (in_intercept_routine)
 
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 call to dest, if the channel supports transfer.
 
int ast_transfer_protocol (struct ast_channel *chan, char *dest, int *protocol)
 Transfer a call to dest, if the channel supports transfer.
 
char * ast_transfercapability2str (int transfercapability)
 Gives the string form of a given transfer capability.
 
int ast_undestroyed_channels (void)
 
void ast_uninstall_music_functions (void)
 
struct ast_namedgroups * ast_unref_namedgroups (struct ast_namedgroups *groups)
 
int ast_waitfor (struct ast_channel *c, int ms)
 Wait for input on a channel.
 
struct ast_channelast_waitfor_n (struct ast_channel **c, int n, int *ms)
 Waits for input on a group of channels Wait for input on an array of channels for a given # of milliseconds.
 
int ast_waitfor_n_fd (int *fds, int n, int *ms, int *exception)
 Wait for x amount of time on a file descriptor to have input.

 
struct ast_channelast_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.

 
int ast_waitfordigit (struct ast_channel *c, int ms)
 Waits for a digit.
 
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 monitor for reading.
 
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.
 
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.
 
int ast_write_video (struct ast_channel *chan, struct ast_frame *fr)
 Write video frame to a channel This function writes the given frame to the indicated channel.
 
static int calc_monitor_jump (int samples, int sample_rate, int seek_rate)
 calculates the number of samples to jump forward with in a monitor stream.
 
static void call_forward_inherit (struct ast_channel *new_chan, struct ast_channel *parent, struct ast_channel *orig)
 
static void * channel_cc_params_copy (void *data)
 
static void channel_cc_params_destroy (void *data)
 
static void channel_do_masquerade (struct ast_channel *original, struct ast_channel *clonechan)
 Masquerade a channel.
 
static int channel_feature_hooks_set_full (struct ast_channel *chan, struct ast_bridge_features *features, int replace)
 
static struct varsheadchannel_get_external_vars (struct external_vars *channelvars, struct ast_channel *chan)
 
static int channel_has_external_vars (struct external_vars *channelvars)
 
static void channel_req_accountcodes (struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship, int precious)
 
static void channel_set_external_vars (struct external_vars *channelvars, size_t varc, char **vars)
 
static void channel_set_intercept_mode (int in_intercept_mode)
 
static void channels_shutdown (void)
 
static void clone_variables (struct ast_channel *original, struct ast_channel *clonechan)
 Clone channel variables from 'clone' channel into 'original' channel.
 
static char * complete_channeltypes (struct ast_cli_args *a)
 
static void deactivate_generator_nolock (struct ast_channel *chan)
 
static int deactivate_silence_generator (struct ast_channel *chan)
 
static void destroy_hooks (struct ast_channel *chan)
 
static int do_ids_conflict (const struct ast_assigned_ids *assignedids, int rdlock)
 
static const char * dtmf_direction_to_string (enum DtmfDirection direction)
 
static void features_destroy (void *obj)
 
static void free_external_channelvars (struct external_vars *channelvars)
 
static void free_translation (struct ast_channel *clonechan)
 
static int generator_force (const void *data)
 
static void generator_write_format_change (struct ast_channel *chan)
 
static void handle_cause (int cause, int *outstate)
 
static char * handle_cli_core_show_channeltype (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 Show details about a channel driver - CLI command.
 
static char * handle_cli_core_show_channeltypes (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 Show channel types - CLI command.
 
static int indicate_connected_line (struct ast_channel *chan, const void *data, size_t datalen)
 
static int indicate_data_internal (struct ast_channel *chan, int _condition, const void *data, size_t datalen)
 
static int indicate_redirecting (struct ast_channel *chan, const void *data, size_t datalen)
 
int internal_channel_set_current_storage_driver (const char *driver_name)
 
static int attribute_const is_visible_indication (enum ast_control_frame_type condition)
 
static struct ast_framekill_exception (struct ast_channel *chan)
 
static int kill_fixup (struct ast_channel *oldchan, struct ast_channel *newchan)
 
static int kill_hangup (struct ast_channel *chan)
 
static struct ast_framekill_read (struct ast_channel *chan)
 
static int kill_write (struct ast_channel *chan, struct ast_frame *frame)
 
static void moh_cleanup (struct ast_channel *chan)
 
static int namedgroup_cmp_cb (void *obj, void *arg, int flags)
 Comparison function used for named group container.
 
static int namedgroup_hash_cb (const void *obj, const int flags)
 Hashing function used for named group container.
 
static int namedgroup_match (void *obj, void *arg, int flags)
 
static int party_id_build_data (unsigned char *data, size_t datalen, const struct ast_party_id *id, const char *label, const struct ast_party_id_ies *ies, const struct ast_set_party_id *update)
 
static int party_name_build_data (unsigned char *data, size_t datalen, const struct ast_party_name *name, const char *label, const struct ast_party_name_ies *ies)
 
static int party_number_build_data (unsigned char *data, size_t datalen, const struct ast_party_number *number, const char *label, const struct ast_party_number_ies *ies)
 
static int party_subaddress_build_data (unsigned char *data, size_t datalen, const struct ast_party_subaddress *subaddress, const char *label, const struct ast_party_subaddress_ies *ies)
 
static void plc_ds_destroy (void *data)
 
static void queue_dtmf_readq (struct ast_channel *chan, struct ast_frame *f)
 
static int redirecting_reason_build_data (unsigned char *data, size_t datalen, const struct ast_party_redirecting_reason *reason, const char *label, const struct ast_party_redirecting_reason_ies *ies)
 
static struct ast_channelrequest_channel (const char *type, struct ast_format_cap *request_cap, struct ast_stream_topology *topology, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
 
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.
 
static void send_dtmf_begin_event (struct ast_channel *chan, enum DtmfDirection direction, const char digit)
 
static void send_dtmf_end_event (struct ast_channel *chan, enum DtmfDirection direction, const char digit, long duration_ms)
 
static void send_flash_event (struct ast_channel *chan)
 
static void send_wink_event (struct ast_channel *chan)
 
static void set_channel_answer_time (struct ast_channel *chan)
 
static int set_format (struct ast_channel *chan, struct ast_format_cap *cap_set, const int direction, int interleaved_stereo)
 
static int set_security_requirements (const struct ast_channel *requestor, struct ast_channel *out)
 
static int should_skip_dtmf (struct ast_channel *chan)
 Determine whether or not we should ignore DTMF in the readq.
 
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 no voice frames are received during dtmf processing (direct media or muted sender case using SIP INFO)
 
static void * silence_generator_alloc (struct ast_channel *chan, void *data)
 
static int silence_generator_generate (struct ast_channel *chan, void *data, int len, int samples)
 
static void silence_generator_release (struct ast_channel *chan, void *data)
 
static void suppress_datastore_destroy_cb (void *data)
 
static void suppress_framehook_destroy_cb (void *data)
 
static struct ast_framesuppress_framehook_event_cb (struct ast_channel *chan, struct ast_frame *frame, enum ast_framehook_event event, void *data)
 
static void suppress_framehook_fixup_cb (void *data, int framehook_id, struct ast_channel *old_chan, struct ast_channel *new_chan)
 
static const struct ast_datastore_infosuppress_get_datastore_information (enum ast_frame_type frametype)
 
static int tech_write (struct ast_channel *chan, struct ast_stream *stream, struct ast_stream *default_stream, struct ast_frame *frame)
 
static void * tonepair_alloc (struct ast_channel *chan, void *params)
 
static int tonepair_generator (struct ast_channel *chan, void *data, int len, int samples)
 
static void tonepair_release (struct ast_channel *chan, void *params)
 
static void varshead_dtor (void *obj)
 Destructor for lists of variables.
 

Variables

static struct external_vars ami_vars
 
static struct external_vars ari_vars
 
const struct ast_channel_tech ast_kill_tech
 Kill the channel channel driver technology descriptor.
 
static void(* ast_moh_cleanup_ptr )(struct ast_channel *) = NULL
 
static int(* ast_moh_start_ptr )(struct ast_channel *, const char *, const char *) = NULL
 
static void(* ast_moh_stop_ptr )(struct ast_channel *) = NULL
 
static struct backends backends = AST_RWLIST_HEAD_INIT_VALUE
 
static const struct ast_datastore_info bridge_features_info
 
static const struct causes_map causes []
 
static const struct ast_datastore_info cc_channel_datastore_info
 
static int chancount
 
static ast_mutex_t channel_move_lock = AST_MUTEX_INIT_VALUE
 
static struct ast_cli_entry cli_channel []
 
unsigned long global_fin
 
unsigned long global_fout
 
static const struct ast_channel_tech null_tech
 
static const struct ast_datastore_info plc_ds_info
 
static const struct set_format_access set_format_access_read
 
static const struct set_format_access set_format_access_write
 
static struct ast_generator silence_generator
 
static const struct ast_datastore_info suppress_datastore_voice
 
static const struct ast_channel_tech surrogate_tech
 Channel technology used to extract a channel from a running application. The channel created with this technology will be immediately hung up - most external applications won't ever want to see this.
 
static struct ast_generator tonepair
 

Detailed Description

Channel Management.

Author
Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m

Definition in file channel.c.

Macro Definition Documentation

◆ AST_DEFAULT_EMULATE_DTMF_DURATION

#define AST_DEFAULT_EMULATE_DTMF_DURATION   100

Default amount of time to use when emulating a DTMF digit as a begin and end 100ms

Definition at line 106 of file channel.c.

◆ AST_MIN_DTMF_GAP

#define AST_MIN_DTMF_GAP   45

Minimum amount of time between the end of the last digit and the beginning of a new one - 45ms

Definition at line 116 of file channel.c.

◆ DEFAULT_AMA_FLAGS

#define DEFAULT_AMA_FLAGS   AST_AMA_DOCUMENTATION

Definition at line 112 of file channel.c.

◆ DEFAULT_EMULATE_MF_DURATION

#define DEFAULT_EMULATE_MF_DURATION   55

Default amount of time to use when emulating an MF digit as a begin and end 55ms

Definition at line 110 of file channel.c.

◆ FORMAT

#define FORMAT   "%-15.15s %-40.40s %-13.13s %-13.13s %-13.13s %-13.13s\n"

◆ STATE2STR_BUFSIZE

#define STATE2STR_BUFSIZE   32

Definition at line 102 of file channel.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Element identifiers for connected line indication frame data.

Note
Only add to the end of this enum.
Enumerator
AST_CONNECTED_LINE_NUMBER 
AST_CONNECTED_LINE_NAME 
AST_CONNECTED_LINE_NUMBER_PLAN 
AST_CONNECTED_LINE_ID_PRESENTATION 
AST_CONNECTED_LINE_SOURCE 
AST_CONNECTED_LINE_SUBADDRESS 
AST_CONNECTED_LINE_SUBADDRESS_TYPE 
AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN 
AST_CONNECTED_LINE_SUBADDRESS_VALID 
AST_CONNECTED_LINE_TAG 
AST_CONNECTED_LINE_VERSION 
AST_CONNECTED_LINE_NAME_VALID 
AST_CONNECTED_LINE_NAME_CHAR_SET 
AST_CONNECTED_LINE_NAME_PRESENTATION 
AST_CONNECTED_LINE_NUMBER_VALID 
AST_CONNECTED_LINE_NUMBER_PRESENTATION 
AST_CONNECTED_LINE_PRIV_NUMBER 
AST_CONNECTED_LINE_PRIV_NUMBER_PLAN 
AST_CONNECTED_LINE_PRIV_NUMBER_VALID 
AST_CONNECTED_LINE_PRIV_NUMBER_PRESENTATION 
AST_CONNECTED_LINE_PRIV_NAME 
AST_CONNECTED_LINE_PRIV_NAME_VALID 
AST_CONNECTED_LINE_PRIV_NAME_CHAR_SET 
AST_CONNECTED_LINE_PRIV_NAME_PRESENTATION 
AST_CONNECTED_LINE_PRIV_SUBADDRESS 
AST_CONNECTED_LINE_PRIV_SUBADDRESS_TYPE 
AST_CONNECTED_LINE_PRIV_SUBADDRESS_ODD_EVEN 
AST_CONNECTED_LINE_PRIV_SUBADDRESS_VALID 
AST_CONNECTED_LINE_PRIV_TAG 

Definition at line 8729 of file channel.c.

8729 {
8733 AST_CONNECTED_LINE_ID_PRESENTATION,/* Combined number and name presentation. */
8741 /*
8742 * No more party id combined number and name presentation values
8743 * need to be created.
8744 */
8763};
@ AST_CONNECTED_LINE_NUMBER_VALID
Definition channel.c:8748
@ AST_CONNECTED_LINE_SOURCE
Definition channel.c:8734
@ AST_CONNECTED_LINE_PRIV_SUBADDRESS_VALID
Definition channel.c:8761
@ AST_CONNECTED_LINE_PRIV_SUBADDRESS_ODD_EVEN
Definition channel.c:8760
@ AST_CONNECTED_LINE_PRIV_NAME_VALID
Definition channel.c:8755
@ AST_CONNECTED_LINE_PRIV_SUBADDRESS_TYPE
Definition channel.c:8759
@ AST_CONNECTED_LINE_PRIV_NUMBER_PRESENTATION
Definition channel.c:8753
@ AST_CONNECTED_LINE_NAME_CHAR_SET
Definition channel.c:8746
@ AST_CONNECTED_LINE_SUBADDRESS_VALID
Definition channel.c:8738
@ AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN
Definition channel.c:8737
@ AST_CONNECTED_LINE_SUBADDRESS
Definition channel.c:8735
@ AST_CONNECTED_LINE_PRIV_NUMBER_PLAN
Definition channel.c:8751
@ AST_CONNECTED_LINE_NUMBER
Definition channel.c:8730
@ AST_CONNECTED_LINE_ID_PRESENTATION
Definition channel.c:8733
@ AST_CONNECTED_LINE_PRIV_NAME_PRESENTATION
Definition channel.c:8757
@ AST_CONNECTED_LINE_PRIV_NAME
Definition channel.c:8754
@ AST_CONNECTED_LINE_TAG
Definition channel.c:8739
@ AST_CONNECTED_LINE_PRIV_NUMBER_VALID
Definition channel.c:8752
@ AST_CONNECTED_LINE_NUMBER_PRESENTATION
Definition channel.c:8749
@ AST_CONNECTED_LINE_PRIV_NAME_CHAR_SET
Definition channel.c:8756
@ AST_CONNECTED_LINE_NAME
Definition channel.c:8731
@ AST_CONNECTED_LINE_NAME_PRESENTATION
Definition channel.c:8747
@ AST_CONNECTED_LINE_SUBADDRESS_TYPE
Definition channel.c:8736
@ AST_CONNECTED_LINE_PRIV_SUBADDRESS
Definition channel.c:8758
@ AST_CONNECTED_LINE_PRIV_TAG
Definition channel.c:8762
@ AST_CONNECTED_LINE_NAME_VALID
Definition channel.c:8745
@ AST_CONNECTED_LINE_PRIV_NUMBER
Definition channel.c:8750
@ AST_CONNECTED_LINE_NUMBER_PLAN
Definition channel.c:8732
@ AST_CONNECTED_LINE_VERSION
Definition channel.c:8740

◆ anonymous enum

anonymous enum

Element identifiers for redirecting indication frame data.

Note
Only add to the end of this enum.
Enumerator
AST_REDIRECTING_FROM_NUMBER 
AST_REDIRECTING_FROM_NAME 
AST_REDIRECTING_FROM_NUMBER_PLAN 
AST_REDIRECTING_FROM_ID_PRESENTATION 
AST_REDIRECTING_TO_NUMBER 
AST_REDIRECTING_TO_NAME 
AST_REDIRECTING_TO_NUMBER_PLAN 
AST_REDIRECTING_TO_ID_PRESENTATION 
AST_REDIRECTING_REASON_CODE 
AST_REDIRECTING_COUNT 
AST_REDIRECTING_FROM_SUBADDRESS 
AST_REDIRECTING_FROM_SUBADDRESS_TYPE 
AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN 
AST_REDIRECTING_FROM_SUBADDRESS_VALID 
AST_REDIRECTING_TO_SUBADDRESS 
AST_REDIRECTING_TO_SUBADDRESS_TYPE 
AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN 
AST_REDIRECTING_TO_SUBADDRESS_VALID 
AST_REDIRECTING_FROM_TAG 
AST_REDIRECTING_TO_TAG 
AST_REDIRECTING_VERSION 
AST_REDIRECTING_FROM_NAME_VALID 
AST_REDIRECTING_FROM_NAME_CHAR_SET 
AST_REDIRECTING_FROM_NAME_PRESENTATION 
AST_REDIRECTING_FROM_NUMBER_VALID 
AST_REDIRECTING_FROM_NUMBER_PRESENTATION 
AST_REDIRECTING_TO_NAME_VALID 
AST_REDIRECTING_TO_NAME_CHAR_SET 
AST_REDIRECTING_TO_NAME_PRESENTATION 
AST_REDIRECTING_TO_NUMBER_VALID 
AST_REDIRECTING_TO_NUMBER_PRESENTATION 
AST_REDIRECTING_ORIG_NUMBER 
AST_REDIRECTING_ORIG_NUMBER_VALID 
AST_REDIRECTING_ORIG_NUMBER_PLAN 
AST_REDIRECTING_ORIG_NUMBER_PRESENTATION 
AST_REDIRECTING_ORIG_NAME 
AST_REDIRECTING_ORIG_NAME_VALID 
AST_REDIRECTING_ORIG_NAME_CHAR_SET 
AST_REDIRECTING_ORIG_NAME_PRESENTATION 
AST_REDIRECTING_ORIG_SUBADDRESS 
AST_REDIRECTING_ORIG_SUBADDRESS_TYPE 
AST_REDIRECTING_ORIG_SUBADDRESS_ODD_EVEN 
AST_REDIRECTING_ORIG_SUBADDRESS_VALID 
AST_REDIRECTING_ORIG_TAG 
AST_REDIRECTING_ORIG_REASON_CODE 
AST_REDIRECTING_PRIV_TO_NUMBER 
AST_REDIRECTING_PRIV_TO_NUMBER_PLAN 
AST_REDIRECTING_PRIV_TO_NUMBER_VALID 
AST_REDIRECTING_PRIV_TO_NUMBER_PRESENTATION 
AST_REDIRECTING_PRIV_TO_NAME 
AST_REDIRECTING_PRIV_TO_NAME_VALID 
AST_REDIRECTING_PRIV_TO_NAME_CHAR_SET 
AST_REDIRECTING_PRIV_TO_NAME_PRESENTATION 
AST_REDIRECTING_PRIV_TO_SUBADDRESS 
AST_REDIRECTING_PRIV_TO_SUBADDRESS_TYPE 
AST_REDIRECTING_PRIV_TO_SUBADDRESS_ODD_EVEN 
AST_REDIRECTING_PRIV_TO_SUBADDRESS_VALID 
AST_REDIRECTING_PRIV_TO_TAG 
AST_REDIRECTING_PRIV_FROM_NUMBER 
AST_REDIRECTING_PRIV_FROM_NUMBER_PLAN 
AST_REDIRECTING_PRIV_FROM_NUMBER_VALID 
AST_REDIRECTING_PRIV_FROM_NUMBER_PRESENTATION 
AST_REDIRECTING_PRIV_FROM_NAME 
AST_REDIRECTING_PRIV_FROM_NAME_VALID 
AST_REDIRECTING_PRIV_FROM_NAME_CHAR_SET 
AST_REDIRECTING_PRIV_FROM_NAME_PRESENTATION 
AST_REDIRECTING_PRIV_FROM_SUBADDRESS 
AST_REDIRECTING_PRIV_FROM_SUBADDRESS_TYPE 
AST_REDIRECTING_PRIV_FROM_SUBADDRESS_ODD_EVEN 
AST_REDIRECTING_PRIV_FROM_SUBADDRESS_VALID 
AST_REDIRECTING_PRIV_FROM_TAG 
AST_REDIRECTING_PRIV_ORIG_NUMBER 
AST_REDIRECTING_PRIV_ORIG_NUMBER_VALID 
AST_REDIRECTING_PRIV_ORIG_NUMBER_PLAN 
AST_REDIRECTING_PRIV_ORIG_NUMBER_PRESENTATION 
AST_REDIRECTING_PRIV_ORIG_NAME 
AST_REDIRECTING_PRIV_ORIG_NAME_VALID 
AST_REDIRECTING_PRIV_ORIG_NAME_CHAR_SET 
AST_REDIRECTING_PRIV_ORIG_NAME_PRESENTATION 
AST_REDIRECTING_PRIV_ORIG_SUBADDRESS 
AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_TYPE 
AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_ODD_EVEN 
AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_VALID 
AST_REDIRECTING_PRIV_ORIG_TAG 
AST_REDIRECTING_REASON_STR 
AST_REDIRECTING_ORIG_REASON_STR 

Definition at line 9205 of file channel.c.

9205 {
9209 AST_REDIRECTING_FROM_ID_PRESENTATION,/* Combined number and name presentation. */
9213 AST_REDIRECTING_TO_ID_PRESENTATION,/* Combined number and name presentation. */
9227 /*
9228 * No more party id combined number and name presentation values
9229 * need to be created.
9230 */
9296};
@ AST_REDIRECTING_FROM_NAME_PRESENTATION
Definition channel.c:9233
@ AST_REDIRECTING_TO_NAME
Definition channel.c:9211
@ AST_REDIRECTING_VERSION
Definition channel.c:9226
@ AST_REDIRECTING_PRIV_FROM_NAME_VALID
Definition channel.c:9273
@ AST_REDIRECTING_PRIV_FROM_SUBADDRESS_ODD_EVEN
Definition channel.c:9278
@ AST_REDIRECTING_TO_TAG
Definition channel.c:9225
@ AST_REDIRECTING_FROM_NUMBER_PLAN
Definition channel.c:9208
@ AST_REDIRECTING_PRIV_TO_NAME_VALID
Definition channel.c:9260
@ AST_REDIRECTING_ORIG_TAG
Definition channel.c:9253
@ AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_ODD_EVEN
Definition channel.c:9291
@ AST_REDIRECTING_REASON_CODE
Definition channel.c:9214
@ AST_REDIRECTING_PRIV_TO_NUMBER_VALID
Definition channel.c:9257
@ AST_REDIRECTING_PRIV_TO_NUMBER_PRESENTATION
Definition channel.c:9258
@ AST_REDIRECTING_ORIG_REASON_CODE
Definition channel.c:9254
@ AST_REDIRECTING_TO_NAME_PRESENTATION
Definition channel.c:9238
@ AST_REDIRECTING_PRIV_TO_NAME
Definition channel.c:9259
@ AST_REDIRECTING_PRIV_ORIG_NAME_VALID
Definition channel.c:9286
@ AST_REDIRECTING_ORIG_NUMBER_VALID
Definition channel.c:9242
@ AST_REDIRECTING_FROM_NUMBER_PRESENTATION
Definition channel.c:9235
@ AST_REDIRECTING_ORIG_SUBADDRESS_VALID
Definition channel.c:9252
@ AST_REDIRECTING_FROM_NUMBER_VALID
Definition channel.c:9234
@ AST_REDIRECTING_TO_NAME_VALID
Definition channel.c:9236
@ AST_REDIRECTING_PRIV_FROM_NAME
Definition channel.c:9272
@ AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN
Definition channel.c:9222
@ AST_REDIRECTING_ORIG_SUBADDRESS_ODD_EVEN
Definition channel.c:9251
@ AST_REDIRECTING_PRIV_FROM_SUBADDRESS_TYPE
Definition channel.c:9277
@ AST_REDIRECTING_PRIV_TO_SUBADDRESS_VALID
Definition channel.c:9266
@ AST_REDIRECTING_PRIV_TO_SUBADDRESS_ODD_EVEN
Definition channel.c:9265
@ AST_REDIRECTING_ORIG_NAME_CHAR_SET
Definition channel.c:9247
@ AST_REDIRECTING_PRIV_FROM_SUBADDRESS
Definition channel.c:9276
@ AST_REDIRECTING_TO_NUMBER_PLAN
Definition channel.c:9212
@ AST_REDIRECTING_PRIV_TO_NUMBER
Definition channel.c:9255
@ AST_REDIRECTING_PRIV_FROM_NUMBER_VALID
Definition channel.c:9270
@ AST_REDIRECTING_ORIG_NAME
Definition channel.c:9245
@ AST_REDIRECTING_ORIG_SUBADDRESS
Definition channel.c:9249
@ AST_REDIRECTING_FROM_TAG
Definition channel.c:9224
@ AST_REDIRECTING_PRIV_ORIG_NUMBER_PLAN
Definition channel.c:9283
@ AST_REDIRECTING_TO_NUMBER
Definition channel.c:9210
@ AST_REDIRECTING_ORIG_SUBADDRESS_TYPE
Definition channel.c:9250
@ AST_REDIRECTING_FROM_NAME_CHAR_SET
Definition channel.c:9232
@ AST_REDIRECTING_PRIV_FROM_TAG
Definition channel.c:9280
@ AST_REDIRECTING_FROM_ID_PRESENTATION
Definition channel.c:9209
@ AST_REDIRECTING_PRIV_FROM_NUMBER
Definition channel.c:9268
@ AST_REDIRECTING_PRIV_TO_NUMBER_PLAN
Definition channel.c:9256
@ AST_REDIRECTING_TO_NUMBER_VALID
Definition channel.c:9239
@ AST_REDIRECTING_FROM_SUBADDRESS_VALID
Definition channel.c:9219
@ AST_REDIRECTING_FROM_NAME_VALID
Definition channel.c:9231
@ AST_REDIRECTING_PRIV_TO_NAME_CHAR_SET
Definition channel.c:9261
@ AST_REDIRECTING_PRIV_ORIG_TAG
Definition channel.c:9293
@ AST_REDIRECTING_FROM_SUBADDRESS_TYPE
Definition channel.c:9217
@ AST_REDIRECTING_PRIV_TO_TAG
Definition channel.c:9267
@ AST_REDIRECTING_COUNT
Definition channel.c:9215
@ AST_REDIRECTING_FROM_SUBADDRESS
Definition channel.c:9216
@ AST_REDIRECTING_PRIV_ORIG_NAME_CHAR_SET
Definition channel.c:9287
@ AST_REDIRECTING_ORIG_NAME_VALID
Definition channel.c:9246
@ AST_REDIRECTING_TO_ID_PRESENTATION
Definition channel.c:9213
@ AST_REDIRECTING_PRIV_FROM_NUMBER_PLAN
Definition channel.c:9269
@ AST_REDIRECTING_PRIV_TO_NAME_PRESENTATION
Definition channel.c:9262
@ AST_REDIRECTING_PRIV_FROM_NUMBER_PRESENTATION
Definition channel.c:9271
@ AST_REDIRECTING_PRIV_FROM_NAME_PRESENTATION
Definition channel.c:9275
@ AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_TYPE
Definition channel.c:9290
@ AST_REDIRECTING_ORIG_REASON_STR
Definition channel.c:9295
@ AST_REDIRECTING_ORIG_NAME_PRESENTATION
Definition channel.c:9248
@ AST_REDIRECTING_PRIV_FROM_NAME_CHAR_SET
Definition channel.c:9274
@ AST_REDIRECTING_ORIG_NUMBER
Definition channel.c:9241
@ AST_REDIRECTING_PRIV_ORIG_NAME
Definition channel.c:9285
@ AST_REDIRECTING_PRIV_TO_SUBADDRESS_TYPE
Definition channel.c:9264
@ AST_REDIRECTING_PRIV_ORIG_NUMBER_VALID
Definition channel.c:9282
@ AST_REDIRECTING_PRIV_ORIG_NUMBER_PRESENTATION
Definition channel.c:9284
@ AST_REDIRECTING_TO_SUBADDRESS_VALID
Definition channel.c:9223
@ AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_VALID
Definition channel.c:9292
@ AST_REDIRECTING_TO_SUBADDRESS_TYPE
Definition channel.c:9221
@ AST_REDIRECTING_REASON_STR
Definition channel.c:9294
@ AST_REDIRECTING_FROM_NAME
Definition channel.c:9207
@ AST_REDIRECTING_PRIV_ORIG_NUMBER
Definition channel.c:9281
@ AST_REDIRECTING_PRIV_FROM_SUBADDRESS_VALID
Definition channel.c:9279
@ AST_REDIRECTING_ORIG_NUMBER_PRESENTATION
Definition channel.c:9244
@ AST_REDIRECTING_PRIV_TO_SUBADDRESS
Definition channel.c:9263
@ AST_REDIRECTING_PRIV_ORIG_NAME_PRESENTATION
Definition channel.c:9288
@ AST_REDIRECTING_TO_NUMBER_PRESENTATION
Definition channel.c:9240
@ AST_REDIRECTING_FROM_NUMBER
Definition channel.c:9206
@ AST_REDIRECTING_ORIG_NUMBER_PLAN
Definition channel.c:9243
@ AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN
Definition channel.c:9218
@ AST_REDIRECTING_PRIV_ORIG_SUBADDRESS
Definition channel.c:9289
@ AST_REDIRECTING_TO_SUBADDRESS
Definition channel.c:9220
@ AST_REDIRECTING_TO_NAME_CHAR_SET
Definition channel.c:9237

◆ DtmfDirection

Enumerator
DTMF_RECEIVED 
DTMF_SENT 

Definition at line 3358 of file channel.c.

3358 {
3360 DTMF_SENT
3361};
@ DTMF_SENT
Definition channel.c:3360
@ DTMF_RECEIVED
Definition channel.c:3359

Function Documentation

◆ __ast_answer()

int __ast_answer ( struct ast_channel chan,
unsigned int  delay 
)

Answer a channel, with a selectable delay before returning.

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

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

Note
The channel passed does not need to be locked, but is locked by the function when needed.
This function will wait up to 'delay' milliseconds for media to arrive on the channel before returning to the caller, so that the caller can properly assume the channel is 'ready' for media flow. If 'delay' is less than 500, the function will wait up to 500 milliseconds.
Return values
0on success
non-zeroon failure

Definition at line 2695 of file channel.c.

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 {
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
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
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:
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}
#define ast_log
Definition astobj2.c:42
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition channel.c:4278
int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to the head of a channel's frame queue.
Definition channel.c:1176
int ast_waitfor(struct ast_channel *c, int ms)
Wait for input on a channel.
Definition channel.c:3166
int ast_raw_answer(struct ast_channel *chan)
Answer a channel.
Definition channel.c:2690
const char * ast_channel_name(const struct ast_channel *chan)
#define ast_channel_lock(chan)
Definition channel.h:2983
#define ast_channel_unlock(chan)
Definition channel.h:2984
ast_channel_state
ast_channel states
@ AST_STATE_RING
@ AST_STATE_RINGING
#define SCOPE_TRACE(__level,...)
#define ast_frisolate(fr)
Makes a frame independent of any static storage.
#define ast_frfree(fr)
@ AST_FRAME_DTMF_END
@ AST_FRAME_DTMF_BEGIN
@ AST_FRAME_BRIDGE_ACTION_SYNC
@ AST_FRAME_TEXT_DATA
@ AST_FRAME_CONTROL
@ AST_FRAME_BRIDGE_ACTION
@ AST_CONTROL_HANGUP
#define ast_debug(level,...)
Log a DEBUG message.
#define LOG_WARNING
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
int errno
static int frames
Definition parser.c:51
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
enum ast_frame_type frametype
int done
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
Definition utils.c:2315
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition time.h:159
#define MAX(a, b)
Definition utils.h:254

References ast_channel_lock, ast_channel_name(), ast_channel_unlock, AST_CONTROL_HANGUP, ast_debug, AST_FRAME_BRIDGE_ACTION, AST_FRAME_BRIDGE_ACTION_SYNC, AST_FRAME_CNG, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_HTML, AST_FRAME_IAX, AST_FRAME_IMAGE, AST_FRAME_MODEM, AST_FRAME_NULL, AST_FRAME_RTCP, AST_FRAME_TEXT, AST_FRAME_TEXT_DATA, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_frfree, ast_frisolate, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_HEAD_NOLOCK, AST_LIST_INSERT_HEAD, AST_LIST_REMOVE_HEAD, ast_log, ast_queue_frame_head(), ast_raw_answer(), ast_read(), ast_remaining_ms(), AST_STATE_RING, AST_STATE_RINGING, ast_tvnow(), ast_waitfor(), done, errno, frames, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, MAX, SCOPE_TRACE, and ast_frame::subclass.

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

◆ __ast_change_name_nolink()

static void __ast_change_name_nolink ( struct ast_channel chan,
const char *  newname 
)
static

this function simply changes the name of the channel and issues a manager_event with out unlinking and linking the channel from the ao2_container. This should only be used when the channel has already been unlinked from the ao2_container.

Definition at line 6761 of file channel.c.

6762{
6763 /*** DOCUMENTATION
6764 <managerEvent language="en_US" name="Rename">
6765 <managerEventInstance class="EVENT_FLAG_CALL">
6766 <since>
6767 <version>16.24.0</version>
6768 <version>18.10.0</version>
6769 <version>19.2.0</version>
6770 </since>
6771 <synopsis>Raised when the name of a channel is changed.</synopsis>
6772 </managerEventInstance>
6773 </managerEvent>
6774 ***/
6775 ast_manager_event(chan, EVENT_FLAG_CALL, "Rename",
6776 "Channel: %s\r\n"
6777 "Newname: %s\r\n"
6778 "Uniqueid: %s\r\n",
6779 ast_channel_name(chan), newname, ast_channel_uniqueid(chan));
6780 ast_channel_name_set(chan, newname);
6781}
const char * ast_channel_uniqueid(const struct ast_channel *chan)
void ast_channel_name_set(struct ast_channel *chan, const char *value)
#define EVENT_FLAG_CALL
Definition manager.h:76
#define ast_manager_event(chan, category, event, contents,...)
Definition manager.h:257

References ast_channel_name(), ast_channel_name_set(), ast_channel_uniqueid(), ast_manager_event, and EVENT_FLAG_CALL.

Referenced by ast_change_name().

◆ __ast_channel_alloc()

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

Create a channel structure.

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

Definition at line 967 of file channel.c.

974{
975 va_list ap;
976 struct ast_channel *result;
977
978 va_start(ap, name_fmt);
979 result = __ast_channel_alloc_ap(needqueue, state, cid_num, cid_name, acctcode, exten, context,
980 assignedids, requestor, amaflag, endpoint, NULL, file, line, function, name_fmt, ap);
981 va_end(ap);
982
983 return result;
984}
static PGresult * result
Definition cel_pgsql.c:84
static struct ast_channel * __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, enum ama_flags amaflag, struct ast_endpoint *endpoint, struct ast_channel_initializers *initializers, const char *file, int line, const char *function, const char *name_fmt, va_list ap)
Create a new channel structure.
Definition channel.c:746
#define NULL
Definition resample.c:96
Main Channel structure associated with a channel.
char exten[AST_MAX_EXTENSION]
struct ast_endpoint * endpoint
char context[AST_MAX_CONTEXT]

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

◆ __ast_channel_alloc_ap()

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

Create a new channel structure.

Definition at line 746 of file channel.c.

751{
752 struct ast_channel *tmp;
753 struct varshead *headp;
754 char *tech = "", *tech2 = NULL;
755 struct ast_format_cap *nativeformats;
756 struct ast_sched_context *schedctx;
757 struct ast_timer *timer;
758 struct timeval now;
759 const struct ast_channel_tech *channel_tech;
760 struct ast_stream_topology *topology;
761
762 /* If shutting down, don't allocate any new channels */
763 if (ast_shutting_down()) {
764 ast_log(LOG_WARNING, "Channel allocation failed: Refusing due to active shutdown\n");
765 return NULL;
766 }
767
768 tmp = __ast_channel_internal_alloc_with_initializers(ast_channel_destructor, assignedids, requestor, initializers,
769 file, line, function);
770 if (!tmp) {
771 /* Channel structure allocation failure. */
772 return NULL;
773 }
774
776
777 /*
778 * Init file descriptors to unopened state so
779 * the destructor can know not to close them.
780 */
784
786 if (!nativeformats) {
787 /*
788 * Aborting the channel creation. We do not need to complete staging
789 * the channel snapshot because the channel has not been finalized or
790 * linked into the channels container yet. Nobody else knows about
791 * this channel nor will anybody ever know about it.
792 */
793 return ast_channel_unref(tmp);
794 }
795 ast_format_cap_append(nativeformats, ast_format_none, 0);
796 ast_channel_nativeformats_set(tmp, nativeformats);
797 ao2_ref(nativeformats, -1);
798
803
804 if (!(schedctx = ast_sched_context_create())) {
805 ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n");
806 /* See earlier channel creation abort comment above. */
807 return ast_channel_unref(tmp);
808 }
809 ast_channel_sched_set(tmp, schedctx);
810
816
817 if (cid_name) {
819 ast_channel_caller(tmp)->id.name.str = ast_strdup(cid_name);
820 if (!ast_channel_caller(tmp)->id.name.str) {
821 /* See earlier channel creation abort comment above. */
822 return ast_channel_unref(tmp);
823 }
824 }
825 if (cid_num) {
827 ast_channel_caller(tmp)->id.number.str = ast_strdup(cid_num);
828 if (!ast_channel_caller(tmp)->id.number.str) {
829 /* See earlier channel creation abort comment above. */
830 return ast_channel_unref(tmp);
831 }
832 }
833
834 if ((timer = ast_timer_open())) {
836 if (strcmp(ast_timer_get_name(ast_channel_timer(tmp)), "timerfd")) {
837 needqueue = 0;
838 }
840 }
841
842 if (needqueue && ast_channel_internal_alertpipe_init(tmp)) {
843 /* See earlier channel creation abort comment above. */
844 return ast_channel_unref(tmp);
845 }
846
847 if (!(topology = ast_stream_topology_alloc())) {
848 return ast_channel_unref(tmp);
849 }
851
852 /* Always watch the alertpipe */
854 /* And timing pipe */
856
857 /* Initial state */
860
863
866
867 now = ast_tvnow();
869
871
872 if (!ast_strlen_zero(name_fmt)) {
873 char *slash, *slash2;
874 /* Almost every channel is calling this function, and setting the name via the ast_string_field_build() call.
875 * And they all use slightly different formats for their name string.
876 * This means, to set the name here, we have to accept variable args, and call the string_field_build from here.
877 * This means, that the stringfields must have a routine that takes the va_lists directly, and
878 * uses them to build the string, instead of forming the va_lists internally from the vararg ... list.
879 * This new function was written so this can be accomplished.
880 */
881 ast_channel_name_build_va(tmp, name_fmt, ap);
882 tech = ast_strdupa(ast_channel_name(tmp));
883 if ((slash = strchr(tech, '/'))) {
884 if ((slash2 = strchr(slash + 1, '/'))) {
885 tech2 = slash + 1;
886 *slash2 = '\0';
887 }
888 *slash = '\0';
889 }
890 } else {
891 /*
892 * Start the string with '-' so it becomes an empty string
893 * in the destructor.
894 */
895 ast_channel_name_set(tmp, "-**Unknown**");
896 }
897
898 if (amaflag != AST_AMA_NONE) {
899 ast_channel_amaflags_set(tmp, amaflag);
900 } else {
902 }
903
904 if (!ast_strlen_zero(acctcode)) {
905 ast_channel_accountcode_set(tmp, acctcode);
906 }
907 ast_channel_language_set(tmp, ast_defaultlanguage);
908
909 ast_channel_context_set(tmp, S_OR(context, "default"));
910 ast_channel_exten_set(tmp, S_OR(exten, "s"));
912
913 headp = ast_channel_varshead(tmp);
915
919
920 channel_tech = ast_get_channel_tech(tech);
921 if (!channel_tech && !ast_strlen_zero(tech2)) {
922 channel_tech = ast_get_channel_tech(tech2);
923 }
924 if (channel_tech) {
925 ast_channel_tech_set(tmp, channel_tech);
926 } else {
928 }
929
930 /* You might scream "locking inversion" at seeing this but it is actually perfectly fine.
931 * Since the channel was just created nothing can know about it yet or even acquire it.
932 */
933 ast_channel_lock(tmp);
934
936
937 if (do_ids_conflict(assignedids, 0)) {
941 /* See earlier channel creation abort comment above. */
942 return ast_channel_unref(tmp);
943 }
944
945 /* Finalize and link into the channels container. */
950
951
952 if (endpoint) {
953 ast_channel_endpoint_set(tmp, endpoint);
954 }
955
956 /*
957 * And now, since the channel structure is built, and has its name, let
958 * the world know of its existence
959 */
961
962 ast_debug(1, "Channel %p '%s' allocated\n", tmp, ast_channel_name(tmp));
963
964 return tmp;
965}
int ast_shutting_down(void)
Definition asterisk.c:1889
#define ast_strdup(str)
A wrapper for strdup()
Definition astmm.h:241
#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
@ OBJ_NOLOCK
Assume that the ao2_container is already locked.
Definition astobj2.h:1063
static struct ast_timer * timer
Definition chan_iax2.c:401
void ast_party_redirecting_init(struct ast_party_redirecting *init)
Initialize the given redirecting structure.
Definition channel.c:2109
static const struct ast_channel_tech null_tech
Definition channel.c:703
static int chancount
Definition channel.c:97
void ast_party_dialed_init(struct ast_party_dialed *init)
Initialize the given dialed structure.
Definition channel.c:1915
unsigned long global_fin
Definition channel.c:99
static int do_ids_conflict(const struct ast_assigned_ids *assignedids, int rdlock)
Definition channel.c:711
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
Definition channel.c:2009
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
Definition channel.c:2417
static void ast_channel_destructor(void *obj)
Free a channel structure.
Definition channel.c:2181
unsigned long global_fout
Definition channel.c:99
const struct ast_channel_tech * ast_get_channel_tech(const char *name)
Get handle to channel driver based on name.
Definition channel.c:593
#define DEFAULT_AMA_FLAGS
Definition channel.c:112
void ast_party_caller_init(struct ast_party_caller *init)
Initialize the given caller structure.
Definition channel.c:1965
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
struct varshead * ast_channel_varshead(struct ast_channel *chan)
int ast_channel_internal_alert_readfd(struct ast_channel *chan)
void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
void ast_channel_internal_fd_clear_all(struct ast_channel *chan)
void ast_channel_hold_state_set(struct ast_channel *chan, int value)
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
void ast_channel_vstreamid_set(struct ast_channel *chan, int value)
@ AST_CHANNEL_ERROR_ID_EXISTS
Definition channel.h:4916
void ast_channel_streamid_set(struct ast_channel *chan, int value)
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
void ast_channel_timingfd_set(struct ast_channel *chan, int value)
void ast_channel_endpoint_set(struct ast_channel *chan, struct ast_endpoint *endpoint)
@ AST_AMA_NONE
Definition channel.h:1198
#define AST_ALERT_FD
Definition channel.h:202
void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer *value)
void ast_channel_fin_set(struct ast_channel *chan, unsigned int value)
void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format)
int ast_channel_timingfd(const struct ast_channel *chan)
#define AST_TIMING_FD
Definition channel.h:203
void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format)
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
void ast_channel_creationtime_set(struct ast_channel *chan, struct timeval *value)
void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
#define ast_channel_unref(c)
Decrease channel reference count.
Definition channel.h:3019
void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value)
struct ast_party_connected_line * ast_channel_connected_indicated(struct ast_channel *chan)
void ast_channel_context_set(struct ast_channel *chan, const char *value)
void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state)
void ast_channel_fout_set(struct ast_channel *chan, unsigned int value)
struct ast_autochan_list * ast_channel_autochans(struct ast_channel *chan)
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
struct ast_timer * ast_channel_timer(const struct ast_channel *chan)
void ast_channel_internal_alertpipe_clear(struct ast_channel *chan)
void ast_channel_priority_set(struct ast_channel *chan, int value)
int ast_channel_internal_alertpipe_init(struct ast_channel *chan)
void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context *value)
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
struct ast_datastore_list * ast_channel_datastores(struct ast_channel *chan)
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_internal_set_stream_topology(struct ast_channel *chan, struct ast_stream_topology *topology)
struct ast_channel * __ast_channel_internal_alloc_with_initializers(void(*destructor)(void *obj), const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const struct ast_channel_initializers *initializers, const char *file, int line, const char *function)
struct ast_channelstorage_instance * current_channel_storage_instance
The current channel storage instance.
int ast_channel_internal_setup_topics(struct ast_channel *chan)
void ast_channel_internal_finalize(struct ast_channel *chan)
void ast_channel_internal_errno_set(enum ast_channel_error error)
void ast_channel_name_build_va(struct ast_channel *chan, const char *fmt, va_list ap)
#define CHANNELSTORAGE_API(_instance, _func,...)
struct ast_format * ast_format_none
Built-in "null" format.
@ AST_FORMAT_CAP_FLAG_DEFAULT
Definition format_cap.h:38
#define ast_format_cap_append(cap, format, framing)
Add format capability to capabilities structure.
Definition format_cap.h:99
#define ast_format_cap_alloc(flags)
Allocate a new ast_format_cap structure.
Definition format_cap.h:49
static const char name[]
Definition format_mp3.c:68
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
@ AST_CONTROL_UNHOLD
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
Definition lock.h:764
char ast_defaultlanguage[]
Definition options.c:99
void ast_pbx_hangup_handler_init(struct ast_channel *chan)
Init the hangup handler container on a channel.
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
Definition sched.c:238
struct ast_stream_topology * ast_stream_topology_alloc(void)
Create a stream topology.
Definition stream.c:652
#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
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition strings.h:65
Structure to describe a channel "technology", ie a channel driver See for examples:
Definition channel.h:648
Format capabilities structure, holds formats + preference order + etc.
Definition format_cap.c:54
struct ast_party_id id
Caller party ID.
Definition channel.h:422
struct ast_party_name name
Subscriber name.
Definition channel.h:342
struct ast_party_number number
Subscriber phone number.
Definition channel.h:344
unsigned char valid
TRUE if the name information is valid/present.
Definition channel.h:281
char * str
Subscriber name (Malloced)
Definition channel.h:266
unsigned char valid
TRUE if the number information is valid/present.
Definition channel.h:299
char * str
Subscriber phone number (Malloced)
Definition channel.h:293
Number structure.
const char * ast_timer_get_name(const struct ast_timer *handle)
Get name of timer in use.
Definition timing.c:196
struct ast_timer * ast_timer_open(void)
Open a timer.
Definition timing.c:122
int ast_timer_fd(const struct ast_timer *handle)
Get a poll()-able file descriptor for a timer.
Definition timing.c:161

References __ast_channel_internal_alloc_with_initializers(), ao2_ref, AST_ALERT_FD, AST_AMA_NONE, ast_atomic_fetchadd_int(), ast_channel_amaflags_set(), ast_channel_autochans(), ast_channel_caller(), ast_channel_connected(), ast_channel_connected_indicated(), ast_channel_context_set(), ast_channel_creationtime_set(), ast_channel_datastores(), ast_channel_destructor(), ast_channel_dialed(), ast_channel_endpoint_set(), AST_CHANNEL_ERROR_ID_EXISTS, ast_channel_exten_set(), ast_channel_fin_set(), ast_channel_fout_set(), ast_channel_hold_state_set(), ast_channel_internal_alert_readfd(), ast_channel_internal_alertpipe_clear(), ast_channel_internal_alertpipe_init(), ast_channel_internal_errno_set(), ast_channel_internal_fd_clear_all(), ast_channel_internal_finalize(), ast_channel_internal_set_stream_topology(), ast_channel_internal_setup_topics(), ast_channel_lock, ast_channel_name(), ast_channel_name_build_va(), ast_channel_name_set(), ast_channel_nativeformats_set(), ast_channel_priority_set(), ast_channel_redirecting(), ast_channel_sched_set(), ast_channel_set_fd(), ast_channel_set_rawreadformat(), ast_channel_set_rawwriteformat(), ast_channel_set_readformat(), ast_channel_set_writeformat(), ast_channel_stage_snapshot(), ast_channel_stage_snapshot_done(), ast_channel_state_set(), ast_channel_streamid_set(), ast_channel_tech_set(), ast_channel_timer(), ast_channel_timer_set(), ast_channel_timingfd(), ast_channel_timingfd_set(), ast_channel_unlock, ast_channel_unref, ast_channel_varshead(), ast_channel_vstreamid_set(), AST_CONTROL_UNHOLD, ast_debug, ast_defaultlanguage, ast_format_cap_alloc, ast_format_cap_append, AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_none, ast_get_channel_tech(), AST_LIST_HEAD_INIT_NOLOCK, ast_log, ast_party_caller_init(), ast_party_connected_line_init(), ast_party_dialed_init(), ast_party_redirecting_init(), ast_pbx_hangup_handler_init(), ast_sched_context_create(), ast_shutting_down(), ast_strdup, ast_strdupa, ast_stream_topology_alloc(), ast_strlen_zero(), ast_timer_fd(), ast_timer_get_name(), ast_timer_open(), AST_TIMING_FD, ast_tvnow(), chancount, CHANNELSTORAGE_API, current_channel_storage_instance, DEFAULT_AMA_FLAGS, do_ids_conflict(), global_fin, global_fout, ast_party_caller::id, LOG_WARNING, name, ast_party_id::name, NULL, null_tech, ast_party_id::number, OBJ_NOLOCK, S_OR, ast_party_name::str, ast_party_number::str, timer, ast_party_name::valid, and ast_party_number::valid.

Referenced by __ast_channel_alloc(), and __ast_channel_alloc_with_initializers().

◆ __ast_channel_alloc_with_initializers()

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

Create a channel structure.

Since
18.25.0
Return values
NULLfailure
non-NULLsuccessfully allocated channel
Note
Absolutely NO channel locks should be held before calling this function.
By default, new channels are set to the "s" extension and "default" context.
Same as __ast_channel_alloc but with ast_channel_initializers struct.

Definition at line 986 of file channel.c.

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

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

◆ __ast_dummy_channel_alloc()

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

Definition at line 1007 of file channel.c.

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

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

◆ __ast_queue_frame()

static int __ast_queue_frame ( struct ast_channel chan,
struct ast_frame fin,
int  head,
struct ast_frame after 
)
static

Definition at line 1041 of file channel.c.

1042{
1043 struct ast_frame *f;
1044 struct ast_frame *cur;
1045 unsigned int new_frames = 0;
1046 unsigned int new_voice_frames = 0;
1047 unsigned int queued_frames = 0;
1048 unsigned int queued_voice_frames = 0;
1050
1051 ast_channel_lock(chan);
1052
1053 /*
1054 * Check the last frame on the queue if we are queuing the new
1055 * frames after it.
1056 */
1057 cur = AST_LIST_LAST(ast_channel_readq(chan));
1058 if (cur && cur->frametype == AST_FRAME_CONTROL && !head && (!after || after == cur)) {
1059 switch (cur->subclass.integer) {
1061 if (fin->frametype == AST_FRAME_CONTROL
1062 && fin->subclass.integer == AST_CONTROL_HANGUP) {
1063 /*
1064 * Destroy the end-of-Q marker frame so we can queue the hangup
1065 * frame in its place.
1066 */
1068 ast_frfree(cur);
1069
1070 /*
1071 * This has degenerated to a normal queue append anyway. Since
1072 * we just destroyed the last frame in the queue we must make
1073 * sure that "after" is NULL or bad things will happen.
1074 */
1075 after = NULL;
1076 break;
1077 }
1078 /* Fall through */
1079 case AST_CONTROL_HANGUP:
1080 /* Don't queue anything. */
1081 ast_channel_unlock(chan);
1082 return 0;
1083 default:
1084 break;
1085 }
1086 }
1087
1088 /* Build copies of all the new frames and count them */
1090 for (cur = fin; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
1091 if (!(f = ast_frdup(cur))) {
1092 if (AST_LIST_FIRST(&frames)) {
1094 }
1095 ast_channel_unlock(chan);
1096 return -1;
1097 }
1098
1100 new_frames++;
1101 if (f->frametype == AST_FRAME_VOICE) {
1102 new_voice_frames++;
1103 }
1104 }
1105
1106 /* Count how many frames exist on the queue */
1108 queued_frames++;
1109 if (cur->frametype == AST_FRAME_VOICE) {
1110 queued_voice_frames++;
1111 }
1112 }
1113
1114 if ((queued_frames + new_frames > 128 || queued_voice_frames + new_voice_frames > 96)) {
1115 int total_queued = queued_frames + new_frames;
1116 int total_voice = queued_voice_frames + new_voice_frames;
1117 int count = 0;
1118 ast_log(LOG_WARNING, "Exceptionally long %squeue length (%d voice / %d total) queuing to %s\n",
1119 queued_frames + new_frames > 128 ? "" : "voice ", total_voice, total_queued, ast_channel_name(chan));
1121 /* Save the most recent frame */
1122 if (!AST_LIST_NEXT(cur, frame_list)) {
1123 break;
1124 } else if (cur->frametype == AST_FRAME_VOICE || cur->frametype == AST_FRAME_VIDEO || cur->frametype == AST_FRAME_NULL) {
1125 if (++count > 64) {
1126 break;
1127 }
1129 ast_frfree(cur);
1130
1131 /* Read from the alert pipe for each flushed frame. */
1133 }
1134 }
1136 if (count) {
1137 ast_debug(4, "Discarded %d frame%s due to queue overload on %s\n", count, ESS(count), ast_channel_name(chan));
1138 }
1139 }
1140
1141 if (after) {
1143 } else {
1144 if (head) {
1147 }
1149 }
1150
1151 if (ast_channel_alert_writable(chan)) {
1152 /* Write to the alert pipe for each added frame */
1153 while (new_frames--) {
1154 if (ast_channel_alert_write(chan)) {
1155 ast_log(LOG_WARNING, "Unable to write to alert pipe on %s (qlen = %u): %s!\n",
1156 ast_channel_name(chan), queued_frames, strerror(errno));
1157 break;
1158 }
1159 }
1160 } else if (ast_channel_timingfd(chan) > -1) {
1163 pthread_kill(ast_channel_blocker(chan), SIGURG);
1164 }
1165
1166 ast_channel_unlock(chan);
1167
1168 return 0;
1169}
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
pthread_t ast_channel_blocker(const struct ast_channel *chan)
int ast_channel_alert_write(struct ast_channel *chan)
struct ast_readq_list * ast_channel_readq(struct ast_channel *chan)
ast_alert_status_t ast_channel_internal_alert_read(struct ast_channel *chan)
@ AST_FLAG_BLOCKING
Definition channel.h:1005
int ast_channel_alert_writable(struct ast_channel *chan)
#define ESS(x)
Definition cli.h:59
#define ast_frdup(fr)
Copies a frame.
@ AST_CONTROL_END_OF_Q
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.
#define AST_LIST_INSERT_LIST_AFTER(head, list, elm, field)
Inserts a whole list after a specific entry in a list.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
#define AST_LIST_APPEND_LIST(head, list, field)
Appends a whole list to the tail of a list.
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
int ast_timer_enable_continuous(const struct ast_timer *handle)
Enable continuous mode.
Definition timing.c:176
#define ast_test_flag(p, flag)
Definition utils.h:64

References ast_channel_alert_writable(), ast_channel_alert_write(), ast_channel_blocker(), ast_channel_flags(), ast_channel_internal_alert_read(), ast_channel_lock, ast_channel_name(), ast_channel_readq(), ast_channel_timer(), ast_channel_timingfd(), ast_channel_unlock, AST_CONTROL_END_OF_Q, AST_CONTROL_HANGUP, ast_debug, AST_FLAG_BLOCKING, AST_FRAME_CONTROL, AST_FRAME_NULL, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_frdup, ast_frfree, AST_LIST_APPEND_LIST, AST_LIST_FIRST, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_HEAD_NOLOCK, AST_LIST_INSERT_LIST_AFTER, AST_LIST_INSERT_TAIL, AST_LIST_LAST, AST_LIST_NEXT, AST_LIST_REMOVE, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log, ast_test_flag, ast_timer_enable_continuous(), errno, ESS, frames, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, NULL, and ast_frame::subclass.

Referenced by __ast_read(), ast_queue_frame(), and ast_queue_frame_head().

◆ __ast_read()

static struct ast_frame * __ast_read ( struct ast_channel chan,
int  dropaudio,
int  dropnondefault 
)
static
Todo:
XXX It is possible to write a digit to the audiohook twice if the digit was originally read while the channel was in autoservice.

Definition at line 3541 of file channel.c.

3542{
3543 struct ast_frame *f = NULL; /* the return value */
3544 int prestate;
3545 int cause = 0;
3546 struct ast_stream *stream = NULL, *default_stream = NULL;
3547
3548 /* this function is very long so make sure there is only one return
3549 * point at the end (there are only two exceptions to this).
3550 */
3551 ast_channel_lock(chan);
3552
3553 /* Stop if we're a zombie or need a soft hangup */
3555 if (ast_channel_generator(chan))
3557
3558 /*
3559 * It is possible for chan->_softhangup to be set and there
3560 * still be control frames that need to be read. Instead of
3561 * just going to 'done' in the case of ast_check_hangup(), we
3562 * need to queue the end-of-Q frame so that it can mark the end
3563 * of the read queue. If there are frames to be read,
3564 * ast_queue_control() will be called repeatedly, but will only
3565 * queue the first end-of-Q frame.
3566 */
3569 } else {
3570 goto done;
3571 }
3572 } else {
3573#ifdef AST_DEVMODE
3574 /*
3575 * The ast_waitfor() code records which of the channel's file
3576 * descriptors reported that data is available. In theory,
3577 * ast_read() should only be called after ast_waitfor() reports
3578 * that a channel has data available for reading but certain
3579 * situations with stasis and ARI could give a false indication.
3580 * For this reason, we don't stop any processing.
3581 */
3582 if (ast_channel_fdno(chan) == -1) {
3583 ast_debug(3,
3584 "ast_read() on chan '%s' called with no recorded file descriptor.\n",
3585 ast_channel_name(chan));
3586 }
3587#endif
3588 }
3589
3590 prestate = ast_channel_state(chan);
3591
3592 if (ast_channel_timingfd(chan) > -1 && ast_channel_fdno(chan) == AST_TIMING_FD) {
3593 enum ast_timer_event res;
3594 int trigger_dtmf_emulating = should_trigger_dtmf_emulating(chan);
3595
3597
3599
3600 switch (res) {
3602 if (ast_timer_ack(ast_channel_timer(chan), 1) < 0) {
3603 ast_log(LOG_ERROR, "Failed to acknowledge timer in ast_read\n");
3604 goto done;
3605 }
3606
3607 if (ast_channel_timingfunc(chan)) {
3608 /* save a copy of func/data before unlocking the channel */
3610 void *data = ast_channel_timingdata(chan);
3611 int got_ref = 0;
3613 ao2_ref(data, 1);
3614 got_ref = 1;
3615 }
3616 ast_channel_fdno_set(chan, -1);
3617 ast_channel_unlock(chan);
3618 func(data);
3619 if (got_ref) {
3620 ao2_ref(data, -1);
3621 }
3622
3623 if (trigger_dtmf_emulating) {
3624 /*
3625 * Since we're breaking out of this switch block and not
3626 * returning, we need to re-lock the channel.
3627 */
3628 ast_channel_lock(chan);
3629 /* generate null frame to trigger dtmf emulating */
3630 f = &ast_null_frame;
3631 break;
3632 }
3633 } else if (trigger_dtmf_emulating) {
3634 /* generate null frame to trigger dtmf emulating */
3635 f = &ast_null_frame;
3636 break;
3637 } else {
3639 /* generate very last null frame to trigger dtmf emulating */
3640 f = &ast_null_frame;
3641 break;
3642 }
3643
3644 /* cannot 'goto done' because the channel is already unlocked */
3645 return &ast_null_frame;
3646
3648 if (AST_LIST_EMPTY(ast_channel_readq(chan)) ||
3651 }
3652 break;
3653 }
3654
3657 }
3658
3659 /* Read and ignore anything on the alertpipe, but read only
3660 one sizeof(blah) per frame that we send from it */
3662 f = &ast_null_frame;
3663 goto done;
3664 }
3665
3666 /* Check for pending read queue */
3667 if (!AST_LIST_EMPTY(ast_channel_readq(chan))) {
3668 int skipped_dtmf_frame = 0;
3669 int skip_dtmf = should_skip_dtmf(chan);
3670
3672 /* We have to be picky about which frame we pull off of the readq because
3673 * there are cases where we want to leave DTMF frames on the queue until
3674 * some later time. */
3675
3676 if ( (f->frametype == AST_FRAME_DTMF_BEGIN || f->frametype == AST_FRAME_DTMF_END) && skip_dtmf) {
3677 skipped_dtmf_frame = 1;
3678 continue;
3679 }
3680
3682 break;
3683 }
3685
3686 if (!f) {
3687 /* There were no acceptable frames on the readq. */
3688 f = &ast_null_frame;
3689 if (!skipped_dtmf_frame) {
3690 /*
3691 * Do not trigger alert pipe if only buffered dtmf begin or end frames
3692 * are left in the readq.
3693 */
3695 } else {
3696 /*
3697 * Safely disable continuous timer events if only buffered dtmf begin or end
3698 * frames are left in the readq.
3699 */
3701 }
3702 }
3703
3704 /* Interpret hangup and end-of-Q frames to return NULL */
3705 /* XXX why not the same for frames from the channel ? */
3706 if (f->frametype == AST_FRAME_CONTROL) {
3707 switch (f->subclass.integer) {
3708 case AST_CONTROL_HANGUP:
3710 cause = f->data.uint32;
3711 /* Fall through */
3713 ast_frfree(f);
3714 f = NULL;
3715 break;
3716 default:
3717 break;
3718 }
3719 } else if (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_VIDEO) {
3720 if (ast_channel_tech(chan) && ast_channel_tech(chan)->read_stream) {
3723 } else {
3724 /* Since this channel driver does not support multistream determine the default stream this frame
3725 * originated from and update the frame to include it.
3726 */
3727 stream = default_stream = ast_channel_get_default_stream(chan, ast_format_get_type(f->subclass.format));
3728 /* In order to allow media to be passed up the underlying media type has to have a format negotiated on
3729 * the channel itself. In cases where this hasn't happened the channel driver is incorrectly passing up
3730 * a frame for a format that has not been negotiated. If this occurs just drop the frame as we have no
3731 * stream that it came from.
3732 */
3733 if (!stream) {
3734 ast_frfree(f);
3735 f = &ast_null_frame;
3736 } else {
3738 }
3739 }
3740 }
3741 } else {
3743 if (ast_channel_tech(chan)->exception)
3744 f = ast_channel_tech(chan)->exception(chan);
3745 else {
3746 ast_log(LOG_WARNING, "Exception flag set on '%s', but no exception handler\n", ast_channel_name(chan));
3747 f = &ast_null_frame;
3748 }
3749 /* Clear the exception flag */
3751 } else if (ast_channel_tech(chan) && ast_channel_tech(chan)->read_stream) {
3752 f = ast_channel_tech(chan)->read_stream(chan);
3753
3754 /* This channel driver supports multistream so the stream_num on the frame is valid, the only
3755 * thing different is that we need to find the default stream so we know whether to invoke the
3756 * default stream logic or not (such as transcoding).
3757 */
3758 if (f && (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_VIDEO)) {
3761 }
3762 } else if (ast_channel_tech(chan) && ast_channel_tech(chan)->read) {
3763 f = ast_channel_tech(chan)->read(chan);
3764
3765 /* Since this channel driver does not support multistream determine the default stream this frame
3766 * originated from and update the frame to include it.
3767 */
3768 if (f && (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_VIDEO)) {
3769 stream = default_stream = ast_channel_get_default_stream(chan, ast_format_get_type(f->subclass.format));
3770 if (!stream) {
3771 ast_frfree(f);
3772 f = &ast_null_frame;
3773 } else {
3775 }
3776 }
3777 }
3778 else
3779 ast_log(LOG_WARNING, "No read routine on channel %s\n", ast_channel_name(chan));
3780 }
3781
3782 if (stream == default_stream) {
3783 /* Perform the framehook read event here. After the frame enters the framehook list
3784 * there is no telling what will happen, <insert mad scientist laugh here>!!! */
3786 }
3787
3788 /*
3789 * Reset the recorded file descriptor that triggered this read so that we can
3790 * easily detect when ast_read() is called without properly using ast_waitfor().
3791 */
3792 ast_channel_fdno_set(chan, -1);
3793
3794 if (f) {
3795 struct ast_frame *readq_tail = AST_LIST_LAST(ast_channel_readq(chan));
3796 struct ast_control_read_action_payload *read_action_payload;
3798 int hooked = 0;
3799
3800 /* if the channel driver returned more than one frame, stuff the excess
3801 into the readq for the next ast_read call
3802 */
3803 if (AST_LIST_NEXT(f, frame_list)) {
3807 }
3808
3809 if (dropnondefault && stream != default_stream) {
3810 /* If the frame originates from a non-default stream and the caller can not handle other streams
3811 * absorb the frame and replace it with a null one instead.
3812 */
3813 ast_frfree(f);
3814 f = &ast_null_frame;
3815 }
3816
3817 switch (f->frametype) {
3818 case AST_FRAME_CONTROL:
3820 if (prestate == AST_STATE_UP && ast_channel_is_bridged(chan)) {
3821 ast_debug(1, "Dropping duplicate answer!\n");
3822 ast_frfree(f);
3823 f = &ast_null_frame;
3824 } else {
3825 /*
3826 * Mark when outgoing channel answered so we can know how
3827 * long the channel has been up.
3828 */
3830
3832 }
3833 } else if (f->subclass.integer == AST_CONTROL_READ_ACTION) {
3834 read_action_payload = f->data.ptr;
3835 switch (read_action_payload->action) {
3839 if (ast_connected_line_parse_data(read_action_payload->payload,
3840 read_action_payload->payload_size, &connected)) {
3842 break;
3843 }
3844 ast_channel_unlock(chan);
3847 read_action_payload->payload,
3848 read_action_payload->payload_size);
3849 }
3851 ast_channel_lock(chan);
3852 break;
3854 ast_channel_unlock(chan);
3855 ast_sendtext(chan, (const char *)read_action_payload->payload);
3856 ast_channel_lock(chan);
3857 break;
3859 ast_channel_unlock(chan);
3860 ast_sendtext_data(chan, (struct ast_msg_data *)read_action_payload->payload);
3861 ast_channel_lock(chan);
3862 break;
3863 }
3864 ast_frfree(f);
3865 f = &ast_null_frame;
3866 } else if (f->subclass.integer == AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE && dropnondefault) {
3867 /* The caller of this function is incapable of handling streams so we don't accept the change request
3868 * and stick to the streams currently on the channel.
3869 */
3871 ast_frfree(f);
3872 f = &ast_null_frame;
3873 } else if (f->subclass.integer == AST_CONTROL_STREAM_TOPOLOGY_CHANGED && dropnondefault) {
3874 /* The caller of this function is incapable of handling streams so we absorb the notification that the
3875 * stream topology has changed.
3876 */
3877 ast_frfree(f);
3878 f = &ast_null_frame;
3879 } else if (f->subclass.integer == AST_CONTROL_FLASH) {
3880 send_flash_event(chan);
3881 } else if (f->subclass.integer == AST_CONTROL_WINK) {
3882 send_wink_event(chan);
3883 }
3884 break;
3885 case AST_FRAME_DTMF_END:
3887 ast_log(LOG_DTMF, "DTMF end '%c' received on %s, duration %ld ms\n", f->subclass.integer, ast_channel_name(chan), f->len);
3888 /* Queue it up if DTMF is deferred, or if DTMF emulation is forced. */
3890 queue_dtmf_readq(chan, f);
3891 ast_frfree(f);
3892 f = &ast_null_frame;
3894 if (!ast_tvzero(*ast_channel_dtmf_tv(chan)) &&
3896 /* If it hasn't been long enough, defer this digit */
3897 queue_dtmf_readq(chan, f);
3898 ast_frfree(f);
3899 f = &ast_null_frame;
3900 } else {
3901 /* There was no begin, turn this into a begin and send the end later */
3902 struct timeval tv = ast_tvnow();
3906 ast_channel_dtmf_tv_set(chan, &tv);
3907 if (f->len) {
3908 if (f->len > option_dtmfminduration)
3910 else
3912 } else
3914 ast_log(LOG_DTMF, "DTMF begin emulation of '%c' with duration %u queued on %s\n", f->subclass.integer, ast_channel_emulate_dtmf_duration(chan), ast_channel_name(chan));
3915
3916 /*
3917 * Start generating 50 fps timer events (null frames) for dtmf emulating
3918 * independently from any existing incoming voice frames.
3919 * If channel generator is already activated in regular mode use these
3920 * timer events to generate null frames.
3921 */
3922 if (!ast_channel_generator(chan)) {
3923 struct ast_timer *timer = ast_channel_timer(chan);
3924 if (timer) {
3926 } else {
3927 ast_log(LOG_WARNING, "No timing module loaded, DTMF length may be inaccurate\n");
3928 }
3929 }
3930 }
3931 if (ast_channel_audiohooks(chan)) {
3932 struct ast_frame *old_frame = f;
3933 /*!
3934 * \todo XXX It is possible to write a digit to the audiohook twice
3935 * if the digit was originally read while the channel was in autoservice. */
3937 if (old_frame != f)
3938 ast_frfree(old_frame);
3939 }
3940 } else {
3941 struct timeval now = ast_tvnow();
3943 ast_log(LOG_DTMF, "DTMF end accepted with begin '%c' on %s\n", f->subclass.integer, ast_channel_name(chan));
3945 if (!f->len)
3946 f->len = ast_tvdiff_ms(now, *ast_channel_dtmf_tv(chan));
3947
3948 /* detect tones that were received on
3949 * the wire with durations shorter than
3950 * option_dtmfminduration and set f->len
3951 * to the actual duration of the DTMF
3952 * frames on the wire. This will cause
3953 * dtmf emulation to be triggered later
3954 * on.
3955 */
3957 f->len = ast_tvdiff_ms(now, *ast_channel_dtmf_tv(chan));
3958 ast_log(LOG_DTMF, "DTMF end '%c' detected to have actual duration %ld on the wire, emulation will be triggered on %s\n", f->subclass.integer, f->len, ast_channel_name(chan));
3959 }
3960 } else if (!f->len) {
3961 ast_log(LOG_DTMF, "DTMF end accepted without begin '%c' on %s\n", f->subclass.integer, ast_channel_name(chan));
3963 }
3965 ast_log(LOG_DTMF, "DTMF end '%c' has duration %ld but want minimum %u, emulating on %s\n", f->subclass.integer, f->len, option_dtmfminduration, ast_channel_name(chan));
3969 ast_frfree(f);
3970 f = &ast_null_frame;
3971
3972 /* Start generating 50 fps timer events (null frames) for dtmf emulating
3973 * independently from any existing incoming voice frames.
3974 * If channel generator is already activated in regular mode use these
3975 * timer events to generate null frames.
3976 */
3977 if (!ast_channel_generator(chan)) {
3978 struct ast_timer *timer = ast_channel_timer(chan);
3979 if (timer) {
3981 } else {
3982 ast_log(LOG_WARNING, "No timing module loaded, DTMF length may be inaccurate\n");
3983 }
3984 }
3985 } else {
3986 ast_log(LOG_DTMF, "DTMF end passthrough '%c' on %s\n", f->subclass.integer, ast_channel_name(chan));
3987 if (f->len < option_dtmfminduration) {
3989 }
3990 ast_channel_dtmf_tv_set(chan, &now);
3991
3992 /* Start generating 50 fps timer events (null frames) for dtmf emulating
3993 * independently from any existing incoming voice frames.
3994 * If channel generator is already activated in regular mode use these
3995 * timer events to generate null frames.
3996 */
3997 if (!ast_channel_generator(chan)) {
3998 struct ast_timer *timer = ast_channel_timer(chan);
3999 if (timer) {
4001 } else {
4002 ast_log(LOG_WARNING, "No timing module loaded, DTMF length may be inaccurate\n");
4003 }
4004 }
4005 }
4006 if (ast_channel_audiohooks(chan)) {
4007 struct ast_frame *old_frame = f;
4009 if (old_frame != f)
4010 ast_frfree(old_frame);
4011 }
4012 }
4013 break;
4016 ast_log(LOG_DTMF, "DTMF begin '%c' received on %s\n", f->subclass.integer, ast_channel_name(chan));
4018 (!ast_tvzero(*ast_channel_dtmf_tv(chan)) &&
4020 ast_log(LOG_DTMF, "DTMF begin ignored '%c' on %s\n", f->subclass.integer, ast_channel_name(chan));
4021 ast_frfree(f);
4022 f = &ast_null_frame;
4023 } else {
4024 struct timeval now = ast_tvnow();
4026 ast_channel_dtmf_tv_set(chan, &now);
4027 ast_log(LOG_DTMF, "DTMF begin passthrough '%c' on %s\n", f->subclass.integer, ast_channel_name(chan));
4028 }
4029 break;
4030 case AST_FRAME_NULL:
4031 /* The EMULATE_DTMF flag must be cleared here as opposed to when the duration
4032 * is reached , because we want to make sure we pass at least one
4033 * voice frame through before starting the next digit, to ensure a gap
4034 * between DTMF digits. */
4036 struct timeval now = ast_tvnow();
4040 } else if (ast_tvdiff_ms(now, *ast_channel_dtmf_tv(chan)) >= ast_channel_emulate_dtmf_duration(chan)) {
4042 ast_frfree(f);
4043 f = ast_channel_dtmff(chan);
4046 f->len = ast_tvdiff_ms(now, *ast_channel_dtmf_tv(chan));
4047 ast_channel_dtmf_tv_set(chan, &now);
4050 ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass.integer, ast_channel_name(chan));
4051 if (ast_channel_audiohooks(chan)) {
4052 struct ast_frame *old_frame = f;
4054 if (old_frame != f) {
4055 ast_frfree(old_frame);
4056 }
4057 }
4058
4059 /* Start generating 50 fps timer events (null frames) for dtmf emulating
4060 * independently from any existing incoming voice frames.
4061 * If channel generator is already activated in regular mode use these
4062 * timer events to generate null frames.
4063 */
4064 if (!ast_channel_generator(chan)) {
4065 struct ast_timer *timer = ast_channel_timer(chan);
4066 if (timer) {
4068 } else {
4069 ast_log(LOG_WARNING, "No timing module loaded, DTMF length may be inaccurate\n");
4070 }
4071 }
4072 }
4073 }
4074 break;
4075 case AST_FRAME_VOICE:
4076 /* If media was received from a non-default stream don't perform any actions, let it just go through */
4077 if (stream != default_stream) {
4078 break;
4079 }
4080
4081 /* The EMULATE_DTMF flag must be cleared here as opposed to when the duration
4082 * is reached , because we want to make sure we pass at least one
4083 * voice frame through before starting the next digit, to ensure a gap
4084 * between DTMF digits. */
4088 }
4089
4090 if (dropaudio || ast_test_flag(ast_channel_flags(chan), AST_FLAG_IN_DTMF)) {
4091 if (dropaudio)
4093 ast_frfree(f);
4094 f = &ast_null_frame;
4095 }
4096
4098 struct timeval now = ast_tvnow();
4101 ast_frfree(f);
4102 f = ast_channel_dtmff(chan);
4105 f->len = ast_tvdiff_ms(now, *ast_channel_dtmf_tv(chan));
4106 ast_channel_dtmf_tv_set(chan, &now);
4107 if (ast_channel_audiohooks(chan)) {
4108 struct ast_frame *old_frame = f;
4110 if (old_frame != f)
4111 ast_frfree(old_frame);
4112 }
4113 ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass.integer, ast_channel_name(chan));
4114 } else {
4115 /* Drop voice frames while we're still in the middle of the digit */
4116 ast_frfree(f);
4117 f = &ast_null_frame;
4118 }
4119 break;
4120 }
4121 if (f->frametype != AST_FRAME_VOICE) {
4122 break;
4123 }
4126 struct ast_format *core_format;
4127
4128 /*
4129 * Note: This frame may not be one of the current native
4130 * formats. We may have gotten it out of the read queue from
4131 * a previous multi-frame translation, from a framehook
4132 * injected frame, or the device we're talking to isn't
4133 * respecting negotiated formats. Regardless we will accept
4134 * all frames.
4135 *
4136 * Update the read translation path to handle the new format
4137 * that just came in. If the core wants slinear we need to
4138 * setup a new translation path because the core is usually
4139 * doing something with the audio itself and may not handle
4140 * any other format. e.g., Softmix bridge, holding bridge
4141 * announcer channel, recording, AMD... Otherwise, we'll
4142 * setup to pass the frame as is to the core. In this case
4143 * the core doesn't care. The channel is likely in
4144 * autoservice, safesleep, or the channel is in a bridge.
4145 * Let the bridge technology deal with format compatibility
4146 * between the channels in the bridge.
4147 *
4148 * Beware of the transcode_via_slin and genericplc options as
4149 * they force any transcoding to go through slin on a bridge.
4150 * Unfortunately transcode_via_slin is enabled by default and
4151 * genericplc is enabled in the codecs.conf.sample file.
4152 *
4153 * XXX Only updating translation to slinear frames has some
4154 * corner cases if slinear is one of the native formats and
4155 * there are different sample rates involved. We might wind
4156 * up with conflicting translation paths between channels
4157 * where the read translation path on this channel reduces
4158 * the sample rate followed by a write translation path on
4159 * the peer channel that increases the sample rate.
4160 */
4161 core_format = ast_channel_readformat(chan);
4162 if (!ast_format_cache_is_slinear(core_format)) {
4163 core_format = f->subclass.format;
4164 }
4165 if (ast_set_read_format_path(chan, f->subclass.format, core_format)) {
4166 /* Drop frame. We couldn't make it compatible with the core. */
4167 ast_frfree(f);
4168 f = &ast_null_frame;
4169 break;
4170 }
4171 }
4172 /*
4173 * Send frame to audiohooks if present, if frametype is linear, to preserve
4174 * functional compatibility with previous behavior. If not linear, hold off
4175 * until transcoding is done where we are more likely to have a linear frame
4176 */
4178 /* Place hooked after declaration */
4179 struct ast_frame *old_frame = f;
4180 hooked = 1;
4181
4183 if (old_frame != f) {
4184 ast_frfree(old_frame);
4185 }
4186 }
4187
4188 if (ast_channel_readtrans(chan)
4190 f = ast_translate(ast_channel_readtrans(chan), f, 1);
4191 if (!f) {
4192 f = &ast_null_frame;
4193 }
4194 }
4195
4196 /* Second chance at hooking a linear frame, also the last chance */
4197 if (ast_channel_audiohooks(chan) && !hooked) {
4198 struct ast_frame *old_frame = f;
4199
4201 if (old_frame != f) {
4202 ast_frfree(old_frame);
4203 }
4204 }
4205
4206 /*
4207 * It is possible for the translation process on the channel to have
4208 * produced multiple frames from the single input frame we passed it; if
4209 * this happens, queue the additional frames *before* the frames we may
4210 * have queued earlier. if the readq was empty, put them at the head of
4211 * the queue, and if it was not, put them just after the frame that was
4212 * at the end of the queue.
4213 */
4214 if (AST_LIST_NEXT(f, frame_list)) {
4215 struct ast_frame *cur, *multi_frame = AST_LIST_NEXT(f, frame_list);
4216
4217 /* Mark these frames as being re-queued */
4218 for (cur = multi_frame; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
4220 }
4221
4222 if (!readq_tail) {
4223 ast_queue_frame_head(chan, multi_frame);
4224 } else {
4225 __ast_queue_frame(chan, multi_frame, 0, readq_tail);
4226 }
4227 ast_frfree(multi_frame);
4229 }
4230
4231 /*
4232 * Run generator sitting on the line if timing device not available
4233 * and synchronous generation of outgoing frames is necessary
4234 */
4236 break;
4237 case AST_FRAME_RTCP:
4238 /* Incoming RTCP feedback needs to get to the translator for
4239 * outgoing media, which means we treat it as an ast_write */
4240 if (ast_channel_writetrans(chan)) {
4242 }
4243 break;
4244 default:
4245 /* Just pass it on! */
4246 break;
4247 }
4248 } else {
4249 /* Make sure we always return NULL in the future */
4252 }
4253 if (cause)
4254 ast_channel_hangupcause_set(chan, cause);
4255 if (ast_channel_generator(chan))
4257 /* We no longer End the CDR here */
4258 }
4259
4260 /* High bit prints debugging */
4261 if (ast_channel_fin(chan) & DEBUGCHAN_FLAG)
4262 ast_frame_dump(ast_channel_name(chan), f, "<<");
4264
4265done:
4268
4270 /* The list gets recreated if audiohooks are added again later */
4273 }
4274 ast_channel_unlock(chan);
4275 return f;
4276}
@ AST_ALERT_READ_FATAL
Definition alertpipe.h:28
char digit
struct ast_frame * ast_audiohook_write_list(struct ast_channel *chan, struct ast_audiohook_list *audiohook_list, enum ast_audiohook_direction direction, struct ast_frame *frame)
Pass a frame off to be handled by the audiohook core.
Definition audiohook.c:1116
@ AST_AUDIOHOOK_DIRECTION_READ
Definition audiohook.h:49
int ast_audiohook_write_list_empty(struct ast_audiohook_list *audiohook_list)
Determine if a audiohook_list is empty or not.
Definition audiohook.c:1108
void ast_audiohook_detach_list(struct ast_audiohook_list *audiohook_list)
Detach audiohooks from list and destroy said list.
Definition audiohook.c:602
static int connected
Definition cdr_pgsql.c:73
static void send_dtmf_begin_event(struct ast_channel *chan, enum DtmfDirection direction, const char digit)
Definition channel.c:3375
int ast_set_read_format_path(struct ast_channel *chan, struct ast_format *raw_format, struct ast_format *core_format)
Set specific read path on channel.
Definition channel.c:5511
#define AST_MIN_DTMF_GAP
Definition channel.c:116
static void ast_read_generator_actions(struct ast_channel *chan, struct ast_frame *f)
Definition channel.c:3429
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to a channel's frame queue.
Definition channel.c:1171
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition channel.c:2059
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:4774
#define AST_DEFAULT_EMULATE_DTMF_DURATION
Definition channel.c:106
static void queue_dtmf_readq(struct ast_channel *chan, struct ast_frame *f)
Definition channel.c:3483
int ast_channel_stream_topology_changed(struct ast_channel *chan, struct ast_stream_topology *topology)
Provide notice to a channel that the stream topology has changed.
Definition channel.c:11068
void ast_party_connected_line_copy(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src)
Copy the source connected line information to the destination connected line.
Definition channel.c:2018
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame.
Definition channel.c:1289
static int should_skip_dtmf(struct ast_channel *chan)
Determine whether or not we should ignore DTMF in the readq.
Definition channel.c:3501
int ast_setstate(struct ast_channel *chan, enum ast_channel_state state)
Change the state of a channel.
Definition channel.c:7422
void ast_deactivate_generator(struct ast_channel *chan)
Definition channel.c:2892
int ast_sendtext(struct ast_channel *chan, const char *text)
Sends text to a channel.
Definition channel.c:4832
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:8853
int ast_check_hangup(struct ast_channel *chan)
Checks to see if a channel is needing hang up.
Definition channel.c:446
int ast_channel_is_bridged(const struct ast_channel *chan)
Determine if a channel is in a bridge.
Definition channel.c:10617
static void send_flash_event(struct ast_channel *chan)
Definition channel.c:3419
static void send_dtmf_end_event(struct ast_channel *chan, enum DtmfDirection direction, const char digit, long duration_ms)
Definition channel.c:3390
int ast_channel_connected_line_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *connected_info, int is_frame)
Run a connected line interception subroutine and update a channel's connected line information.
Definition channel.c:10406
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:4676
static void set_channel_answer_time(struct ast_channel *chan)
Definition channel.c:2627
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
static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, int head, struct ast_frame *after)
Definition channel.c:1041
static void send_wink_event(struct ast_channel *chan)
Definition channel.c:3424
int(* ast_timing_func_t)(const void *data)
Definition channel.h:919
struct ast_format * ast_channel_rawreadformat(struct ast_channel *chan)
#define DEBUGCHAN_FLAG
Definition channel.h:877
void * ast_channel_music_state(const struct ast_channel *chan)
unsigned int ast_channel_fin(const struct ast_channel *chan)
void * ast_channel_timingdata(const struct ast_channel *chan)
void ast_channel_dtmf_tv_set(struct ast_channel *chan, struct timeval *value)
int ast_channel_fdno(const struct ast_channel *chan)
struct ast_trans_pvt * ast_channel_readtrans(const struct ast_channel *chan)
struct ast_trans_pvt * ast_channel_writetrans(const struct ast_channel *chan)
char ast_channel_dtmf_digit_to_emulate(const struct ast_channel *chan)
struct ast_framehook_list * ast_channel_framehooks(const struct ast_channel *chan)
void ast_channel_audiohooks_set(struct ast_channel *chan, struct ast_audiohook_list *value)
@ AST_SOFTHANGUP_DEV
Definition channel.h:1141
struct ast_audiohook_list * ast_channel_audiohooks(const struct ast_channel *chan)
struct ast_stream_topology * ast_channel_get_stream_topology(const struct ast_channel *chan)
Retrieve the topology of streams on a channel.
void ast_channel_fdno_set(struct ast_channel *chan, int value)
ast_timing_func_t ast_channel_timingfunc(const struct ast_channel *chan)
void ast_channel_dtmf_digit_to_emulate_set(struct ast_channel *chan, char value)
void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
struct ast_stream * ast_channel_get_default_stream(struct ast_channel *chan, enum ast_media_type type)
Retrieve the default stream of a specific media type on a channel.
struct ast_generator * ast_channel_generator(const struct ast_channel *chan)
void ast_channel_emulate_dtmf_duration_set(struct ast_channel *chan, unsigned int value)
struct ast_frame * ast_channel_dtmff(struct ast_channel *chan)
@ AST_FLAG_ZOMBIE
Definition channel.h:1007
@ AST_FLAG_END_DTMF_ONLY
Definition channel.h:1027
@ AST_FLAG_EXCEPTION
Definition channel.h:1009
@ AST_FLAG_EMULATE_DTMF
Definition channel.h:1024
@ AST_FLAG_IN_DTMF
Definition channel.h:1021
@ AST_FLAG_DEFER_DTMF
Definition channel.h:1001
@ AST_FLAG_TIMINGDATA_IS_AO2_OBJ
Definition channel.h:1074
unsigned int ast_channel_emulate_dtmf_duration(const struct ast_channel *chan)
#define AST_JITTERBUFFER_FD
Definition channel.h:206
int ast_channel_softhangup_internal_flag(struct ast_channel *chan)
struct timeval * ast_channel_dtmf_tv(struct ast_channel *chan)
#define FRAMECOUNT_INC(x)
Definition channel.h:880
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
int ast_channel_fd_isset(const struct ast_channel *chan, int which)
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
@ AST_STATE_UP
enum ast_media_type ast_format_get_type(const struct ast_format *format)
Get the media type of a format.
Definition format.c:354
enum ast_format_cmp_res ast_format_cmp(const struct ast_format *format1, const struct ast_format *format2)
Compare two formats.
Definition format.c:201
@ AST_FORMAT_CMP_EQUAL
Definition format.h:36
int ast_format_cache_is_slinear(struct ast_format *format)
Determines if a format is one of the cached slin formats.
struct ast_frame * ast_framehook_list_read_event(struct ast_framehook_list *framehooks, struct ast_frame *frame)
This is used by the channel API push a frame read event to a channel's framehook list.
Definition framehook.c:318
unsigned int option_dtmfminduration
Definition options.c:84
@ AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO
@ AST_FRAME_READ_ACTION_SEND_TEXT
@ AST_FRAME_READ_ACTION_SEND_TEXT_DATA
void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
Definition main/frame.c:731
@ AST_FRFLAG_REQUEUED
@ AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE
@ AST_CONTROL_READ_ACTION
@ AST_CONTROL_ANSWER
@ AST_CONTROL_STREAM_TOPOLOGY_CHANGED
@ AST_CONTROL_CONNECTED_LINE
@ AST_CONTROL_FLASH
struct ast_frame ast_null_frame
Definition main/frame.c:79
#define LOG_ERROR
#define LOG_DTMF
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
int ast_stream_get_position(const struct ast_stream *stream)
Get the position of the stream in the topology.
Definition stream.c:500
struct ast_stream * ast_stream_topology_get_stream(const struct ast_stream_topology *topology, unsigned int position)
Get a specific stream from the topology.
Definition stream.c:791
struct ast_frame *(*const read)(struct ast_channel *chan)
Read a frame (or chain of frames from the same stream), in standard format (see frame....
Definition channel.h:754
struct ast_frame *(*const read_stream)(struct ast_channel *chan)
Read a frame (or chain of frames from the same stream), in standard format (see frame....
Definition channel.h:767
struct ast_frame *(*const exception)(struct ast_channel *chan)
Handle an exception, reading a frame.
Definition channel.h:785
Definition of a media format.
Definition format.c:43
struct ast_format * format
union ast_frame::@235 data
void(* digit)(struct ast_channel *chan, char digit)
Definition channel.h:237
Structure used to transport a message through the frame core.
Connected Line/Party information.
Definition channel.h:458
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition time.h:117
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_timer_ack(const struct ast_timer *handle, unsigned int quantity)
Acknowledge a timer event.
Definition timing.c:171
int ast_timer_set_rate(const struct ast_timer *handle, unsigned int rate)
Set the timing tick rate.
Definition timing.c:166
enum ast_timer_event ast_timer_get_event(const struct ast_timer *handle)
Retrieve timing event.
Definition timing.c:186
int ast_timer_disable_continuous(const struct ast_timer *handle)
Disable continuous mode.
Definition timing.c:181
ast_timer_event
Definition timing.h:57
@ AST_TIMING_EVENT_CONTINUOUS
Definition timing.h:59
@ AST_TIMING_EVENT_EXPIRED
Definition timing.h:58
struct ast_frame * ast_translate(struct ast_trans_pvt *tr, struct ast_frame *f, int consume)
translates one or more frames Apply an input frame into the translator and receive zero or one output...
Definition translate.c:623
#define ast_clear_flag(p, flag)
Definition utils.h:78
#define ast_set_flag(p, flag)
Definition utils.h:71

References __ast_queue_frame(), ast_control_read_action_payload::action, ao2_ref, AST_ALERT_READ_FATAL, ast_audiohook_detach_list(), AST_AUDIOHOOK_DIRECTION_READ, ast_audiohook_write_list(), ast_audiohook_write_list_empty(), ast_channel_alert_write(), ast_channel_audiohooks(), ast_channel_audiohooks_set(), ast_channel_connected(), ast_channel_connected_line_sub(), ast_channel_dtmf_digit_to_emulate(), ast_channel_dtmf_digit_to_emulate_set(), ast_channel_dtmf_tv(), ast_channel_dtmf_tv_set(), ast_channel_dtmff(), ast_channel_emulate_dtmf_duration(), ast_channel_emulate_dtmf_duration_set(), ast_channel_fd_isset(), ast_channel_fdno(), ast_channel_fdno_set(), ast_channel_fin(), ast_channel_fin_set(), ast_channel_flags(), ast_channel_framehooks(), ast_channel_generator(), ast_channel_get_default_stream(), ast_channel_get_stream_topology(), ast_channel_hangupcause_set(), ast_channel_internal_alert_read(), ast_channel_is_bridged(), ast_channel_lock, ast_channel_music_state(), ast_channel_name(), ast_channel_rawreadformat(), ast_channel_readformat(), ast_channel_readq(), ast_channel_readtrans(), ast_channel_softhangup_internal_flag(), ast_channel_softhangup_internal_flag_add(), ast_channel_stream_topology_changed(), ast_channel_timer(), ast_channel_timingdata(), ast_channel_timingfd(), ast_channel_timingfunc(), ast_channel_unlock, ast_channel_writetrans(), ast_check_hangup(), ast_clear_flag, ast_connected_line_parse_data(), AST_CONTROL_ANSWER, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_END_OF_Q, AST_CONTROL_FLASH, AST_CONTROL_HANGUP, AST_CONTROL_READ_ACTION, AST_CONTROL_STREAM_TOPOLOGY_CHANGED, AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE, AST_CONTROL_WINK, ast_deactivate_generator(), ast_debug, AST_DEFAULT_EMULATE_DTMF_DURATION, AST_FLAG_DEFER_DTMF, AST_FLAG_EMULATE_DTMF, AST_FLAG_END_DTMF_ONLY, AST_FLAG_EXCEPTION, AST_FLAG_IN_DTMF, AST_FLAG_TIMINGDATA_IS_AO2_OBJ, AST_FLAG_ZOMBIE, ast_format_cache_is_slinear(), ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_get_type(), AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, ast_frame_dump(), AST_FRAME_NULL, AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO, AST_FRAME_READ_ACTION_SEND_TEXT, AST_FRAME_READ_ACTION_SEND_TEXT_DATA, AST_FRAME_RTCP, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_framehook_list_read_event(), AST_FRFLAG_REQUEUED, ast_frfree, ast_indicate_data(), AST_JITTERBUFFER_FD, AST_LIST_EMPTY, AST_LIST_FIRST, AST_LIST_LAST, AST_LIST_NEXT, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log, AST_MIN_DTMF_GAP, ast_null_frame, ast_party_connected_line_copy(), ast_party_connected_line_free(), ast_party_connected_line_init(), ast_queue_control(), ast_queue_frame(), ast_queue_frame_head(), ast_read_generator_actions(), ast_sendtext(), ast_sendtext_data(), ast_set_flag, ast_set_read_format_path(), ast_setstate(), AST_SOFTHANGUP_DEV, AST_STATE_UP, ast_stream_get_position(), ast_stream_topology_get_stream(), ast_test_flag, ast_timer_ack(), ast_timer_disable_continuous(), ast_timer_get_event(), ast_timer_set_rate(), AST_TIMING_EVENT_CONTINUOUS, AST_TIMING_EVENT_EXPIRED, AST_TIMING_FD, ast_translate(), ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), connected, ast_frame::data, DEBUGCHAN_FLAG, digit, ast_generator::digit, done, DTMF_RECEIVED, ast_channel_tech::exception, ast_frame_subclass::format, FRAMECOUNT_INC, ast_frame::frametype, ast_frame_subclass::integer, ast_frame::len, LOG_DTMF, LOG_ERROR, LOG_WARNING, NULL, option_dtmfminduration, ast_control_read_action_payload::payload, ast_control_read_action_payload::payload_size, ast_frame::ptr, queue_dtmf_readq(), ast_channel_tech::read, ast_channel_tech::read_stream, send_dtmf_begin_event(), send_dtmf_end_event(), send_flash_event(), send_wink_event(), set_channel_answer_time(), should_skip_dtmf(), should_trigger_dtmf_emulating(), ast_frame::stream_num, ast_frame::subclass, timer, and ast_frame::uint32.

Referenced by ast_read(), ast_read_noaudio(), ast_read_stream(), and ast_read_stream_noaudio().

◆ __ast_request_and_dial()

struct ast_channel * __ast_request_and_dial ( const char *  type,
struct ast_format_cap cap,
const struct ast_assigned_ids assignedids,
const struct ast_channel requestor,
const char *  addr,
int  timeout,
int *  reason,
const char *  cid_num,
const char *  cid_name,
struct outgoing_helper oh 
)

Request a channel of a given type, with data as optional information used by the low level module and attempt to place a call on it.

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

Definition at line 5997 of file channel.c.

5998{
5999 int dummy_outstate;
6000 int cause = 0;
6001 struct ast_channel *chan;
6002 int res = 0;
6003 int last_subclass = 0;
6005
6006 if (outstate)
6007 *outstate = 0;
6008 else
6009 outstate = &dummy_outstate; /* make outstate always a valid pointer */
6010
6011 chan = ast_request(type, cap, assignedids, requestor, addr, &cause);
6012 if (!chan) {
6013 ast_log(LOG_NOTICE, "Unable to request channel %s/%s\n", type, addr);
6014 handle_cause(cause, outstate);
6015 return NULL;
6016 }
6017
6018 if (oh) {
6019 if (oh->vars) {
6020 ast_set_variables(chan, oh->vars);
6021 }
6022 if (!ast_strlen_zero(oh->cid_num) && !ast_strlen_zero(oh->cid_name)) {
6023 /*
6024 * Use the oh values instead of the function parameters for the
6025 * outgoing CallerID.
6026 */
6027 cid_num = oh->cid_num;
6028 cid_name = oh->cid_name;
6029 }
6030 if (oh->parent_channel) {
6031 /* Safely inherit variables and datastores from the parent channel. */
6037 ast_channel_unlock(chan);
6038 }
6039 if (!ast_strlen_zero(oh->account)) {
6040 ast_channel_lock(chan);
6042 ast_channel_accountcode_set(chan, oh->account);
6043 ast_channel_peeraccount_set(chan, oh->account);
6045 ast_channel_unlock(chan);
6046 }
6047 }
6048
6049 /*
6050 * It seems strange to set the CallerID on an outgoing call leg
6051 * to whom we are calling, but this function's callers are doing
6052 * various Originate methods. This call leg goes to the local
6053 * user. Once the local user answers, the dialplan needs to be
6054 * able to access the CallerID from the CALLERID function as if
6055 * the local user had placed this call.
6056 */
6057 ast_set_callerid(chan, cid_num, cid_name, cid_num);
6058
6059 ast_channel_lock(chan);
6061 ast_channel_unlock(chan);
6063 if (cid_num) {
6064 connected.id.number.valid = 1;
6065 connected.id.number.str = (char *) cid_num;
6067 }
6068 if (cid_name) {
6069 connected.id.name.valid = 1;
6070 connected.id.name.str = (char *) cid_name;
6072 }
6074 if (requestor) {
6075 ast_channel_lock_both(chan, (struct ast_channel *) requestor);
6077 ast_channel_unlock(chan);
6078 ast_channel_unlock((struct ast_channel *) requestor);
6079 }
6080
6081 if (ast_call(chan, addr, 0)) { /* ast_call failed... */
6082 ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, addr);
6083 } else {
6084 struct timeval start = ast_tvnow();
6085 res = 1; /* mark success in case chan->_state is already AST_STATE_UP */
6086 while (timeout && ast_channel_state(chan) != AST_STATE_UP) {
6087 struct ast_frame *f;
6088 int ms = ast_remaining_ms(start, timeout);
6089
6090 res = ast_waitfor(chan, ms);
6091 if (res == 0) { /* timeout, treat it like ringing */
6092 *outstate = AST_CONTROL_RINGING;
6093 break;
6094 }
6095 if (res < 0) /* error or done */
6096 break;
6098 if (!(chan = ast_call_forward(NULL, chan, NULL, cap, oh, outstate))) {
6099 return NULL;
6100 }
6101 continue;
6102 }
6103
6104 f = ast_read(chan);
6105 if (!f) {
6106 *outstate = AST_CONTROL_HANGUP;
6107 res = 0;
6108 break;
6109 }
6110 if (f->frametype == AST_FRAME_CONTROL) {
6111 switch (f->subclass.integer) {
6112 case AST_CONTROL_RINGING: /* record but keep going */
6113 *outstate = f->subclass.integer;
6114 break;
6115
6116 case AST_CONTROL_BUSY:
6117 *outstate = f->subclass.integer;
6118 timeout = 0;
6119 break;
6120
6122 *outstate = AST_CONTROL_CONGESTION;
6123 timeout = 0;
6124 break;
6125
6127 *outstate = f->subclass.integer;
6128 timeout = 0;
6129 break;
6130
6131 case AST_CONTROL_ANSWER:
6132 *outstate = f->subclass.integer;
6133 timeout = 0; /* trick to force exit from the while() */
6134 break;
6135
6138 break;
6139
6141 if (oh && oh->connect_on_early_media) {
6142 *outstate = f->subclass.integer;
6143 timeout = 0; /* trick to force exit from the while() */
6144 break;
6145 }
6146 /* Fallthrough */
6147 /* Ignore these */
6149 case AST_CONTROL_HOLD:
6150 case AST_CONTROL_UNHOLD:
6156 case AST_CONTROL_CC:
6157 case -1: /* Ignore -- just stopping indications */
6158 break;
6159
6160 default:
6161 ast_log(LOG_NOTICE, "Don't know what to do with control frame %d\n", f->subclass.integer);
6162 }
6163 last_subclass = f->subclass.integer;
6164 }
6165 ast_frfree(f);
6166 }
6167 }
6168
6169 /* Final fixups */
6170 if (oh) {
6171 if (!ast_strlen_zero(oh->context))
6173 if (!ast_strlen_zero(oh->exten))
6174 ast_channel_exten_set(chan, oh->exten);
6175 if (oh->priority)
6177 }
6178 if (ast_channel_state(chan) == AST_STATE_UP)
6179 *outstate = AST_CONTROL_ANSWER;
6180
6181 if (res <= 0) {
6182 ast_channel_lock(chan);
6183 if (AST_CONTROL_RINGING == last_subclass) {
6185 }
6186 ast_channel_unlock(chan);
6187 ast_hangup(chan);
6188 chan = NULL;
6189 }
6190 return chan;
6191}
#define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED
Definition callerid.h:437
#define AST_CAUSE_NO_ANSWER
Definition causes.h:109
static const char type[]
int ast_call(struct ast_channel *chan, const char *addr, int timeout)
Make a call.
Definition channel.c:6480
static void handle_cause(int cause, int *outstate)
Definition channel.c:5872
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:5921
void ast_hangup(struct ast_channel *chan)
Hangup a channel.
Definition channel.c:2540
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:8376
void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars)
adds a list of channel variables to a channel
Definition channel.c:8183
int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to)
Inherit datastores from a parent to a child.
Definition channel.c:2359
void ast_channel_req_accountcodes(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship)
Setup new channel accountcodes from the requestor channel after ast_request().
Definition channel.c:6453
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:7370
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:6795
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:4368
void ast_party_connected_line_set_init(struct ast_party_connected_line *init, const struct ast_party_connected_line *guide)
Initialize the given connected line structure using the given guide for a set update operation.
Definition channel.c:2032
struct ast_channel * ast_request(const char *type, struct ast_format_cap *request_cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
Requests a channel.
Definition channel.c:6373
@ AST_CHANNEL_REQUESTOR_BRIDGE_PEER
Definition channel.h:1525
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition channel.h:2990
@ AST_FLAG_ORIGINATED
Definition channel.h:1059
const char * ast_channel_call_forward(const struct ast_channel *chan)
@ AST_CONTROL_SRCUPDATE
@ AST_CONTROL_PROGRESS
@ AST_CONTROL_VIDUPDATE
@ AST_CONTROL_PROCEEDING
@ AST_CONTROL_REDIRECTING
@ AST_CONTROL_CONGESTION
@ AST_CONTROL_RINGING
@ AST_CONTROL_SRCCHANGE
@ AST_CONTROL_INCOMPLETE
@ AST_CONTROL_PVT_CAUSE_CODE
#define LOG_NOTICE
int ast_max_forwards_decrement(struct ast_channel *chan)
Decrement the max forwards count for a particular channel.
const char * cid_num
Definition channel.h:1129
struct ast_variable * vars
Definition channel.h:1132
int connect_on_early_media
Definition channel.h:1128
const char * account
Definition channel.h:1131
const char * cid_name
Definition channel.h:1130
const char * exten
Definition channel.h:1126
const char * context
Definition channel.h:1125
struct ast_channel * parent_channel
Definition channel.h:1133

References outgoing_helper::account, ast_call(), ast_call_forward(), AST_CAUSE_NO_ANSWER, ast_channel_call_forward(), ast_channel_connected(), ast_channel_context_set(), ast_channel_datastore_inherit(), ast_channel_exten_set(), ast_channel_flags(), ast_channel_hangupcause_hash_set(), ast_channel_hangupcause_set(), ast_channel_inherit_variables(), ast_channel_lock, ast_channel_lock_both, ast_channel_priority_set(), ast_channel_req_accountcodes(), AST_CHANNEL_REQUESTOR_BRIDGE_PEER, ast_channel_set_connected_line(), ast_channel_stage_snapshot(), ast_channel_stage_snapshot_done(), ast_channel_unlock, AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CC, AST_CONTROL_CONGESTION, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_INCOMPLETE, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_PVT_CAUSE_CODE, AST_CONTROL_REDIRECTING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_CONTROL_UNHOLD, AST_CONTROL_VIDUPDATE, AST_FLAG_ORIGINATED, AST_FRAME_CONTROL, ast_frfree, ast_hangup(), ast_log, ast_max_forwards_decrement(), ast_party_connected_line_set_init(), AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, ast_read(), ast_remaining_ms(), ast_request(), ast_set_callerid(), ast_set_flag, ast_set_variables(), AST_STATE_UP, ast_strlen_zero(), ast_tvnow(), ast_waitfor(), outgoing_helper::cid_name, outgoing_helper::cid_num, outgoing_helper::connect_on_early_media, connected, outgoing_helper::context, ast_frame::data, ast_frame::datalen, outgoing_helper::exten, ast_frame::frametype, handle_cause(), ast_frame_subclass::integer, LOG_NOTICE, NULL, outgoing_helper::parent_channel, outgoing_helper::priority, ast_frame::ptr, ast_frame::subclass, type, and outgoing_helper::vars.

Referenced by announce_to_dial(), and ast_request_and_dial().

◆ adjust_frame_for_plc()

static void adjust_frame_for_plc ( struct ast_channel chan,
struct ast_frame frame,
struct ast_datastore datastore 
)
static

Definition at line 5076 of file channel.c.

5077{
5078 int num_new_samples = frame->samples;
5079 struct plc_ds *plc = datastore->data;
5080
5081 /* As a general note, let me explain the somewhat odd calculations used when taking
5082 * the frame offset into account here. According to documentation in frame.h, the frame's
5083 * offset field indicates the number of bytes that the audio is offset. The plc->samples_buf
5084 * is not an array of bytes, but rather an array of 16-bit integers since it holds SLIN
5085 * samples. So I had two choices to make here with the offset.
5086 *
5087 * 1. Make the offset AST_FRIENDLY_OFFSET bytes. The main downside for this is that
5088 * I can't just add AST_FRIENDLY_OFFSET to the plc->samples_buf and have the pointer
5089 * arithmetic come out right. I would have to do some odd casting or division for this to
5090 * work as I wanted.
5091 * 2. Make the offset AST_FRIENDLY_OFFSET * 2 bytes. This allows the pointer arithmetic
5092 * to work out better with the plc->samples_buf. The downside here is that the buffer's
5093 * allocation contains an extra 64 bytes of unused space.
5094 *
5095 * I decided to go with option 2. This is why in the calloc statement and the statement that
5096 * sets the frame's offset, AST_FRIENDLY_OFFSET is multiplied by 2.
5097 */
5098
5099 /* If this audio frame has no samples to fill in, ignore it */
5100 if (!num_new_samples) {
5101 return;
5102 }
5103
5104 /* First, we need to be sure that our buffer is large enough to accommodate
5105 * the samples we need to fill in. This will likely only occur on the first
5106 * frame we write.
5107 */
5108 if (plc->num_samples < num_new_samples) {
5109 ast_free(plc->samples_buf);
5110 plc->samples_buf = ast_calloc(1, (num_new_samples * sizeof(*plc->samples_buf)) + (AST_FRIENDLY_OFFSET * 2));
5111 if (!plc->samples_buf) {
5112 ast_channel_datastore_remove(chan, datastore);
5113 ast_datastore_free(datastore);
5114 return;
5115 }
5116 plc->num_samples = num_new_samples;
5117 }
5118
5119 if (frame->datalen == 0) {
5121 frame->data.ptr = plc->samples_buf + AST_FRIENDLY_OFFSET;
5122 frame->datalen = num_new_samples * 2;
5123 frame->offset = AST_FRIENDLY_OFFSET * 2;
5124 } else {
5125 plc_rx(&plc->plc_state, frame->data.ptr, frame->samples);
5126 }
5127}
#define ast_free(a)
Definition astmm.h:180
#define ast_calloc(num, len)
A wrapper for calloc()
Definition astmm.h:202
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
Definition channel.c:2385
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Definition datastore.c:68
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
int plc_fillin(plc_state_t *s, int16_t amp[], int len)
Fill-in a block of missing audio samples.
Definition plc.c:175
int plc_rx(plc_state_t *s, int16_t amp[], int len)
Process a block of received audio samples.
Definition plc.c:132
void * data
Definition datastore.h:66
int16_t * samples_buf
Definition channel.c:5056
size_t num_samples
Definition channel.c:5060
plc_state_t plc_state
Definition channel.c:5061

References ast_calloc, ast_channel_datastore_remove(), ast_datastore_free(), ast_free, AST_FRIENDLY_OFFSET, ast_datastore::data, ast_frame::data, ast_frame::datalen, plc_ds::num_samples, ast_frame::offset, plc_fillin(), plc_rx(), plc_ds::plc_state, ast_frame::ptr, ast_frame::samples, and plc_ds::samples_buf.

Referenced by apply_plc().

◆ apply_plc()

static void apply_plc ( struct ast_channel chan,
struct ast_frame frame 
)
static

Definition at line 5129 of file channel.c.

5130{
5131 struct ast_datastore *datastore;
5132 struct plc_ds *plc;
5133
5134 datastore = ast_channel_datastore_find(chan, &plc_ds_info, NULL);
5135 if (datastore) {
5136 plc = datastore->data;
5137 adjust_frame_for_plc(chan, frame, datastore);
5138 return;
5139 }
5140
5141 datastore = ast_datastore_alloc(&plc_ds_info, NULL);
5142 if (!datastore) {
5143 return;
5144 }
5145 plc = ast_calloc(1, sizeof(*plc));
5146 if (!plc) {
5147 ast_datastore_free(datastore);
5148 return;
5149 }
5150 datastore->data = plc;
5151 ast_channel_datastore_add(chan, datastore);
5152 adjust_frame_for_plc(chan, frame, datastore);
5153}
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition channel.c:2376
static const struct ast_datastore_info plc_ds_info
Definition channel.c:5071
static void adjust_frame_for_plc(struct ast_channel *chan, struct ast_frame *frame, struct ast_datastore *datastore)
Definition channel.c:5076
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
Definition channel.c:2390
#define ast_datastore_alloc(info, uid)
Definition datastore.h:85
Structure for a data store object.
Definition datastore.h:64

References adjust_frame_for_plc(), ast_calloc, ast_channel_datastore_add(), ast_channel_datastore_find(), ast_datastore_alloc, ast_datastore_free(), ast_datastore::data, NULL, and plc_ds_info.

Referenced by ast_write_stream().

◆ ast_activate_generator()

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

Activate a given generator

Definition at line 2955 of file channel.c.

2956{
2957 int res = 0;
2958 void *generatordata = NULL;
2959
2960 ast_channel_lock(chan);
2961 if (ast_channel_generatordata(chan)) {
2962 struct ast_generator *generator_old = ast_channel_generator(chan);
2963
2964 if (generator_old && generator_old->release) {
2965 generator_old->release(chan, ast_channel_generatordata(chan));
2966 }
2967 }
2968 if (gen->alloc && !(generatordata = gen->alloc(chan, params))) {
2969 res = -1;
2970 }
2971 ast_channel_generatordata_set(chan, generatordata);
2972 if (!res) {
2973 ast_settimeout(chan, 50, generator_force, chan);
2975 }
2976 ast_channel_unlock(chan);
2977
2978 ast_prod(chan);
2979
2980 return res;
2981}
static struct ast_generator gen
int ast_prod(struct ast_channel *chan)
Send empty audio to prime a channel driver.
Definition channel.c:5023
static int generator_force(const void *data)
Definition channel.c:2920
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:3184
void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator *value)
void ast_channel_generatordata_set(struct ast_channel *chan, void *value)
void * ast_channel_generatordata(const struct ast_channel *chan)
void *(* alloc)(struct ast_channel *chan, void *params)
Definition channel.h:228
void(* release)(struct ast_channel *chan, void *data)
Definition channel.h:230

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

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

◆ ast_active_channels()

int ast_active_channels ( void  )

returns number of active/allocated channels

Returns
number of channels available for lookup

Definition at line 500 of file channel.c.

501{
503}
static int active_channels(struct ast_channelstorage_instance *driver, int rdlock)
returns number of active/allocated channels

References active_channels(), CHANNELSTORAGE_API, and current_channel_storage_instance.

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

◆ ast_answer()

int ast_answer ( struct ast_channel chan)

Answer a channel.

Parameters
chanchannel to answer

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

Note
The channel passed does not need to be locked, but is locked by the function when needed.
This function will wait up to 500 milliseconds for media to arrive on the channel before returning to the caller, so that the caller can properly assume the channel is 'ready' for media flow.
Return values
0on success
non-zeroon failure

Definition at line 2805 of file channel.c.

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

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

Referenced by agent_login_exec(), agi_exec_full(), alarmreceiver_exec(), announce_request(), app_exec(), app_exec(), ast_auto_answer(), ast_bridge_add_channel(), ast_do_pickup(), ast_pickup_call(), auth_exec(), background_detect_exec(), bridge_channel_handle_control(), bridge_parking_push(), bridgeadd_exec(), bridgewait_exec(), common_exec(), conf_exec(), conf_start_record(), confbridge_exec(), count_exec(), dial_exec_full(), dictate_exec(), directory_exec(), disa_exec(), eivr_comm(), handle_answer(), leave_voicemail(), local_call(), media_request_helper(), minivm_accmess_exec(), minivm_greet_exec(), minivm_record_exec(), old_milliwatt_exec(), park_app_exec(), parked_call_app_exec(), pbx_builtin_background(), playback_exec(), privacy_exec(), read_exec(), readexten_exec(), receivefax_exec(), record_exec(), sayunixtime_exec(), send_waveform_to_channel(), sendfax_exec(), setup_privacy_args(), skel_exec(), sla_station_exec(), speech_background(), testclient_exec(), testserver_exec(), vm_exec(), vm_execmain(), vm_playmsgexec(), waitfor_exec(), and zapateller_exec().

◆ ast_auto_answer()

int ast_auto_answer ( struct ast_channel chan)
inline

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

Parameters
chanchannel to answer

See ast_answer()

Return values
0on success
non-zeroon failure

Definition at line 2811 of file channel.c.

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

References ast_answer(), and AST_STATE_UP.

Referenced by record_file(), and senddtmf_exec().

◆ ast_call()

int ast_call ( struct ast_channel chan,
const char *  addr,
int  timeout 
)

Make a call.

Note
Absolutely NO channel locks should be held before calling this function.
Parameters
chanwhich channel to make the call on
addrdestination of the call
timeouttime to wait on for connect (Doesn't seem to be used.)

Place a call, take no longer than timeout ms.

Return values
0on success
-1on failure

Definition at line 6480 of file channel.c.

6481{
6482 /* Place an outgoing call, but don't wait any longer than timeout ms before returning.
6483 If the remote end does not answer within the timeout, then do NOT hang up, but
6484 return anyway. */
6485 int res = -1;
6486 /* Stop if we're a zombie or need a soft hangup */
6487 ast_channel_lock(chan);
6489 if (ast_channel_tech(chan)->call)
6490 res = ast_channel_tech(chan)->call(chan, addr, timeout);
6492 }
6493 ast_channel_unlock(chan);
6494 return res;
6495}
static int call(void *data)
@ AST_FLAG_OUTGOING
Definition channel.h:1019
int(*const call)(struct ast_channel *chan, const char *addr, int timeout)
Make a call.
Definition channel.h:721

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

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

◆ ast_call_forward()

struct ast_channel * ast_call_forward ( struct ast_channel caller,
struct ast_channel orig,
int *  timeout,
struct ast_format_cap cap,
struct outgoing_helper oh,
int *  outstate 
)

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

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

Definition at line 5921 of file channel.c.

5922{
5923 char tmpchan[256];
5924 char forwarder[AST_CHANNEL_NAME];
5925 struct ast_channel *new_chan = NULL;
5926 char *data, *type;
5927 int cause = 0;
5928 int res;
5929
5930 /* gather data and request the new forward channel */
5931 ast_copy_string(tmpchan, ast_channel_call_forward(orig), sizeof(tmpchan));
5932 ast_copy_string(forwarder, ast_channel_name(orig), sizeof(forwarder));
5933 if ((data = strchr(tmpchan, '/'))) {
5934 *data++ = '\0';
5935 type = tmpchan;
5936 } else {
5937 const char *forward_context;
5938 ast_channel_lock(orig);
5939 forward_context = pbx_builtin_getvar_helper(orig, "FORWARD_CONTEXT");
5940 snprintf(tmpchan, sizeof(tmpchan), "%s@%s", ast_channel_call_forward(orig), S_OR(forward_context, ast_channel_context(orig)));
5941 ast_channel_unlock(orig);
5942 data = tmpchan;
5943 type = "Local";
5944 }
5945 if (!(new_chan = ast_request(type, cap, NULL, orig, data, &cause))) {
5946 ast_log(LOG_NOTICE, "Unable to create channel for call forward to '%s/%s' (cause = %d)\n", type, data, cause);
5947 handle_cause(cause, outstate);
5948 ast_hangup(orig);
5949 return NULL;
5950 }
5951
5952 /* Copy/inherit important information into new channel */
5953 if (oh) {
5954 if (oh->vars) {
5955 ast_set_variables(new_chan, oh->vars);
5956 }
5957 if (oh->parent_channel) {
5958 call_forward_inherit(new_chan, oh->parent_channel, orig);
5959 }
5960 if (!ast_strlen_zero(oh->account)) {
5961 ast_channel_lock(new_chan);
5963 ast_channel_accountcode_set(new_chan, oh->account);
5964 ast_channel_peeraccount_set(new_chan, oh->account);
5966 ast_channel_unlock(new_chan);
5967 }
5968 } else if (caller) { /* no outgoing helper so use caller if available */
5969 call_forward_inherit(new_chan, caller, orig);
5970 }
5971
5972 ast_channel_lock_both(orig, new_chan);
5974 pbx_builtin_setvar_helper(new_chan, "FORWARDERNAME", forwarder);
5978 ast_channel_unlock(new_chan);
5979 ast_channel_unlock(orig);
5980
5981 /* call new channel */
5982 res = ast_call(new_chan, data, 0);
5983 if (timeout) {
5984 *timeout = res;
5985 }
5986 if (res) {
5987 ast_log(LOG_NOTICE, "Unable to call forward to channel %s/%s\n", type, (char *)data);
5988 ast_hangup(orig);
5989 ast_hangup(new_chan);
5990 return NULL;
5991 }
5992 ast_hangup(orig);
5993
5994 return new_chan;
5995}
static void call_forward_inherit(struct ast_channel *new_chan, struct ast_channel *parent, struct ast_channel *orig)
Definition channel.c:5893
void ast_channel_set_flag(struct ast_channel *chan, unsigned int flag)
Set a flag on a channel.
Definition channel.c:11099
void ast_party_redirecting_copy(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src)
Copy the source redirecting information to the destination redirecting.
Definition channel.c:2122
@ AST_CHANNEL_REQUESTOR_REPLACEMENT
Definition channel.h:1527
const char * ast_channel_context(const struct ast_channel *chan)
#define AST_CHANNEL_NAME
Definition channel.h:173
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition strings.h:425
const char * data
struct ast_party_caller caller
Channel Caller ID information.

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

Referenced by __ast_request_and_dial().

◆ ast_cause2str()

const char * ast_cause2str ( int  cause)

Gives the string form of a given hangup cause.

Gives the string form of a given cause code.

Definition at line 613 of file channel.c.

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

References ARRAY_LEN, causes, and causes_map::desc.

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

◆ ast_change_name()

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

Change channel name.

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

Definition at line 6783 of file channel.c.

6784{
6785 /* We must re-link, as the hash value will change here. */
6787 ast_channel_lock(chan);
6789 __ast_change_name_nolink(chan, newname);
6791 ast_channel_unlock(chan);
6793}
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:6761
#define remove

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

◆ ast_channel_amaflags2string()

const char * ast_channel_amaflags2string ( enum ama_flags  flags)

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

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

Definition at line 4395 of file channel.c.

4396{
4397 switch (flag) {
4398 case AST_AMA_OMIT:
4399 return "OMIT";
4400 case AST_AMA_BILLING:
4401 return "BILLING";
4403 return "DOCUMENTATION";
4404 default:
4405 return "Unknown";
4406 }
4407}
@ AST_AMA_DOCUMENTATION
Definition channel.h:1201
@ AST_AMA_OMIT
Definition channel.h:1199
@ AST_AMA_BILLING
Definition channel.h:1200
long int flag
Definition f2c.h:83

References AST_AMA_BILLING, AST_AMA_DOCUMENTATION, and AST_AMA_OMIT.

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

◆ ast_channel_bridge_peer()

struct ast_channel * ast_channel_bridge_peer ( struct ast_channel chan)

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

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

Definition at line 10636 of file channel.c.

10637{
10638 struct ast_channel *peer;
10639 struct ast_bridge *bridge;
10640
10641 /* Get the bridge the channel is in. */
10642 ast_channel_lock(chan);
10643 bridge = ast_channel_get_bridge(chan);
10644 ast_channel_unlock(chan);
10645 if (!bridge) {
10646 return NULL;
10647 }
10648
10649 peer = ast_bridge_peer(bridge, chan);
10650 ao2_ref(bridge, -1);
10651 return peer;
10652}
struct ast_channel * ast_bridge_peer(struct ast_bridge *bridge, struct ast_channel *chan)
Get the channel's bridge peer only if the bridge is two-party.
Definition bridge.c:4154
struct ast_bridge * ast_channel_get_bridge(const struct ast_channel *chan)
Get the bridge associated with a channel.
Definition channel.c:10606
Structure that contains information about a bridge.
Definition bridge.h:353

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

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

◆ ast_channel_callback()

struct ast_channel * ast_channel_callback ( ao2_callback_data_fn cb_fn,
void *  arg,
void *  data,
int  ao2_flags 
)

Call a function with every active channel.

Channel search functions

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

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

Since
1.8

Definition at line 1336 of file channel.c.

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

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

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

◆ ast_channel_cc_params_init()

int ast_channel_cc_params_init ( struct ast_channel chan,
const struct ast_cc_config_params base_params 
)

Set up datastore with CCSS parameters for a channel.

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

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

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

Definition at line 10519 of file channel.c.

10521{
10522 struct ast_cc_config_params *cc_params;
10523 struct ast_datastore *cc_datastore;
10524
10525 if (!(cc_params = ast_cc_config_params_init())) {
10526 return -1;
10527 }
10528
10529 if (!(cc_datastore = ast_datastore_alloc(&cc_channel_datastore_info, NULL))) {
10531 return -1;
10532 }
10533
10534 if (base_params) {
10535 ast_cc_copy_config_params(cc_params, base_params);
10536 }
10537 cc_datastore->data = cc_params;
10538 ast_channel_datastore_add(chan, cc_datastore);
10539 return 0;
10540}
#define ast_cc_config_params_init()
Allocate and initialize an ast_cc_config_params structure.
Definition ccss.h:135
void ast_cc_config_params_destroy(struct ast_cc_config_params *params)
Free memory from CCSS configuration params.
Definition ccss.c:714
void ast_cc_copy_config_params(struct ast_cc_config_params *dest, const struct ast_cc_config_params *src)
copy CCSS configuration parameters from one structure to another
Definition ccss.c:876
static const struct ast_datastore_info cc_channel_datastore_info
Definition channel.c:10513

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

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

◆ ast_channel_clear_flag()

void ast_channel_clear_flag ( struct ast_channel chan,
unsigned int  flag 
)

Clear a flag on a channel.

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

Definition at line 11106 of file channel.c.

11107{
11108 ast_channel_lock(chan);
11110 ast_channel_unlock(chan);
11111}

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

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

◆ ast_channel_clear_softhangup()

void ast_channel_clear_softhangup ( struct ast_channel chan,
int  flag 
)

Clear a set of softhangup flags from a channel.

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

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

Definition at line 2423 of file channel.c.

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

References ast_channel_lock, ast_channel_readq(), ast_channel_softhangup_internal_flag(), ast_channel_softhangup_internal_flag_clear(), ast_channel_unlock, AST_CONTROL_END_OF_Q, AST_FRAME_CONTROL, ast_frfree, AST_LIST_LAST, AST_LIST_REMOVE, ast_frame::frametype, ast_frame_subclass::integer, and ast_frame::subclass.

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

◆ ast_channel_close_storage()

void ast_channel_close_storage ( void  )

Definition at line 8002 of file channel.c.

8003{
8005}
void ast_channelstorage_close(struct ast_channelstorage_instance *storage_instance)

References ast_channelstorage_close(), and current_channel_storage_instance.

◆ ast_channel_cmpwhentohangup_tv()

int ast_channel_cmpwhentohangup_tv ( struct ast_channel chan,
struct timeval  offset 
)

Compare a offset with when to hangup channel.

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

Definition at line 524 of file channel.c.

525{
526 struct timeval whentohangup;
527
529 return ast_tvzero(offset) ? 0 : -1;
530
531 if (ast_tvzero(offset))
532 return 1;
533
534 whentohangup = ast_tvadd(offset, ast_tvnow());
535
536 return ast_tvdiff_ms(whentohangup, *ast_channel_whentohangup(chan));
537}
struct timeval * ast_channel_whentohangup(struct ast_channel *chan)
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
Definition extconf.c:2280

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

◆ ast_channel_connected_line_sub()

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

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

Since
11

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

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

Definition at line 10406 of file channel.c.

10407{
10408 const char *sub;
10409 const char *sub_args;
10410 int retval;
10411
10412 ast_channel_lock(sub_chan);
10413 sub = pbx_builtin_getvar_helper(sub_chan, "CONNECTED_LINE_SEND_SUB");
10414 sub = ast_strdupa(S_OR(sub, ""));
10415 sub_args = pbx_builtin_getvar_helper(sub_chan, "CONNECTED_LINE_SEND_SUB_ARGS");
10416 sub_args = ast_strdupa(S_OR(sub_args, ""));
10417
10418 if (ast_strlen_zero(sub)) {
10419 ast_channel_unlock(sub_chan);
10420 return -1;
10421 }
10422
10423 if (is_frame) {
10424 const struct ast_frame *frame = connected_info;
10425
10427 } else {
10428 const struct ast_party_connected_line *connected = connected_info;
10429
10431 }
10432 ast_channel_unlock(sub_chan);
10433
10435 retval = ast_app_run_sub(autoservice_chan, sub_chan, sub, sub_args, 0);
10437 if (!retval) {
10438 struct ast_party_connected_line saved_connected;
10439
10440 ast_party_connected_line_init(&saved_connected);
10441 ast_channel_lock(sub_chan);
10442 ast_party_connected_line_copy(&saved_connected, ast_channel_connected(sub_chan));
10443 ast_channel_unlock(sub_chan);
10444 ast_channel_update_connected_line(sub_chan, &saved_connected, NULL);
10445 ast_party_connected_line_free(&saved_connected);
10446 }
10447
10448 return retval;
10449}
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:9161
static void channel_set_intercept_mode(int in_intercept_mode)
Definition channel.c:10390
int ast_app_run_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_location, const char *sub_args, int ignore_hangup)
Run a subroutine on a channel, placing an optional second channel into autoservice.
Definition main/app.c:328
static struct stasis_subscription * sub
Statsd channel stats. Exmaple of how to subscribe to Stasis events.

References ast_app_run_sub(), ast_channel_connected(), ast_channel_lock, ast_channel_unlock, ast_channel_update_connected_line(), ast_connected_line_parse_data(), ast_party_connected_line_copy(), ast_party_connected_line_free(), ast_party_connected_line_init(), ast_strdupa, ast_strlen_zero(), channel_set_intercept_mode(), connected, ast_frame::data, ast_frame::datalen, NULL, pbx_builtin_getvar_helper(), ast_frame::ptr, S_OR, and sub.

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

◆ ast_channel_datastore_add()

int ast_channel_datastore_add ( struct ast_channel chan,
struct ast_datastore datastore 
)

Add a datastore to a channel.

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

Definition at line 2376 of file channel.c.

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

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

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

◆ ast_channel_datastore_find()

struct ast_datastore * ast_channel_datastore_find ( struct ast_channel chan,
const struct ast_datastore_info info,
const char *  uid 
)

Find a datastore on a channel.

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

Definition at line 2390 of file channel.c.

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

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

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

◆ ast_channel_datastore_inherit()

int ast_channel_datastore_inherit ( struct ast_channel from,
struct ast_channel to 
)

Inherit datastores from a parent to a child.

Note
None of the datastore API calls lock the ast_channel they are using. So, the channel should be locked before calling the functions that take a channel argument.

Definition at line 2359 of file channel.c.

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

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

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

◆ ast_channel_datastore_remove()

int ast_channel_datastore_remove ( struct ast_channel chan,
struct ast_datastore datastore 
)

◆ ast_channel_defer_dtmf()

int ast_channel_defer_dtmf ( struct ast_channel chan)

Set defer DTMF flag on channel.

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

Definition at line 1315 of file channel.c.

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

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

Referenced by __adsi_transmit_messages().

◆ ast_channel_destructor()

static void ast_channel_destructor ( void *  obj)
static

Free a channel structure.

Definition at line 2181 of file channel.c.

2182{
2183 struct ast_channel *chan = obj;
2184 struct ast_var_t *vardata;
2185 struct ast_frame *f;
2186 struct varshead *headp;
2187 struct ast_datastore *datastore;
2188 char device_name[AST_CHANNEL_NAME];
2189 ast_callid callid;
2190
2191 ast_debug(1, "Channel %p '%s' destroying\n", chan, ast_channel_name(chan));
2192
2193 /* If there is native format music-on-hold state, free it */
2194 if (ast_channel_music_state(chan)) {
2195 moh_cleanup(chan);
2196 }
2197
2199
2200 /* Things that may possibly raise Stasis messages shouldn't occur after this point */
2202
2204 /* A channel snapshot should not be in the process of being staged now. */
2206
2207 ast_channel_lock(chan);
2209 ast_channel_unlock(chan);
2210 }
2211
2212 ast_channel_lock(chan);
2213
2215
2216 /* Get rid of each of the data stores on the channel */
2217 while ((datastore = AST_LIST_REMOVE_HEAD(ast_channel_datastores(chan), entry)))
2218 /* Free the data store */
2219 ast_datastore_free(datastore);
2220
2221 /* While the channel is locked, take the reference to its callid while we tear down the call. */
2222 callid = ast_channel_callid(chan);
2224
2225 ast_channel_unlock(chan);
2226
2227 /* Lock and unlock the channel just to be sure nobody has it locked still
2228 due to a reference that was stored in a datastore. (i.e. app_chanspy) */
2229 ast_channel_lock(chan);
2230 ast_channel_unlock(chan);
2231
2232 if (ast_channel_tech_pvt(chan)) {
2233 ast_log_callid(LOG_WARNING, callid, "Channel '%s' may not have been hung up properly\n", ast_channel_name(chan));
2235 }
2236
2237 if (ast_channel_sched(chan)) {
2239 }
2240
2242 char *dashptr;
2243
2244 ast_copy_string(device_name, ast_channel_name(chan), sizeof(device_name));
2245 if ((dashptr = strrchr(device_name, '-'))) {
2246 *dashptr = '\0';
2247 }
2248 } else {
2249 device_name[0] = '\0';
2250 }
2251
2252 /* Free translators */
2253 if (ast_channel_readtrans(chan))
2255 if (ast_channel_writetrans(chan))
2257 if (ast_channel_pbx(chan))
2258 ast_log_callid(LOG_WARNING, callid, "PBX may not have been terminated properly on '%s'\n", ast_channel_name(chan));
2259
2260 /* Free formats */
2266
2272
2273 /* Close pipes if appropriate */
2275 if (ast_channel_timer(chan)) {
2278 }
2280 ast_frfree(f);
2281
2282 /* loop over the variables list, freeing all data and deleting list items */
2283 /* no need to lock the list, as the channel is already locked */
2284 headp = ast_channel_varshead(chan);
2285 while ((vardata = AST_LIST_REMOVE_HEAD(headp, entries)))
2286 ast_var_delete(vardata);
2287
2289
2290 /* Destroy the jitterbuffer */
2291 ast_jb_destroy(chan);
2292
2293 if (ast_channel_cdr(chan)) {
2296 }
2297
2298 if (ast_channel_zone(chan)) {
2300 }
2301
2303
2304 if (device_name[0]) {
2305 /*
2306 * We have a device name to notify of a new state.
2307 *
2308 * Queue an unknown state, because, while we know that this particular
2309 * instance is dead, we don't know the state of all other possible
2310 * instances.
2311 */
2313 }
2314
2316
2319
2321}
void ast_jb_destroy(struct ast_channel *chan)
Destroys jitterbuffer on a channel.
void ast_cdr_free(struct ast_cdr *cdr)
Free a CDR record.
Definition cdr.c:3557
static void moh_cleanup(struct ast_channel *chan)
Definition channel.c:7823
void ast_party_dialed_free(struct ast_party_dialed *doomed)
Destroy the dialed party contents.
Definition channel.c:1958
void ast_party_caller_free(struct ast_party_caller *doomed)
Destroy the caller party contents.
Definition channel.c:2002
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition channel.c:2166
void ast_channel_named_pickupgroups_set(struct ast_channel *chan, struct ast_namedgroups *value)
void * ast_channel_tech_pvt(const struct ast_channel *chan)
void ast_channel_callid_cleanup(struct ast_channel *chan)
void ast_channel_set_oldwriteformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_internal_alertpipe_close(struct ast_channel *chan)
struct ast_cdr * ast_channel_cdr(const struct ast_channel *chan)
ast_callid ast_channel_callid(const struct ast_channel *chan)
struct ast_tone_zone * ast_channel_zone(const struct ast_channel *chan)
void ast_channel_named_callgroups_set(struct ast_channel *chan, struct ast_namedgroups *value)
void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr *value)
struct ast_sched_context * ast_channel_sched(const struct ast_channel *chan)
@ AST_FLAG_DISABLE_DEVSTATE_CACHE
Definition channel.h:1049
@ AST_FLAG_SNAPSHOT_STAGE
Definition channel.h:1070
@ AST_FLAG_DEAD
Definition channel.h:1065
struct ast_pbx * ast_channel_pbx(const struct ast_channel *chan)
void ast_channel_zone_set(struct ast_channel *chan, struct ast_tone_zone *value)
int ast_channel_internal_is_finalized(struct ast_channel *chan)
void ast_channel_internal_cleanup(struct ast_channel *chan)
void ast_var_delete(struct ast_var_t *var)
Definition extconf.c:2469
@ AST_DEVSTATE_CACHABLE
Definition devicestate.h:70
@ AST_DEVSTATE_NOT_CACHABLE
Definition devicestate.h:69
int ast_devstate_changed_literal(enum ast_device_state state, enum ast_devstate_cache cachable, const char *device)
Tells Asterisk the State for Device is changed.
@ AST_DEVICE_UNKNOWN
Definition devicestate.h:53
void ast_channel_publish_final_snapshot(struct ast_channel *chan)
Send the final channel snapshot for a channel, thus removing it from cache.
int ast_app_group_discard(struct ast_channel *chan)
Discard all group counting for a channel.
Definition main/app.c:2320
unsigned int ast_callid
void ast_log_callid(int level, const char *file, int line, const char *function, ast_callid callid, const char *fmt,...)
Used for sending a log message with a known call_id This is a modified logger function which is funct...
Definition logger.c:2471
static struct ast_tone_zone * ast_tone_zone_unref(struct ast_tone_zone *tz)
Release a reference to an ast_tone_zone.
void ast_pbx_hangup_handler_destroy(struct ast_channel *chan)
Destroy the hangup handler container on a channel.
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
Definition sched.c:271
void ast_timer_close(struct ast_timer *handle)
Close an opened timing handle.
Definition timing.c:154
void ast_translator_free_path(struct ast_trans_pvt *tr)
Frees a translator path Frees the given translator path structure.
Definition translate.c:533
#define ast_assert(a)
Definition utils.h:779

References ast_app_group_discard(), ast_assert, ast_atomic_fetchadd_int(), ast_cdr_free(), ast_channel_caller(), ast_channel_callid(), ast_channel_callid_cleanup(), ast_channel_cdr(), ast_channel_cdr_set(), ast_channel_connected(), ast_channel_connected_indicated(), ast_channel_datastores(), ast_channel_dialed(), ast_channel_endpoint_set(), ast_channel_flags(), ast_channel_internal_alertpipe_close(), ast_channel_internal_cleanup(), ast_channel_internal_is_finalized(), ast_channel_lock, ast_channel_music_state(), AST_CHANNEL_NAME, ast_channel_name(), ast_channel_named_callgroups_set(), ast_channel_named_pickupgroups_set(), ast_channel_nativeformats_set(), ast_channel_pbx(), ast_channel_publish_final_snapshot(), ast_channel_readq(), ast_channel_readtrans(), ast_channel_redirecting(), ast_channel_sched(), ast_channel_set_oldwriteformat(), ast_channel_set_rawreadformat(), ast_channel_set_rawwriteformat(), ast_channel_set_readformat(), ast_channel_set_writeformat(), ast_channel_tech_pvt(), ast_channel_timer(), ast_channel_timer_set(), ast_channel_unlock, ast_channel_varshead(), ast_channel_writetrans(), ast_channel_zone(), ast_channel_zone_set(), ast_copy_string(), ast_datastore_free(), ast_debug, AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, ast_devstate_changed_literal(), AST_DEVSTATE_NOT_CACHABLE, AST_FLAG_DEAD, AST_FLAG_DISABLE_DEVSTATE_CACHE, AST_FLAG_SNAPSHOT_STAGE, ast_free, ast_frfree, ast_jb_destroy(), AST_LIST_REMOVE_HEAD, ast_log_callid(), ast_party_caller_free(), ast_party_connected_line_free(), ast_party_dialed_free(), ast_party_redirecting_free(), ast_pbx_hangup_handler_destroy(), ast_sched_context_destroy(), ast_set_flag, ast_test_flag, ast_timer_close(), ast_tone_zone_unref(), ast_translator_free_path(), ast_var_delete(), chancount, ast_datastore::entry, LOG_WARNING, moh_cleanup(), and NULL.

Referenced by __ast_channel_alloc_ap().

◆ ast_channel_early_bridge()

int ast_channel_early_bridge ( struct ast_channel c0,
struct ast_channel c1 
)

Bridge two channels together (early)

Parameters
c0first channel to bridge
c1second channel to bridge

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

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

Definition at line 7448 of file channel.c.

7449{
7450 /* Make sure we can early bridge, if not error out */
7451 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)))
7452 return -1;
7453
7454 return ast_channel_tech(c0)->early_bridge(c0, c1);
7455}
enum ast_bridge_result(*const early_bridge)(struct ast_channel *c0, struct ast_channel *c1)
Bridge two channels of the same type together (early)
Definition channel.h:788

References ast_channel_tech::early_bridge.

Referenced by dial_exec_full(), and wait_for_answer().

◆ ast_channel_end_dtmf()

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

Simulate a DTMF end on a broken bridge channel.

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

Definition at line 10941 of file channel.c.

10942{
10943 int dead;
10944 long duration;
10945
10946 ast_channel_lock(chan);
10949 & ~AST_SOFTHANGUP_ASYNCGOTO);
10950 ast_channel_unlock(chan);
10951 if (dead) {
10952 /* Channel is a zombie or a real hangup. */
10953 return;
10954 }
10955
10956 duration = ast_tvdiff_ms(ast_tvnow(), start);
10957 if (duration < option_dtmfminduration) {
10958 duration = option_dtmfminduration;
10959 }
10960 ast_senddigit_end(chan, digit, duration);
10961 ast_log(LOG_DTMF, "DTMF end '%c' simulated on %s due to %s, duration %ld ms\n",
10962 digit, ast_channel_name(chan), why, duration);
10963}
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition channel.c:4947

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

Referenced by bridge_channel_internal_join(), and channel_do_masquerade().

◆ ast_channel_errno()

enum ast_channel_error ast_channel_errno ( void  )

Get error code for latest channel operation.

Definition at line 11033 of file channel.c.

11034{
11036}
enum ast_channel_error ast_channel_internal_errno(void)

References ast_channel_internal_errno().

Referenced by ari_channels_handle_originate_with_id(), and ast_ari_channels_create().

◆ ast_channel_feature_hooks_append()

int ast_channel_feature_hooks_append ( struct ast_channel chan,
struct ast_bridge_features features 
)

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

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

Definition at line 11023 of file channel.c.

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

References channel_feature_hooks_set_full().

Referenced by AST_TEST_DEFINE(), and AST_TEST_DEFINE().

◆ ast_channel_feature_hooks_get()

struct ast_bridge_features * ast_channel_feature_hooks_get ( struct ast_channel chan)

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

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

Definition at line 10975 of file channel.c.

10976{
10977 struct ast_datastore *datastore;
10978
10980 if (!datastore) {
10981 return NULL;
10982 }
10983 return datastore->data;
10984}
static const struct ast_datastore_info bridge_features_info
Definition channel.c:10970

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

Referenced by bridge_channel_internal_join().

◆ ast_channel_feature_hooks_replace()

int ast_channel_feature_hooks_replace ( struct ast_channel chan,
struct ast_bridge_features features 
)

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

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

Definition at line 11028 of file channel.c.

11029{
11030 return channel_feature_hooks_set_full(chan, features, 1);
11031}

References channel_feature_hooks_set_full().

◆ ast_channel_get_ari_vars()

struct varshead * ast_channel_get_ari_vars ( struct ast_channel chan)

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

Since
14.2.0

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

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

Definition at line 7997 of file channel.c.

7998{
7999 return channel_get_external_vars(&ari_vars, chan);
8000}
static struct varshead * channel_get_external_vars(struct external_vars *channelvars, struct ast_channel *chan)
Definition channel.c:7945
static struct external_vars ari_vars
Definition channel.c:7841

References ari_vars, and channel_get_external_vars().

Referenced by ast_channel_snapshot_create().

◆ ast_channel_get_bridge()

struct ast_bridge * ast_channel_get_bridge ( const struct ast_channel chan)

Get the bridge associated with a channel.

Since
12.0.0
Parameters
chanThe channel whose bridge we want

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

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

Definition at line 10606 of file channel.c.

10607{
10608 struct ast_bridge *bridge;
10609
10610 bridge = ast_channel_internal_bridge(chan);
10611 if (bridge) {
10612 ao2_ref(bridge, +1);
10613 }
10614 return bridge;
10615}
struct ast_bridge * ast_channel_internal_bridge(const struct ast_channel *chan)

References ao2_ref, and ast_channel_internal_bridge().

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

◆ ast_channel_get_bridge_channel()

struct ast_bridge_channel * ast_channel_get_bridge_channel ( struct ast_channel chan)

Get a reference to the channel's bridge pointer.

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

Definition at line 10654 of file channel.c.

10655{
10656 struct ast_bridge_channel *bridge_channel;
10657
10658 bridge_channel = ast_channel_internal_bridge_channel(chan);
10659 if (bridge_channel) {
10660 ao2_ref(bridge_channel, +1);
10661 }
10662 return bridge_channel;
10663}
struct ast_bridge_channel * ast_channel_internal_bridge_channel(const struct ast_channel *chan)
Structure that contains information regarding a channel in a bridge.
struct ast_channel * chan

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

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

◆ ast_channel_get_by_exten()

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

Find a channel by extension and context.

Parameters
extenthe extension to search for
contextthe context to search for

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

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

Definition at line 1430 of file channel.c.

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

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

◆ ast_channel_get_by_name()

struct ast_channel * ast_channel_get_by_name ( const char *  search)

Find a channel by name or uniqueid.

Parameters
searchthe name or uniqueid of the channel to search for

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

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

Definition at line 1417 of file channel.c.

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

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

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

◆ ast_channel_get_by_name_prefix()

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

Find a channel by a name prefix.

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

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

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

Definition at line 1400 of file channel.c.

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

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

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

◆ ast_channel_get_by_uniqueid()

struct ast_channel * ast_channel_get_by_uniqueid ( const char *  uniqueid)

Find a channel by a uniqueid.

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

Definition at line 1442 of file channel.c.

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

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

◆ ast_channel_get_cc_agent_type()

int ast_channel_get_cc_agent_type ( struct ast_channel chan,
char *  agent_type,
size_t  size 
)

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

Since
1.8

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

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

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

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

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

Definition at line 10585 of file channel.c.

10586{
10587 int len = size;
10588 char *slash;
10589
10591 return 0;
10592 }
10593
10595 if ((slash = strchr(agent_type, '/'))) {
10596 *slash = '\0';
10597 }
10598 return 0;
10599}
static struct aco_type 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:7478
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define AST_OPTION_CC_AGENT_TYPE

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

Referenced by find_agent_callbacks().

◆ ast_channel_get_cc_config_params()

struct ast_cc_config_params * ast_channel_get_cc_config_params ( struct ast_channel chan)

Get the CCSS parameters from a channel.

Since
1.8

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

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

Definition at line 10542 of file channel.c.

10543{
10544 struct ast_datastore *cc_datastore;
10545
10546 if (!ast_cc_is_enabled()) {
10547 return NULL;
10548 }
10549
10550 if (!(cc_datastore = ast_channel_datastore_find(chan, &cc_channel_datastore_info, NULL))) {
10551 /* If we can't find the datastore, it almost definitely means that the channel type being
10552 * used has not had its driver modified to parse CC config parameters. The best action
10553 * to take here is to create the parameters on the spot with the defaults set.
10554 */
10555 if (ast_channel_cc_params_init(chan, NULL)) {
10556 return NULL;
10557 }
10558 if (!(cc_datastore = ast_channel_datastore_find(chan, &cc_channel_datastore_info, NULL))) {
10559 /* Should be impossible */
10560 return NULL;
10561 }
10562 }
10563
10564 ast_assert(cc_datastore->data != NULL);
10565 return cc_datastore->data;
10566}
int ast_cc_is_enabled(void)
Determine if CCSS is enabled.
Definition ccss.c:4540
int ast_channel_cc_params_init(struct ast_channel *chan, const struct ast_cc_config_params *base_params)
Set up datastore with CCSS parameters for a channel.
Definition channel.c:10519

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

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

◆ ast_channel_get_current_storage_driver_name()

const char * ast_channel_get_current_storage_driver_name ( void  )

Get the name of the current channel storage driver.

Returns
The name of the current channel storage driver

Definition at line 8041 of file channel.c.

8042{
8045}
const struct ast_channelstorage_driver * current_channel_storage_driver
The current channel storage driver.

References current_channel_storage_driver, and ast_channelstorage_driver::driver_name.

Referenced by handle_show_settings().

◆ ast_channel_get_device_name()

int ast_channel_get_device_name ( struct ast_channel chan,
char *  device_name,
size_t  name_buffer_length 
)

Get a device name given its channel structure.

Since
1.8

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

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

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

Definition at line 10568 of file channel.c.

10569{
10570 int len = name_buffer_length;
10571 char *dash;
10572 if (!ast_channel_queryoption(chan, AST_OPTION_DEVICE_NAME, device_name, &len, 0)) {
10573 return 0;
10574 }
10575
10576 /* Dang. Do it the old-fashioned way */
10577 ast_copy_string(device_name, ast_channel_name(chan), name_buffer_length);
10578 if ((dash = strrchr(device_name, '-'))) {
10579 *dash = '\0';
10580 }
10581
10582 return 0;
10583}
#define AST_OPTION_DEVICE_NAME

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

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

◆ ast_channel_get_duration()

int ast_channel_get_duration ( struct ast_channel chan)

Obtain how long the channel since the channel was created.

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

Definition at line 2830 of file channel.c.

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

References ast_channel_get_duration_ms().

Referenced by end_bridge_callback(), and serialize_showchan().

◆ ast_channel_get_duration_ms()

int64_t ast_channel_get_duration_ms ( struct ast_channel chan)

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

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

Definition at line 2820 of file channel.c.

2821{
2822 ast_assert(NULL != chan);
2823
2825 return 0;
2826 }
2828}
struct timeval ast_channel_creationtime(struct ast_channel *chan)

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

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

◆ ast_channel_get_intercept_mode()

int ast_channel_get_intercept_mode ( void  )

Am I currently running an intercept dialplan routine.

Since
13.14.0

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

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

Definition at line 10401 of file channel.c.

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

References ast_threadstorage_get_ptr().

Referenced by run_agi().

◆ ast_channel_get_manager_vars()

struct varshead * ast_channel_get_manager_vars ( struct ast_channel chan)

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

Since
12

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

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

Definition at line 7992 of file channel.c.

7993{
7994 return channel_get_external_vars(&ami_vars, chan);
7995}
static struct external_vars ami_vars
Definition channel.c:7840

References ami_vars, and channel_get_external_vars().

Referenced by append_channel_vars(), and ast_channel_snapshot_create().

◆ ast_channel_get_up_time()

int ast_channel_get_up_time ( struct ast_channel chan)

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

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

Definition at line 2845 of file channel.c.

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

References ast_channel_get_up_time_ms().

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

◆ ast_channel_get_up_time_ms()

int64_t ast_channel_get_up_time_ms ( struct ast_channel chan)

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

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

Definition at line 2835 of file channel.c.

2836{
2837 ast_assert(NULL != chan);
2838
2840 return 0;
2841 }
2843}
struct timeval ast_channel_answertime(struct ast_channel *chan)

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

Referenced by ast_channel_get_up_time(), and end_bridge_callback().

◆ ast_channel_get_vars()

struct varshead * ast_channel_get_vars ( struct ast_channel chan)

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

Since
12

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

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

Definition at line 7920 of file channel.c.

7921{
7922 RAII_VAR(struct varshead *, ret, NULL, ao2_cleanup);
7923 struct ast_var_t *cv;
7924
7925 ret = ao2_alloc(sizeof(*ret), varshead_dtor);
7926
7927 if (!ret) {
7928 return NULL;
7929 }
7930
7933
7934 if (!var) {
7935 return NULL;
7936 }
7937
7939 }
7940
7941 ao2_ref(ret, +1);
7942 return ret;
7943}
#define var
Definition ast_expr2f.c:605
#define ao2_cleanup(obj)
Definition astobj2.h:1934
#define ao2_alloc(data_size, destructor_fn)
Definition astobj2.h:409
static void varshead_dtor(void *obj)
Destructor for lists of variables.
Definition channel.c:7910
const char * ast_var_name(const struct ast_var_t *var)
Definition chanvars.c:60
#define ast_var_assign(name, value)
Definition chanvars.h:40
const char * ast_var_value(const struct ast_var_t *var)
Definition chanvars.c:80
struct ast_var_t::@220 entries
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition utils.h:981

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

◆ ast_channel_hangupcause_hash_set()

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

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

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

Definition at line 4368 of file channel.c.

4369{
4370 char causevar[256];
4371
4372 if (ast_channel_dialed_causes_add(chan, cause_code, datalen)) {
4373 ast_log(LOG_WARNING, "Unable to store hangup cause for %s on %s\n", cause_code->chan_name, ast_channel_name(chan));
4374 }
4375
4376 if (cause_code->emulate_sip_cause) {
4377 snprintf(causevar, sizeof(causevar), "HASH(SIP_CAUSE,%s)", cause_code->chan_name);
4378 ast_func_write(chan, causevar, cause_code->code);
4379 }
4380}
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

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

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

◆ ast_channel_has_ari_vars()

int ast_channel_has_ari_vars ( void  )

Return whether or not any ARI variables have been set.

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

Definition at line 7869 of file channel.c.

7870{
7872}
static int channel_has_external_vars(struct external_vars *channelvars)
Definition channel.c:7853

References ari_vars, and channel_has_external_vars().

◆ ast_channel_has_audio_frame_or_monitor()

int ast_channel_has_audio_frame_or_monitor ( struct ast_channel chan)

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

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

Definition at line 2517 of file channel.c.

2518{
2521}
int ast_framehook_list_contains_no_active(struct ast_framehook_list *framehooks)
Determine if a framehook list is free of active framehooks or not.
Definition framehook.c:282

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

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

◆ ast_channel_has_hook_requiring_audio()

int ast_channel_has_hook_requiring_audio ( struct ast_channel chan)

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

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

Definition at line 2523 of file channel.c.

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

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

Referenced by native_rtp_bridge_capable().

◆ ast_channel_has_manager_vars()

int ast_channel_has_manager_vars ( void  )

Return whether or not any manager variables have been set.

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

Definition at line 7864 of file channel.c.

7865{
7867}

References ami_vars, and channel_has_external_vars().

Referenced by ast_channel_publish_varset().

◆ ast_channel_inherit_variables()

void ast_channel_inherit_variables ( const struct ast_channel parent,
struct ast_channel child 
)

Inherits channel variable from parent to child channel.

Parameters
parentParent channel
childChild channel

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

Definition at line 6795 of file channel.c.

6796{
6797 struct ast_var_t *current;
6798 struct ast_var_t *newvar;
6799 const char *varname;
6800 int vartype;
6801
6803 varname = ast_var_full_name(current);
6804 if (!varname) {
6805 continue;
6806 }
6807
6808 vartype = 0;
6809 if (varname[0] == '_') {
6810 vartype = 1;
6811 if (varname[1] == '_') {
6812 vartype = 2;
6813 }
6814 }
6815
6816 switch (vartype) {
6817 case 1:
6818 newvar = ast_var_assign(&varname[1], ast_var_value(current));
6819 break;
6820 case 2:
6821 newvar = ast_var_assign(varname, ast_var_value(current));
6822 break;
6823 default:
6824 continue;
6825 }
6826 if (newvar) {
6827 ast_debug(1, "Inheriting variable %s from %s to %s.\n",
6828 ast_var_full_name(newvar), ast_channel_name(parent),
6829 ast_channel_name(child));
6832 ast_var_value(newvar));
6833 }
6834 }
6835}
size_t current
const char * ast_var_full_name(const struct ast_var_t *var)
Definition chanvars.c:75
void ast_channel_publish_varset(struct ast_channel *chan, const char *variable, const char *value)
Publish a ast_channel_publish_varset for a channel.

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

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

◆ ast_channel_is_bridged()

int ast_channel_is_bridged ( const struct ast_channel chan)

Determine if a channel is in a bridge.

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

Definition at line 10617 of file channel.c.

10618{
10619 return ast_channel_internal_bridge(chan) != NULL;
10620}

References ast_channel_internal_bridge(), and NULL.

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

◆ ast_channel_is_leaving_bridge()

int ast_channel_is_leaving_bridge ( struct ast_channel chan)

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

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

Definition at line 10622 of file channel.c.

10623{
10624 int hangup_flags = ast_channel_softhangup_internal_flag(chan);
10625 int hangup_test = hangup_flags & AST_SOFTHANGUP_ASYNCGOTO;
10626 int unbridge = ast_channel_unbridged(chan);
10627
10628 /* This function should only return true if either the unbridged flag or
10629 * the ASYNCGOTO soft hangup flag is set and when no other soft hangup
10630 * flags are set. Any other soft hangup flags being set should make it
10631 * return false.
10632 */
10633 return ((hangup_test || unbridge) && (hangup_test == hangup_flags));
10634}
@ AST_SOFTHANGUP_ASYNCGOTO
Definition channel.h:1146
int ast_channel_unbridged(struct ast_channel *chan)
This function will check if the bridge needs to be re-evaluated due to external changes.

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

Referenced by ast_indicate_data(), and bridge_channel_internal_pull().

◆ ast_channel_iterator_all_new()

struct ast_channel_iterator * ast_channel_iterator_all_new ( void  )

Create a new channel iterator.

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

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

Definition at line 1380 of file channel.c.

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

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

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

◆ ast_channel_iterator_by_exten_new()

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

Create a new channel iterator based on extension.

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

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

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

Definition at line 1357 of file channel.c.

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

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

Referenced by common_exec(), and pickup_by_exten().

◆ ast_channel_iterator_by_name_new()

struct ast_channel_iterator * ast_channel_iterator_by_name_new ( const char *  name,
size_t  name_len 
)

Create a new channel iterator based on name.

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

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

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

Definition at line 1368 of file channel.c.

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

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

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

◆ ast_channel_iterator_destroy()

struct ast_channel_iterator * ast_channel_iterator_destroy ( struct ast_channel_iterator i)

Destroy a channel iterator.

Parameters
ithe itereator to destroy

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

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

Definition at line 1349 of file channel.c.

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

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

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

◆ ast_channel_iterator_next()

struct ast_channel * ast_channel_iterator_next ( struct ast_channel_iterator i)

Get the next channel for a channel iterator.

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

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

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

Definition at line 1388 of file channel.c.

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

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

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

◆ ast_channel_make_compatible()

int ast_channel_make_compatible ( struct ast_channel chan,
struct ast_channel peer 
)

Make the frame formats of two channels compatible.

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

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

Return values
0on success.
-1on error.

Definition at line 6739 of file channel.c.

6740{
6741 /*
6742 * Set up translation from the peer to the chan first in case we
6743 * need to hear any in-band tones and the other direction fails.
6744 */
6745 if (ast_channel_make_compatible_helper(peer, chan)) {
6746 return -1;
6747 }
6748
6749 /* Set up translation from the chan to the peer */
6750 if (ast_channel_make_compatible_helper(chan, peer)) {
6751 return -1;
6752 }
6753
6754 return 0;
6755}
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:6660

References ast_channel_make_compatible_helper().

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

◆ ast_channel_make_compatible_helper()

static int ast_channel_make_compatible_helper ( struct ast_channel from,
struct ast_channel to 
)
static

Set up translation from one channel to another.

Definition at line 6660 of file channel.c.

6661{
6662 struct ast_format_cap *src_cap;
6663 struct ast_format_cap *dst_cap;
6664 RAII_VAR(struct ast_format *, best_src_fmt, NULL, ao2_cleanup);
6665 RAII_VAR(struct ast_format *, best_dst_fmt, NULL, ao2_cleanup);
6666 int no_path;
6667
6668 /*
6669 * We cannot short circuit this code because it is possible to ask
6670 * to make compatible two channels that are "compatible" because
6671 * they already have translation paths setup but together make for
6672 * a sub-optimal path. e.g., The From channel has g722 -> ulaw
6673 * and the To channel has ulaw -> g722. They are "compatible" but
6674 * together the translations are unnecessary and the audio loses
6675 * fidelity in the process.
6676 */
6677
6678 ast_channel_lock_both(from, to);
6679
6680 src_cap = ast_channel_nativeformats(from); /* shallow copy, do not destroy */
6681 dst_cap = ast_channel_nativeformats(to); /* shallow copy, do not destroy */
6682
6683 /* If there's no audio in this call, don't bother with trying to find a translation path */
6687 ast_channel_unlock(from);
6688 return 0;
6689 }
6690
6691 no_path = ast_translator_best_choice(dst_cap, src_cap, &best_dst_fmt, &best_src_fmt);
6692
6694 ast_channel_unlock(from);
6695
6696 if (no_path) {
6697 ast_log(LOG_WARNING, "No path to translate from %s to %s\n",
6699 return -1;
6700 }
6701
6702 /* if the best path is not 'pass through', then
6703 * transcoding is needed; if desired, force transcode path
6704 * to use SLINEAR between channels, but only if there is
6705 * no direct conversion available. If generic PLC is
6706 * desired, then transcoding via SLINEAR is a requirement
6707 * even if the formats are the same.
6708 */
6710 || (ast_format_cmp(best_dst_fmt, best_src_fmt) == AST_FORMAT_CMP_NOT_EQUAL
6712
6713 int use_slin = (ast_format_cache_is_slinear(best_src_fmt)
6714 || ast_format_cache_is_slinear(best_dst_fmt))
6716
6717 if (use_slin || ast_translate_path_steps(best_dst_fmt, best_src_fmt) != 1) {
6718 int best_sample_rate = (ast_format_get_sample_rate(best_src_fmt) > ast_format_get_sample_rate(best_dst_fmt)) ?
6719 ast_format_get_sample_rate(best_src_fmt) : ast_format_get_sample_rate(best_dst_fmt);
6720
6721 /* pick the best signed linear format based upon what preserves the sample rate the best. */
6722 ao2_replace(best_src_fmt, ast_format_cache_get_slin_by_rate(best_sample_rate));
6723 }
6724 }
6725
6726 if (ast_set_read_format(from, best_src_fmt)) {
6727 ast_log(LOG_WARNING, "Unable to set read format on channel %s to %s\n",
6728 ast_channel_name(from), ast_format_get_name(best_src_fmt));
6729 return -1;
6730 }
6731 if (ast_set_write_format(to, best_src_fmt)) {
6732 ast_log(LOG_WARNING, "Unable to set write format on channel %s to %s\n",
6733 ast_channel_name(to), ast_format_get_name(best_src_fmt));
6734 return -1;
6735 }
6736 return 0;
6737}
#define ao2_replace(dst, src)
Replace one object reference with another cleaning up the original.
Definition astobj2.h:501
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
Definition channel.c:5785
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
Definition channel.c:5826
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
@ AST_MEDIA_TYPE_AUDIO
Definition codec.h:32
unsigned int ast_format_get_sample_rate(const struct ast_format *format)
Get the sample rate of a media format.
Definition format.c:379
@ AST_FORMAT_CMP_NOT_EQUAL
Definition format.h:38
const char * ast_format_get_name(const struct ast_format *format)
Get the name associated with a format.
Definition format.c:334
struct ast_format * ast_format_cache_get_slin_by_rate(unsigned int rate)
Retrieve the best signed linear format given a sample rate.
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
#define ast_opt_transcode_via_slin
Definition options.h:128
#define ast_opt_generic_plc_on_equal_codecs
Definition options.h:146
#define ast_opt_generic_plc
Definition options.h:144
int ast_translator_best_choice(struct ast_format_cap *dst_cap, struct ast_format_cap *src_cap, struct ast_format **dst_fmt_out, struct ast_format **src_fmt_out)
Chooses the best translation path.
Definition translate.c:1676
unsigned int ast_translate_path_steps(struct ast_format *dest, struct ast_format *src)
Returns the number of steps required to convert from 'src' to 'dest'.
Definition translate.c:1810

References ao2_cleanup, ao2_replace, ast_channel_lock_both, ast_channel_name(), ast_channel_nativeformats(), ast_channel_unlock, ast_format_cache_get_slin_by_rate(), ast_format_cache_is_slinear(), ast_format_cap_has_type(), ast_format_cmp(), AST_FORMAT_CMP_NOT_EQUAL, ast_format_get_name(), ast_format_get_sample_rate(), ast_log, AST_MEDIA_TYPE_AUDIO, ast_opt_generic_plc, ast_opt_generic_plc_on_equal_codecs, ast_opt_transcode_via_slin, ast_set_read_format(), ast_set_write_format(), ast_translate_path_steps(), ast_translator_best_choice(), LOG_WARNING, NULL, and RAII_VAR.

Referenced by ast_channel_make_compatible().

◆ ast_channel_move()

int ast_channel_move ( struct ast_channel dest,
struct ast_channel source 
)

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

Since
12

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

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

Definition at line 10738 of file channel.c.

10739{
10740 RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
10742
10743 if (dest == source) {
10744 ast_log(LOG_WARNING, "Can't move channel '%s' into itself!\n",
10745 ast_channel_name(dest));
10746 return -1;
10747 }
10748
10749 ast_channel_lock_both(dest, source);
10750
10753 /* Zombies! Run! */
10755 "Can't move channel. One or both is dead (%s <-- %s)\n",
10756 ast_channel_name(dest), ast_channel_name(source));
10757 ast_channel_unlock(source);
10758 ast_channel_unlock(dest);
10759 return -1;
10760 }
10761
10762 ast_channel_masq_set(dest, source);
10763 ast_channel_masqr_set(source, dest);
10764
10765 blob = ast_json_pack("{s: s}",
10766 "newchanneluniqueid", ast_channel_uniqueid(dest));
10768
10769 ast_channel_unlock(dest);
10770 ast_channel_unlock(source);
10771
10772 channel_do_masquerade(dest, source);
10773 return 0;
10774}
ast_mutex_t lock
Definition app_sla.c:337
static void channel_do_masquerade(struct ast_channel *original, struct ast_channel *clonechan)
Masquerade a channel.
Definition channel.c:6881
static ast_mutex_t channel_move_lock
Definition channel.c:10736
void ast_channel_masqr_set(struct ast_channel *chan, struct ast_channel *value)
void ast_channel_masq_set(struct ast_channel *chan, struct ast_channel *value)
struct stasis_message_type * ast_channel_masquerade_type(void)
Message type for when a channel is being masqueraded.
void ast_channel_publish_blob(struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
Publish a channel blob message.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition json.c:73
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition json.c:612
#define SCOPED_MUTEX(varname, lock)
scoped lock specialization for mutexes
Definition lock.h:596
Abstract JSON element (object, array, string, int, ...).

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

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

◆ ast_channel_name_to_dial_string()

void ast_channel_name_to_dial_string ( char *  channel_name)

Removes the trailing identifiers from a channel name string.

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

Definition at line 6863 of file channel.c.

6864{
6865 char *dash;
6866
6867 /* Truncate after the dash */
6868 dash = strrchr(channel_name, '-');
6869 if (dash) {
6870 *dash = '\0';
6871 }
6872}

Referenced by parked_user_set_parker_dial_string(), and setup_park_common_datastore().

◆ ast_channel_open_storage()

int ast_channel_open_storage ( void  )

Definition at line 8020 of file channel.c.

8021{
8024 if (rc) {
8025 ast_log(LOG_ERROR, "No channel storage backends available\n");
8026 return -1;
8027 }
8028 }
8029
8033 ast_log(LOG_ERROR, "Failed to open channel storage driver '%s'\n",
8035 return -1;
8036 }
8037
8038 return 0;
8039}
int internal_channel_set_current_storage_driver(const char *driver_name)
Definition channel.c:8047
struct ast_channelstorage_instance * ast_channelstorage_open(const struct ast_channelstorage_driver *storage_driver, const char *instance_name)
#define AST_CHANNELSTORAGE_DEFAULT_TYPE

References AST_CHANNELSTORAGE_DEFAULT_TYPE, ast_channelstorage_open(), ast_log, current_channel_storage_driver, current_channel_storage_instance, ast_channelstorage_driver::driver_name, internal_channel_set_current_storage_driver(), and LOG_ERROR.

Referenced by ast_channels_init().

◆ ast_channel_queryoption()

int ast_channel_queryoption ( struct ast_channel channel,
int  option,
void *  data,
int *  datalen,
int  block 
)

Checks the value of an option.

Query the value of an option Works similarly to setoption except only reads the options.

Definition at line 7478 of file channel.c.

7479{
7480 int res;
7481
7482 ast_channel_lock(chan);
7483 if (!ast_channel_tech(chan)->queryoption) {
7484 errno = ENOSYS;
7485 ast_channel_unlock(chan);
7486 return -1;
7487 }
7488
7489 if (block)
7490 ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n");
7491
7492 res = ast_channel_tech(chan)->queryoption(chan, option, data, datalen);
7493 ast_channel_unlock(chan);
7494
7495 return res;
7496}
int(*const queryoption)(struct ast_channel *chan, int option, void *data, int *datalen)
Query a given option. Called with chan locked.
Definition channel.h:800

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

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

◆ ast_channel_queue_connected_line_update()

void ast_channel_queue_connected_line_update ( struct ast_channel chan,
const struct ast_party_connected_line connected,
const struct ast_set_party_connected_line update 
)

Queue a connected line update frame on a channel.

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

Definition at line 9174 of file channel.c.

9175{
9176 unsigned char data[1024]; /* This should be large enough */
9177 size_t datalen;
9178
9179 datalen = ast_connected_line_build_data(data, sizeof(data), connected, update);
9180 if (datalen == (size_t) -1) {
9181 return;
9182 }
9183
9185}
int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen)
Queue a control frame with payload.
Definition channel.c:1296
int ast_connected_line_build_data(unsigned char *data, size_t datalen, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Build the connected line information data frame.
Definition channel.c:8765
static void update(int code_size, int y, int wi, int fi, int dq, int sr, int dqsez, struct g726_state *state_ptr)
Definition codec_g726.c:367

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

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

◆ ast_channel_queue_redirecting_update()

void ast_channel_queue_redirecting_update ( struct ast_channel chan,
const struct ast_party_redirecting redirecting,
const struct ast_set_party_redirecting update 
)

Queue a redirecting update frame on a channel.

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

Definition at line 10365 of file channel.c.

10366{
10367 unsigned char data[1024]; /* This should be large enough */
10368 size_t datalen;
10369
10370 datalen = ast_redirecting_build_data(data, sizeof(data), redirecting, update);
10371 if (datalen == (size_t) -1) {
10372 return;
10373 }
10374
10375 ast_queue_control_data(chan, AST_CONTROL_REDIRECTING, data, datalen);
10376}
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:9336

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

Referenced by set_redirecting().

◆ ast_channel_reason2str()

const char * ast_channel_reason2str ( int  reason)

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

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

Definition at line 5849 of file channel.c.

5850{
5851 switch (reason) /* the following appear to be the only ones actually returned by request_and_dial */
5852 {
5853 case 0:
5854 return "Call Failure (not BUSY, and not NO_ANSWER, maybe Circuit busy or down?)";
5855 case AST_CONTROL_HANGUP:
5856 return "Hangup";
5857 case AST_CONTROL_RING:
5858 return "Local Ring";
5860 return "Remote end Ringing";
5861 case AST_CONTROL_ANSWER:
5862 return "Remote end has Answered";
5863 case AST_CONTROL_BUSY:
5864 return "Remote end is Busy";
5866 return "Congestion (circuits busy)";
5867 default:
5868 return "Unknown Reason!!";
5869 }
5870}

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

Referenced by attempt_thread().

◆ ast_channel_redirecting_sub()

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

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

Since
11

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

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

Definition at line 10451 of file channel.c.

10452{
10453 const char *sub;
10454 const char *sub_args;
10455 int retval;
10456
10457 ast_channel_lock(sub_chan);
10458 sub = pbx_builtin_getvar_helper(sub_chan, "REDIRECTING_SEND_SUB");
10459 sub = ast_strdupa(S_OR(sub, ""));
10460 sub_args = pbx_builtin_getvar_helper(sub_chan, "REDIRECTING_SEND_SUB_ARGS");
10461 sub_args = ast_strdupa(S_OR(sub_args, ""));
10462
10463 if (ast_strlen_zero(sub)) {
10464 ast_channel_unlock(sub_chan);
10465 return -1;
10466 }
10467
10468 if (is_frame) {
10469 const struct ast_frame *frame = redirecting_info;
10470
10472 } else {
10473 const struct ast_party_redirecting *redirecting = redirecting_info;
10474
10476 }
10477 ast_channel_unlock(sub_chan);
10478
10480 retval = ast_app_run_sub(autoservice_chan, sub_chan, sub, sub_args, 0);
10482 if (!retval) {
10483 struct ast_party_redirecting saved_redirecting;
10484
10485 ast_party_redirecting_init(&saved_redirecting);
10486 ast_channel_lock(sub_chan);
10487 ast_party_redirecting_copy(&saved_redirecting, ast_channel_redirecting(sub_chan));
10488 ast_channel_unlock(sub_chan);
10489 ast_channel_update_redirecting(sub_chan, &saved_redirecting, NULL);
10490 ast_party_redirecting_free(&saved_redirecting);
10491 }
10492
10493 return retval;
10494}
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:10352
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:9547
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
Definition channel.h:524

References ast_app_run_sub(), ast_channel_lock, ast_channel_redirecting(), ast_channel_unlock, ast_channel_update_redirecting(), ast_party_redirecting_copy(), ast_party_redirecting_free(), ast_party_redirecting_init(), ast_redirecting_parse_data(), ast_strdupa, ast_strlen_zero(), channel_set_intercept_mode(), ast_frame::data, ast_frame::datalen, NULL, pbx_builtin_getvar_helper(), ast_frame::ptr, S_OR, and sub.

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

◆ ast_channel_register()

int ast_channel_register ( const struct ast_channel_tech tech)

Register a new telephony channel in Asterisk.

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

Definition at line 540 of file channel.c.

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

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

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

◆ ast_channel_release()

struct ast_channel * ast_channel_release ( struct ast_channel chan)

Unlink and release reference to a channel.

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

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

Definition at line 1571 of file channel.c.

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

References ast_channel_unlink(), and ast_channel_unref.

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

◆ ast_channel_req_accountcodes()

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

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

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

Definition at line 6453 of file channel.c.

6454{
6455 channel_req_accountcodes(chan, requestor, relationship, 0);
6456}
static void channel_req_accountcodes(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship, int precious)
Definition channel.c:6395

References channel_req_accountcodes().

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

◆ ast_channel_req_accountcodes_precious()

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

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

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

Definition at line 6458 of file channel.c.

6459{
6460 channel_req_accountcodes(chan, requestor, relationship, 1);
6461}

References channel_req_accountcodes().

Referenced by ring_entry().

◆ ast_channel_request_stream_topology_change()

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

Request that the stream topology of a channel change.

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

Definition at line 11038 of file channel.c.

11040{
11041 int res;
11042
11043 ast_assert(chan != NULL);
11044 ast_assert(topology != NULL);
11045
11046 ast_channel_lock(chan);
11048 ast_channel_unlock(chan);
11049 return -1;
11050 }
11051
11053 ast_debug(2, "%s: Topologies already match. Current: %s Requested: %s\n",
11054 ast_channel_name(chan),
11056 ast_str_tmp(256, ast_stream_topology_to_str(topology, &STR_TMP)));
11057 ast_channel_unlock(chan);
11058 return 0;
11059 }
11060
11062
11063 res = ast_channel_tech(chan)->indicate(chan, AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE, topology, sizeof(topology));
11064 ast_channel_unlock(chan);
11065 return res;
11066}
static int indicate(void *data)
int ast_channel_is_multistream(struct ast_channel *chan)
Determine if a channel is multi-stream capable.
void ast_channel_internal_set_stream_topology_change_source(struct ast_channel *chan, void *change_source)
const char * ast_stream_topology_to_str(const struct ast_stream_topology *topology, struct ast_str **buf)
Get a string representing the topology for debugging/display purposes.
Definition stream.c:939
int ast_stream_topology_equal(const struct ast_stream_topology *left, const struct ast_stream_topology *right)
Compare two stream topologies to see if they are equal.
Definition stream.c:699
#define ast_str_tmp(init_len, __expr)
Provides a temporary ast_str and returns a copy of its buffer.
Definition strings.h:1189
int(*const indicate)(struct ast_channel *c, int condition, const void *data, size_t datalen)
Indicate a particular condition (e.g. AST_CONTROL_BUSY or AST_CONTROL_RINGING or AST_CONTROL_CONGESTI...
Definition channel.h:791

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

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

◆ ast_channel_sendhtml()

int ast_channel_sendhtml ( struct ast_channel channel,
int  subclass,
const char *  data,
int  datalen 
)

Sends HTML on given channel Send HTML or URL on link.

Returns
0 on success or -1 on failure

Definition at line 6647 of file channel.c.

6648{
6649 if (ast_channel_tech(chan)->send_html)
6650 return ast_channel_tech(chan)->send_html(chan, subclass, data, datalen);
6651 return -1;
6652}
int(*const send_html)(struct ast_channel *chan, int subclass, const char *data, int len)
Send HTML data.
Definition channel.h:782

References ast_channel_tech::send_html.

Referenced by ast_channel_sendurl(), and wait_for_answer().

◆ ast_channel_sendurl()

int ast_channel_sendurl ( struct ast_channel channel,
const char *  url 
)

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

Returns
0 on success or -1 on failure

Definition at line 6654 of file channel.c.

6655{
6656 return ast_channel_sendhtml(chan, AST_HTML_URL, url, strlen(url) + 1);
6657}
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:6647
#define AST_HTML_URL
static char url[512]

References ast_channel_sendhtml(), AST_HTML_URL, and url.

Referenced by dial_exec_full(), and try_calling().

◆ ast_channel_set_ari_vars()

void ast_channel_set_ari_vars ( size_t  varc,
char **  vars 
)

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

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

Definition at line 7901 of file channel.c.

7902{
7903 channel_set_external_vars(&ari_vars, varc, vars);
7904}
static void channel_set_external_vars(struct external_vars *channelvars, size_t varc, char **vars)
Definition channel.c:7874

References ari_vars, and channel_set_external_vars().

Referenced by general_apply().

◆ ast_channel_set_caller()

void ast_channel_set_caller ( struct ast_channel chan,
const struct ast_party_caller caller,
const struct ast_set_party_caller update 
)

Set the caller id information in the Asterisk channel.

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

Definition at line 7395 of file channel.c.

7396{
7397 if (ast_channel_caller(chan) == caller) {
7398 /* Don't set to self */
7399 return;
7400 }
7401
7402 ast_channel_lock(chan);
7405 ast_channel_unlock(chan);
7406}
void ast_party_caller_set(struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update)
Set the caller information based on another caller source.
Definition channel.c:1994
void ast_channel_snapshot_invalidate_segment(struct ast_channel *chan, enum ast_channel_snapshot_segment_invalidation segment)
Invalidate a channel snapshot segment from being reused.
@ AST_CHANNEL_SNAPSHOT_INVALIDATE_CALLER

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

◆ ast_channel_set_caller_event()

void ast_channel_set_caller_event ( struct ast_channel chan,
const struct ast_party_caller caller,
const struct ast_set_party_caller update 
)

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

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

Definition at line 7408 of file channel.c.

7409{
7410 if (ast_channel_caller(chan) == caller) {
7411 /* Don't set to self */
7412 return;
7413 }
7414
7415 ast_channel_lock(chan);
7419 ast_channel_unlock(chan);
7420}
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.

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

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

◆ ast_channel_set_connected_line()

void ast_channel_set_connected_line ( struct ast_channel chan,
const struct ast_party_connected_line connected,
const struct ast_set_party_connected_line update 
)

Set the connected line information in the Asterisk channel.

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

Definition at line 8376 of file channel.c.

8377{
8378 if (ast_channel_connected(chan) == connected) {
8379 /* Don't set to self */
8380 return;
8381 }
8382
8383 ast_channel_lock(chan);
8387 ast_channel_unlock(chan);
8388}
void ast_party_connected_line_set(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src, const struct ast_set_party_connected_line *update)
Set the connected line information based on another connected line source.
Definition channel.c:2041
@ AST_CHANNEL_SNAPSHOT_INVALIDATE_CONNECTED

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

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

◆ ast_channel_set_fd()

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

◆ ast_channel_set_flag()

void ast_channel_set_flag ( struct ast_channel chan,
unsigned int  flag 
)

Set a flag on a channel.

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

Definition at line 11099 of file channel.c.

11100{
11101 ast_channel_lock(chan);
11103 ast_channel_unlock(chan);
11104}

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

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

◆ ast_channel_set_manager_vars()

void ast_channel_set_manager_vars ( size_t  varc,
char **  vars 
)

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

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

Definition at line 7896 of file channel.c.

7897{
7898 channel_set_external_vars(&ami_vars, varc, vars);
7899}

References ami_vars, and channel_set_external_vars().

Referenced by load_channelvars().

◆ ast_channel_set_redirecting()

void ast_channel_set_redirecting ( struct ast_channel chan,
const struct ast_party_redirecting redirecting,
const struct ast_set_party_redirecting update 
)

Set the redirecting id information in the Asterisk channel.

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

Definition at line 9187 of file channel.c.

9188{
9189 if (ast_channel_redirecting(chan) == redirecting) {
9190 /* Don't set to self */
9191 return;
9192 }
9193
9194 ast_channel_lock(chan);
9198 ast_channel_unlock(chan);
9199}
void ast_party_redirecting_set(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src, const struct ast_set_party_redirecting *update)
Set the redirecting information based on another redirecting source.
Definition channel.c:2153

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

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

◆ ast_channel_setoption()

int ast_channel_setoption ( struct ast_channel channel,
int  option,
void *  data,
int  datalen,
int  block 
)

Sets an option on a channel.

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

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

Returns
0 on success and -1 on failure

Definition at line 7458 of file channel.c.

7459{
7460 int res;
7461
7462 ast_channel_lock(chan);
7463 if (!ast_channel_tech(chan)->setoption) {
7464 errno = ENOSYS;
7465 ast_channel_unlock(chan);
7466 return -1;
7467 }
7468
7469 if (block)
7470 ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n");
7471
7472 res = ast_channel_tech(chan)->setoption(chan, option, data, datalen);
7473 ast_channel_unlock(chan);
7474
7475 return res;
7476}
int(*const setoption)(struct ast_channel *chan, int option, void *data, int datalen)
Set a given option. Called with chan locked.
Definition channel.h:797

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

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

◆ ast_channel_setwhentohangup_tv()

void ast_channel_setwhentohangup_tv ( struct ast_channel chan,
struct timeval  offset 
)

Set when to hangup channel.

Set when to hang a channel up.

Definition at line 511 of file channel.c.

512{
513 if (ast_tvzero(offset)) {
514 ast_channel_whentohangup_set(chan, &offset);
515 } else {
516 struct timeval tv = ast_tvadd(offset, ast_tvnow());
518 }
520 return;
521}
void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value)

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

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

◆ ast_channel_softhangup_cb()

static int ast_channel_softhangup_cb ( void *  obj,
void *  arg,
void *  data,
int  flags 
)
static

Definition at line 485 of file channel.c.

486{
487 struct ast_channel *chan = obj;
488
490
491 return 0;
492}
int ast_softhangup(struct ast_channel *chan, int cause)
Softly hangup a channel, lock.
Definition channel.c:2462
@ AST_SOFTHANGUP_SHUTDOWN
Definition channel.h:1151

References ast_softhangup(), and AST_SOFTHANGUP_SHUTDOWN.

Referenced by ast_softhangup_all().

◆ ast_channel_softhangup_withcause_locked()

void ast_channel_softhangup_withcause_locked ( struct ast_channel chan,
int  causecode 
)

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

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

Definition at line 469 of file channel.c.

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

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

Referenced by action_hangup().

◆ ast_channel_start_silence_generator()

struct ast_silence_generator * ast_channel_start_silence_generator ( struct ast_channel chan)

Starts a silence generator on the given channel.

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

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

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

Definition at line 8232 of file channel.c.

8233{
8235
8236 if (!(state = ast_calloc(1, sizeof(*state)))) {
8237 return NULL;
8238 }
8239
8240 state->old_write_format = ao2_bump(ast_channel_writeformat(chan));
8241
8242 if (ast_set_write_format(chan, ast_format_slin) < 0) {
8243 ast_log(LOG_ERROR, "Could not set write format to SLINEAR\n");
8244 ast_free(state);
8245 return NULL;
8246 }
8247
8249
8250 ast_debug(1, "Started silence generator on '%s'\n", ast_channel_name(chan));
8251
8252 return state;
8253}
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition astobj2.h:480
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
Definition channel.c:2955
static struct ast_generator silence_generator
Definition channel.c:8222
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.

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

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

◆ ast_channel_stop_silence_generator()

void ast_channel_stop_silence_generator ( struct ast_channel chan,
struct ast_silence_generator state 
)

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

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

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

Definition at line 8278 of file channel.c.

8279{
8280 if (!state) {
8281 return;
8282 }
8283
8284 if (deactivate_silence_generator(chan)) {
8285 ast_debug(1, "Stopped silence generator on '%s'\n", ast_channel_name(chan));
8286 if (ast_set_write_format(chan, state->old_write_format) < 0) {
8287 ast_log(LOG_ERROR, "Could not return write format to its original state\n");
8288 }
8289 }
8290 ao2_cleanup(state->old_write_format);
8291 ast_free(state);
8292}
static int deactivate_silence_generator(struct ast_channel *chan)
Definition channel.c:8255

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

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

◆ ast_channel_stream_topology_changed()

int ast_channel_stream_topology_changed ( struct ast_channel chan,
struct ast_stream_topology topology 
)

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

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

Definition at line 11068 of file channel.c.

11069{
11070 ast_assert(chan != NULL);
11071 ast_assert(topology != NULL);
11072
11074 return -1;
11075 }
11076
11077 return ast_channel_tech(chan)->indicate(chan, AST_CONTROL_STREAM_TOPOLOGY_CHANGED, topology, sizeof(topology));
11078}

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

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

◆ ast_channel_stream_topology_changed_externally()

int ast_channel_stream_topology_changed_externally ( struct ast_channel chan)

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

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

Definition at line 11080 of file channel.c.

11081{
11082 int res;
11084
11085 ast_assert(chan != NULL);
11086
11087 if (!ast_channel_is_multistream(chan)) {
11088 return -1;
11089 }
11090
11091 ast_channel_lock(chan);
11093 res = ast_queue_frame(chan, &f);
11094 ast_channel_unlock(chan);
11095
11096 return res;
11097}
static const char ast_stream_topology_changed_external[]
Set as the change source reason when a channel stream topology has been changed externally as a resul...
Definition channel.h:223

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

Referenced by handle_negotiated_sdp(), and unreal_colp_stream_topology_request_change().

◆ ast_channel_string2amaflag()

enum ama_flags ast_channel_string2amaflag ( const char *  flag)

Convert a string to a detail record AMA flag.

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

Definition at line 4382 of file channel.c.

4383{
4384 if (!strcasecmp(flag, "default"))
4385 return DEFAULT_AMA_FLAGS;
4386 if (!strcasecmp(flag, "omit"))
4387 return AST_AMA_OMIT;
4388 if (!strcasecmp(flag, "billing"))
4389 return AST_AMA_BILLING;
4390 if (!strcasecmp(flag, "documentation"))
4391 return AST_AMA_DOCUMENTATION;
4392 return AST_AMA_NONE;
4393}

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

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

◆ ast_channel_supports_html()

int ast_channel_supports_html ( struct ast_channel channel)

Checks for HTML support on a channel.

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

Definition at line 6642 of file channel.c.

6643{
6644 return (ast_channel_tech(chan)->send_html) ? 1 : 0;
6645}

Referenced by dial_exec_full(), and try_calling().

◆ ast_channel_suppress()

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

Suppress passing of a frame type on a channel.

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

Definition at line 10849 of file channel.c.

10850{
10851 struct suppress_data *suppress;
10852 const struct ast_datastore_info *datastore_info = NULL;
10853 struct ast_datastore *datastore = NULL;
10854 struct ast_framehook_interface interface = {
10856 .event_cb = suppress_framehook_event_cb,
10857 .destroy_cb = suppress_framehook_destroy_cb,
10858 .chan_fixup_cb = suppress_framehook_fixup_cb,
10859 };
10860 int framehook_id;
10861
10862 if (!(datastore_info = suppress_get_datastore_information(frametype))) {
10863 ast_log(LOG_WARNING, "Attempted to suppress an unsupported frame type (%u).\n", frametype);
10864 return -1;
10865 }
10866
10867 if ((datastore = ast_channel_datastore_find(chan, datastore_info, NULL))) {
10868 suppress = datastore->data;
10869 suppress->direction |= direction;
10870 return 0;
10871 }
10872
10873 if (!(suppress = ao2_alloc(sizeof(*suppress), NULL))) {
10874 ast_log(LOG_WARNING, "Failed to allocate data while attempting to suppress a stream.\n");
10875 return -1;
10876 }
10877
10878 suppress->frametype = frametype;
10879 suppress->direction |= direction;
10880
10881 interface.data = suppress;
10882
10883 framehook_id = ast_framehook_attach(chan, &interface);
10884 if (framehook_id < 0) {
10885 /* Hook attach failed. Get rid of the evidence. */
10886 ast_log(LOG_WARNING, "Failed to attach framehook while attempting to suppress a stream.\n");
10887 ao2_ref(suppress, -1);
10888 return -1;
10889 }
10890
10891 /* One ref for the framehook */
10892 ao2_ref(suppress, +1);
10893
10894 suppress->framehook_id = framehook_id;
10895
10896 if (!(datastore = ast_datastore_alloc(datastore_info, NULL))) {
10897 ast_log(LOG_WARNING, "Failed to allocate datastore while attempting to suppress a stream.\n");
10898 ast_framehook_detach(chan, framehook_id);
10899 ao2_ref(suppress, -1);
10900 return -1;
10901 }
10902
10903 /* the ref provided by the allocation is taken by the datastore */
10904 datastore->data = suppress;
10905
10906 ast_channel_datastore_add(chan, datastore);
10907
10908 return 0;
10909}
static void suppress_framehook_fixup_cb(void *data, int framehook_id, struct ast_channel *old_chan, struct ast_channel *new_chan)
Definition channel.c:10797
static const struct ast_datastore_info * suppress_get_datastore_information(enum ast_frame_type frametype)
Definition channel.c:10839
static void suppress_framehook_destroy_cb(void *data)
Definition channel.c:10786
static struct ast_frame * suppress_framehook_event_cb(struct ast_channel *chan, struct ast_frame *frame, enum ast_framehook_event event, void *data)
Definition channel.c:10804
int ast_framehook_attach(struct ast_channel *chan, struct ast_framehook_interface *i)
Attach an framehook onto a channel for frame interception.
Definition framehook.c:132
int ast_framehook_detach(struct ast_channel *chan, int framehook_id)
Detach an framehook from a channel.
Definition framehook.c:177
#define AST_FRAMEHOOK_INTERFACE_VERSION
Definition framehook.h:227
direction
Structure for a data store type.
Definition datastore.h:31
enum ast_frame_type frametype
Definition channel.c:10792
unsigned int direction
Definition channel.c:10793

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

Referenced by app_control_mute(), and mute_channel().

◆ ast_channel_undefer_dtmf()

void ast_channel_undefer_dtmf ( struct ast_channel chan)

Unset defer DTMF flag on channel.

Undo defer. ast_read will return any DTMF characters that were queued

Definition at line 1329 of file channel.c.

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

References ast_channel_clear_flag(), and AST_FLAG_DEFER_DTMF.

Referenced by __adsi_transmit_messages().

◆ ast_channel_unlink()

void ast_channel_unlink ( struct ast_channel chan)

Remove a channel from the global channels container.

Parameters
chanchannel to remove

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

Definition at line 10601 of file channel.c.

References CHANNELSTORAGE_API, current_channel_storage_instance, and remove.

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

◆ ast_channel_unregister()

void ast_channel_unregister ( const struct ast_channel_tech tech)

◆ ast_channel_unsuppress()

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

Stop suppressing of a frame type on a channel.

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

Definition at line 10911 of file channel.c.

10912{
10913 const struct ast_datastore_info *datastore_info = NULL;
10914 struct ast_datastore *datastore = NULL;
10915 struct suppress_data *suppress;
10916
10917 if (!(datastore_info = suppress_get_datastore_information(frametype))) {
10918 ast_log(LOG_WARNING, "Attempted to unsuppress an unsupported frame type (%u).\n", frametype);
10919 return -1;
10920 }
10921
10922 if (!(datastore = ast_channel_datastore_find(chan, datastore_info, NULL))) {
10923 /* Nothing to do! */
10924 return 0;
10925 }
10926
10927 suppress = datastore->data;
10928
10929 suppress->direction &= ~(direction);
10930
10931 if (suppress->direction == 0) {
10932 /* Nothing left to suppress. Bye! */
10933 ast_framehook_detach(chan, suppress->framehook_id);
10934 ast_channel_datastore_remove(chan, datastore);
10935 ast_datastore_free(datastore);
10936 }
10937
10938 return 0;
10939}

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

Referenced by app_control_unmute(), and mute_channel().

◆ ast_channel_update_connected_line()

void ast_channel_update_connected_line ( struct ast_channel chan,
const struct ast_party_connected_line connected,
const struct ast_set_party_connected_line update 
)

Indicate that the connected line information has changed.

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

Definition at line 9161 of file channel.c.

9162{
9163 unsigned char data[1024]; /* This should be large enough */
9164 size_t datalen;
9165
9166 datalen = ast_connected_line_build_data(data, sizeof(data), connected, update);
9167 if (datalen == (size_t) -1) {
9168 return;
9169 }
9170
9171 ast_indicate_data(chan, AST_CONTROL_CONNECTED_LINE, data, datalen);
9172}

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

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

◆ ast_channel_update_redirecting()

void ast_channel_update_redirecting ( struct ast_channel chan,
const struct ast_party_redirecting redirecting,
const struct ast_set_party_redirecting update 
)

Indicate that the redirecting id has changed.

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

Definition at line 10352 of file channel.c.

10353{
10354 unsigned char data[1024]; /* This should be large enough */
10355 size_t datalen;
10356
10357 datalen = ast_redirecting_build_data(data, sizeof(data), redirecting, update);
10358 if (datalen == (size_t) -1) {
10359 return;
10360 }
10361
10362 ast_indicate_data(chan, AST_CONTROL_REDIRECTING, data, datalen);
10363}

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

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

◆ ast_channel_yank()

struct ast_channel * ast_channel_yank ( struct ast_channel yankee)

Gain control of a channel in the system.

Since
12

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

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

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

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

Definition at line 10665 of file channel.c.

10666{
10667 struct ast_channel *yanked_chan;
10668 struct {
10669 char *accountcode;
10670 char *exten;
10671 char *context;
10672 char *name;
10673 int amaflags;
10674 int priority;
10675 struct ast_format *readformat;
10676 struct ast_format *writeformat;
10677 } my_vars = { 0, };
10678
10679 ast_channel_lock(yankee);
10680 my_vars.accountcode = ast_strdupa(ast_channel_accountcode(yankee));
10681 my_vars.exten = ast_strdupa(ast_channel_exten(yankee));
10682 my_vars.context = ast_strdupa(ast_channel_context(yankee));
10683 my_vars.name = ast_strdupa(ast_channel_name(yankee));
10684 my_vars.amaflags = ast_channel_amaflags(yankee);
10685 my_vars.priority = ast_channel_priority(yankee);
10686 /* The priority as returned by ast_channel_yank is where the channel
10687 * should go if the dialplan is executed on it. If the channel is
10688 * already executing dialplan then the priority currently set is
10689 * where it is currently. We increment it so it becomes where it should
10690 * execute.
10691 */
10693 my_vars.priority++;
10694 }
10695 my_vars.writeformat = ao2_bump(ast_channel_writeformat(yankee));
10696 my_vars.readformat = ao2_bump(ast_channel_readformat(yankee));
10697 ast_channel_unlock(yankee);
10698
10699 /* Do not hold any channel locks while calling channel_alloc() since the function
10700 * locks the channel container when linking the new channel in. */
10701 if (!(yanked_chan = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, my_vars.accountcode,
10702 my_vars.exten, my_vars.context, NULL, yankee, my_vars.amaflags,
10703 "Surrogate/%s", my_vars.name))) {
10704 ao2_cleanup(my_vars.writeformat);
10705 ao2_cleanup(my_vars.readformat);
10706 return NULL;
10707 }
10708
10709 /* Make formats okay */
10710 ast_channel_set_readformat(yanked_chan, my_vars.readformat);
10711 ast_channel_set_writeformat(yanked_chan, my_vars.writeformat);
10712 ao2_cleanup(my_vars.readformat);
10713 ao2_cleanup(my_vars.writeformat);
10714 ast_channel_priority_set(yanked_chan, my_vars.priority);
10715
10716 ast_channel_unlock(yanked_chan);
10717
10718 if (ast_channel_move(yanked_chan, yankee)) {
10719 ast_hangup(yanked_chan);
10720 return NULL;
10721 }
10722
10723 return yanked_chan;
10724}
static char accountcode[AST_MAX_ACCOUNT_CODE]
Definition chan_iax2.c:510
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:10738
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
Definition channel.h:1299
int ast_channel_priority(const struct ast_channel *chan)
const char * ast_channel_accountcode(const struct ast_channel *chan)
enum ama_flags ast_channel_amaflags(const struct ast_channel *chan)
@ AST_FLAG_IN_AUTOLOOP
Definition channel.h:1017
const char * ast_channel_exten(const struct ast_channel *chan)
@ AST_STATE_DOWN
struct ast_format * writeformat
struct ast_format * readformat

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

Referenced by ast_async_goto(), and ast_bridge_add_channel().

◆ ast_channels_init()

int ast_channels_init ( void  )

Provided by channel.c

Definition at line 8069 of file channel.c.

8070{
8071
8072 if (ast_channelstorage_init() != 0) {
8073 return -1;
8074 }
8075
8076 /*
8077 * channel_storage_type is a global variable set by options.c
8078 * from the "channel_storage_backend" option in asterisk.conf.
8079 */
8080 if (ast_channel_open_storage() != 0) {
8081 return -1;
8082 }
8083
8085
8087
8089
8091
8094
8095 return 0;
8096}
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition clicompat.c:19
static void channels_shutdown(void)
Definition channel.c:8007
int ast_channel_open_storage()
Definition channel.c:8020
int ast_channel_register(const struct ast_channel_tech *tech)
Register a new telephony channel in Asterisk.
Definition channel.c:540
static const struct ast_channel_tech surrogate_tech
Channel technology used to extract a channel from a running application. The channel created with thi...
Definition channel.c:697
static struct ast_cli_entry cli_channel[]
Definition channel.c:391
int ast_channelstorage_init(void)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition cli.h:265
#define AST_RWLIST_HEAD_INIT(head)
Initializes an rwlist head structure.
int ast_stasis_channels_init(void)
Initialize the stasis channel topic and message types.

References ami_vars, ari_vars, ARRAY_LEN, ast_channel_open_storage(), ast_channel_register(), ast_channelstorage_init(), ast_cli_register_multiple, ast_register_cleanup(), AST_RWLIST_HEAD_INIT, ast_stasis_channels_init(), channels_shutdown(), cli_channel, and surrogate_tech.

Referenced by asterisk_daemon().

◆ ast_channeltype_list()

struct ast_variable * ast_channeltype_list ( void  )

return an ast_variable list of channeltypes

Definition at line 189 of file channel.c.

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

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

Referenced by ast_var_channel_types(), and ast_var_channel_types_table().

◆ ast_check_hangup()

int ast_check_hangup ( struct ast_channel chan)

Checks to see if a channel is needing hang up.

Check to see if a channel is needing hang up.

Definition at line 446 of file channel.c.

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

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

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

◆ ast_check_hangup_locked()

int ast_check_hangup_locked ( struct ast_channel chan)

◆ ast_connected_line_build_data()

int ast_connected_line_build_data ( unsigned char *  data,
size_t  datalen,
const struct ast_party_connected_line connected,
const struct ast_set_party_connected_line update 
)

Build the connected line information data frame.

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

Definition at line 8765 of file channel.c.

8766{
8767 int32_t value;
8768 size_t pos = 0;
8769 int res;
8770
8771 static const struct ast_party_id_ies ies = {
8773 .name.char_set = AST_CONNECTED_LINE_NAME_CHAR_SET,
8774 .name.presentation = AST_CONNECTED_LINE_NAME_PRESENTATION,
8775 .name.valid = AST_CONNECTED_LINE_NAME_VALID,
8776
8777 .number.str = AST_CONNECTED_LINE_NUMBER,
8778 .number.plan = AST_CONNECTED_LINE_NUMBER_PLAN,
8779 .number.presentation = AST_CONNECTED_LINE_NUMBER_PRESENTATION,
8780 .number.valid = AST_CONNECTED_LINE_NUMBER_VALID,
8781
8782 .subaddress.str = AST_CONNECTED_LINE_SUBADDRESS,
8783 .subaddress.type = AST_CONNECTED_LINE_SUBADDRESS_TYPE,
8784 .subaddress.odd_even_indicator = AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN,
8785 .subaddress.valid = AST_CONNECTED_LINE_SUBADDRESS_VALID,
8786
8788 .combined_presentation = AST_CONNECTED_LINE_ID_PRESENTATION,
8789 };
8790
8791 static const struct ast_party_id_ies priv_ies = {
8794 .name.presentation = AST_CONNECTED_LINE_PRIV_NAME_PRESENTATION,
8796
8797 .number.str = AST_CONNECTED_LINE_PRIV_NUMBER,
8799 .number.presentation = AST_CONNECTED_LINE_PRIV_NUMBER_PRESENTATION,
8801
8802 .subaddress.str = AST_CONNECTED_LINE_PRIV_SUBADDRESS,
8803 .subaddress.type = AST_CONNECTED_LINE_PRIV_SUBADDRESS_TYPE,
8804 .subaddress.odd_even_indicator = AST_CONNECTED_LINE_PRIV_SUBADDRESS_ODD_EVEN,
8805 .subaddress.valid = AST_CONNECTED_LINE_PRIV_SUBADDRESS_VALID,
8806
8808 .combined_presentation = 0,/* Not sent. */
8809 };
8810
8811 /*
8812 * The size of integer values must be fixed in case the frame is
8813 * shipped to another machine.
8814 */
8815
8816 /* Connected line frame version */
8817 if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8818 ast_log(LOG_WARNING, "No space left for connected line frame version\n");
8819 return -1;
8820 }
8821 data[pos++] = AST_CONNECTED_LINE_VERSION;
8822 data[pos++] = 1;
8823 data[pos++] = 2;/* Version 1 did not have a version ie */
8824
8825 res = party_id_build_data(data + pos, datalen - pos, &connected->id,
8826 "connected line", &ies, update ? &update->id : NULL);
8827 if (res < 0) {
8828 return -1;
8829 }
8830 pos += res;
8831
8832 res = party_id_build_data(data + pos, datalen - pos, &connected->priv,
8833 "connected line priv", &priv_ies, update ? &update->priv : NULL);
8834 if (res < 0) {
8835 return -1;
8836 }
8837 pos += res;
8838
8839 /* Connected line source */
8840 if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) {
8841 ast_log(LOG_WARNING, "No space left for connected line source\n");
8842 return -1;
8843 }
8844 data[pos++] = AST_CONNECTED_LINE_SOURCE;
8845 data[pos++] = sizeof(value);
8846 value = htonl(connected->source);
8847 memcpy(data + pos, &value, sizeof(value));
8848 pos += sizeof(value);
8849
8850 return pos;
8851}
static int party_id_build_data(unsigned char *data, size_t datalen, const struct ast_party_id *id, const char *label, const struct ast_party_id_ies *ies, const struct ast_set_party_id *update)
Definition channel.c:8645
struct ast_party_name_ies name
Subscriber name ies.
Definition channel.c:8616
int str
Subscriber name ie.
Definition channel.c:8393
int value
Definition syslog.c:37

References AST_CONNECTED_LINE_ID_PRESENTATION, AST_CONNECTED_LINE_NAME, AST_CONNECTED_LINE_NAME_CHAR_SET, AST_CONNECTED_LINE_NAME_PRESENTATION, AST_CONNECTED_LINE_NAME_VALID, AST_CONNECTED_LINE_NUMBER, AST_CONNECTED_LINE_NUMBER_PLAN, AST_CONNECTED_LINE_NUMBER_PRESENTATION, AST_CONNECTED_LINE_NUMBER_VALID, AST_CONNECTED_LINE_PRIV_NAME, AST_CONNECTED_LINE_PRIV_NAME_CHAR_SET, AST_CONNECTED_LINE_PRIV_NAME_PRESENTATION, AST_CONNECTED_LINE_PRIV_NAME_VALID, AST_CONNECTED_LINE_PRIV_NUMBER, AST_CONNECTED_LINE_PRIV_NUMBER_PLAN, AST_CONNECTED_LINE_PRIV_NUMBER_PRESENTATION, AST_CONNECTED_LINE_PRIV_NUMBER_VALID, AST_CONNECTED_LINE_PRIV_SUBADDRESS, AST_CONNECTED_LINE_PRIV_SUBADDRESS_ODD_EVEN, AST_CONNECTED_LINE_PRIV_SUBADDRESS_TYPE, AST_CONNECTED_LINE_PRIV_SUBADDRESS_VALID, AST_CONNECTED_LINE_PRIV_TAG, AST_CONNECTED_LINE_SOURCE, AST_CONNECTED_LINE_SUBADDRESS, AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN, AST_CONNECTED_LINE_SUBADDRESS_TYPE, AST_CONNECTED_LINE_SUBADDRESS_VALID, AST_CONNECTED_LINE_TAG, AST_CONNECTED_LINE_VERSION, ast_log, connected, LOG_WARNING, ast_party_id_ies::name, NULL, party_id_build_data(), ast_party_name_ies::str, update(), and value.

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

◆ ast_connected_line_copy_from_caller()

void ast_connected_line_copy_from_caller ( struct ast_party_connected_line dest,
const struct ast_party_caller src 
)

Copy the caller information to the connected line information.

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

Definition at line 8361 of file channel.c.

8362{
8363 ast_party_id_copy(&dest->id, &src->id);
8364 ast_party_id_copy(&dest->ani, &src->ani);
8365 dest->ani2 = src->ani2;
8366}
void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src)
Copy the source party id information to the destination party id.
Definition channel.c:1752
int ani2
Automatic Number Identification 2 (Info Digits)
Definition channel.h:435
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition channel.h:429
struct ast_party_id id
Connected party ID.
Definition channel.h:460
int ani2
Automatic Number Identification 2 (Info Digits)
Definition channel.h:477
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition channel.h:467

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

Referenced by after_bridge_move_channel(), agent_request_exec(), app_exec(), ast_ari_channels_dial(), ast_do_pickup(), ast_unreal_call_setup(), begin_dial_prerun(), bridge_reconfigured_connected_line_update(), copy_caller_data(), dial_exec_full(), do_forward(), findmeexec(), park_local_transfer(), ring_entry(), update_connected_line_from_peer(), update_connected_line_from_peer(), and wait_for_answer().

◆ ast_connected_line_copy_to_caller()

void ast_connected_line_copy_to_caller ( struct ast_party_caller dest,
const struct ast_party_connected_line src 
)

Copy the connected line information to the caller information.

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

Definition at line 8368 of file channel.c.

8369{
8370 ast_party_id_copy(&dest->id, &src->id);
8371 ast_party_id_copy(&dest->ani, &src->ani);
8372
8373 dest->ani2 = src->ani2;
8374}

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

Referenced by ast_unreal_call_setup(), and unreal_colp_redirect_indicate().

◆ ast_connected_line_parse_data()

int ast_connected_line_parse_data ( const unsigned char *  data,
size_t  datalen,
struct ast_party_connected_line connected 
)

Parse connected line indication frame data.

Since
1.8
Parameters
dataBuffer with the frame data to parse
datalenSize of the buffer
connectedExtracted connected line information
Return values
0on success.
-1on error.
Note
The filled in connected line structure needs to be initialized by ast_party_connected_line_set_init() before calling. If defaults are not required use ast_party_connected_line_init().
The filled in connected line structure needs to be destroyed by ast_party_connected_line_free() when it is no longer needed.

Definition at line 8853 of file channel.c.

8854{
8855 size_t pos;
8856 unsigned char ie_len;
8857 unsigned char ie_id;
8858 int32_t value;
8859 int frame_version = 1;
8860 int combined_presentation = 0;
8861 int got_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
8862
8863 for (pos = 0; pos < datalen; pos += ie_len) {
8864 if (datalen < pos + sizeof(ie_id) + sizeof(ie_len)) {
8865 ast_log(LOG_WARNING, "Invalid connected line update\n");
8866 return -1;
8867 }
8868 ie_id = data[pos++];
8869 ie_len = data[pos++];
8870 if (datalen < pos + ie_len) {
8871 ast_log(LOG_WARNING, "Invalid connected line update\n");
8872 return -1;
8873 }
8874
8875 switch (ie_id) {
8876/* Connected line party frame version */
8878 if (ie_len != 1) {
8879 ast_log(LOG_WARNING, "Invalid connected line frame version (%u)\n",
8880 (unsigned) ie_len);
8881 break;
8882 }
8883 frame_version = data[pos];
8884 break;
8885/* Connected line party id name */
8887 ast_free(connected->id.name.str);
8888 connected->id.name.str = ast_malloc(ie_len + 1);
8889 if (connected->id.name.str) {
8890 memcpy(connected->id.name.str, data + pos, ie_len);
8891 connected->id.name.str[ie_len] = 0;
8892 }
8893 break;
8895 if (ie_len != 1) {
8896 ast_log(LOG_WARNING, "Invalid connected line name char set (%u)\n",
8897 (unsigned) ie_len);
8898 break;
8899 }
8900 connected->id.name.char_set = data[pos];
8901 break;
8903 if (ie_len != 1) {
8904 ast_log(LOG_WARNING, "Invalid connected line name presentation (%u)\n",
8905 (unsigned) ie_len);
8906 break;
8907 }
8908 connected->id.name.presentation = data[pos];
8909 break;
8911 if (ie_len != 1) {
8912 ast_log(LOG_WARNING, "Invalid connected line name valid (%u)\n",
8913 (unsigned) ie_len);
8914 break;
8915 }
8916 connected->id.name.valid = data[pos];
8917 break;
8918/* Connected line party id number */
8920 ast_free(connected->id.number.str);
8921 connected->id.number.str = ast_malloc(ie_len + 1);
8922 if (connected->id.number.str) {
8923 memcpy(connected->id.number.str, data + pos, ie_len);
8924 connected->id.number.str[ie_len] = 0;
8925 }
8926 break;
8928 if (ie_len != 1) {
8929 ast_log(LOG_WARNING, "Invalid connected line numbering plan (%u)\n",
8930 (unsigned) ie_len);
8931 break;
8932 }
8933 connected->id.number.plan = data[pos];
8934 break;
8936 if (ie_len != 1) {
8937 ast_log(LOG_WARNING, "Invalid connected line number presentation (%u)\n",
8938 (unsigned) ie_len);
8939 break;
8940 }
8941 connected->id.number.presentation = data[pos];
8942 break;
8944 if (ie_len != 1) {
8945 ast_log(LOG_WARNING, "Invalid connected line number valid (%u)\n",
8946 (unsigned) ie_len);
8947 break;
8948 }
8949 connected->id.number.valid = data[pos];
8950 break;
8951/* Connected line party id subaddress */
8953 ast_free(connected->id.subaddress.str);
8954 connected->id.subaddress.str = ast_malloc(ie_len + 1);
8955 if (connected->id.subaddress.str) {
8956 memcpy(connected->id.subaddress.str, data + pos, ie_len);
8957 connected->id.subaddress.str[ie_len] = 0;
8958 }
8959 break;
8961 if (ie_len != 1) {
8962 ast_log(LOG_WARNING, "Invalid connected line type of subaddress (%u)\n",
8963 (unsigned) ie_len);
8964 break;
8965 }
8966 connected->id.subaddress.type = data[pos];
8967 break;
8969 if (ie_len != 1) {
8971 "Invalid connected line subaddress odd-even indicator (%u)\n",
8972 (unsigned) ie_len);
8973 break;
8974 }
8975 connected->id.subaddress.odd_even_indicator = data[pos];
8976 break;
8978 if (ie_len != 1) {
8979 ast_log(LOG_WARNING, "Invalid connected line subaddress valid (%u)\n",
8980 (unsigned) ie_len);
8981 break;
8982 }
8983 connected->id.subaddress.valid = data[pos];
8984 break;
8985/* Connected line party tag */
8987 ast_free(connected->id.tag);
8988 connected->id.tag = ast_malloc(ie_len + 1);
8989 if (connected->id.tag) {
8990 memcpy(connected->id.tag, data + pos, ie_len);
8991 connected->id.tag[ie_len] = 0;
8992 }
8993 break;
8994/* Connected line party id combined presentation */
8996 if (ie_len != 1) {
8997 ast_log(LOG_WARNING, "Invalid connected line combined presentation (%u)\n",
8998 (unsigned) ie_len);
8999 break;
9000 }
9001 combined_presentation = data[pos];
9002 got_combined_presentation = 1;
9003 break;
9004/* Private connected line party id name */
9006 ast_free(connected->priv.name.str);
9007 connected->priv.name.str = ast_malloc(ie_len + 1);
9008 if (connected->priv.name.str) {
9009 memcpy(connected->priv.name.str, data + pos, ie_len);
9010 connected->priv.name.str[ie_len] = 0;
9011 }
9012 break;
9014 if (ie_len != 1) {
9015 ast_log(LOG_WARNING, "Invalid connected line private name char set (%u)\n",
9016 (unsigned) ie_len);
9017 break;
9018 }
9019 connected->priv.name.char_set = data[pos];
9020 break;
9022 if (ie_len != 1) {
9023 ast_log(LOG_WARNING, "Invalid connected line private name presentation (%u)\n",
9024 (unsigned) ie_len);
9025 break;
9026 }
9027 connected->priv.name.presentation = data[pos];
9028 break;
9030 if (ie_len != 1) {
9031 ast_log(LOG_WARNING, "Invalid connected line private name valid (%u)\n",
9032 (unsigned) ie_len);
9033 break;
9034 }
9035 connected->priv.name.valid = data[pos];
9036 break;
9037/* Private connected line party id number */
9039 ast_free(connected->priv.number.str);
9040 connected->priv.number.str = ast_malloc(ie_len + 1);
9041 if (connected->priv.number.str) {
9042 memcpy(connected->priv.number.str, data + pos, ie_len);
9043 connected->priv.number.str[ie_len] = 0;
9044 }
9045 break;
9047 if (ie_len != 1) {
9048 ast_log(LOG_WARNING, "Invalid connected line private numbering plan (%u)\n",
9049 (unsigned) ie_len);
9050 break;
9051 }
9052 connected->priv.number.plan = data[pos];
9053 break;
9055 if (ie_len != 1) {
9056 ast_log(LOG_WARNING, "Invalid connected line private number presentation (%u)\n",
9057 (unsigned) ie_len);
9058 break;
9059 }
9060 connected->priv.number.presentation = data[pos];
9061 break;
9063 if (ie_len != 1) {
9064 ast_log(LOG_WARNING, "Invalid connected line private number valid (%u)\n",
9065 (unsigned) ie_len);
9066 break;
9067 }
9068 connected->priv.number.valid = data[pos];
9069 break;
9070/* Private connected line party id subaddress */
9072 ast_free(connected->priv.subaddress.str);
9073 connected->priv.subaddress.str = ast_malloc(ie_len + 1);
9074 if (connected->priv.subaddress.str) {
9075 memcpy(connected->priv.subaddress.str, data + pos, ie_len);
9076 connected->priv.subaddress.str[ie_len] = 0;
9077 }
9078 break;
9080 if (ie_len != 1) {
9081 ast_log(LOG_WARNING, "Invalid connected line private type of subaddress (%u)\n",
9082 (unsigned) ie_len);
9083 break;
9084 }
9085 connected->priv.subaddress.type = data[pos];
9086 break;
9088 if (ie_len != 1) {
9090 "Invalid connected line private subaddress odd-even indicator (%u)\n",
9091 (unsigned) ie_len);
9092 break;
9093 }
9094 connected->priv.subaddress.odd_even_indicator = data[pos];
9095 break;
9097 if (ie_len != 1) {
9098 ast_log(LOG_WARNING, "Invalid connected line private subaddress valid (%u)\n",
9099 (unsigned) ie_len);
9100 break;
9101 }
9102 connected->priv.subaddress.valid = data[pos];
9103 break;
9104/* Private connected line party tag */
9106 ast_free(connected->priv.tag);
9107 connected->priv.tag = ast_malloc(ie_len + 1);
9108 if (connected->priv.tag) {
9109 memcpy(connected->priv.tag, data + pos, ie_len);
9110 connected->priv.tag[ie_len] = 0;
9111 }
9112 break;
9113/* Connected line party source */
9115 if (ie_len != sizeof(value)) {
9116 ast_log(LOG_WARNING, "Invalid connected line source (%u)\n",
9117 (unsigned) ie_len);
9118 break;
9119 }
9120 memcpy(&value, data + pos, sizeof(value));
9121 connected->source = ntohl(value);
9122 break;
9123/* Connected line party unknown element */
9124 default:
9125 ast_debug(1, "Unknown connected line element: %u (%u)\n",
9126 (unsigned) ie_id, (unsigned) ie_len);
9127 break;
9128 }
9129 }
9130
9131 switch (frame_version) {
9132 case 1:
9133 /*
9134 * The other end is an earlier version that we need to adjust
9135 * for compatibility.
9136 */
9137 connected->id.name.valid = 1;
9138 connected->id.name.char_set = AST_PARTY_CHAR_SET_ISO8859_1;
9139 connected->id.number.valid = 1;
9140 if (got_combined_presentation) {
9141 connected->id.name.presentation = combined_presentation;
9142 connected->id.number.presentation = combined_presentation;
9143 }
9144 break;
9145 case 2:
9146 /* The other end is at the same level as we are. */
9147 break;
9148 default:
9149 /*
9150 * The other end is newer than we are.
9151 * We need to assume that they are compatible with us.
9152 */
9153 ast_debug(1, "Connected line frame has newer version: %u\n",
9154 (unsigned) frame_version);
9155 break;
9156 }
9157
9158 return 0;
9159}
#define ast_malloc(len)
A wrapper for malloc()
Definition astmm.h:191
@ AST_PARTY_CHAR_SET_ISO8859_1
Definition channel.h:246

References AST_CONNECTED_LINE_ID_PRESENTATION, AST_CONNECTED_LINE_NAME, AST_CONNECTED_LINE_NAME_CHAR_SET, AST_CONNECTED_LINE_NAME_PRESENTATION, AST_CONNECTED_LINE_NAME_VALID, AST_CONNECTED_LINE_NUMBER, AST_CONNECTED_LINE_NUMBER_PLAN, AST_CONNECTED_LINE_NUMBER_PRESENTATION, AST_CONNECTED_LINE_NUMBER_VALID, AST_CONNECTED_LINE_PRIV_NAME, AST_CONNECTED_LINE_PRIV_NAME_CHAR_SET, AST_CONNECTED_LINE_PRIV_NAME_PRESENTATION, AST_CONNECTED_LINE_PRIV_NAME_VALID, AST_CONNECTED_LINE_PRIV_NUMBER, AST_CONNECTED_LINE_PRIV_NUMBER_PLAN, AST_CONNECTED_LINE_PRIV_NUMBER_PRESENTATION, AST_CONNECTED_LINE_PRIV_NUMBER_VALID, AST_CONNECTED_LINE_PRIV_SUBADDRESS, AST_CONNECTED_LINE_PRIV_SUBADDRESS_ODD_EVEN, AST_CONNECTED_LINE_PRIV_SUBADDRESS_TYPE, AST_CONNECTED_LINE_PRIV_SUBADDRESS_VALID, AST_CONNECTED_LINE_PRIV_TAG, AST_CONNECTED_LINE_SOURCE, AST_CONNECTED_LINE_SUBADDRESS, AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN, AST_CONNECTED_LINE_SUBADDRESS_TYPE, AST_CONNECTED_LINE_SUBADDRESS_VALID, AST_CONNECTED_LINE_TAG, AST_CONNECTED_LINE_VERSION, ast_debug, ast_free, ast_log, ast_malloc, AST_PARTY_CHAR_SET_ISO8859_1, ast_party_id_ies::combined_presentation, connected, LOG_WARNING, and value.

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

◆ ast_deactivate_generator()

void ast_deactivate_generator ( struct ast_channel chan)

Deactivate an active generator

Definition at line 2892 of file channel.c.

2893{
2894 ast_channel_lock(chan);
2897 /* if in the middle of dtmf emulation keep 50 tick per sec timer on rolling */
2898 struct ast_timer *timer = ast_channel_timer(chan);
2899 if (timer) {
2901 } else {
2902 ast_log(LOG_WARNING, "No timing module loaded, DTMF length may be inaccurate\n");
2903 }
2904 }
2905 ast_channel_unlock(chan);
2906}
static void deactivate_generator_nolock(struct ast_channel *chan)
Definition channel.c:2877

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

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

◆ ast_dummy_channel_destructor()

static void ast_dummy_channel_destructor ( void *  obj)
static

Free a dummy channel structure.

Definition at line 2324 of file channel.c.

2325{
2326 struct ast_channel *chan = obj;
2327 struct ast_datastore *datastore;
2328 struct ast_var_t *vardata;
2329 struct varshead *headp;
2330
2332
2333 /* Get rid of each of the data stores on the channel */
2334 while ((datastore = AST_LIST_REMOVE_HEAD(ast_channel_datastores(chan), entry))) {
2335 /* Free the data store */
2336 ast_datastore_free(datastore);
2337 }
2338
2344
2345 /* loop over the variables list, freeing all data and deleting list items */
2346 /* no need to lock the list, as the channel is already locked */
2347 headp = ast_channel_varshead(chan);
2348 while ((vardata = AST_LIST_REMOVE_HEAD(headp, entries)))
2349 ast_var_delete(vardata);
2350
2351 if (ast_channel_cdr(chan)) {
2354 }
2355
2357}

References ast_cdr_free(), ast_channel_caller(), ast_channel_cdr(), ast_channel_cdr_set(), ast_channel_connected(), ast_channel_connected_indicated(), ast_channel_datastores(), ast_channel_dialed(), ast_channel_internal_cleanup(), ast_channel_redirecting(), ast_channel_varshead(), ast_datastore_free(), AST_LIST_REMOVE_HEAD, ast_party_caller_free(), ast_party_connected_line_free(), ast_party_dialed_free(), ast_party_redirecting_free(), ast_pbx_hangup_handler_destroy(), ast_var_delete(), and NULL.

Referenced by __ast_dummy_channel_alloc().

◆ ast_get_channel_tech()

const struct ast_channel_tech * ast_get_channel_tech ( const char *  name)

Get handle to channel driver based on name.

Get a channel technology structure by name.

Definition at line 593 of file channel.c.

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

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

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

◆ ast_get_group()

ast_group_t ast_get_group ( const char *  s)

Definition at line 7654 of file channel.c.

7655{
7656 char *piece;
7657 char *c;
7658 int start=0, finish=0, x;
7659 ast_group_t group = 0;
7660
7661 if (ast_strlen_zero(s))
7662 return 0;
7663
7664 c = ast_strdupa(s);
7665
7666 while ((piece = strsep(&c, ","))) {
7667 if (sscanf(piece, "%30d-%30d", &start, &finish) == 2) {
7668 /* Range */
7669 } else if (sscanf(piece, "%30d", &start)) {
7670 /* Just one */
7671 finish = start;
7672 } else {
7673 ast_log(LOG_ERROR, "Syntax error parsing group configuration '%s' at '%s'. Ignoring.\n", s, piece);
7674 continue;
7675 }
7676 for (x = start; x <= finish; x++) {
7677 if ((x > 63) || (x < 0)) {
7678 ast_log(LOG_WARNING, "Ignoring invalid group %d (maximum group is 63)\n", x);
7679 } else
7680 group |= ((ast_group_t) 1 << x);
7681 }
7682 }
7683 return group;
7684}
char * strsep(char **str, const char *delims)
unsigned long long ast_group_t
Definition channel.h:215
static struct test_val c

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

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

◆ ast_get_namedgroups()

struct ast_namedgroups * ast_get_namedgroups ( const char *  s)

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

Remove leading and trailing whitespace

Definition at line 7711 of file channel.c.

7712{
7713 struct ao2_container *namedgroups;
7714 char *piece;
7715 char *c;
7716
7717 if (!s) {
7718 return NULL;
7719 }
7720
7721 /*! \brief Remove leading and trailing whitespace */
7723 if (ast_strlen_zero(c)) {
7724 return NULL;
7725 }
7726
7729 if (!namedgroups) {
7730 return NULL;
7731 }
7732
7733 while ((piece = strsep(&c, ","))) {
7734 struct namedgroup_member *member;
7735 size_t len;
7736
7737 /* remove leading/trailing whitespace */
7738 piece = ast_strip(piece);
7739
7740 len = strlen(piece);
7741 if (!len) {
7742 continue;
7743 }
7744
7746 if (!member) {
7747 ao2_ref(namedgroups, -1);
7748 return NULL;
7749 }
7750 strcpy(member->name, piece);/* Safe */
7751 member->hash = ast_str_hash(member->name);
7752
7753 /* every group name may exist only once, delete duplicates */
7754 ao2_find(namedgroups, member, OBJ_POINTER | OBJ_UNLINK | OBJ_NODATA);
7755 ao2_link(namedgroups, member);
7756 ao2_ref(member, -1);
7757 }
7758
7759 if (!ao2_container_count(namedgroups)) {
7760 /* There were no group names specified. */
7761 ao2_ref(namedgroups, -1);
7762 namedgroups = NULL;
7763 }
7764
7765 return (struct ast_namedgroups *) namedgroups;
7766}
#define ao2_link(container, obj)
Add an object to a container.
Definition astobj2.h:1532
#define OBJ_POINTER
Definition astobj2.h:1150
@ AO2_ALLOC_OPT_LOCK_NOLOCK
Definition astobj2.h:367
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
#define ao2_find(container, arg, flags)
Definition astobj2.h:1736
#define ao2_alloc_options(data_size, destructor_fn, options)
Definition astobj2.h:404
@ OBJ_NODATA
Definition astobj2.h:1044
@ OBJ_UNLINK
Definition astobj2.h:1039
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
Definition astobj2.h:1303
static int namedgroup_cmp_cb(void *obj, void *arg, int flags)
Comparison function used for named group container.
Definition channel.c:7695
static int namedgroup_hash_cb(const void *obj, const int flags)
Hashing function used for named group container.
Definition channel.c:7704
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
Definition strings.h:1259
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
Definition strings.h:186
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Definition strings.h:223
char *attribute_pure ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
Definition strings.h:161
Generic container type.
Named group member structure.
Definition channel.c:7687

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

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

◆ ast_hangup()

void ast_hangup ( struct ast_channel chan)

Hangup a channel.

Hang up a channel.

Definition at line 2540 of file channel.c.

2541{
2542 /* Be NULL safe for RAII_VAR() usage. */
2543 if (!chan) {
2544 return;
2545 }
2546
2547 ast_debug(1, "Channel %p '%s' hanging up. Refs: %d\n", chan, ast_channel_name(chan),
2548 ao2_ref(chan, 0));
2549
2551
2552 ast_channel_lock(chan);
2553
2554 while (ast_channel_masq(chan) || ast_channel_masqr(chan)) {
2556 }
2557
2558 /* Mark as a zombie so a masquerade cannot be setup on this channel. */
2560
2561 ast_channel_unlock(chan);
2562
2563 /*
2564 * XXX if running the hangup handlers here causes problems
2565 * because the handlers take too long to execute, we could move
2566 * the meat of this function into another thread. A thread
2567 * where channels go to die.
2568 *
2569 * If this is done, ast_autoservice_chan_hangup_peer() will no
2570 * longer be needed.
2571 */
2573 ast_channel_unlink(chan);
2574 ast_channel_lock(chan);
2575
2576 destroy_hooks(chan);
2577
2578 free_translation(chan);
2579 /* Close audio stream */
2580 if (ast_channel_stream(chan)) {
2583 }
2584 /* Close video stream */
2585 if (ast_channel_vstream(chan)) {
2588 }
2589 if (ast_channel_sched(chan)) {
2592 }
2593
2594 if (ast_channel_generatordata(chan)) { /* Clear any tone stuff remaining */
2595 if (ast_channel_generator(chan) && ast_channel_generator(chan)->release) {
2597 }
2598 }
2601
2603 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_channel_blockproc(chan));
2606 ast_assert(0);
2607 }
2608
2609 if (ast_channel_tech(chan)->hangup) {
2610 ast_channel_tech(chan)->hangup(chan);
2611 }
2612
2613 ast_channel_unlock(chan);
2614
2615 ast_cc_offer(chan);
2616
2617 ast_channel_unref(chan);
2618}
int ast_cc_offer(struct ast_channel *caller_chan)
Offer CC to a caller.
Definition ccss.c:3780
static int hangup(void *data)
static void destroy_hooks(struct ast_channel *chan)
Definition channel.c:2529
static void free_translation(struct ast_channel *clonechan)
Definition channel.c:2486
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
struct ast_channel * ast_channel_masq(const struct ast_channel *chan)
int ast_channel_blocker_tid(const struct ast_channel *chan)
void ast_channel_stream_set(struct ast_channel *chan, struct ast_filestream *value)
const char * ast_channel_blockproc(const struct ast_channel *chan)
struct ast_filestream * ast_channel_vstream(const struct ast_channel *chan)
struct ast_filestream * ast_channel_stream(const struct ast_channel *chan)
struct ast_channel * ast_channel_masqr(const struct ast_channel *chan)
void ast_channel_vstream_set(struct ast_channel *chan, struct ast_filestream *value)
int ast_closestream(struct ast_filestream *f)
Closes a stream.
Definition file.c:1130
#define CHANNEL_DEADLOCK_AVOIDANCE(chan)
Definition lock.h:481
int ast_pbx_hangup_handler_run(struct ast_channel *chan)
Run all hangup handlers on the channel.
int(*const hangup)(struct ast_channel *chan)
Hangup (and possibly destroy) the channel.
Definition channel.h:724
int ast_get_tid(void)
Get current thread ID.
Definition utils.c:2786

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

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

◆ ast_indicate()

int ast_indicate ( struct ast_channel chan,
int  condition 
)

Indicates condition of channel.

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

Definition at line 4298 of file channel.c.

4299{
4300 return ast_indicate_data(chan, condition, NULL, 0);
4301}

References ast_indicate_data(), and NULL.

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

◆ ast_indicate_data()

int ast_indicate_data ( struct ast_channel chan,
int  condition,
const void *  data,
size_t  datalen 
)

Indicates condition of channel, with payload.

Note
Absolutely NO channel locks should be held before calling this function.
Indicate a condition such as AST_CONTROL_HOLD with payload being music on hold class
Parameters
chanchannel to change the indication
conditionwhich condition to indicate on the channel
datapointer to payload data
datalensize of payload data
Returns
Returns 0 on success, -1 on failure

Definition at line 4676 of file channel.c.

4677{
4678 int res;
4679 /* this frame is used by framehooks. if it is set, we must free it at the end of this function */
4680 struct ast_frame *awesome_frame = NULL;
4681
4682 ast_channel_lock(chan);
4683
4684 /* Don't bother if the channel is about to go away, anyway. */
4687 && _condition != AST_CONTROL_MASQUERADE_NOTIFY) {
4688 res = -1;
4689 goto indicate_cleanup;
4690 }
4691
4693 /* Do framehooks now, do it, go, go now */
4694 struct ast_frame frame = {
4696 .subclass.integer = _condition,
4697 .data.ptr = (void *) data, /* this cast from const is only okay because we do the ast_frdup below */
4698 .datalen = datalen
4699 };
4700
4701 /* we have now committed to freeing this frame */
4702 awesome_frame = ast_frdup(&frame);
4703
4704 /* who knows what we will get back! the anticipation is killing me. */
4706 awesome_frame);
4707 if (!awesome_frame
4708 || awesome_frame->frametype != AST_FRAME_CONTROL) {
4709 res = 0;
4710 goto indicate_cleanup;
4711 }
4712
4713 _condition = awesome_frame->subclass.integer;
4714 data = awesome_frame->data.ptr;
4715 datalen = awesome_frame->datalen;
4716 }
4717
4718 res = indicate_data_internal(chan, _condition, data, datalen);
4719
4720indicate_cleanup:
4721 ast_channel_unlock(chan);
4722 if (awesome_frame) {
4723 ast_frfree(awesome_frame);
4724 }
4725
4726 return res;
4727}
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:10622
static int indicate_data_internal(struct ast_channel *chan, int _condition, const void *data, size_t datalen)
Definition channel.c:4492
int ast_framehook_list_is_empty(struct ast_framehook_list *framehooks)
Determine if an framehook list is empty or not.
Definition framehook.c:274
struct ast_frame * ast_framehook_list_write_event(struct ast_framehook_list *framehooks, struct ast_frame *frame)
This is used by the channel API push a frame write event to a channel's framehook list.
Definition framehook.c:313
@ AST_CONTROL_MASQUERADE_NOTIFY

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

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

◆ ast_install_music_functions()

void ast_install_music_functions ( int(*)(struct ast_channel *, const char *, const char *)  start_ptr,
void(*)(struct ast_channel *)  stop_ptr,
void(*)(struct ast_channel *)  cleanup_ptr 
)

Definition at line 7786 of file channel.c.

7789{
7790 ast_moh_start_ptr = start_ptr;
7791 ast_moh_stop_ptr = stop_ptr;
7792 ast_moh_cleanup_ptr = cleanup_ptr;
7793}
static void(* ast_moh_cleanup_ptr)(struct ast_channel *)
Definition channel.c:7784
static void(* ast_moh_stop_ptr)(struct ast_channel *)
Definition channel.c:7783
static int(* ast_moh_start_ptr)(struct ast_channel *, const char *, const char *)
Definition channel.c:7782

References ast_moh_cleanup_ptr, ast_moh_start_ptr, and ast_moh_stop_ptr.

Referenced by load_module(), and reload().

◆ ast_is_deferrable_frame()

int ast_is_deferrable_frame ( const struct ast_frame frame)

Should we keep this frame for later?

There are functions such as ast_safe_sleep which will service a channel to ensure that it does not have a large backlog of queued frames. When this happens, we want to hold on to specific frame types and just drop others. This function will tell if the frame we just read should be held onto.

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

Definition at line 1454 of file channel.c.

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

References AST_FRAME_BRIDGE_ACTION, AST_FRAME_BRIDGE_ACTION_SYNC, AST_FRAME_CNG, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_HTML, AST_FRAME_IAX, AST_FRAME_IMAGE, AST_FRAME_MODEM, AST_FRAME_NULL, AST_FRAME_RTCP, AST_FRAME_TEXT, AST_FRAME_TEXT_DATA, AST_FRAME_VIDEO, AST_FRAME_VOICE, and ast_frame::frametype.

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

◆ ast_moh_cleanup()

void ast_moh_cleanup ( struct ast_channel chan)

Clean up music on hold state on a given channel.

Parameters
chanThe channel where music on hold was configured.
Deprecated:
This function no longer does anything but is kept for backwards compatibility.

Definition at line 7818 of file channel.c.

7819{
7820 /* A nop but needed for API compat */
7821}

◆ ast_moh_start()

int ast_moh_start ( struct ast_channel chan,
const char *  mclass,
const char *  interpclass 
)

Turn on music on hold on a given channel.

Parameters
chanThe channel structure that will get music on hold
mclassThe class to use if the musicclass is not currently set on the channel structure. NULL and the empty string are equivalent.
interpclassThe class to use if the musicclass is not currently set on the channel structure or in the mclass argument. NULL and the empty string are equivalent.
Return values
Zeroon success
non-zeroon failure

Definition at line 7802 of file channel.c.

7803{
7805 return ast_moh_start_ptr(chan, mclass, interpclass);
7806
7807 ast_verb(3, "Music class %s requested but no musiconhold loaded.\n", mclass ? mclass : (interpclass ? interpclass : "default"));
7808
7809 return -1;
7810}

References ast_moh_start_ptr, and ast_verb.

Referenced by app_control_moh_start(), app_exec(), ast_ari_bridges_start_moh(), ast_bridge_channel_playfile(), ast_unreal_indicate(), chan_pjsip_indicate(), channel_do_masquerade(), conf_moh_start(), conf_moh_unsuspend(), conf_start_moh(), console_indicate(), dahdi_indicate(), dial_exec_full(), handle_setmusic(), iax2_indicate(), jingle_indicate(), limits_interval_playback(), moh_handle_digit(), monitor_dial(), ooh323_indicate(), participant_entertainment_start(), play_moh_exec(), queue_exec(), retrydial_exec(), rna(), say_periodic_announcement(), say_position(), start_moh_exec(), and unistim_indicate().

◆ ast_moh_stop()

void ast_moh_stop ( struct ast_channel chan)

◆ ast_namedgroups_intersect()

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

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

Definition at line 8158 of file channel.c.

8159{
8160 void *match;
8161 struct ao2_container *group_a = (struct ao2_container *) a;
8162 struct ao2_container *group_b = (struct ao2_container *) b;
8163
8164 if (!a || !b) {
8165 return 0;
8166 }
8167
8168 /*
8169 * Do groups a and b intersect? Since a and b are hash tables,
8170 * the average time complexity is:
8171 * O(a.count <= b.count ? a.count : b.count)
8172 */
8173 if (ao2_container_count(group_b) < ao2_container_count(group_a)) {
8174 /* Traverse over the smaller group. */
8175 SWAP(group_a, group_b);
8176 }
8177 match = ao2_callback(group_a, 0, namedgroup_match, group_b);
8179
8180 return match != NULL;
8181}
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
Definition astobj2.h:1693
static int match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
Definition chan_iax2.c:2401
static int namedgroup_match(void *obj, void *arg, int flags)
Definition channel.c:8148
static struct test_val b
static struct test_val a
#define SWAP(a, b)
Definition utils.h:256

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

Referenced by find_channel_by_group().

◆ ast_party_caller_copy()

void ast_party_caller_copy ( struct ast_party_caller dest,
const struct ast_party_caller src 
)

Copy the source caller information to the destination caller.

Since
1.8
Parameters
destDestination caller
srcSource caller

Definition at line 1973 of file channel.c.

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

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

Referenced by recalling_enter().

◆ ast_party_caller_free()

void ast_party_caller_free ( struct ast_party_caller doomed)

Destroy the caller party contents.

Since
1.8
Parameters
doomedThe caller party to destroy.

Definition at line 2002 of file channel.c.

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

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

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

◆ ast_party_caller_init()

void ast_party_caller_init ( struct ast_party_caller init)

Initialize the given caller structure.

Since
1.8
Parameters
initCaller structure to initialize.

Definition at line 1965 of file channel.c.

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

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

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

◆ ast_party_caller_set()

void ast_party_caller_set ( struct ast_party_caller dest,
const struct ast_party_caller src,
const struct ast_set_party_caller update 
)

Set the caller information based on another caller source.

Since
1.8

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

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

Definition at line 1994 of file channel.c.

1995{
1996 ast_party_id_set(&dest->id, &src->id, update ? &update->id : NULL);
1997 ast_party_id_set(&dest->ani, &src->ani, update ? &update->ani : NULL);
1998 ast_party_id_set(&dest->priv, &src->priv, update ? &update->priv : NULL);
1999 dest->ani2 = src->ani2;
2000}
void ast_party_id_set(struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update)
Set the source party id information into the destination party id.
Definition channel.c:1775

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

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

◆ ast_party_caller_set_init()

void ast_party_caller_set_init ( struct ast_party_caller init,
const struct ast_party_caller guide 
)

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

Since
1.8

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

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

Definition at line 1986 of file channel.c.

1987{
1988 ast_party_id_set_init(&init->id, &guide->id);
1989 ast_party_id_set_init(&init->ani, &guide->ani);
1990 ast_party_id_set_init(&init->priv, &guide->priv);
1991 init->ani2 = guide->ani2;
1992}
void ast_party_id_set_init(struct ast_party_id *init, const struct ast_party_id *guide)
Initialize the given party id structure using the given guide for a set update operation.
Definition channel.c:1767

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

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

◆ ast_party_connected_line_collect_caller()

void ast_party_connected_line_collect_caller ( struct ast_party_connected_line connected,
struct ast_party_caller caller 
)

Collect the caller party information into a connected line structure.

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

Definition at line 2050 of file channel.c.

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

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

◆ ast_party_connected_line_copy()

void ast_party_connected_line_copy ( struct ast_party_connected_line dest,
const struct ast_party_connected_line src 
)

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

Since
1.8
Parameters
destDestination connected line
srcSource connected line

Definition at line 2018 of file channel.c.

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

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

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

◆ ast_party_connected_line_free()

void ast_party_connected_line_free ( struct ast_party_connected_line doomed)

◆ ast_party_connected_line_init()

void ast_party_connected_line_init ( struct ast_party_connected_line init)

◆ ast_party_connected_line_set()

void ast_party_connected_line_set ( struct ast_party_connected_line dest,
const struct ast_party_connected_line src,
const struct ast_set_party_connected_line update 
)

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

Since
1.8

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

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

Definition at line 2041 of file channel.c.

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

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

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

◆ ast_party_connected_line_set_init()

void ast_party_connected_line_set_init ( struct ast_party_connected_line init,
const struct ast_party_connected_line guide 
)

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

Since
1.8

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

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

Definition at line 2032 of file channel.c.

2033{
2034 ast_party_id_set_init(&init->id, &guide->id);
2035 ast_party_id_set_init(&init->ani, &guide->ani);
2036 ast_party_id_set_init(&init->priv, &guide->priv);
2037 init->ani2 = guide->ani2;
2038 init->source = guide->source;
2039}

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

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

◆ ast_party_dialed_copy()

void ast_party_dialed_copy ( struct ast_party_dialed dest,
const struct ast_party_dialed src 
)

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

Since
1.8
Parameters
destDestination dialed party
srcSource dialed party

Definition at line 1923 of file channel.c.

1924{
1925 if (dest == src) {
1926 /* Don't copy to self */
1927 return;
1928 }
1929
1930 ast_free(dest->number.str);
1931 dest->number.str = ast_strdup(src->number.str);
1932 dest->number.plan = src->number.plan;
1935}
void ast_party_subaddress_copy(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src)
Copy the source party subaddress information to the destination party subaddress.
Definition channel.c:1692
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition channel.h:393
char * str
Subscriber phone number (Malloced)
Definition channel.h:388
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition channel.h:390
struct ast_party_dialed::@217 number
Dialed/Called number.
int transit_network_select
Transit Network Select.
Definition channel.h:399

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

Referenced by ast_unreal_call_setup().

◆ ast_party_dialed_free()

void ast_party_dialed_free ( struct ast_party_dialed doomed)

Destroy the dialed party contents.

Since
1.8
Parameters
doomedThe dialed party to destroy.

Definition at line 1958 of file channel.c.

1959{
1960 ast_free(doomed->number.str);
1961 doomed->number.str = NULL;
1963}
void ast_party_subaddress_free(struct ast_party_subaddress *doomed)
Destroy the party subaddress contents.
Definition channel.c:1731

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

Referenced by ast_channel_destructor(), ast_dummy_channel_destructor(), and callerid_write().

◆ ast_party_dialed_init()

void ast_party_dialed_init ( struct ast_party_dialed init)

Initialize the given dialed structure.

Since
1.8
Parameters
initDialed structure to initialize.

Definition at line 1915 of file channel.c.

1916{
1917 init->number.str = NULL;
1918 init->number.plan = 0;/* Unknown */
1920 init->transit_network_select = 0;
1921}
void ast_party_subaddress_init(struct ast_party_subaddress *init)
Initialize the given subaddress structure.
Definition channel.c:1684

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

Referenced by __ast_channel_alloc_ap().

◆ ast_party_dialed_set()

void ast_party_dialed_set ( struct ast_party_dialed dest,
const struct ast_party_dialed src 
)

Set the dialed information based on another dialed source.

Since
1.8

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

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

Definition at line 1945 of file channel.c.

1946{
1947 if (src->number.str && src->number.str != dest->number.str) {
1948 ast_free(dest->number.str);
1949 dest->number.str = ast_strdup(src->number.str);
1950 }
1951 dest->number.plan = src->number.plan;
1952
1954
1956}
void ast_party_subaddress_set(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src)
Set the source party subaddress information into the destination party subaddress.
Definition channel.c:1714

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

Referenced by callerid_write().

◆ ast_party_dialed_set_init()

void ast_party_dialed_set_init ( struct ast_party_dialed init,
const struct ast_party_dialed guide 
)

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

Since
1.8

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

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

Definition at line 1937 of file channel.c.

1938{
1939 init->number.str = NULL;
1940 init->number.plan = guide->number.plan;
1943}
void ast_party_subaddress_set_init(struct ast_party_subaddress *init, const struct ast_party_subaddress *guide)
Initialize the given party subaddress structure using the given guide for a set update operation.
Definition channel.c:1706

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

Referenced by callerid_write().

◆ ast_party_id_copy()

void ast_party_id_copy ( struct ast_party_id dest,
const struct ast_party_id src 
)

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

Since
1.8
Parameters
destDestination party id
srcSource party id

Definition at line 1752 of file channel.c.

1753{
1754 if (dest == src) {
1755 /* Don't copy to self */
1756 return;
1757 }
1758
1759 ast_party_name_copy(&dest->name, &src->name);
1760 ast_party_number_copy(&dest->number, &src->number);
1762
1763 ast_free(dest->tag);
1764 dest->tag = ast_strdup(src->tag);
1765}
void ast_party_number_copy(struct ast_party_number *dest, const struct ast_party_number *src)
Copy the source party number information to the destination party number.
Definition channel.c:1639
void ast_party_name_copy(struct ast_party_name *dest, const struct ast_party_name *src)
Copy the source party name information to the destination party name.
Definition channel.c:1586
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition channel.h:346
char * tag
User-set "tag".
Definition channel.h:356

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

Referenced by ast_connected_line_copy_from_caller(), ast_connected_line_copy_to_caller(), ast_party_caller_copy(), ast_party_connected_line_copy(), ast_party_id_merge_copy(), ast_party_redirecting_copy(), ast_sip_session_create_outgoing(), ast_sip_set_id_from_invite(), caller_id_outgoing_request(), caller_id_outgoing_response(), chan_pjsip_new(), copy_redirecting_id(), queue_connected_line_update(), set_from_header(), stir_shaken_outgoing_request(), and update_initial_connected_line().

◆ ast_party_id_free()

void ast_party_id_free ( struct ast_party_id doomed)

Destroy the party id contents.

Since
1.8
Parameters
doomedThe party id to destroy.

Definition at line 1798 of file channel.c.

1799{
1800 ast_party_name_free(&doomed->name);
1801 ast_party_number_free(&doomed->number);
1803
1804 ast_free(doomed->tag);
1805 doomed->tag = NULL;
1806}
void ast_party_name_free(struct ast_party_name *doomed)
Destroy the party name contents.
Definition channel.c:1625
void ast_party_number_free(struct ast_party_number *doomed)
Destroy the party number contents.
Definition channel.c:1678

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

Referenced by ast_party_caller_free(), ast_party_connected_line_free(), ast_party_id_reset(), ast_party_redirecting_free(), caller_id_outgoing_request(), caller_id_outgoing_response(), endpoint_destructor(), fetch_callerid_num(), session_destructor(), set_from_header(), stir_shaken_outgoing_request(), and update_incoming_connected_line().

◆ ast_party_id_init()

void ast_party_id_init ( struct ast_party_id init)

Initialize the given party id structure.

Since
1.8
Parameters
initParty id structure to initialize.

Definition at line 1744 of file channel.c.

1745{
1746 ast_party_name_init(&init->name);
1749 init->tag = NULL;
1750}
void ast_party_name_init(struct ast_party_name *init)
Initialize the given name structure.
Definition channel.c:1578
void ast_party_number_init(struct ast_party_number *init)
Initialize the given number structure.
Definition channel.c:1631

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

Referenced by ast_party_caller_init(), ast_party_connected_line_init(), ast_party_id_reset(), ast_party_redirecting_init(), ast_sip_endpoint_alloc(), ast_sip_session_alloc(), caller_id_outgoing_request(), caller_id_outgoing_response(), dial_exec_full(), fetch_callerid_num(), set_from_header(), stir_shaken_outgoing_request(), and update_incoming_connected_line().

◆ ast_party_id_invalidate()

void ast_party_id_invalidate ( struct ast_party_id id)

Invalidate all components of the given party id.

Since
11.0
Parameters
idThe party id to invalidate.

Definition at line 1876 of file channel.c.

1877{
1878 id->name.valid = 0;
1879 id->number.valid = 0;
1880 id->subaddress.valid = 0;
1881}

◆ ast_party_id_merge()

struct ast_party_id ast_party_id_merge ( struct ast_party_id base,
struct ast_party_id overlay 
)

Merge a given party id into another given party id.

Since
11.0

This function will generate an effective party id.

Each party id component of the party id 'base' is overwritten by components of the party id 'overlay' if the overlay component is marked as valid. However the component 'tag' of the base party id remains untouched.

Parameters
baseThe party id which is merged.
overlayThe party id which is used to merge into.
Returns
The merged party id as a struct, not as a pointer.
Note
The merged party id returned is a shallow copy and must not be freed.

Definition at line 1889 of file channel.c.

1890{
1891 struct ast_party_id merged;
1892
1893 merged = *base;
1894 if (overlay->name.valid) {
1895 merged.name = overlay->name;
1896 }
1897 if (overlay->number.valid) {
1898 merged.number = overlay->number;
1899 }
1900 if (overlay->subaddress.valid) {
1901 merged.subaddress = overlay->subaddress;
1902 }
1903 /* Note the actual structure is returned and not a pointer to it! */
1904 return merged;
1905}
Information needed to identify an endpoint in a call.
Definition channel.h:340
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition channel.h:330

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

Referenced by ast_channel_connected_effective_id(), ast_channel_redirecting_effective_from(), ast_channel_redirecting_effective_orig(), ast_channel_redirecting_effective_to(), and ast_party_id_merge_copy().

◆ ast_party_id_merge_copy()

void ast_party_id_merge_copy ( struct ast_party_id dest,
struct ast_party_id base,
struct ast_party_id overlay 
)

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

Since
11.0

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

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

Definition at line 1907 of file channel.c.

1908{
1909 struct ast_party_id merged;
1910
1911 merged = ast_party_id_merge(base, overlay);
1912 ast_party_id_copy(dest, &merged);
1913}
struct ast_party_id ast_party_id_merge(struct ast_party_id *base, struct ast_party_id *overlay)
Merge a given party id into another given party id.
Definition channel.c:1889

References ast_party_id_copy(), and ast_party_id_merge().

◆ ast_party_id_presentation()

int ast_party_id_presentation ( const struct ast_party_id id)

Determine the overall presentation value for the given party.

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

Definition at line 1808 of file channel.c.

1809{
1810 int number_priority;
1811 int number_value;
1812 int number_screening;
1813 int name_priority;
1814 int name_value;
1815
1816 /* Determine name presentation priority. */
1817 if (!id->name.valid) {
1818 name_value = AST_PRES_UNAVAILABLE;
1819 name_priority = 3;
1820 } else {
1821 name_value = id->name.presentation & AST_PRES_RESTRICTION;
1822 switch (name_value) {
1824 name_priority = 0;
1825 break;
1826 case AST_PRES_ALLOWED:
1827 name_priority = 1;
1828 break;
1830 name_priority = 2;
1831 break;
1832 default:
1833 name_value = AST_PRES_UNAVAILABLE;
1834 name_priority = 3;
1835 break;
1836 }
1837 }
1838
1839 /* Determine number presentation priority. */
1840 if (!id->number.valid) {
1841 number_screening = AST_PRES_USER_NUMBER_UNSCREENED;
1842 number_value = AST_PRES_UNAVAILABLE;
1843 number_priority = 3;
1844 } else {
1845 number_screening = id->number.presentation & AST_PRES_NUMBER_TYPE;
1846 number_value = id->number.presentation & AST_PRES_RESTRICTION;
1847 switch (number_value) {
1849 number_priority = 0;
1850 break;
1851 case AST_PRES_ALLOWED:
1852 number_priority = 1;
1853 break;
1855 number_priority = 2;
1856 break;
1857 default:
1858 number_screening = AST_PRES_USER_NUMBER_UNSCREENED;
1859 number_value = AST_PRES_UNAVAILABLE;
1860 number_priority = 3;
1861 break;
1862 }
1863 }
1864
1865 /* Select the wining presentation value. */
1866 if (name_priority < number_priority) {
1867 number_value = name_value;
1868 }
1869 if (number_value == AST_PRES_UNAVAILABLE) {
1871 }
1872
1873 return number_value | number_screening;
1874}
enum queue_result id
Definition app_queue.c:1790
#define AST_PRES_USER_NUMBER_UNSCREENED
Definition callerid.h:426
#define AST_PRES_UNAVAILABLE
Definition callerid.h:434
#define AST_PRES_RESTRICTED
Definition callerid.h:433
#define AST_PRES_ALLOWED
Definition callerid.h:432
#define AST_PRES_NUMBER_NOT_AVAILABLE
Definition callerid.h:461
#define AST_PRES_NUMBER_TYPE
Definition callerid.h:425
#define AST_PRES_RESTRICTION
Definition callerid.h:431

References AST_PRES_ALLOWED, AST_PRES_NUMBER_NOT_AVAILABLE, AST_PRES_NUMBER_TYPE, AST_PRES_RESTRICTED, AST_PRES_RESTRICTION, AST_PRES_UNAVAILABLE, AST_PRES_USER_NUMBER_UNSCREENED, and id.

Referenced by add_privacy_header(), add_privacy_params(), ast_json_party_id(), ast_sip_can_present_connected_id(), ast_str_retrieve_variable(), ast_var_channels_table(), channel_snapshot_caller_create(), iax2_call(), is_colp_update_allowed(), my_send_callerid(), party_id_build_data(), party_id_read(), queue_exec(), redirecting_read(), set_from_header(), setup_env(), and socket_process_helper().

◆ ast_party_id_reset()

void ast_party_id_reset ( struct ast_party_id id)

Destroy and initialize the given party id structure.

Since
11.0
Parameters
idThe party id to reset.

Definition at line 1883 of file channel.c.

1884{
1887}

References ast_party_id_free(), and ast_party_id_init().

Referenced by after_bridge_move_channel(), ast_do_pickup(), channel_do_masquerade(), and retransfer_enter().

◆ ast_party_id_set()

void ast_party_id_set ( struct ast_party_id dest,
const struct ast_party_id src,
const struct ast_set_party_id update 
)

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

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

Definition at line 1775 of file channel.c.

1776{
1777 if (dest == src) {
1778 /* Don't set to self */
1779 return;
1780 }
1781
1782 if (!update || update->name) {
1783 ast_party_name_set(&dest->name, &src->name);
1784 }
1785 if (!update || update->number) {
1786 ast_party_number_set(&dest->number, &src->number);
1787 }
1788 if (!update || update->subaddress) {
1790 }
1791
1792 if (src->tag && src->tag != dest->tag) {
1793 ast_free(dest->tag);
1794 dest->tag = ast_strdup(src->tag);
1795 }
1796}
void ast_party_number_set(struct ast_party_number *dest, const struct ast_party_number *src)
Set the source party number information into the destination party number.
Definition channel.c:1661
void ast_party_name_set(struct ast_party_name *dest, const struct ast_party_name *src)
Set the source party name information into the destination party name.
Definition channel.c:1608

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

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

◆ ast_party_id_set_init()

void ast_party_id_set_init ( struct ast_party_id init,
const struct ast_party_id guide 
)

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

Since
1.8

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

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

Definition at line 1767 of file channel.c.

1768{
1769 ast_party_name_set_init(&init->name, &guide->name);
1770 ast_party_number_set_init(&init->number, &guide->number);
1772 init->tag = NULL;
1773}
void ast_party_name_set_init(struct ast_party_name *init, const struct ast_party_name *guide)
Initialize the given party name structure using the given guide for a set update operation.
Definition channel.c:1600
void ast_party_number_set_init(struct ast_party_number *init, const struct ast_party_number *guide)
Initialize the given party number structure using the given guide for a set update operation.
Definition channel.c:1653

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

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

◆ ast_party_name_copy()

void ast_party_name_copy ( struct ast_party_name dest,
const struct ast_party_name src 
)

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

Since
1.8
Parameters
destDestination party name
srcSource party name

Definition at line 1586 of file channel.c.

1587{
1588 if (dest == src) {
1589 /* Don't copy to self */
1590 return;
1591 }
1592
1593 ast_free(dest->str);
1594 dest->str = ast_strdup(src->str);
1595 dest->char_set = src->char_set;
1596 dest->presentation = src->presentation;
1597 dest->valid = src->valid;
1598}
int char_set
Character set the name is using.
Definition channel.h:274
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition channel.h:279

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

Referenced by ast_party_id_copy().

◆ ast_party_name_free()

void ast_party_name_free ( struct ast_party_name doomed)

Destroy the party name contents.

Since
1.8
Parameters
doomedThe party name to destroy.

Definition at line 1625 of file channel.c.

1626{
1627 ast_free(doomed->str);
1628 doomed->str = NULL;
1629}

References ast_free, NULL, and ast_party_name::str.

Referenced by analog_ss_thread(), and ast_party_id_free().

◆ ast_party_name_init()

void ast_party_name_init ( struct ast_party_name init)

Initialize the given name structure.

Since
1.8
Parameters
initName structure to initialize.

Definition at line 1578 of file channel.c.

1579{
1580 init->str = NULL;
1583 init->valid = 0;
1584}

References AST_PARTY_CHAR_SET_ISO8859_1, AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, ast_party_name::char_set, NULL, ast_party_name::presentation, ast_party_name::str, and ast_party_name::valid.

Referenced by analog_ss_thread(), and ast_party_id_init().

◆ ast_party_name_set()

void ast_party_name_set ( struct ast_party_name dest,
const struct ast_party_name src 
)

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

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

Definition at line 1608 of file channel.c.

1609{
1610 if (dest == src) {
1611 /* Don't set to self */
1612 return;
1613 }
1614
1615 if (src->str && src->str != dest->str) {
1616 ast_free(dest->str);
1617 dest->str = ast_strdup(src->str);
1618 }
1619
1620 dest->char_set = src->char_set;
1621 dest->presentation = src->presentation;
1622 dest->valid = src->valid;
1623}

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

Referenced by ast_party_id_set().

◆ ast_party_name_set_init()

void ast_party_name_set_init ( struct ast_party_name init,
const struct ast_party_name guide 
)

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

Since
1.8

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

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

Definition at line 1600 of file channel.c.

1601{
1602 init->str = NULL;
1603 init->char_set = guide->char_set;
1604 init->presentation = guide->presentation;
1605 init->valid = guide->valid;
1606}

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

Referenced by ast_party_id_set_init().

◆ ast_party_number_copy()

void ast_party_number_copy ( struct ast_party_number dest,
const struct ast_party_number src 
)

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

Since
1.8
Parameters
destDestination party number
srcSource party number

Definition at line 1639 of file channel.c.

1640{
1641 if (dest == src) {
1642 /* Don't copy to self */
1643 return;
1644 }
1645
1646 ast_free(dest->str);
1647 dest->str = ast_strdup(src->str);
1648 dest->plan = src->plan;
1649 dest->presentation = src->presentation;
1650 dest->valid = src->valid;
1651}
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition channel.h:297
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition channel.h:295

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

Referenced by ast_party_id_copy().

◆ ast_party_number_free()

void ast_party_number_free ( struct ast_party_number doomed)

Destroy the party number contents.

Since
1.8
Parameters
doomedThe party number to destroy.

Definition at line 1678 of file channel.c.

1679{
1680 ast_free(doomed->str);
1681 doomed->str = NULL;
1682}

References ast_free, NULL, and ast_party_number::str.

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

◆ ast_party_number_init()

void ast_party_number_init ( struct ast_party_number init)

Initialize the given number structure.

Since
1.8
Parameters
initNumber structure to initialize.

Definition at line 1631 of file channel.c.

1632{
1633 init->str = NULL;
1634 init->plan = 0;/* Unknown */
1636 init->valid = 0;
1637}

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

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

◆ ast_party_number_set()

void ast_party_number_set ( struct ast_party_number dest,
const struct ast_party_number src 
)

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

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

Definition at line 1661 of file channel.c.

1662{
1663 if (dest == src) {
1664 /* Don't set to self */
1665 return;
1666 }
1667
1668 if (src->str && src->str != dest->str) {
1669 ast_free(dest->str);
1670 dest->str = ast_strdup(src->str);
1671 }
1672
1673 dest->plan = src->plan;
1674 dest->presentation = src->presentation;
1675 dest->valid = src->valid;
1676}

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

Referenced by ast_party_id_set().

◆ ast_party_number_set_init()

void ast_party_number_set_init ( struct ast_party_number init,
const struct ast_party_number guide 
)

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

Since
1.8

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

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

Definition at line 1653 of file channel.c.

1654{
1655 init->str = NULL;
1656 init->plan = guide->plan;
1657 init->presentation = guide->presentation;
1658 init->valid = guide->valid;
1659}

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

Referenced by ast_party_id_set_init().

◆ ast_party_redirecting_copy()

void ast_party_redirecting_copy ( struct ast_party_redirecting dest,
const struct ast_party_redirecting src 
)

Copy the source redirecting information to the destination redirecting.

Since
1.8
Parameters
destDestination redirecting
srcSource redirecting

Definition at line 2122 of file channel.c.

2123{
2124 if (dest == src) {
2125 /* Don't copy to self */
2126 return;
2127 }
2128
2129 ast_party_id_copy(&dest->orig, &src->orig);
2130 ast_party_id_copy(&dest->from, &src->from);
2131 ast_party_id_copy(&dest->to, &src->to);
2132 ast_party_id_copy(&dest->priv_orig, &src->priv_orig);
2133 ast_party_id_copy(&dest->priv_from, &src->priv_from);
2134 ast_party_id_copy(&dest->priv_to, &src->priv_to);
2137 dest->count = src->count;
2138}
void ast_party_redirecting_reason_copy(struct ast_party_redirecting_reason *dest, const struct ast_party_redirecting_reason *src)
Copy the source redirecting reason information to the destination redirecting reason.
Definition channel.c:2072
struct ast_party_id priv_to
Call is redirecting to a new party (Sent to the caller) - private representation.
Definition channel.h:541
struct ast_party_redirecting_reason orig_reason
Reason for the redirection by the original party.
Definition channel.h:547
struct ast_party_redirecting_reason reason
Reason for the redirection.
Definition channel.h:544
struct ast_party_id priv_from
Who is redirecting the call (Sent to the party the call is redirected toward) - private representatio...
Definition channel.h:538
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition channel.h:529
int count
Number of times the call was redirected.
Definition channel.h:550
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition channel.h:532
struct ast_party_id orig
Who originally redirected the call (Sent to the party the call is redirected toward)
Definition channel.h:526
struct ast_party_id priv_orig
Who originally redirected the call (Sent to the party the call is redirected toward) - private repres...
Definition channel.h:535

References ast_party_id_copy(), ast_party_redirecting_reason_copy(), ast_party_redirecting::count, ast_party_redirecting::from, ast_party_redirecting::orig, ast_party_redirecting::orig_reason, ast_party_redirecting::priv_from, ast_party_redirecting::priv_orig, ast_party_redirecting::priv_to, ast_party_redirecting::reason, and ast_party_redirecting::to.

Referenced by ast_ari_channels_dial(), ast_call_forward(), ast_channel_redirecting_sub(), ast_unreal_call_setup(), begin_dial_prerun(), call_forward_inherit(), dial_exec_full(), do_forward(), ring_entry(), and wait_for_answer().

◆ ast_party_redirecting_free()

void ast_party_redirecting_free ( struct ast_party_redirecting doomed)

◆ ast_party_redirecting_init()

void ast_party_redirecting_init ( struct ast_party_redirecting init)

Initialize the given redirecting structure.

Since
1.8
Parameters
initRedirecting structure to initialize.

Definition at line 2109 of file channel.c.

2110{
2111 ast_party_id_init(&init->orig);
2112 ast_party_id_init(&init->from);
2113 ast_party_id_init(&init->to);
2116 ast_party_id_init(&init->priv_to);
2119 init->count = 0;
2120}
void ast_party_redirecting_reason_init(struct ast_party_redirecting_reason *init)
Initialize the given redirecting reason structure.
Definition channel.c:2066

References ast_party_id_init(), ast_party_redirecting_reason_init(), ast_party_redirecting::count, ast_party_redirecting::from, ast_party_redirecting::orig, ast_party_redirecting::orig_reason, ast_party_redirecting::priv_from, ast_party_redirecting::priv_orig, ast_party_redirecting::priv_to, ast_party_redirecting::reason, and ast_party_redirecting::to.

Referenced by __ast_channel_alloc_ap(), ast_channel_redirecting_sub(), AST_TEST_DEFINE(), call_forward_inherit(), do_forward(), set_redirecting(), and wait_for_answer().

◆ ast_party_redirecting_reason_copy()

void ast_party_redirecting_reason_copy ( struct ast_party_redirecting_reason dest,
const struct ast_party_redirecting_reason src 
)

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

Parameters
destDestination redirecting reason
srcSource redirecting reason

Definition at line 2072 of file channel.c.

2073{
2074 if (dest == src) {
2075 return;
2076 }
2077
2078 ast_free(dest->str);
2079 dest->str = ast_strdup(src->str);
2080 dest->code = src->code;
2081}
int code
enum AST_REDIRECTING_REASON value for redirection
Definition channel.h:512
char * str
a string value for the redirecting reason
Definition channel.h:509

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

Referenced by ast_party_redirecting_copy().

◆ ast_party_redirecting_reason_free()

void ast_party_redirecting_reason_free ( struct ast_party_redirecting_reason doomed)

Destroy the redirecting reason contents.

Parameters
doomedThe redirecting reason to destroy.

Definition at line 2103 of file channel.c.

2104{
2105 ast_free(doomed->str);
2106}

References ast_free, and ast_party_redirecting_reason::str.

Referenced by ast_party_redirecting_free().

◆ ast_party_redirecting_reason_init()

void ast_party_redirecting_reason_init ( struct ast_party_redirecting_reason init)

Initialize the given redirecting reason structure.

Parameters
initRedirecting reason structure to initialize

Definition at line 2066 of file channel.c.

2067{
2068 init->str = NULL;
2070}
@ AST_REDIRECTING_REASON_UNKNOWN
Definition callerid.h:499

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

Referenced by ast_party_redirecting_init().

◆ ast_party_redirecting_reason_set()

void ast_party_redirecting_reason_set ( struct ast_party_redirecting_reason dest,
const struct ast_party_redirecting_reason src 
)

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

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

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

Definition at line 2089 of file channel.c.

2090{
2091 if (dest == src) {
2092 return;
2093 }
2094
2095 if (src->str && src->str != dest->str) {
2096 ast_free(dest->str);
2097 dest->str = ast_strdup(src->str);
2098 }
2099
2100 dest->code = src->code;
2101}

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

Referenced by ast_party_redirecting_set().

◆ ast_party_redirecting_reason_set_init()

void ast_party_redirecting_reason_set_init ( struct ast_party_redirecting_reason init,
const struct ast_party_redirecting_reason guide 
)

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

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

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

Definition at line 2083 of file channel.c.

2084{
2085 init->str = NULL;
2086 init->code = guide->code;
2087}

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

Referenced by ast_party_redirecting_set_init().

◆ ast_party_redirecting_set()

void ast_party_redirecting_set ( struct ast_party_redirecting dest,
const struct ast_party_redirecting src,
const struct ast_set_party_redirecting update 
)

Set the redirecting information based on another redirecting source.

Since
1.8

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

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

Definition at line 2153 of file channel.c.

2154{
2155 ast_party_id_set(&dest->orig, &src->orig, update ? &update->orig : NULL);
2156 ast_party_id_set(&dest->from, &src->from, update ? &update->from : NULL);
2157 ast_party_id_set(&dest->to, &src->to, update ? &update->to : NULL);
2158 ast_party_id_set(&dest->priv_orig, &src->priv_orig, update ? &update->priv_orig : NULL);
2159 ast_party_id_set(&dest->priv_from, &src->priv_from, update ? &update->priv_from : NULL);
2160 ast_party_id_set(&dest->priv_to, &src->priv_to, update ? &update->priv_to : NULL);
2163 dest->count = src->count;
2164}
void ast_party_redirecting_reason_set(struct ast_party_redirecting_reason *dest, const struct ast_party_redirecting_reason *src)
Set the redirecting reason information based on another redirecting reason source.
Definition channel.c:2089

References ast_party_id_set(), ast_party_redirecting_reason_set(), ast_party_redirecting::count, ast_party_redirecting::from, NULL, ast_party_redirecting::orig, ast_party_redirecting::orig_reason, ast_party_redirecting::priv_from, ast_party_redirecting::priv_orig, ast_party_redirecting::priv_to, ast_party_redirecting::reason, ast_party_redirecting::to, and update().

Referenced by ast_channel_set_redirecting().

◆ ast_party_redirecting_set_init()

void ast_party_redirecting_set_init ( struct ast_party_redirecting init,
const struct ast_party_redirecting guide 
)

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

Since
1.8

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

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

Definition at line 2140 of file channel.c.

2141{
2142 ast_party_id_set_init(&init->orig, &guide->orig);
2143 ast_party_id_set_init(&init->from, &guide->from);
2144 ast_party_id_set_init(&init->to, &guide->to);
2145 ast_party_id_set_init(&init->priv_orig, &guide->priv_orig);
2146 ast_party_id_set_init(&init->priv_from, &guide->priv_from);
2147 ast_party_id_set_init(&init->priv_to, &guide->priv_to);
2150 init->count = guide->count;
2151}
void ast_party_redirecting_reason_set_init(struct ast_party_redirecting_reason *init, const struct ast_party_redirecting_reason *guide)
Initialize the given redirecting reason structure using the given guide for a set update operation.
Definition channel.c:2083

References ast_party_id_set_init(), ast_party_redirecting_reason_set_init(), ast_party_redirecting::count, ast_party_redirecting::from, ast_party_redirecting::orig, ast_party_redirecting::orig_reason, ast_party_redirecting::priv_from, ast_party_redirecting::priv_orig, ast_party_redirecting::priv_to, ast_party_redirecting::reason, and ast_party_redirecting::to.

Referenced by indicate_redirecting(), and redirecting_write().

◆ ast_party_subaddress_copy()

void ast_party_subaddress_copy ( struct ast_party_subaddress dest,
const struct ast_party_subaddress src 
)

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

Since
1.8
Parameters
destDestination party subaddress
srcSource party subaddress

Definition at line 1692 of file channel.c.

1693{
1694 if (dest == src) {
1695 /* Don't copy to self */
1696 return;
1697 }
1698
1699 ast_free(dest->str);
1700 dest->str = ast_strdup(src->str);
1701 dest->type = src->type;
1703 dest->valid = src->valid;
1704}
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition channel.h:328
char * str
Malloced subaddress string.
Definition channel.h:315
int type
Q.931 subaddress type.
Definition channel.h:322

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

Referenced by ast_party_dialed_copy(), and ast_party_id_copy().

◆ ast_party_subaddress_free()

void ast_party_subaddress_free ( struct ast_party_subaddress doomed)

Destroy the party subaddress contents.

Since
1.8
Parameters
doomedThe party subaddress to destroy.

Definition at line 1731 of file channel.c.

1732{
1733 ast_free(doomed->str);
1734 doomed->str = NULL;
1735}

References ast_free, NULL, and ast_party_subaddress::str.

Referenced by ast_party_dialed_free(), and ast_party_id_free().

◆ ast_party_subaddress_init()

void ast_party_subaddress_init ( struct ast_party_subaddress init)

Initialize the given subaddress structure.

Since
1.8
Parameters
initSubaddress structure to initialize.

Definition at line 1684 of file channel.c.

1685{
1686 init->str = NULL;
1687 init->type = 0;
1688 init->odd_even_indicator = 0;
1689 init->valid = 0;
1690}

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

Referenced by ast_party_dialed_init(), and ast_party_id_init().

◆ ast_party_subaddress_set()

void ast_party_subaddress_set ( struct ast_party_subaddress dest,
const struct ast_party_subaddress src 
)

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

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

Definition at line 1714 of file channel.c.

1715{
1716 if (dest == src) {
1717 /* Don't set to self */
1718 return;
1719 }
1720
1721 if (src->str && src->str != dest->str) {
1722 ast_free(dest->str);
1723 dest->str = ast_strdup(src->str);
1724 }
1725
1726 dest->type = src->type;
1728 dest->valid = src->valid;
1729}

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

Referenced by ast_party_dialed_set(), and ast_party_id_set().

◆ ast_party_subaddress_set_init()

void ast_party_subaddress_set_init ( struct ast_party_subaddress init,
const struct ast_party_subaddress guide 
)

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

Since
1.8

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

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

Definition at line 1706 of file channel.c.

1707{
1708 init->str = NULL;
1709 init->type = guide->type;
1711 init->valid = guide->valid;
1712}

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

Referenced by ast_party_dialed_set_init(), and ast_party_id_set_init().

◆ ast_pre_call()

int ast_pre_call ( struct ast_channel chan,
const char *  sub_args 
)

Execute a Gosub call on the channel before a call is placed.

Since
11.0

This is called between ast_request() and ast_call() to execute a predial routine on the newly created channel.

Parameters
chanChannel to execute Gosub.
sub_argsGosub application parameter string.
Note
Absolutely NO channel locks should be held before calling this function.
Return values
0on success.
-1on error.

Definition at line 6463 of file channel.c.

6464{
6465 int (*pre_call)(struct ast_channel *chan, const char *sub_args);
6466
6467 ast_channel_lock(chan);
6468 pre_call = ast_channel_tech(chan)->pre_call;
6469 if (pre_call) {
6470 int res;
6471
6472 res = pre_call(chan, sub_args);
6473 ast_channel_unlock(chan);
6474 return res;
6475 }
6476 ast_channel_unlock(chan);
6477 return ast_app_exec_sub(NULL, chan, sub_args, 0);
6478}
int ast_app_exec_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_args, int ignore_hangup)
Run a subroutine on a channel, placing an optional second channel into autoservice.
Definition main/app.c:297
int(* pre_call)(struct ast_channel *chan, const char *sub_args)
Execute a Gosub call on the channel in a technology specific way before a call is placed.
Definition channel.h:861

References ast_app_exec_sub(), ast_channel_lock, ast_channel_unlock, NULL, and ast_channel_tech::pre_call.

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

◆ ast_print_group()

char * ast_print_group ( char *  buf,
int  buflen,
ast_group_t  group 
)

Print call group and pickup group —.

Print call and pickup groups into buffer.

Definition at line 8099 of file channel.c.

8100{
8101 unsigned int i;
8102 int first = 1;
8103 char num[3];
8104
8105 buf[0] = '\0';
8106
8107 if (!group) /* Return empty string if no group */
8108 return buf;
8109
8110 for (i = 0; i <= 63; i++) { /* Max group is 63 */
8111 if (group & ((ast_group_t) 1 << i)) {
8112 if (!first) {
8113 strncat(buf, ", ", buflen - strlen(buf) - 1);
8114 } else {
8115 first = 0;
8116 }
8117 snprintf(num, sizeof(num), "%u", i);
8118 strncat(buf, num, buflen - strlen(buf) - 1);
8119 }
8120 }
8121 return buf;
8122}
struct sla_ringing_trunk * first
Definition app_sla.c:338
char buf[BUFSIZE]
Definition eagi_proxy.c:66

References buf, and first.

Referenced by callgroup_to_str(), func_channel_read(), pickupgroup_to_str(), and serialize_showchan().

◆ ast_print_namedgroups()

char * ast_print_namedgroups ( struct ast_str **  buf,
struct ast_namedgroups *  group 
)

Print named call groups and named pickup groups.

Definition at line 8124 of file channel.c.

8125{
8126 struct ao2_container *grp = (struct ao2_container *) group;
8127 struct namedgroup_member *ng;
8128 int first = 1;
8129 struct ao2_iterator it;
8130
8131 if (!grp) {
8132 return ast_str_buffer(*buf);
8133 }
8134
8135 for (it = ao2_iterator_init(grp, 0); (ng = ao2_iterator_next(&it)); ao2_ref(ng, -1)) {
8136 if (!first) {
8137 ast_str_append(buf, 0, ", ");
8138 } else {
8139 first = 0;
8140 }
8141 ast_str_append(buf, 0, "%s", ng->name);
8142 }
8144
8145 return ast_str_buffer(*buf);
8146}
#define ao2_iterator_next(iter)
Definition astobj2.h:1911
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition strings.h:1139
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition strings.h:761
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition astobj2.h:1821

References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_str_append(), ast_str_buffer(), buf, first, and namedgroup_member::name.

Referenced by func_channel_read(), named_callgroups_to_str(), and named_pickupgroups_to_str().

◆ ast_prod()

int ast_prod ( struct ast_channel chan)

Send empty audio to prime a channel driver.

Definition at line 5023 of file channel.c.

5024{
5025 struct ast_frame a = { AST_FRAME_VOICE };
5026 char nothing[128];
5027
5028 /* Send an empty audio frame to get things moving */
5029 if (ast_channel_state(chan) != AST_STATE_UP) {
5030 ast_debug(3, "Prodding channel '%s'\n", ast_channel_name(chan));
5031 a.subclass.format = ast_channel_rawwriteformat(chan);
5032 a.data.ptr = nothing + AST_FRIENDLY_OFFSET;
5033 a.src = "ast_prod"; /* this better match check in ast_write */
5034 if (ast_write(chan, &a))
5035 ast_log(LOG_WARNING, "Prodding channel '%s' failed\n", ast_channel_name(chan));
5036 }
5037 return 0;
5038}
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:5167
struct ast_format * ast_channel_rawwriteformat(struct ast_channel *chan)

References a, ast_channel_name(), ast_channel_rawwriteformat(), ast_debug, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log, AST_STATE_UP, ast_write(), and LOG_WARNING.

Referenced by ast_activate_generator().

◆ ast_queue_answer()

int ast_queue_answer ( struct ast_channel chan,
const struct ast_stream_topology topology 
)

Queue an ANSWER control frame with topology.

Parameters
chanchannel to queue frame onto
topologytopology to be passed through the core to the peer channel
Return values
0success
non-zerofailure

Definition at line 1304 of file channel.c.

1305{
1306 struct ast_frame f = {
1309 .subclass.topology = (struct ast_stream_topology *)topology,
1310 };
1311 return ast_queue_frame(chan, &f);
1312}

References AST_CONTROL_ANSWER, AST_FRAME_CONTROL, ast_queue_frame(), ast_frame_subclass::integer, and ast_frame::subclass.

◆ ast_queue_control()

int ast_queue_control ( struct ast_channel chan,
enum ast_control_frame_type  control 
)

◆ ast_queue_control_data()

int ast_queue_control_data ( struct ast_channel chan,
enum ast_control_frame_type  control,
const void *  data,
size_t  datalen 
)

Queue a control frame with payload.

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

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

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

Definition at line 1296 of file channel.c.

1298{
1299 struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = control, .data.ptr = (void *) data, .datalen = datalen };
1300 return ast_queue_frame(chan, &f);
1301}

References AST_FRAME_CONTROL, ast_queue_frame(), ast_frame::data, ast_frame::datalen, ast_frame_subclass::integer, and ast_frame::subclass.

Referenced by __analog_handle_event(), after_bridge_move_channel(), analog_callwaiting_deluxe(), ast_channel_queue_connected_line_update(), ast_channel_queue_redirecting_update(), chan_pjsip_incoming_response_update_cause(), close_udptl_connection(), fax_gateway_indicate_t38(), iax2_transfer(), jingle_action_session_terminate(), onModeChanged(), ooh323_indicate(), queue_read_action_payload(), setup_udptl_connection(), socket_process_helper(), t38_change_state(), t38_framehook(), t38_interpret_parameters(), transfer_redirect(), transfer_refer(), and xfer_client_on_evsub_state().

◆ ast_queue_frame()

int ast_queue_frame ( struct ast_channel chan,
struct ast_frame f 
)

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

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

Definition at line 1171 of file channel.c.

1172{
1173 return __ast_queue_frame(chan, fin, 0, NULL);
1174}

References __ast_queue_frame(), and NULL.

Referenced by __ast_read(), action_atxfer(), action_cancel_atxfer(), apply_negotiated_sdp_stream(), ast_channel_set_unbridged_nolock(), ast_channel_setwhentohangup_tv(), ast_channel_stream_topology_changed_externally(), ast_dsp_process(), ast_msg_data_queue_frame(), ast_queue_answer(), ast_queue_cc_frame(), ast_queue_control(), ast_queue_control_data(), ast_queue_hangup(), ast_queue_hangup_with_cause(), ast_queue_hold(), ast_queue_unhold(), ast_softhangup_nolock(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), attended_transfer_exec(), bridge_channel_internal_push_full(), bridge_channel_poke(), channel_do_masquerade(), cli_console_dial(), cli_console_sendtext(), conf_stop_record(), dahdi_queue_frame(), dahdi_read(), dictate_exec(), dtmf_info_incoming_request(), exec_command_on_condition(), handle_command(), handle_incoming_request(), handle_negotiated_sdp(), iax2_queue_frame(), load_stream_readqueue(), manager_play_dtmf(), manager_send_flash(), ooh323_onReceivedDigit(), queue_dtmf_readq(), refer_incoming_invite_request(), set_interval_hook(), stream_monitor(), stream_periodic_frames(), stream_periodic_frames(), t38_tx_packet_handler(), unistim_do_senddigit(), unreal_queue_frame(), and wakeup_sub().

◆ ast_queue_frame_head()

int ast_queue_frame_head ( struct ast_channel chan,
struct ast_frame f 
)

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

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

Definition at line 1176 of file channel.c.

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

References __ast_queue_frame(), and NULL.

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

◆ ast_queue_hangup()

int ast_queue_hangup ( struct ast_channel chan)

Queue a hangup frame for channel.

Queue a hangup frame.

Definition at line 1182 of file channel.c.

1183{
1186 int res, cause, tech_cause;
1187
1188 if (!blob) {
1189 return -1;
1190 }
1191
1192 /* Yeah, let's not change a lock-critical value without locking */
1193 ast_channel_lock(chan);
1195
1196 cause = ast_channel_hangupcause(chan);
1197 if (cause) {
1198 ast_json_object_set(blob, "cause", ast_json_integer_create(cause));
1199 }
1200 tech_cause = ast_channel_tech_hangupcause(chan);
1201 if (tech_cause) {
1202 ast_json_object_set(blob, "tech_cause", ast_json_integer_create(tech_cause));
1203 }
1204
1206
1207 res = ast_queue_frame(chan, &f);
1208 ast_channel_unlock(chan);
1209 return res;
1210}
int ast_channel_tech_hangupcause(const struct ast_channel *chan)
struct stasis_message_type * ast_channel_hangup_request_type(void)
Message type for when a hangup is requested on a channel.
struct ast_json * ast_json_object_create(void)
Create a new JSON object.
Definition json.c:399
struct ast_json * ast_json_integer_create(intmax_t value)
Create a JSON integer.
Definition json.c:327
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
Set a field in a JSON object.
Definition json.c:414

References ast_channel_hangup_request_type(), ast_channel_hangupcause(), ast_channel_lock, ast_channel_publish_blob(), ast_channel_softhangup_internal_flag_add(), ast_channel_tech_hangupcause(), ast_channel_unlock, AST_CONTROL_HANGUP, AST_FRAME_CONTROL, ast_json_integer_create(), ast_json_object_create(), ast_json_object_set(), ast_json_unref(), ast_queue_frame(), AST_SOFTHANGUP_DEV, ast_frame_subclass::integer, RAII_VAR, and ast_frame::subclass.

Referenced by analog_callwaiting_deluxe(), ast_app_exec_sub(), ast_unreal_fixup(), call(), chan_pjsip_session_end(), cli_console_hangup(), close_call(), iax2_destroy(), iax2_queue_hangup(), mbl_queue_hangup(), refer_incoming_invite_request(), and session_inv_on_media_update().

◆ ast_queue_hangup_with_cause()

int ast_queue_hangup_with_cause ( struct ast_channel chan,
int  cause 
)

Queue a hangup frame for channel.

Queue a hangup frame with hangupcause set.

Definition at line 1213 of file channel.c.

1214{
1215 RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
1217 int res;
1218 int tech_cause = 0;
1219
1220 if (cause >= 0) {
1221 f.data.uint32 = cause;
1222 }
1223
1224 /* Yeah, let's not change a lock-critical value without locking */
1225 ast_channel_lock(chan);
1227 if (cause < 0) {
1229 }
1230 blob = ast_json_pack("{s: i}",
1231 "cause", cause);
1232 if (!blob) {
1233 ast_channel_unlock(chan);
1234 return -1;
1235 }
1236
1237 tech_cause = ast_channel_tech_hangupcause(chan);
1238 if (tech_cause) {
1239 ast_json_object_set(blob, "tech_cause", ast_json_integer_create(tech_cause));
1240 }
1241
1243
1244 res = ast_queue_frame(chan, &f);
1245 ast_channel_unlock(chan);
1246 return res;
1247}

References ast_channel_hangup_request_type(), ast_channel_hangupcause(), ast_channel_lock, ast_channel_publish_blob(), ast_channel_softhangup_internal_flag_add(), ast_channel_tech_hangupcause(), ast_channel_unlock, AST_CONTROL_HANGUP, AST_FRAME_CONTROL, ast_json_integer_create(), ast_json_object_set(), ast_json_pack(), ast_json_unref(), ast_queue_frame(), AST_SOFTHANGUP_DEV, ast_frame::data, ast_frame_subclass::integer, NULL, RAII_VAR, ast_frame::subclass, and ast_frame::uint32.

Referenced by __analog_handle_event(), _websocket_request_hangup(), ast_unreal_hangup(), close_call(), close_client(), dahdi_handle_event(), discard_call(), handle_call_outgoing(), jingle_action_session_terminate(), jingle_queue_hangup_with_cause(), onCallCleared(), and transfer_cancel_step2().

◆ ast_queue_hold()

int ast_queue_hold ( struct ast_channel chan,
const char *  musicclass 
)

Queue a hold frame.

Parameters
chanchannel to queue frame onto
musicclassThe suggested musicclass for the other end to use
Note
The channel does not need to be locked before calling this function.
Return values
zeroon success
non-zeroon failure

Definition at line 1249 of file channel.c.

1250{
1252 struct ast_json *blob = NULL;
1253 int res;
1254
1255 if (!ast_strlen_zero(musicclass)) {
1256 f.data.ptr = (void *) musicclass;
1257 f.datalen = strlen(musicclass) + 1;
1258
1259 blob = ast_json_pack("{s: s}",
1260 "musicclass", musicclass);
1261 }
1262
1263 ast_channel_lock(chan);
1265 ast_channel_unlock(chan);
1266
1267 res = ast_queue_frame(chan, &f);
1268
1269 ast_json_unref(blob);
1270
1271 return res;
1272}
struct stasis_message_type * ast_channel_hold_type(void)
Message type for when a channel is placed on hold.

References ast_channel_hold_type(), ast_channel_lock, ast_channel_publish_blob(), ast_channel_unlock, AST_CONTROL_HOLD, AST_FRAME_CONTROL, ast_json_pack(), ast_json_unref(), ast_queue_frame(), ast_strlen_zero(), ast_frame::data, ast_frame::datalen, ast_frame_subclass::integer, NULL, ast_frame::ptr, and ast_frame::subclass.

Referenced by __analog_handle_event(), analog_callwaiting_deluxe(), analog_hangup(), apply_negotiated_sdp_stream(), dahdi_handle_event(), dahdi_hangup(), iax2_queue_hold(), jingle_action_session_info(), sub_hold(), and transfer_call_step1().

◆ ast_queue_unhold()

int ast_queue_unhold ( struct ast_channel chan)

Queue an unhold frame.

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

Definition at line 1274 of file channel.c.

1275{
1277 int res;
1278
1279 ast_channel_lock(chan);
1281 ast_channel_unlock(chan);
1282
1283 res = ast_queue_frame(chan, &f);
1284
1285 return res;
1286}
struct stasis_message_type * ast_channel_unhold_type(void)
Message type for when a channel is removed from hold.

References ast_channel_lock, ast_channel_publish_blob(), ast_channel_unhold_type(), ast_channel_unlock, AST_CONTROL_UNHOLD, AST_FRAME_CONTROL, ast_queue_frame(), ast_frame_subclass::integer, NULL, and ast_frame::subclass.

Referenced by __analog_handle_event(), __analog_ss_thread(), __dahdi_exception(), analog_callwaiting_deluxe(), analog_exception(), analog_hangup(), analog_ss_thread(), apply_negotiated_sdp_stream(), dahdi_handle_event(), dahdi_hangup(), iax2_queue_unhold(), jingle_action_session_info(), key_dial_page(), refer_incoming_invite_request(), session_inv_on_create_offer(), sub_unhold(), transfer_cancel_step2(), and unistim_hangup().

◆ ast_raw_answer()

int ast_raw_answer ( struct ast_channel chan)

Answer a channel.

Parameters
chanchannel to answer

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

Note
The channel passed does not need to be locked, but is locked by the function when needed.
Unlike ast_answer(), this function will not wait for media flow to begin. The caller should be careful before sending media to the channel before incoming media arrives, as the outgoing media may be lost.
Return values
0on success
non-zeroon failure

Definition at line 2690 of file channel.c.

2691{
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:2638

References ast_raw_answer_with_stream_topology(), and NULL.

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

◆ ast_raw_answer_with_stream_topology()

int ast_raw_answer_with_stream_topology ( struct ast_channel chan,
struct ast_stream_topology topology 
)

Answer a channel passing in a stream topology.

Since
18.0.0
Parameters
chanchannel to answer
topologythe peer's stream topology

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

Note
The channel passed does not need to be locked, but is locked by the function when needed.
Unlike ast_answer(), this function will not wait for media flow to begin. The caller should be careful before sending media to the channel before incoming media arrives, as the outgoing media may be lost.
The topology is usually that of the peer channel and may be NULL.
Return values
0on success
non-zeroon failure

Definition at line 2638 of file channel.c.

2639{
2640 int res = 0;
2641 SCOPE_TRACE(1, "%s\n", ast_channel_name(chan));
2642
2643 ast_channel_lock(chan);
2644
2645 /* You can't answer an outbound call */
2647 ast_channel_unlock(chan);
2648 return 0;
2649 }
2650
2651 /* Stop if we're a zombie or need a soft hangup */
2653 ast_channel_unlock(chan);
2654 return -1;
2655 }
2656
2657 /*
2658 * Mark when incoming channel answered so we can know how
2659 * long the channel has been up.
2660 */
2662
2663 ast_channel_unlock(chan);
2664
2665 switch (ast_channel_state(chan)) {
2666 case AST_STATE_RINGING:
2667 case AST_STATE_RING:
2668 ast_channel_lock(chan);
2669 if (ast_channel_tech(chan)->answer_with_stream_topology) {
2670 res = ast_channel_tech(chan)->answer_with_stream_topology(chan, topology);
2671
2672 } else if (ast_channel_tech(chan)->answer) {
2673 res = ast_channel_tech(chan)->answer(chan);
2674 }
2676 ast_channel_unlock(chan);
2677 break;
2678 case AST_STATE_UP:
2679 /* Fall through */
2680 default:
2681 ast_debug(2, "Skipping answer, since channel state on %s is %s\n", ast_channel_name(chan), ast_state2str(ast_channel_state(chan)));
2682 break;
2683 }
2684
2685 ast_indicate(chan, -1);
2686
2687 return res;
2688}
static int answer(void *data)
Definition chan_pjsip.c:687
const char * ast_state2str(enum ast_channel_state state)
Gives the string form of a given channel state.
Definition channel.c:637
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition channel.c:4298
int(*const answer)(struct ast_channel *chan)
Answer the channel.
Definition channel.h:727
int(*const answer_with_stream_topology)(struct ast_channel *chan, struct ast_stream_topology *topology)
Answer the channel with topology.
Definition channel.h:740

References answer(), ast_channel_tech::answer, ast_channel_tech::answer_with_stream_topology, ast_channel_flags(), ast_channel_lock, ast_channel_name(), ast_channel_unlock, ast_check_hangup(), ast_debug, AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, ast_indicate(), ast_setstate(), ast_state2str(), AST_STATE_RING, AST_STATE_RINGING, AST_STATE_UP, ast_test_flag, SCOPE_TRACE, and set_channel_answer_time().

Referenced by ast_raw_answer(), and pre_bridge_setup().

◆ ast_read()

struct ast_frame * ast_read ( struct ast_channel chan)

Reads a frame.

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

Definition at line 4278 of file channel.c.

4279{
4280 return __ast_read(chan, 0, 1);
4281}
static struct ast_frame * __ast_read(struct ast_channel *chan, int dropaudio, int dropnondefault)
Definition channel.c:3541

References __ast_read().

Referenced by __adsi_transmit_messages(), __analog_ss_thread(), __ast_answer(), __ast_play_and_record(), __ast_request_and_dial(), adsi_careful_send(), analog_ss_thread(), ast_recvtext(), AST_TEST_DEFINE(), ast_tonepair(), ast_transfer_protocol(), ast_waitfordigit_full(), async_agi_read_frame(), audiosocket_run(), autoservice_run(), background_detect_exec(), channel_spy(), conf_flush(), conf_run(), dial_exec_full(), dial_trunk(), dictate_exec(), disa_exec(), disable_t38(), do_broadcast(), do_waiting(), echo_exec(), eivr_comm(), generic_fax_exec(), handle_recordfile(), handle_speechrecognize(), isAnsweringMachine(), jack_exec(), measurenoise(), moh_channel_thread(), monitor_dial(), mp3_exec(), read_from_chan(), read_mf_digits(), read_sf_digits(), receive_dtmf_digits(), receivefax_t38_init(), record_exec(), recordthread(), run_agi(), safe_sleep_conditional(), scan_exec(), send_waveform_to_channel(), sendfax_t38_init(), speech_background(), stasis_app_exec(), wait_exec(), wait_for_answer(), wait_for_answer(), wait_for_hangup(), wait_for_signal_or_hangup(), wait_for_winner(), waitforring_exec(), and waitstream_core().

◆ ast_read_generator_actions()

static void ast_read_generator_actions ( struct ast_channel chan,
struct ast_frame f 
)
static

Definition at line 3429 of file channel.c.

3430{
3431 struct ast_generator *generator;
3432 void *gendata;
3433 int res;
3434 int samples;
3435
3436 generator = ast_channel_generator(chan);
3437 if (!generator
3438 || !generator->generate
3439 || f->frametype != AST_FRAME_VOICE
3441 || ast_channel_timingfunc(chan)) {
3442 return;
3443 }
3444
3445 /*
3446 * We must generate frames in phase locked mode since
3447 * we have no internal timer available.
3448 */
3450 float factor;
3452 samples = (int) (((float) f->samples) * factor);
3453 } else {
3454 samples = f->samples;
3455 }
3456
3457 gendata = ast_channel_generatordata(chan);
3458 ast_channel_generatordata_set(chan, NULL); /* reset, to let writes go through */
3459
3460 /*
3461 * This unlock is here based on two assumptions that hold true at
3462 * this point in the code. 1) this function is only called from
3463 * within __ast_read() and 2) all generators call ast_write() in
3464 * their generate callback.
3465 *
3466 * The reason this is added is so that when ast_write is called,
3467 * the lock that occurs there will not recursively lock the
3468 * channel. Doing this will allow deadlock avoidance to work in
3469 * deeper functions.
3470 */
3471 ast_channel_unlock(chan);
3472 res = generator->generate(chan, gendata, f->datalen, samples);
3473 ast_channel_lock(chan);
3474 if (generator == ast_channel_generator(chan)) {
3475 ast_channel_generatordata_set(chan, gendata);
3476 if (res) {
3477 ast_debug(1, "Auto-deactivating generator\n");
3479 }
3480 }
3481}
int(* generate)(struct ast_channel *chan, void *data, int len, int samples)
Definition channel.h:235

References ast_channel_generator(), ast_channel_generatordata(), ast_channel_generatordata_set(), ast_channel_lock, ast_channel_timingfunc(), ast_channel_unlock, ast_channel_writeformat(), ast_deactivate_generator(), ast_debug, ast_format_cmp(), AST_FORMAT_CMP_NOT_EQUAL, ast_format_get_sample_rate(), AST_FRAME_VOICE, ast_frame::datalen, ast_frame_subclass::format, ast_frame::frametype, ast_generator::generate, NULL, ast_frame::samples, and ast_frame::subclass.

Referenced by __ast_read().

◆ ast_read_noaudio()

struct ast_frame * ast_read_noaudio ( struct ast_channel chan)

Reads a frame, returning AST_FRAME_NULL frame if audio.

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

Definition at line 4288 of file channel.c.

4289{
4290 return __ast_read(chan, 1, 1);
4291}

References __ast_read().

Referenced by ast_control_tone(), and conf_run().

◆ ast_read_stream()

struct ast_frame * ast_read_stream ( struct ast_channel chan)

Reads a frame, but does not filter to just the default streams.

Parameters
chanchannel to read a frame from
Returns
Returns a frame, or NULL on error. If it returns NULL, you best just stop reading frames and assume the channel has been disconnected.
Note
This function will not perform any filtering and will return media frames from all streams on the channel. To determine which stream a frame originated from the stream_num on it can be examined.

Definition at line 4283 of file channel.c.

4284{
4285 return __ast_read(chan, 0, 0);
4286}

References __ast_read().

Referenced by AST_TEST_DEFINE(), bridge_handle_trip(), read_from_chan(), and stream_echo_perform().

◆ ast_read_stream_noaudio()

struct ast_frame * ast_read_stream_noaudio ( struct ast_channel chan)

Reads a frame, but does not filter to just the default streams, returning AST_FRAME_NULL frame if audio.

Parameters
chanchannel to read a frame from
Returns
Returns a frame, or NULL on error. If it returns NULL, you best just stop reading frames and assume the channel has been disconnected.
Note
This function will not perform any filtering and will return media frames from all streams on the channel. To determine which stream a frame originated from the stream_num on it can be examined.
Audio is replaced with AST_FRAME_NULL to avoid transcode when the resulting audio is not necessary.

Definition at line 4293 of file channel.c.

4294{
4295 return __ast_read(chan, 1, 0);
4296}

References __ast_read().

Referenced by bridge_handle_trip().

◆ ast_readstring()

int ast_readstring ( struct ast_channel c,
char *  s,
int  len,
int  timeout,
int  rtimeout,
char *  enders 
)

Reads multiple digits.

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

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

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

Definition at line 6577 of file channel.c.

6578{
6579 return ast_readstring_full(c, s, len, timeout, ftimeout, enders, -1, -1);
6580}
int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int ftimeout, char *enders, int audiofd, int ctrlfd)
Definition channel.c:6582

References ast_readstring_full(), c, and len().

Referenced by __adsi_transmit_messages(), adsi_begin_download(), adsi_get_cpeinfo(), adsi_load_session(), app_exec(), ast_app_getdata_terminator(), dialout(), do_directory(), forward_message(), privacy_exec(), vm_authenticate(), vm_newuser_setup(), and vm_options().

◆ ast_readstring_full()

int ast_readstring_full ( struct ast_channel c,
char *  s,
int  len,
int  timeout,
int  ftimeout,
char *  enders,
int  audiofd,
int  ctrlfd 
)

Definition at line 6582 of file channel.c.

6583{
6584 int pos = 0; /* index in the buffer where we accumulate digits */
6585 int to = ftimeout;
6586
6587 struct ast_silence_generator *silgen = NULL;
6588
6589 /* Stop if we're a zombie or need a soft hangup */
6591 return -1;
6592 if (!len)
6593 return -1;
6594 for (;;) {
6595 int d;
6596 if (ast_channel_stream(c)) {
6597 d = ast_waitstream_full(c, AST_DIGIT_ANY, audiofd, ctrlfd);
6599 if (!silgen && ast_opt_transmit_silence)
6601 usleep(1000);
6602 if (!d)
6603 d = ast_waitfordigit_full(c, to, NULL, audiofd, ctrlfd);
6604 } else {
6605 if (!silgen && ast_opt_transmit_silence)
6607 d = ast_waitfordigit_full(c, to, NULL, audiofd, ctrlfd);
6608 }
6609 if (d < 0) {
6611 return AST_GETDATA_FAILED;
6612 }
6613 if (d == 0) {
6614 s[pos] = '\0';
6616 return AST_GETDATA_TIMEOUT;
6617 }
6618 if (d == 1) {
6619 s[pos] = '\0';
6622 }
6623 if (strchr(enders, d) && (pos == 0)) {
6624 s[pos] = '\0';
6627 }
6628 if (!strchr(enders, d)) {
6629 s[pos++] = d;
6630 }
6631 if (strchr(enders, d) || (pos >= len)) {
6632 s[pos] = '\0';
6634 return AST_GETDATA_COMPLETE;
6635 }
6636 to = timeout;
6637 }
6638 /* Never reached */
6639 return 0;
6640}
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
Definition channel.c:8232
void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state)
Stops a previously-started silence generator on the given channel.
Definition channel.c:8278
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:3244
int ast_waitstream_full(struct ast_channel *c, const char *breakon, int audiofd, int monfd)
Definition file.c:1883
int ast_stopstream(struct ast_channel *c)
Stops a stream.
Definition file.c:223
#define AST_DIGIT_ANY
Definition file.h:48
@ AST_GETDATA_FAILED
@ AST_GETDATA_INTERRUPTED
@ AST_GETDATA_COMPLETE
@ AST_GETDATA_TIMEOUT
@ AST_GETDATA_EMPTY_END_TERMINATED
#define ast_opt_transmit_silence
Definition options.h:134
static struct test_val d

References ast_channel_flags(), ast_channel_start_silence_generator(), ast_channel_stop_silence_generator(), ast_channel_stream(), ast_check_hangup(), AST_DIGIT_ANY, AST_FLAG_ZOMBIE, AST_GETDATA_COMPLETE, AST_GETDATA_EMPTY_END_TERMINATED, AST_GETDATA_FAILED, AST_GETDATA_INTERRUPTED, AST_GETDATA_TIMEOUT, ast_opt_transmit_silence, ast_stopstream(), ast_test_flag, ast_waitfordigit_full(), ast_waitstream_full(), c, d, len(), and NULL.

Referenced by ast_app_getdata_full(), and ast_readstring().

◆ ast_recvchar()

int ast_recvchar ( struct ast_channel chan,
int  timeout 
)

Receives a text character from a channel.

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

Read a char of text from a channel

Returns
0 on success, -1 on failure

Definition at line 4729 of file channel.c.

4730{
4731 int c;
4732 char *buf = ast_recvtext(chan, timeout);
4733 if (buf == NULL)
4734 return -1; /* error or timeout */
4735 c = *(unsigned char *)buf;
4736 ast_free(buf);
4737 return c;
4738}
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:4740

References ast_free, ast_recvtext(), buf, c, and NULL.

Referenced by handle_recvchar().

◆ ast_recvtext()

char * ast_recvtext ( struct ast_channel chan,
int  timeout 
)

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

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

Definition at line 4740 of file channel.c.

4741{
4742 int res;
4743 char *buf = NULL;
4744 struct timeval start = ast_tvnow();
4745 int ms;
4746
4747 while ((ms = ast_remaining_ms(start, timeout))) {
4748 struct ast_frame *f;
4749
4750 if (ast_check_hangup(chan)) {
4751 break;
4752 }
4753 res = ast_waitfor(chan, ms);
4754 if (res <= 0) {/* timeout or error */
4755 break;
4756 }
4757 f = ast_read(chan);
4758 if (f == NULL) {
4759 break; /* no frame */
4760 }
4762 ast_frfree(f);
4763 break;
4764 } else if (f->frametype == AST_FRAME_TEXT) { /* what we want */
4765 buf = ast_strndup((char *) f->data.ptr, f->datalen); /* dup and break */
4766 ast_frfree(f);
4767 break;
4768 }
4769 ast_frfree(f);
4770 }
4771 return buf;
4772}
#define ast_strndup(str, len)
A wrapper for strndup()
Definition astmm.h:256

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

Referenced by ast_recvchar(), handle_recvtext(), and recvtext_exec().

◆ ast_redirecting_build_data()

int ast_redirecting_build_data ( unsigned char *  data,
size_t  datalen,
const struct ast_party_redirecting redirecting,
const struct ast_set_party_redirecting update 
)

Build the redirecting id data frame.

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

Definition at line 9336 of file channel.c.

9337{
9338 int32_t value;
9339 size_t pos = 0;
9340 int res;
9341
9342 static const struct ast_party_id_ies orig_ies = {
9344 .name.char_set = AST_REDIRECTING_ORIG_NAME_CHAR_SET,
9345 .name.presentation = AST_REDIRECTING_ORIG_NAME_PRESENTATION,
9346 .name.valid = AST_REDIRECTING_ORIG_NAME_VALID,
9347
9348 .number.str = AST_REDIRECTING_ORIG_NUMBER,
9349 .number.plan = AST_REDIRECTING_ORIG_NUMBER_PLAN,
9350 .number.presentation = AST_REDIRECTING_ORIG_NUMBER_PRESENTATION,
9351 .number.valid = AST_REDIRECTING_ORIG_NUMBER_VALID,
9352
9353 .subaddress.str = AST_REDIRECTING_ORIG_SUBADDRESS,
9354 .subaddress.type = AST_REDIRECTING_ORIG_SUBADDRESS_TYPE,
9355 .subaddress.odd_even_indicator = AST_REDIRECTING_ORIG_SUBADDRESS_ODD_EVEN,
9356 .subaddress.valid = AST_REDIRECTING_ORIG_SUBADDRESS_VALID,
9357
9359 .combined_presentation = 0,/* Not sent. */
9360 };
9361 static const struct ast_party_id_ies from_ies = {
9363 .name.char_set = AST_REDIRECTING_FROM_NAME_CHAR_SET,
9364 .name.presentation = AST_REDIRECTING_FROM_NAME_PRESENTATION,
9365 .name.valid = AST_REDIRECTING_FROM_NAME_VALID,
9366
9367 .number.str = AST_REDIRECTING_FROM_NUMBER,
9368 .number.plan = AST_REDIRECTING_FROM_NUMBER_PLAN,
9369 .number.presentation = AST_REDIRECTING_FROM_NUMBER_PRESENTATION,
9370 .number.valid = AST_REDIRECTING_FROM_NUMBER_VALID,
9371
9372 .subaddress.str = AST_REDIRECTING_FROM_SUBADDRESS,
9373 .subaddress.type = AST_REDIRECTING_FROM_SUBADDRESS_TYPE,
9374 .subaddress.odd_even_indicator = AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN,
9375 .subaddress.valid = AST_REDIRECTING_FROM_SUBADDRESS_VALID,
9376
9378 .combined_presentation = AST_REDIRECTING_FROM_ID_PRESENTATION,
9379 };
9380 static const struct ast_party_id_ies to_ies = {
9382 .name.char_set = AST_REDIRECTING_TO_NAME_CHAR_SET,
9383 .name.presentation = AST_REDIRECTING_TO_NAME_PRESENTATION,
9384 .name.valid = AST_REDIRECTING_TO_NAME_VALID,
9385
9386 .number.str = AST_REDIRECTING_TO_NUMBER,
9387 .number.plan = AST_REDIRECTING_TO_NUMBER_PLAN,
9388 .number.presentation = AST_REDIRECTING_TO_NUMBER_PRESENTATION,
9389 .number.valid = AST_REDIRECTING_TO_NUMBER_VALID,
9390
9391 .subaddress.str = AST_REDIRECTING_TO_SUBADDRESS,
9392 .subaddress.type = AST_REDIRECTING_TO_SUBADDRESS_TYPE,
9393 .subaddress.odd_even_indicator = AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN,
9394 .subaddress.valid = AST_REDIRECTING_TO_SUBADDRESS_VALID,
9395
9397 .combined_presentation = AST_REDIRECTING_TO_ID_PRESENTATION,
9398 };
9399 static const struct ast_party_id_ies priv_orig_ies = {
9404
9407 .number.presentation = AST_REDIRECTING_PRIV_ORIG_NUMBER_PRESENTATION,
9409
9410 .subaddress.str = AST_REDIRECTING_PRIV_ORIG_SUBADDRESS,
9412 .subaddress.odd_even_indicator = AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_ODD_EVEN,
9414
9416 .combined_presentation = 0,/* Not sent. */
9417 };
9418 static const struct ast_party_id_ies priv_from_ies = {
9423
9426 .number.presentation = AST_REDIRECTING_PRIV_FROM_NUMBER_PRESENTATION,
9428
9429 .subaddress.str = AST_REDIRECTING_PRIV_FROM_SUBADDRESS,
9431 .subaddress.odd_even_indicator = AST_REDIRECTING_PRIV_FROM_SUBADDRESS_ODD_EVEN,
9433
9435 .combined_presentation = 0,/* Not sent. */
9436 };
9437 static const struct ast_party_id_ies priv_to_ies = {
9440 .name.presentation = AST_REDIRECTING_PRIV_TO_NAME_PRESENTATION,
9442
9443 .number.str = AST_REDIRECTING_PRIV_TO_NUMBER,
9445 .number.presentation = AST_REDIRECTING_PRIV_TO_NUMBER_PRESENTATION,
9447
9448 .subaddress.str = AST_REDIRECTING_PRIV_TO_SUBADDRESS,
9449 .subaddress.type = AST_REDIRECTING_PRIV_TO_SUBADDRESS_TYPE,
9450 .subaddress.odd_even_indicator = AST_REDIRECTING_PRIV_TO_SUBADDRESS_ODD_EVEN,
9451 .subaddress.valid = AST_REDIRECTING_PRIV_TO_SUBADDRESS_VALID,
9452
9454 .combined_presentation = 0,/* Not sent. */
9455 };
9456 static const struct ast_party_redirecting_reason_ies reason_ies = {
9459 };
9460
9461 static const struct ast_party_redirecting_reason_ies orig_reason_ies = {
9464 };
9465
9466 /* Redirecting frame version */
9467 if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
9468 ast_log(LOG_WARNING, "No space left for redirecting frame version\n");
9469 return -1;
9470 }
9471 data[pos++] = AST_REDIRECTING_VERSION;
9472 data[pos++] = 1;
9473 data[pos++] = 2;/* Version 1 did not have a version ie */
9474
9475 res = party_id_build_data(data + pos, datalen - pos, &redirecting->orig,
9476 "redirecting-orig", &orig_ies, update ? &update->orig : NULL);
9477 if (res < 0) {
9478 return -1;
9479 }
9480 pos += res;
9481
9482 res = party_id_build_data(data + pos, datalen - pos, &redirecting->from,
9483 "redirecting-from", &from_ies, update ? &update->from : NULL);
9484 if (res < 0) {
9485 return -1;
9486 }
9487 pos += res;
9488
9489 res = party_id_build_data(data + pos, datalen - pos, &redirecting->to,
9490 "redirecting-to", &to_ies, update ? &update->to : NULL);
9491 if (res < 0) {
9492 return -1;
9493 }
9494 pos += res;
9495
9496 res = party_id_build_data(data + pos, datalen - pos, &redirecting->priv_orig,
9497 "redirecting-priv-orig", &priv_orig_ies, update ? &update->priv_orig : NULL);
9498 if (res < 0) {
9499 return -1;
9500 }
9501 pos += res;
9502
9503 res = party_id_build_data(data + pos, datalen - pos, &redirecting->priv_from,
9504 "redirecting-priv-from", &priv_from_ies, update ? &update->priv_from : NULL);
9505 if (res < 0) {
9506 return -1;
9507 }
9508 pos += res;
9509
9510 res = party_id_build_data(data + pos, datalen - pos, &redirecting->priv_to,
9511 "redirecting-priv-to", &priv_to_ies, update ? &update->priv_to : NULL);
9512 if (res < 0) {
9513 return -1;
9514 }
9515 pos += res;
9516
9517 /* Redirecting reason */
9518 res = redirecting_reason_build_data(data + pos, datalen - pos, &redirecting->reason,
9519 "redirecting-reason", &reason_ies);
9520 if (res < 0) {
9521 return -1;
9522 }
9523 pos += res;
9524
9525 /* Redirecting original reason */
9526 res = redirecting_reason_build_data(data + pos, datalen - pos, &redirecting->orig_reason,
9527 "redirecting-orig-reason", &orig_reason_ies);
9528 if (res < 0) {
9529 return -1;
9530 }
9531 pos += res;
9532
9533 /* Redirecting count */
9534 if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) {
9535 ast_log(LOG_WARNING, "No space left for redirecting count\n");
9536 return -1;
9537 }
9538 data[pos++] = AST_REDIRECTING_COUNT;
9539 data[pos++] = sizeof(value);
9540 value = htonl(redirecting->count);
9541 memcpy(data + pos, &value, sizeof(value));
9542 pos += sizeof(value);
9543
9544 return pos;
9545}
static int redirecting_reason_build_data(unsigned char *data, size_t datalen, const struct ast_party_redirecting_reason *reason, const char *label, const struct ast_party_redirecting_reason_ies *ies)
Definition channel.c:9303

References ast_log, AST_REDIRECTING_COUNT, AST_REDIRECTING_FROM_ID_PRESENTATION, AST_REDIRECTING_FROM_NAME, AST_REDIRECTING_FROM_NAME_CHAR_SET, AST_REDIRECTING_FROM_NAME_PRESENTATION, AST_REDIRECTING_FROM_NAME_VALID, AST_REDIRECTING_FROM_NUMBER, AST_REDIRECTING_FROM_NUMBER_PLAN, AST_REDIRECTING_FROM_NUMBER_PRESENTATION, AST_REDIRECTING_FROM_NUMBER_VALID, AST_REDIRECTING_FROM_SUBADDRESS, AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_FROM_SUBADDRESS_TYPE, AST_REDIRECTING_FROM_SUBADDRESS_VALID, AST_REDIRECTING_FROM_TAG, AST_REDIRECTING_ORIG_NAME, AST_REDIRECTING_ORIG_NAME_CHAR_SET, AST_REDIRECTING_ORIG_NAME_PRESENTATION, AST_REDIRECTING_ORIG_NAME_VALID, AST_REDIRECTING_ORIG_NUMBER, AST_REDIRECTING_ORIG_NUMBER_PLAN, AST_REDIRECTING_ORIG_NUMBER_PRESENTATION, AST_REDIRECTING_ORIG_NUMBER_VALID, AST_REDIRECTING_ORIG_REASON_CODE, AST_REDIRECTING_ORIG_REASON_STR, AST_REDIRECTING_ORIG_SUBADDRESS, AST_REDIRECTING_ORIG_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_ORIG_SUBADDRESS_TYPE, AST_REDIRECTING_ORIG_SUBADDRESS_VALID, AST_REDIRECTING_ORIG_TAG, AST_REDIRECTING_PRIV_FROM_NAME, AST_REDIRECTING_PRIV_FROM_NAME_CHAR_SET, AST_REDIRECTING_PRIV_FROM_NAME_PRESENTATION, AST_REDIRECTING_PRIV_FROM_NAME_VALID, AST_REDIRECTING_PRIV_FROM_NUMBER, AST_REDIRECTING_PRIV_FROM_NUMBER_PLAN, AST_REDIRECTING_PRIV_FROM_NUMBER_PRESENTATION, AST_REDIRECTING_PRIV_FROM_NUMBER_VALID, AST_REDIRECTING_PRIV_FROM_SUBADDRESS, AST_REDIRECTING_PRIV_FROM_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_PRIV_FROM_SUBADDRESS_TYPE, AST_REDIRECTING_PRIV_FROM_SUBADDRESS_VALID, AST_REDIRECTING_PRIV_FROM_TAG, AST_REDIRECTING_PRIV_ORIG_NAME, AST_REDIRECTING_PRIV_ORIG_NAME_CHAR_SET, AST_REDIRECTING_PRIV_ORIG_NAME_PRESENTATION, AST_REDIRECTING_PRIV_ORIG_NAME_VALID, AST_REDIRECTING_PRIV_ORIG_NUMBER, AST_REDIRECTING_PRIV_ORIG_NUMBER_PLAN, AST_REDIRECTING_PRIV_ORIG_NUMBER_PRESENTATION, AST_REDIRECTING_PRIV_ORIG_NUMBER_VALID, AST_REDIRECTING_PRIV_ORIG_SUBADDRESS, AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_TYPE, AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_VALID, AST_REDIRECTING_PRIV_ORIG_TAG, AST_REDIRECTING_PRIV_TO_NAME, AST_REDIRECTING_PRIV_TO_NAME_CHAR_SET, AST_REDIRECTING_PRIV_TO_NAME_PRESENTATION, AST_REDIRECTING_PRIV_TO_NAME_VALID, AST_REDIRECTING_PRIV_TO_NUMBER, AST_REDIRECTING_PRIV_TO_NUMBER_PLAN, AST_REDIRECTING_PRIV_TO_NUMBER_PRESENTATION, AST_REDIRECTING_PRIV_TO_NUMBER_VALID, AST_REDIRECTING_PRIV_TO_SUBADDRESS, AST_REDIRECTING_PRIV_TO_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_PRIV_TO_SUBADDRESS_TYPE, AST_REDIRECTING_PRIV_TO_SUBADDRESS_VALID, AST_REDIRECTING_PRIV_TO_TAG, AST_REDIRECTING_REASON_CODE, AST_REDIRECTING_REASON_STR, AST_REDIRECTING_TO_ID_PRESENTATION, AST_REDIRECTING_TO_NAME, AST_REDIRECTING_TO_NAME_CHAR_SET, AST_REDIRECTING_TO_NAME_PRESENTATION, AST_REDIRECTING_TO_NAME_VALID, AST_REDIRECTING_TO_NUMBER, AST_REDIRECTING_TO_NUMBER_PLAN, AST_REDIRECTING_TO_NUMBER_PRESENTATION, AST_REDIRECTING_TO_NUMBER_VALID, AST_REDIRECTING_TO_SUBADDRESS, AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_TO_SUBADDRESS_TYPE, AST_REDIRECTING_TO_SUBADDRESS_VALID, AST_REDIRECTING_TO_TAG, AST_REDIRECTING_VERSION, ast_party_redirecting_reason_ies::code, ast_party_redirecting::count, ast_party_redirecting::from, LOG_WARNING, ast_party_id_ies::name, NULL, ast_party_redirecting::orig, ast_party_redirecting::orig_reason, party_id_build_data(), ast_party_redirecting::priv_from, ast_party_redirecting::priv_orig, ast_party_redirecting::priv_to, ast_party_redirecting::reason, redirecting_reason_build_data(), ast_party_name_ies::str, ast_party_redirecting::to, update(), and value.

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

◆ ast_redirecting_parse_data()

int ast_redirecting_parse_data ( const unsigned char *  data,
size_t  datalen,
struct ast_party_redirecting redirecting 
)

Parse redirecting indication frame data.

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

Definition at line 9547 of file channel.c.

9548{
9549 size_t pos;
9550 unsigned char ie_len;
9551 unsigned char ie_id;
9552 int32_t value;
9553 int frame_version = 1;
9554 int from_combined_presentation = 0;
9555 int got_from_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
9556 int to_combined_presentation = 0;
9557 int got_to_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
9558
9559 for (pos = 0; pos < datalen; pos += ie_len) {
9560 if (datalen < pos + sizeof(ie_id) + sizeof(ie_len)) {
9561 ast_log(LOG_WARNING, "Invalid redirecting update\n");
9562 return -1;
9563 }
9564 ie_id = data[pos++];
9565 ie_len = data[pos++];
9566 if (datalen < pos + ie_len) {
9567 ast_log(LOG_WARNING, "Invalid redirecting update\n");
9568 return -1;
9569 }
9570
9571 switch (ie_id) {
9572/* Redirecting frame version */
9574 if (ie_len != 1) {
9575 ast_log(LOG_WARNING, "Invalid redirecting frame version (%u)\n",
9576 (unsigned) ie_len);
9577 break;
9578 }
9579 frame_version = data[pos];
9580 break;
9581/* Redirecting-orig party id name */
9583 ast_free(redirecting->orig.name.str);
9584 redirecting->orig.name.str = ast_malloc(ie_len + 1);
9585 if (redirecting->orig.name.str) {
9586 memcpy(redirecting->orig.name.str, data + pos, ie_len);
9587 redirecting->orig.name.str[ie_len] = 0;
9588 }
9589 break;
9591 if (ie_len != 1) {
9592 ast_log(LOG_WARNING, "Invalid redirecting-orig name char set (%u)\n",
9593 (unsigned) ie_len);
9594 break;
9595 }
9596 redirecting->orig.name.char_set = data[pos];
9597 break;
9599 if (ie_len != 1) {
9600 ast_log(LOG_WARNING, "Invalid redirecting-orig name presentation (%u)\n",
9601 (unsigned) ie_len);
9602 break;
9603 }
9604 redirecting->orig.name.presentation = data[pos];
9605 break;
9607 if (ie_len != 1) {
9608 ast_log(LOG_WARNING, "Invalid redirecting-orig name valid (%u)\n",
9609 (unsigned) ie_len);
9610 break;
9611 }
9612 redirecting->orig.name.valid = data[pos];
9613 break;
9614/* Redirecting-orig party id number */
9616 ast_free(redirecting->orig.number.str);
9617 redirecting->orig.number.str = ast_malloc(ie_len + 1);
9618 if (redirecting->orig.number.str) {
9619 memcpy(redirecting->orig.number.str, data + pos, ie_len);
9620 redirecting->orig.number.str[ie_len] = 0;
9621 }
9622 break;
9624 if (ie_len != 1) {
9625 ast_log(LOG_WARNING, "Invalid redirecting-orig numbering plan (%u)\n",
9626 (unsigned) ie_len);
9627 break;
9628 }
9629 redirecting->orig.number.plan = data[pos];
9630 break;
9632 if (ie_len != 1) {
9633 ast_log(LOG_WARNING, "Invalid redirecting-orig number presentation (%u)\n",
9634 (unsigned) ie_len);
9635 break;
9636 }
9637 redirecting->orig.number.presentation = data[pos];
9638 break;
9640 if (ie_len != 1) {
9641 ast_log(LOG_WARNING, "Invalid redirecting-orig number valid (%u)\n",
9642 (unsigned) ie_len);
9643 break;
9644 }
9645 redirecting->orig.number.valid = data[pos];
9646 break;
9647/* Redirecting-orig party id subaddress */
9649 ast_free(redirecting->orig.subaddress.str);
9650 redirecting->orig.subaddress.str = ast_malloc(ie_len + 1);
9651 if (redirecting->orig.subaddress.str) {
9652 memcpy(redirecting->orig.subaddress.str, data + pos, ie_len);
9653 redirecting->orig.subaddress.str[ie_len] = 0;
9654 }
9655 break;
9657 if (ie_len != 1) {
9658 ast_log(LOG_WARNING, "Invalid redirecting-orig type of subaddress (%u)\n",
9659 (unsigned) ie_len);
9660 break;
9661 }
9662 redirecting->orig.subaddress.type = data[pos];
9663 break;
9665 if (ie_len != 1) {
9667 "Invalid redirecting-orig subaddress odd-even indicator (%u)\n",
9668 (unsigned) ie_len);
9669 break;
9670 }
9671 redirecting->orig.subaddress.odd_even_indicator = data[pos];
9672 break;
9674 if (ie_len != 1) {
9675 ast_log(LOG_WARNING, "Invalid redirecting-orig subaddress valid (%u)\n",
9676 (unsigned) ie_len);
9677 break;
9678 }
9679 redirecting->orig.subaddress.valid = data[pos];
9680 break;
9681/* Redirecting-orig party id tag */
9683 ast_free(redirecting->orig.tag);
9684 redirecting->orig.tag = ast_malloc(ie_len + 1);
9685 if (redirecting->orig.tag) {
9686 memcpy(redirecting->orig.tag, data + pos, ie_len);
9687 redirecting->orig.tag[ie_len] = 0;
9688 }
9689 break;
9690/* Redirecting-from party id name */
9692 ast_free(redirecting->from.name.str);
9693 redirecting->from.name.str = ast_malloc(ie_len + 1);
9694 if (redirecting->from.name.str) {
9695 memcpy(redirecting->from.name.str, data + pos, ie_len);
9696 redirecting->from.name.str[ie_len] = 0;
9697 }
9698 break;
9700 if (ie_len != 1) {
9701 ast_log(LOG_WARNING, "Invalid redirecting-from name char set (%u)\n",
9702 (unsigned) ie_len);
9703 break;
9704 }
9705 redirecting->from.name.char_set = data[pos];
9706 break;
9708 if (ie_len != 1) {
9709 ast_log(LOG_WARNING, "Invalid redirecting-from name presentation (%u)\n",
9710 (unsigned) ie_len);
9711 break;
9712 }
9713 redirecting->from.name.presentation = data[pos];
9714 break;
9716 if (ie_len != 1) {
9717 ast_log(LOG_WARNING, "Invalid redirecting-from name valid (%u)\n",
9718 (unsigned) ie_len);
9719 break;
9720 }
9721 redirecting->from.name.valid = data[pos];
9722 break;
9723/* Redirecting-from party id number */
9725 ast_free(redirecting->from.number.str);
9726 redirecting->from.number.str = ast_malloc(ie_len + 1);
9727 if (redirecting->from.number.str) {
9728 memcpy(redirecting->from.number.str, data + pos, ie_len);
9729 redirecting->from.number.str[ie_len] = 0;
9730 }
9731 break;
9733 if (ie_len != 1) {
9734 ast_log(LOG_WARNING, "Invalid redirecting-from numbering plan (%u)\n",
9735 (unsigned) ie_len);
9736 break;
9737 }
9738 redirecting->from.number.plan = data[pos];
9739 break;
9741 if (ie_len != 1) {
9742 ast_log(LOG_WARNING, "Invalid redirecting-from number presentation (%u)\n",
9743 (unsigned) ie_len);
9744 break;
9745 }
9746 redirecting->from.number.presentation = data[pos];
9747 break;
9749 if (ie_len != 1) {
9750 ast_log(LOG_WARNING, "Invalid redirecting-from number valid (%u)\n",
9751 (unsigned) ie_len);
9752 break;
9753 }
9754 redirecting->from.number.valid = data[pos];
9755 break;
9756/* Redirecting-from party id combined presentation */
9758 if (ie_len != 1) {
9759 ast_log(LOG_WARNING, "Invalid redirecting-from combined presentation (%u)\n",
9760 (unsigned) ie_len);
9761 break;
9762 }
9763 from_combined_presentation = data[pos];
9764 got_from_combined_presentation = 1;
9765 break;
9766/* Redirecting-from party id subaddress */
9768 ast_free(redirecting->from.subaddress.str);
9769 redirecting->from.subaddress.str = ast_malloc(ie_len + 1);
9770 if (redirecting->from.subaddress.str) {
9771 memcpy(redirecting->from.subaddress.str, data + pos, ie_len);
9772 redirecting->from.subaddress.str[ie_len] = 0;
9773 }
9774 break;
9776 if (ie_len != 1) {
9777 ast_log(LOG_WARNING, "Invalid redirecting-from type of subaddress (%u)\n",
9778 (unsigned) ie_len);
9779 break;
9780 }
9781 redirecting->from.subaddress.type = data[pos];
9782 break;
9784 if (ie_len != 1) {
9786 "Invalid redirecting-from subaddress odd-even indicator (%u)\n",
9787 (unsigned) ie_len);
9788 break;
9789 }
9790 redirecting->from.subaddress.odd_even_indicator = data[pos];
9791 break;
9793 if (ie_len != 1) {
9794 ast_log(LOG_WARNING, "Invalid redirecting-from subaddress valid (%u)\n",
9795 (unsigned) ie_len);
9796 break;
9797 }
9798 redirecting->from.subaddress.valid = data[pos];
9799 break;
9800/* Redirecting-from party id tag */
9802 ast_free(redirecting->from.tag);
9803 redirecting->from.tag = ast_malloc(ie_len + 1);
9804 if (redirecting->from.tag) {
9805 memcpy(redirecting->from.tag, data + pos, ie_len);
9806 redirecting->from.tag[ie_len] = 0;
9807 }
9808 break;
9809/* Redirecting-to party id name */
9811 ast_free(redirecting->to.name.str);
9812 redirecting->to.name.str = ast_malloc(ie_len + 1);
9813 if (redirecting->to.name.str) {
9814 memcpy(redirecting->to.name.str, data + pos, ie_len);
9815 redirecting->to.name.str[ie_len] = 0;
9816 }
9817 break;
9819 if (ie_len != 1) {
9820 ast_log(LOG_WARNING, "Invalid redirecting-to name char set (%u)\n",
9821 (unsigned) ie_len);
9822 break;
9823 }
9824 redirecting->to.name.char_set = data[pos];
9825 break;
9827 if (ie_len != 1) {
9828 ast_log(LOG_WARNING, "Invalid redirecting-to name presentation (%u)\n",
9829 (unsigned) ie_len);
9830 break;
9831 }
9832 redirecting->to.name.presentation = data[pos];
9833 break;
9835 if (ie_len != 1) {
9836 ast_log(LOG_WARNING, "Invalid redirecting-to name valid (%u)\n",
9837 (unsigned) ie_len);
9838 break;
9839 }
9840 redirecting->to.name.valid = data[pos];
9841 break;
9842/* Redirecting-to party id number */
9844 ast_free(redirecting->to.number.str);
9845 redirecting->to.number.str = ast_malloc(ie_len + 1);
9846 if (redirecting->to.number.str) {
9847 memcpy(redirecting->to.number.str, data + pos, ie_len);
9848 redirecting->to.number.str[ie_len] = 0;
9849 }
9850 break;
9852 if (ie_len != 1) {
9853 ast_log(LOG_WARNING, "Invalid redirecting-to numbering plan (%u)\n",
9854 (unsigned) ie_len);
9855 break;
9856 }
9857 redirecting->to.number.plan = data[pos];
9858 break;
9860 if (ie_len != 1) {
9861 ast_log(LOG_WARNING, "Invalid redirecting-to number presentation (%u)\n",
9862 (unsigned) ie_len);
9863 break;
9864 }
9865 redirecting->to.number.presentation = data[pos];
9866 break;
9868 if (ie_len != 1) {
9869 ast_log(LOG_WARNING, "Invalid redirecting-to number valid (%u)\n",
9870 (unsigned) ie_len);
9871 break;
9872 }
9873 redirecting->to.number.valid = data[pos];
9874 break;
9875/* Redirecting-to party id combined presentation */
9877 if (ie_len != 1) {
9878 ast_log(LOG_WARNING, "Invalid redirecting-to combined presentation (%u)\n",
9879 (unsigned) ie_len);
9880 break;
9881 }
9882 to_combined_presentation = data[pos];
9883 got_to_combined_presentation = 1;
9884 break;
9885/* Redirecting-to party id subaddress */
9887 ast_free(redirecting->to.subaddress.str);
9888 redirecting->to.subaddress.str = ast_malloc(ie_len + 1);
9889 if (redirecting->to.subaddress.str) {
9890 memcpy(redirecting->to.subaddress.str, data + pos, ie_len);
9891 redirecting->to.subaddress.str[ie_len] = 0;
9892 }
9893 break;
9895 if (ie_len != 1) {
9896 ast_log(LOG_WARNING, "Invalid redirecting-to type of subaddress (%u)\n",
9897 (unsigned) ie_len);
9898 break;
9899 }
9900 redirecting->to.subaddress.type = data[pos];
9901 break;
9903 if (ie_len != 1) {
9905 "Invalid redirecting-to subaddress odd-even indicator (%u)\n",
9906 (unsigned) ie_len);
9907 break;
9908 }
9909 redirecting->to.subaddress.odd_even_indicator = data[pos];
9910 break;
9912 if (ie_len != 1) {
9913 ast_log(LOG_WARNING, "Invalid redirecting-to subaddress valid (%u)\n",
9914 (unsigned) ie_len);
9915 break;
9916 }
9917 redirecting->to.subaddress.valid = data[pos];
9918 break;
9919/* Redirecting-to party id tag */
9921 ast_free(redirecting->to.tag);
9922 redirecting->to.tag = ast_malloc(ie_len + 1);
9923 if (redirecting->to.tag) {
9924 memcpy(redirecting->to.tag, data + pos, ie_len);
9925 redirecting->to.tag[ie_len] = 0;
9926 }
9927 break;
9928/* Private redirecting-orig party id name */
9930 ast_free(redirecting->priv_orig.name.str);
9931 redirecting->priv_orig.name.str = ast_malloc(ie_len + 1);
9932 if (redirecting->priv_orig.name.str) {
9933 memcpy(redirecting->priv_orig.name.str, data + pos, ie_len);
9934 redirecting->priv_orig.name.str[ie_len] = 0;
9935 }
9936 break;
9938 if (ie_len != 1) {
9939 ast_log(LOG_WARNING, "Invalid private redirecting-orig name char set (%u)\n",
9940 (unsigned) ie_len);
9941 break;
9942 }
9943 redirecting->priv_orig.name.char_set = data[pos];
9944 break;
9946 if (ie_len != 1) {
9947 ast_log(LOG_WARNING, "Invalid private redirecting-orig name presentation (%u)\n",
9948 (unsigned) ie_len);
9949 break;
9950 }
9951 redirecting->priv_orig.name.presentation = data[pos];
9952 break;
9954 if (ie_len != 1) {
9955 ast_log(LOG_WARNING, "Invalid private redirecting-orig name valid (%u)\n",
9956 (unsigned) ie_len);
9957 break;
9958 }
9959 redirecting->priv_orig.name.valid = data[pos];
9960 break;
9961/* Private redirecting-orig party id number */
9963 ast_free(redirecting->priv_orig.number.str);
9964 redirecting->priv_orig.number.str = ast_malloc(ie_len + 1);
9965 if (redirecting->priv_orig.number.str) {
9966 memcpy(redirecting->priv_orig.number.str, data + pos, ie_len);
9967 redirecting->priv_orig.number.str[ie_len] = 0;
9968 }
9969 break;
9971 if (ie_len != 1) {
9972 ast_log(LOG_WARNING, "Invalid private redirecting-orig numbering plan (%u)\n",
9973 (unsigned) ie_len);
9974 break;
9975 }
9976 redirecting->priv_orig.number.plan = data[pos];
9977 break;
9979 if (ie_len != 1) {
9980 ast_log(LOG_WARNING, "Invalid private redirecting-orig number presentation (%u)\n",
9981 (unsigned) ie_len);
9982 break;
9983 }
9984 redirecting->priv_orig.number.presentation = data[pos];
9985 break;
9987 if (ie_len != 1) {
9988 ast_log(LOG_WARNING, "Invalid private redirecting-orig number valid (%u)\n",
9989 (unsigned) ie_len);
9990 break;
9991 }
9992 redirecting->priv_orig.number.valid = data[pos];
9993 break;
9994/* Private redirecting-orig party id subaddress */
9996 ast_free(redirecting->priv_orig.subaddress.str);
9997 redirecting->priv_orig.subaddress.str = ast_malloc(ie_len + 1);
9998 if (redirecting->priv_orig.subaddress.str) {
9999 memcpy(redirecting->priv_orig.subaddress.str, data + pos, ie_len);
10000 redirecting->priv_orig.subaddress.str[ie_len] = 0;
10001 }
10002 break;
10004 if (ie_len != 1) {
10005 ast_log(LOG_WARNING, "Invalid private redirecting-orig type of subaddress (%u)\n",
10006 (unsigned) ie_len);
10007 break;
10008 }
10009 redirecting->priv_orig.subaddress.type = data[pos];
10010 break;
10012 if (ie_len != 1) {
10014 "Invalid private redirecting-orig subaddress odd-even indicator (%u)\n",
10015 (unsigned) ie_len);
10016 break;
10017 }
10018 redirecting->priv_orig.subaddress.odd_even_indicator = data[pos];
10019 break;
10021 if (ie_len != 1) {
10022 ast_log(LOG_WARNING, "Invalid private redirecting-orig subaddress valid (%u)\n",
10023 (unsigned) ie_len);
10024 break;
10025 }
10026 redirecting->priv_orig.subaddress.valid = data[pos];
10027 break;
10028/* Private redirecting-orig party id tag */
10030 ast_free(redirecting->priv_orig.tag);
10031 redirecting->priv_orig.tag = ast_malloc(ie_len + 1);
10032 if (redirecting->priv_orig.tag) {
10033 memcpy(redirecting->priv_orig.tag, data + pos, ie_len);
10034 redirecting->priv_orig.tag[ie_len] = 0;
10035 }
10036 break;
10037/* Private redirecting-from party id name */
10039 ast_free(redirecting->priv_from.name.str);
10040 redirecting->priv_from.name.str = ast_malloc(ie_len + 1);
10041 if (redirecting->priv_from.name.str) {
10042 memcpy(redirecting->priv_from.name.str, data + pos, ie_len);
10043 redirecting->priv_from.name.str[ie_len] = 0;
10044 }
10045 break;
10047 if (ie_len != 1) {
10048 ast_log(LOG_WARNING, "Invalid private redirecting-from name char set (%u)\n",
10049 (unsigned) ie_len);
10050 break;
10051 }
10052 redirecting->priv_from.name.char_set = data[pos];
10053 break;
10055 if (ie_len != 1) {
10056 ast_log(LOG_WARNING, "Invalid private redirecting-from name presentation (%u)\n",
10057 (unsigned) ie_len);
10058 break;
10059 }
10060 redirecting->priv_from.name.presentation = data[pos];
10061 break;
10063 if (ie_len != 1) {
10064 ast_log(LOG_WARNING, "Invalid private redirecting-from name valid (%u)\n",
10065 (unsigned) ie_len);
10066 break;
10067 }
10068 redirecting->priv_from.name.valid = data[pos];
10069 break;
10070/* Private redirecting-from party id number */
10072 ast_free(redirecting->priv_from.number.str);
10073 redirecting->priv_from.number.str = ast_malloc(ie_len + 1);
10074 if (redirecting->priv_from.number.str) {
10075 memcpy(redirecting->priv_from.number.str, data + pos, ie_len);
10076 redirecting->priv_from.number.str[ie_len] = 0;
10077 }
10078 break;
10080 if (ie_len != 1) {
10081 ast_log(LOG_WARNING, "Invalid private redirecting-from numbering plan (%u)\n",
10082 (unsigned) ie_len);
10083 break;
10084 }
10085 redirecting->priv_from.number.plan = data[pos];
10086 break;
10088 if (ie_len != 1) {
10089 ast_log(LOG_WARNING, "Invalid private redirecting-from number presentation (%u)\n",
10090 (unsigned) ie_len);
10091 break;
10092 }
10093 redirecting->priv_from.number.presentation = data[pos];
10094 break;
10096 if (ie_len != 1) {
10097 ast_log(LOG_WARNING, "Invalid private redirecting-from number valid (%u)\n",
10098 (unsigned) ie_len);
10099 break;
10100 }
10101 redirecting->priv_from.number.valid = data[pos];
10102 break;
10103/* Private redirecting-from party id subaddress */
10105 ast_free(redirecting->priv_from.subaddress.str);
10106 redirecting->priv_from.subaddress.str = ast_malloc(ie_len + 1);
10107 if (redirecting->priv_from.subaddress.str) {
10108 memcpy(redirecting->priv_from.subaddress.str, data + pos, ie_len);
10109 redirecting->priv_from.subaddress.str[ie_len] = 0;
10110 }
10111 break;
10113 if (ie_len != 1) {
10114 ast_log(LOG_WARNING, "Invalid private redirecting-from type of subaddress (%u)\n",
10115 (unsigned) ie_len);
10116 break;
10117 }
10118 redirecting->priv_from.subaddress.type = data[pos];
10119 break;
10121 if (ie_len != 1) {
10123 "Invalid private redirecting-from subaddress odd-even indicator (%u)\n",
10124 (unsigned) ie_len);
10125 break;
10126 }
10127 redirecting->priv_from.subaddress.odd_even_indicator = data[pos];
10128 break;
10130 if (ie_len != 1) {
10131 ast_log(LOG_WARNING, "Invalid private redirecting-from subaddress valid (%u)\n",
10132 (unsigned) ie_len);
10133 break;
10134 }
10135 redirecting->priv_from.subaddress.valid = data[pos];
10136 break;
10137/* Private redirecting-from party id tag */
10139 ast_free(redirecting->priv_from.tag);
10140 redirecting->priv_from.tag = ast_malloc(ie_len + 1);
10141 if (redirecting->priv_from.tag) {
10142 memcpy(redirecting->priv_from.tag, data + pos, ie_len);
10143 redirecting->priv_from.tag[ie_len] = 0;
10144 }
10145 break;
10146/* Private redirecting-to party id name */
10148 ast_free(redirecting->priv_to.name.str);
10149 redirecting->priv_to.name.str = ast_malloc(ie_len + 1);
10150 if (redirecting->priv_to.name.str) {
10151 memcpy(redirecting->priv_to.name.str, data + pos, ie_len);
10152 redirecting->priv_to.name.str[ie_len] = 0;
10153 }
10154 break;
10156 if (ie_len != 1) {
10157 ast_log(LOG_WARNING, "Invalid private redirecting-to name char set (%u)\n",
10158 (unsigned) ie_len);
10159 break;
10160 }
10161 redirecting->priv_to.name.char_set = data[pos];
10162 break;
10164 if (ie_len != 1) {
10165 ast_log(LOG_WARNING, "Invalid private redirecting-to name presentation (%u)\n",
10166 (unsigned) ie_len);
10167 break;
10168 }
10169 redirecting->priv_to.name.presentation = data[pos];
10170 break;
10172 if (ie_len != 1) {
10173 ast_log(LOG_WARNING, "Invalid private redirecting-to name valid (%u)\n",
10174 (unsigned) ie_len);
10175 break;
10176 }
10177 redirecting->priv_to.name.valid = data[pos];
10178 break;
10179/* Private redirecting-to party id number */
10181 ast_free(redirecting->priv_to.number.str);
10182 redirecting->priv_to.number.str = ast_malloc(ie_len + 1);
10183 if (redirecting->priv_to.number.str) {
10184 memcpy(redirecting->priv_to.number.str, data + pos, ie_len);
10185 redirecting->priv_to.number.str[ie_len] = 0;
10186 }
10187 break;
10189 if (ie_len != 1) {
10190 ast_log(LOG_WARNING, "Invalid private redirecting-to numbering plan (%u)\n",
10191 (unsigned) ie_len);
10192 break;
10193 }
10194 redirecting->priv_to.number.plan = data[pos];
10195 break;
10197 if (ie_len != 1) {
10198 ast_log(LOG_WARNING, "Invalid private redirecting-to number presentation (%u)\n",
10199 (unsigned) ie_len);
10200 break;
10201 }
10202 redirecting->priv_to.number.presentation = data[pos];
10203 break;
10205 if (ie_len != 1) {
10206 ast_log(LOG_WARNING, "Invalid private redirecting-to number valid (%u)\n",
10207 (unsigned) ie_len);
10208 break;
10209 }
10210 redirecting->priv_to.number.valid = data[pos];
10211 break;
10212/* Private redirecting-to party id subaddress */
10214 ast_free(redirecting->priv_to.subaddress.str);
10215 redirecting->priv_to.subaddress.str = ast_malloc(ie_len + 1);
10216 if (redirecting->priv_to.subaddress.str) {
10217 memcpy(redirecting->priv_to.subaddress.str, data + pos, ie_len);
10218 redirecting->priv_to.subaddress.str[ie_len] = 0;
10219 }
10220 break;
10222 if (ie_len != 1) {
10223 ast_log(LOG_WARNING, "Invalid private redirecting-to type of subaddress (%u)\n",
10224 (unsigned) ie_len);
10225 break;
10226 }
10227 redirecting->priv_to.subaddress.type = data[pos];
10228 break;
10230 if (ie_len != 1) {
10232 "Invalid private redirecting-to subaddress odd-even indicator (%u)\n",
10233 (unsigned) ie_len);
10234 break;
10235 }
10236 redirecting->priv_to.subaddress.odd_even_indicator = data[pos];
10237 break;
10239 if (ie_len != 1) {
10240 ast_log(LOG_WARNING, "Invalid private redirecting-to subaddress valid (%u)\n",
10241 (unsigned) ie_len);
10242 break;
10243 }
10244 redirecting->priv_to.subaddress.valid = data[pos];
10245 break;
10246/* Private redirecting-to party id tag */
10248 ast_free(redirecting->priv_to.tag);
10249 redirecting->priv_to.tag = ast_malloc(ie_len + 1);
10250 if (redirecting->priv_to.tag) {
10251 memcpy(redirecting->priv_to.tag, data + pos, ie_len);
10252 redirecting->priv_to.tag[ie_len] = 0;
10253 }
10254 break;
10255/* Redirecting reason code */
10257 if (ie_len != sizeof(value)) {
10258 ast_log(LOG_WARNING, "Invalid redirecting reason (%u)\n",
10259 (unsigned) ie_len);
10260 break;
10261 }
10262 memcpy(&value, data + pos, sizeof(value));
10263 redirecting->reason.code = ntohl(value);
10264 break;
10265/* Redirecting reason string */
10267 ast_free(redirecting->reason.str);
10268 redirecting->reason.str = ast_malloc(ie_len + 1);
10269 if (redirecting->reason.str) {
10270 memcpy(redirecting->reason.str, data + pos, ie_len);
10271 redirecting->reason.str[ie_len] = 0;
10272 }
10273 break;
10274/* Redirecting orig-reason code */
10276 if (ie_len != sizeof(value)) {
10277 ast_log(LOG_WARNING, "Invalid redirecting original reason (%u)\n",
10278 (unsigned) ie_len);
10279 break;
10280 }
10281 memcpy(&value, data + pos, sizeof(value));
10282 redirecting->orig_reason.code = ntohl(value);
10283 break;
10284/* Redirecting orig-reason string */
10286 ast_free(redirecting->orig_reason.str);
10287 redirecting->orig_reason.str = ast_malloc(ie_len + 1);
10288 if (redirecting->orig_reason.str) {
10289 memcpy(redirecting->orig_reason.str, data + pos, ie_len);
10290 redirecting->orig_reason.str[ie_len] = 0;
10291 }
10292 break;
10293/* Redirecting count */
10295 if (ie_len != sizeof(value)) {
10296 ast_log(LOG_WARNING, "Invalid redirecting count (%u)\n",
10297 (unsigned) ie_len);
10298 break;
10299 }
10300 memcpy(&value, data + pos, sizeof(value));
10301 redirecting->count = ntohl(value);
10302 break;
10303/* Redirecting unknown element */
10304 default:
10305 ast_debug(1, "Unknown redirecting element: %u (%u)\n",
10306 (unsigned) ie_id, (unsigned) ie_len);
10307 break;
10308 }
10309 }
10310
10311 switch (frame_version) {
10312 case 1:
10313 /*
10314 * The other end is an earlier version that we need to adjust
10315 * for compatibility.
10316 *
10317 * The earlier version did not have the orig party id or
10318 * orig_reason value.
10319 */
10320 redirecting->from.name.valid = 1;
10322 redirecting->from.number.valid = 1;
10323 if (got_from_combined_presentation) {
10324 redirecting->from.name.presentation = from_combined_presentation;
10325 redirecting->from.number.presentation = from_combined_presentation;
10326 }
10327
10328 redirecting->to.name.valid = 1;
10330 redirecting->to.number.valid = 1;
10331 if (got_to_combined_presentation) {
10332 redirecting->to.name.presentation = to_combined_presentation;
10333 redirecting->to.number.presentation = to_combined_presentation;
10334 }
10335 break;
10336 case 2:
10337 /* The other end is at the same level as we are. */
10338 break;
10339 default:
10340 /*
10341 * The other end is newer than we are.
10342 * We need to assume that they are compatible with us.
10343 */
10344 ast_debug(1, "Redirecting frame has newer version: %u\n",
10345 (unsigned) frame_version);
10346 break;
10347 }
10348
10349 return 0;
10350}

References ast_debug, ast_free, ast_log, ast_malloc, AST_PARTY_CHAR_SET_ISO8859_1, AST_REDIRECTING_COUNT, AST_REDIRECTING_FROM_ID_PRESENTATION, AST_REDIRECTING_FROM_NAME, AST_REDIRECTING_FROM_NAME_CHAR_SET, AST_REDIRECTING_FROM_NAME_PRESENTATION, AST_REDIRECTING_FROM_NAME_VALID, AST_REDIRECTING_FROM_NUMBER, AST_REDIRECTING_FROM_NUMBER_PLAN, AST_REDIRECTING_FROM_NUMBER_PRESENTATION, AST_REDIRECTING_FROM_NUMBER_VALID, AST_REDIRECTING_FROM_SUBADDRESS, AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_FROM_SUBADDRESS_TYPE, AST_REDIRECTING_FROM_SUBADDRESS_VALID, AST_REDIRECTING_FROM_TAG, AST_REDIRECTING_ORIG_NAME, AST_REDIRECTING_ORIG_NAME_CHAR_SET, AST_REDIRECTING_ORIG_NAME_PRESENTATION, AST_REDIRECTING_ORIG_NAME_VALID, AST_REDIRECTING_ORIG_NUMBER, AST_REDIRECTING_ORIG_NUMBER_PLAN, AST_REDIRECTING_ORIG_NUMBER_PRESENTATION, AST_REDIRECTING_ORIG_NUMBER_VALID, AST_REDIRECTING_ORIG_REASON_CODE, AST_REDIRECTING_ORIG_REASON_STR, AST_REDIRECTING_ORIG_SUBADDRESS, AST_REDIRECTING_ORIG_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_ORIG_SUBADDRESS_TYPE, AST_REDIRECTING_ORIG_SUBADDRESS_VALID, AST_REDIRECTING_ORIG_TAG, AST_REDIRECTING_PRIV_FROM_NAME, AST_REDIRECTING_PRIV_FROM_NAME_CHAR_SET, AST_REDIRECTING_PRIV_FROM_NAME_PRESENTATION, AST_REDIRECTING_PRIV_FROM_NAME_VALID, AST_REDIRECTING_PRIV_FROM_NUMBER, AST_REDIRECTING_PRIV_FROM_NUMBER_PLAN, AST_REDIRECTING_PRIV_FROM_NUMBER_PRESENTATION, AST_REDIRECTING_PRIV_FROM_NUMBER_VALID, AST_REDIRECTING_PRIV_FROM_SUBADDRESS, AST_REDIRECTING_PRIV_FROM_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_PRIV_FROM_SUBADDRESS_TYPE, AST_REDIRECTING_PRIV_FROM_SUBADDRESS_VALID, AST_REDIRECTING_PRIV_FROM_TAG, AST_REDIRECTING_PRIV_ORIG_NAME, AST_REDIRECTING_PRIV_ORIG_NAME_CHAR_SET, AST_REDIRECTING_PRIV_ORIG_NAME_PRESENTATION, AST_REDIRECTING_PRIV_ORIG_NAME_VALID, AST_REDIRECTING_PRIV_ORIG_NUMBER, AST_REDIRECTING_PRIV_ORIG_NUMBER_PLAN, AST_REDIRECTING_PRIV_ORIG_NUMBER_PRESENTATION, AST_REDIRECTING_PRIV_ORIG_NUMBER_VALID, AST_REDIRECTING_PRIV_ORIG_SUBADDRESS, AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_TYPE, AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_VALID, AST_REDIRECTING_PRIV_ORIG_TAG, AST_REDIRECTING_PRIV_TO_NAME, AST_REDIRECTING_PRIV_TO_NAME_CHAR_SET, AST_REDIRECTING_PRIV_TO_NAME_PRESENTATION, AST_REDIRECTING_PRIV_TO_NAME_VALID, AST_REDIRECTING_PRIV_TO_NUMBER, AST_REDIRECTING_PRIV_TO_NUMBER_PLAN, AST_REDIRECTING_PRIV_TO_NUMBER_PRESENTATION, AST_REDIRECTING_PRIV_TO_NUMBER_VALID, AST_REDIRECTING_PRIV_TO_SUBADDRESS, AST_REDIRECTING_PRIV_TO_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_PRIV_TO_SUBADDRESS_TYPE, AST_REDIRECTING_PRIV_TO_SUBADDRESS_VALID, AST_REDIRECTING_PRIV_TO_TAG, AST_REDIRECTING_REASON_CODE, AST_REDIRECTING_REASON_STR, AST_REDIRECTING_TO_ID_PRESENTATION, AST_REDIRECTING_TO_NAME, AST_REDIRECTING_TO_NAME_CHAR_SET, AST_REDIRECTING_TO_NAME_PRESENTATION, AST_REDIRECTING_TO_NAME_VALID, AST_REDIRECTING_TO_NUMBER, AST_REDIRECTING_TO_NUMBER_PLAN, AST_REDIRECTING_TO_NUMBER_PRESENTATION, AST_REDIRECTING_TO_NUMBER_VALID, AST_REDIRECTING_TO_SUBADDRESS, AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_TO_SUBADDRESS_TYPE, AST_REDIRECTING_TO_SUBADDRESS_VALID, AST_REDIRECTING_TO_TAG, AST_REDIRECTING_VERSION, ast_party_name::char_set, ast_party_redirecting_reason::code, ast_party_redirecting::count, ast_party_redirecting::from, LOG_WARNING, ast_party_id::name, ast_party_id::number, ast_party_subaddress::odd_even_indicator, ast_party_redirecting::orig, ast_party_redirecting::orig_reason, ast_party_number::plan, ast_party_name::presentation, ast_party_number::presentation, ast_party_redirecting::priv_from, ast_party_redirecting::priv_orig, ast_party_redirecting::priv_to, ast_party_redirecting::reason, ast_party_name::str, ast_party_number::str, ast_party_subaddress::str, ast_party_redirecting_reason::str, ast_party_id::subaddress, ast_party_id::tag, ast_party_redirecting::to, ast_party_subaddress::type, ast_party_name::valid, ast_party_number::valid, ast_party_subaddress::valid, and value.

Referenced by ast_channel_redirecting_sub(), and indicate_redirecting().

◆ ast_ref_namedgroups()

struct ast_namedgroups * ast_ref_namedgroups ( struct ast_namedgroups *  groups)

Definition at line 7774 of file channel.c.

7775{
7776 if (groups) {
7777 ao2_ref(groups, 1);
7778 }
7779 return groups;
7780}

References ao2_ref.

Referenced by ast_channel_named_callgroups_set(), ast_channel_named_pickupgroups_set(), and mkintf().

◆ ast_request()

struct ast_channel * ast_request ( const char *  type,
struct ast_format_cap request_cap,
const struct ast_assigned_ids assignedids,
const struct ast_channel requestor,
const char *  addr,
int *  cause 
)

Requests a channel.

Parameters
typetype of channel to request
request_capFormat capabilities for requested channel
assignedidsUnique ID to create channel with
requestorchannel asking for data
addrdestination of the call
causeCause of failure

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

Return values
NULLfailure
non-NULLchannel on success

Definition at line 6373 of file channel.c.

6374{
6375 return request_channel(type, request_cap, NULL, assignedids, requestor, addr, cause);
6376}
static struct ast_channel * request_channel(const char *type, struct ast_format_cap *request_cap, struct ast_stream_topology *topology, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
Definition channel.c:6238

References NULL, request_channel(), and type.

Referenced by __ast_request_and_dial(), alloc_playback_chan(), ast_ari_channels_create(), ast_call_forward(), attended_transfer_bridge(), begin_dial_prerun(), blind_transfer_bridge(), build_conf(), chanavail_exec(), conf_run(), conf_start_record(), dial_transfer(), findmeexec(), meetme_menu_admin_extended(), park_local_transfer(), prepare_bridge_media_channel(), prepare_bridge_moh_channel(), retransfer_enter(), ring_entry(), and wait_for_answer().

◆ ast_request_and_dial()

struct ast_channel * ast_request_and_dial ( const char *  type,
struct ast_format_cap cap,
const struct ast_assigned_ids assignedids,
const struct ast_channel requestor,
const char *  addr,
int  timeout,
int *  reason,
const char *  cid_num,
const char *  cid_name 
)

Request a channel of a given type, with data as optional information used by the low level module and attempt to place a call on it.

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

Definition at line 6193 of file channel.c.

6194{
6195 return __ast_request_and_dial(type, cap, assignedids, requestor, addr, timeout, outstate, cidnum, cidname, NULL);
6196}
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:5997

References __ast_request_and_dial(), NULL, and type.

Referenced by generic_recall().

◆ ast_request_with_stream_topology()

struct ast_channel * ast_request_with_stream_topology ( const char *  type,
struct ast_stream_topology topology,
const struct ast_assigned_ids assignedids,
const struct ast_channel requestor,
const char *  addr,
int *  cause 
)

Requests a channel (specifying stream topology)

Parameters
typetype of channel to request
topologyStream topology for requested channel
assignedidsUnique ID to create channel with
requestorchannel asking for data
addrdestination of the call
causeCause of failure

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

Return values
NULLfailure
non-NULLchannel on success

Definition at line 6378 of file channel.c.

6379{
6380 return request_channel(type, NULL, topology, assignedids, requestor, addr, cause);
6381}

References NULL, request_channel(), and type.

Referenced by dial_exec_full(), and do_forward().

◆ ast_safe_sleep()

int ast_safe_sleep ( struct ast_channel chan,
int  ms 
)

Wait, look for hangups.

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

Definition at line 1561 of file channel.c.

1562{
1563 return safe_sleep_conditional(chan, ms, NULL, NULL, 1);
1564}
static int safe_sleep_conditional(struct ast_channel *chan, int timeout_ms, int(*cond)(void *), void *data, unsigned int generate_silence)
Wait, look for hangups and condition arg.
Definition channel.c:1485

References NULL, and safe_sleep_conditional().

Referenced by __analog_ss_thread(), adsi_transmit_message_full(), alarmreceiver_exec(), analog_ss_thread(), ast_senddigit(), ast_senddigit_mf(), conf_run(), dictate_exec(), disa_exec(), dtmf_no_bridge(), dtmf_stream(), flash_exec(), mf_stream(), milliwatt_exec(), old_milliwatt_exec(), pbx_builtin_wait(), play_moh_exec(), playtone(), privacy_exec(), send_tone_burst(), sf_stream(), testclient_exec(), testserver_exec(), try_calling(), waitforcond_exec(), waituntil_exec(), and zapateller_exec().

◆ ast_safe_sleep_conditional()

int ast_safe_sleep_conditional ( struct ast_channel chan,
int  ms,
int(*)(void *)  cond,
void *  data 
)

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

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

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

Definition at line 1555 of file channel.c.

1556{
1557 return safe_sleep_conditional(chan, timeout_ms, cond, data, 1);
1558}
ast_cond_t cond
Definition app_sla.c:336

References cond, ast_frame::data, and safe_sleep_conditional().

◆ ast_safe_sleep_without_silence()

int ast_safe_sleep_without_silence ( struct ast_channel chan,
int  ms 
)

Wait for a specified amount of time, looking for hangups, and do not generate silence.

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

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

Returns
returns -1 on hangup, otherwise 0.
Note
Unlike ast_safe_sleep this will not generate silence if Asterisk is configured to do so.

Definition at line 1566 of file channel.c.

1567{
1568 return safe_sleep_conditional(chan, ms, NULL, NULL, 0);
1569}

References NULL, and safe_sleep_conditional().

Referenced by wait_for_hangup().

◆ ast_say_character_str()

int ast_say_character_str ( struct ast_channel chan,
const char *  str,
const char *  ints,
const char *  lang,
enum ast_say_case_sensitivity  sensitivity 
)

function to pronounce character and phonetic strings

Definition at line 8339 of file channel.c.

8341{
8342 return ast_say_character_str_full(chan, str, ints, lang, sensitivity, -1, -1);
8343}
const char * str
Definition app_jack.c:150
SAY_EXTERN int(* ast_say_character_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, enum ast_say_case_sensitivity sensitivity, int audiofd, int ctrlfd) SAY_INIT(ast_say_character_str_full)
Definition say.h:194

References ast_say_character_str_full, and str.

Referenced by common_exec(), pbx_builtin_saycharacters(), pbx_builtin_saycharacters_case(), play_mailbox_owner(), play_on_channel(), and vmsayname_exec().

◆ ast_say_digit_str()

int ast_say_digit_str ( struct ast_channel chan,
const char *  num,
const char *  ints,
const char *  lang 
)

says digits of a string

Parameters
chanchannel to act upon
numstring to speak
intswhich dtmf to interrupt on
langlanguage to speak in

Vocally says the digits of a given string

Return values
0on succes
DTMFif interrupted
-1on failure

Definition at line 8327 of file channel.c.

8329{
8330 return ast_say_digit_str_full(chan, str, ints, lang, -1, -1);
8331}
SAY_EXTERN int(* ast_say_digit_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd) SAY_INIT(ast_say_digit_str_full)
Same as ast_say_digit_str() with audiofd for received audio and returns 1 on ctrlfd being readable.
Definition say.h:162

References ast_say_digit_str_full, and str.

Referenced by __analog_ss_thread(), forward_message(), invent_message(), invent_message(), pbx_builtin_saydigits(), play_message_callerid(), and play_on_channel().

◆ ast_say_digits()

int ast_say_digits ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  lang 
)

says digits

Parameters
chanchannel to act upon
numnumber to speak
intswhich dtmf to interrupt on
langlanguage to speak

Vocally says digits of a given number

Return values
0on success
DTMFif interrupted
-1on failure

Definition at line 8321 of file channel.c.

8323{
8324 return ast_say_digits_full(chan, num, ints, lang, -1, -1);
8325}
int ast_say_digits_full(struct ast_channel *chan, int num, const char *ints, const char *lang, int audiofd, int ctrlfd)
Same as ast_say_digits() with audiofd for received audio and returns 1 on ctrlfd being readable.
Definition channel.c:8351

References ast_say_digits_full().

Referenced by announce_to_dial(), common_exec(), conf_exec(), conf_run(), and say_parking_space().

◆ ast_say_digits_full()

int ast_say_digits_full ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  lang,
int  audiofd,
int  ctrlfd 
)

◆ ast_say_enumeration()

int ast_say_enumeration ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  lang,
const char *  options 
)

says an enumeration

Parameters
chanchannel to say them enumeration on
numnumber to say on the channel
intswhich dtmf to interrupt on
langlanguage to speak the enumeration
optionsset to 'f' for female, 'm' for male, 'c' for commune, 'n' for neuter

Vocally says an enumeration on a given channel (first, second, third, forth, thirtyfirst, hundredth, ....) Especially useful for dates and messages. Says 'last' if num equals to INT_MAX

Return values
0on success
DTMFdigit on interrupt
-1on failure

Definition at line 8315 of file channel.c.

8317{
8318 return ast_say_enumeration_full(chan, num, ints, language, options, -1, -1);
8319}
static char language[MAX_LANGUAGE]
Definition chan_iax2.c:361
SAY_EXTERN int(* ast_say_enumeration_full)(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd) SAY_INIT(ast_say_enumeration_full)
Same as ast_say_enumeration() with audiofd for received audio and returns 1 on ctrlfd being readable.
Definition say.h:125
static struct test_options options

References ast_say_enumeration_full, language, and options.

Referenced by ast_say_date_da(), ast_say_date_de(), ast_say_date_is(), ast_say_date_with_format_da(), ast_say_date_with_format_de(), ast_say_date_with_format_en(), ast_say_date_with_format_is(), ast_say_date_with_format_pl(), and ast_say_date_with_format_vi().

◆ ast_say_money_str()

int ast_say_money_str ( struct ast_channel chan,
const char *  str,
const char *  ints,
const char *  lang 
)

function to pronounce monetary amounts

Definition at line 8333 of file channel.c.

8335{
8336 return ast_say_money_str_full(chan, str, ints, lang, -1, -1);
8337}
SAY_EXTERN int(* ast_say_money_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd) SAY_INIT(ast_say_money_str_full)
Definition say.h:170

References ast_say_money_str_full, and str.

Referenced by pbx_builtin_saymoney().

◆ ast_say_number()

int ast_say_number ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  lang,
const char *  options 
)

says a number

Parameters
chanchannel to say them number on
numnumber to say on the channel
intswhich dtmf to interrupt on
langlanguage to speak the number
optionsset to 'f' for female, 'm' for male, 'c' for commune, 'n' for neuter

Vocally says a number on a given channel

Return values
0on success
DTMFdigit on interrupt
-1on failure

Definition at line 8303 of file channel.c.

8305{
8306 return ast_say_number_full(chan, num, ints, language, options, -1, -1);
8307}
SAY_EXTERN int(* ast_say_number_full)(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd) SAY_INIT(ast_say_number_full)
Same as ast_say_number() with audiofd for received audio and returns 1 on ctrlfd being readable.
Definition say.h:86

References ast_say_number_full, language, and options.

Referenced by announce_user_count(), app_exec(), ast_say_date_da(), ast_say_date_de(), ast_say_date_en(), ast_say_date_fr(), ast_say_date_gr(), ast_say_date_he(), ast_say_date_hu(), ast_say_date_is(), ast_say_date_ja(), ast_say_date_ka(), ast_say_date_nl(), ast_say_date_pt(), ast_say_date_th(), ast_say_date_with_format_da(), ast_say_date_with_format_de(), ast_say_date_with_format_en(), ast_say_date_with_format_es(), ast_say_date_with_format_fr(), ast_say_date_with_format_is(), ast_say_date_with_format_it(), ast_say_date_with_format_nl(), ast_say_date_with_format_pl(), ast_say_date_with_format_pt(), ast_say_date_with_format_th(), ast_say_date_with_format_vi(), ast_say_datetime_en(), ast_say_datetime_fr(), ast_say_datetime_from_now_en(), ast_say_datetime_from_now_fr(), ast_say_datetime_from_now_he(), ast_say_datetime_from_now_ka(), ast_say_datetime_from_now_pt(), ast_say_datetime_he(), ast_say_datetime_ja(), ast_say_datetime_pt(), ast_say_datetime_th(), ast_say_datetime_zh(), ast_say_time_de(), ast_say_time_en(), ast_say_time_fr(), ast_say_time_gr(), ast_say_time_hu(), ast_say_time_ja(), ast_say_time_ka(), ast_say_time_nl(), ast_say_time_pt(), ast_say_time_pt_BR(), ast_say_time_th(), ast_say_time_zh(), conf_run(), count_exec(), dictate_exec(), get_folder(), get_folder_ja(), gr_say_number_female(), limits_interval_playback(), meetme_menu_admin_extended(), pbx_builtin_saynumber(), play_message(), play_message_duration(), play_on_channel(), playback_common(), say_and_wait(), say_position(), try_calling(), vm_intro_gr(), vm_intro_he(), vm_intro_multilang(), vm_intro_pt(), and vm_intro_pt_BR().

◆ ast_say_ordinal()

int ast_say_ordinal ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  lang,
const char *  options 
)

says an ordinal number

Parameters
chanchannel to say them number on
numordinal number to say on the channel
intswhich dtmf to interrupt on
langlanguage to speak the number
optionsset to 'f' for female, 'm' for male, 'c' for commune, 'n' for neuter

Vocally says an ordinal number on a given channel

Return values
0on success
DTMFdigit on interrupt
-1on failure

Definition at line 8309 of file channel.c.

8311{
8312 return ast_say_ordinal_full(chan, num, ints, language, options, -1, -1);
8313}
SAY_EXTERN int(* ast_say_ordinal_full)(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd) SAY_INIT(ast_say_ordinal_full)
Same as ast_say_number() with audiofd for received audio and returns 1 on ctrlfd being readable.
Definition say.h:105

References ast_say_ordinal_full, language, and options.

Referenced by pbx_builtin_sayordinal().

◆ ast_say_phonetic_str()

int ast_say_phonetic_str ( struct ast_channel chan,
const char *  str,
const char *  ints,
const char *  lang 
)

Definition at line 8345 of file channel.c.

8347{
8348 return ast_say_phonetic_str_full(chan, str, ints, lang, -1, -1);
8349}
SAY_EXTERN int(* ast_say_phonetic_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd) SAY_INIT(ast_say_phonetic_str_full)
Definition say.h:199

References ast_say_phonetic_str_full, and str.

Referenced by pbx_builtin_sayphonetic().

◆ ast_senddigit()

int ast_senddigit ( struct ast_channel chan,
char  digit,
unsigned int  duration 
)

Send a DTMF digit to a channel.

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

Definition at line 4997 of file channel.c.

4998{
4999 if (duration < AST_DEFAULT_EMULATE_DTMF_DURATION) {
5001 }
5002 if (ast_channel_tech(chan)->send_digit_begin) {
5004 ast_safe_sleep(chan, duration);
5005 }
5006
5007 return ast_senddigit_end(chan, digit, duration);
5008}
int ast_senddigit_begin(struct ast_channel *chan, char digit)
Send a DTMF digit to a channel.
Definition channel.c:4897
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait, look for hangups.
Definition channel.c:1561

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

Referenced by dial_exec_full(), and dtmf_stream().

◆ ast_senddigit_begin()

int ast_senddigit_begin ( struct ast_channel chan,
char  digit 
)

Send a DTMF digit to a channel.

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

Definition at line 4897 of file channel.c.

4898{
4899 /* Device does not support DTMF tones, lets fake
4900 * it by doing our own generation. */
4901 static const char * const dtmf_tones[] = {
4902 "941+1336", /* 0 */
4903 "697+1209", /* 1 */
4904 "697+1336", /* 2 */
4905 "697+1477", /* 3 */
4906 "770+1209", /* 4 */
4907 "770+1336", /* 5 */
4908 "770+1477", /* 6 */
4909 "852+1209", /* 7 */
4910 "852+1336", /* 8 */
4911 "852+1477", /* 9 */
4912 "697+1633", /* A */
4913 "770+1633", /* B */
4914 "852+1633", /* C */
4915 "941+1633", /* D */
4916 "941+1209", /* * */
4917 "941+1477" /* # */
4918 };
4919
4920 if (!ast_channel_tech(chan)->send_digit_begin)
4921 return 0;
4922
4923 ast_channel_lock(chan);
4926 ast_channel_unlock(chan);
4927
4928 if (!ast_channel_tech(chan)->send_digit_begin(chan, digit))
4929 return 0;
4930
4931 if (digit >= '0' && digit <='9')
4932 ast_playtones_start(chan, 0, dtmf_tones[digit-'0'], 0);
4933 else if (digit >= 'A' && digit <= 'D')
4934 ast_playtones_start(chan, 0, dtmf_tones[digit-'A'+10], 0);
4935 else if (digit == '*')
4936 ast_playtones_start(chan, 0, dtmf_tones[14], 0);
4937 else if (digit == '#')
4938 ast_playtones_start(chan, 0, dtmf_tones[15], 0);
4939 else {
4940 /* not handled */
4941 ast_debug(1, "Unable to generate DTMF tone '%c' for '%s'\n", digit, ast_channel_name(chan));
4942 }
4943
4944 return 0;
4945}
void ast_channel_sending_dtmf_digit_set(struct ast_channel *chan, char value)
void ast_channel_sending_dtmf_tv_set(struct ast_channel *chan, struct timeval value)
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.

References ast_channel_lock, ast_channel_name(), ast_channel_sending_dtmf_digit_set(), ast_channel_sending_dtmf_tv_set(), ast_channel_unlock, ast_debug, ast_playtones_start(), ast_tvnow(), and digit.

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

◆ ast_senddigit_end()

int ast_senddigit_end ( struct ast_channel chan,
char  digit,
unsigned int  duration 
)

Send a DTMF digit to a channel.

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

Definition at line 4947 of file channel.c.

4948{
4949 int res = -1;
4950
4951 if (ast_channel_tech(chan)->send_digit_end)
4952 res = ast_channel_tech(chan)->send_digit_end(chan, digit, duration);
4953
4954 ast_channel_lock(chan);
4957 }
4958 ast_channel_unlock(chan);
4959
4960 if (res && ast_channel_generator(chan))
4961 ast_playtones_stop(chan);
4962
4963 return 0;
4964}
char ast_channel_sending_dtmf_digit(const struct ast_channel *chan)
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
int(*const send_digit_end)(struct ast_channel *chan, char digit, unsigned int duration)
Stop sending a literal DTMF digit.
Definition channel.h:710

References ast_channel_generator(), ast_channel_lock, ast_channel_sending_dtmf_digit(), ast_channel_sending_dtmf_digit_set(), ast_channel_unlock, ast_playtones_stop(), digit, and ast_channel_tech::send_digit_end.

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

◆ ast_senddigit_external()

int ast_senddigit_external ( struct ast_channel chan,
char  digit,
unsigned int  duration 
)

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

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

Definition at line 5010 of file channel.c.

5011{
5012 if (duration < AST_DEFAULT_EMULATE_DTMF_DURATION) {
5014 }
5015 if (ast_channel_tech(chan)->send_digit_begin) {
5017 usleep(duration * 1000);
5018 }
5019
5020 return ast_senddigit_end(chan, digit, duration);
5021}

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

Referenced by dtmf_stream(), and manager_play_dtmf().

◆ ast_senddigit_mf()

int ast_senddigit_mf ( struct ast_channel chan,
char  digit,
unsigned int  duration,
unsigned int  durationkp,
unsigned int  durationst,
int  is_external 
)

Send an MF digit to a channel.

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

Definition at line 4975 of file channel.c.

4977{
4978 if (duration < DEFAULT_EMULATE_MF_DURATION) {
4979 duration = DEFAULT_EMULATE_MF_DURATION;
4980 }
4981 if (ast_channel_tech(chan)->send_digit_begin) {
4982 if (digit == '*') {
4983 duration = durationkp;
4984 } else if (digit == '#' || digit == 'A' || digit == 'B' || digit == 'C') {
4985 duration = durationst;
4986 }
4988 if (is_external) {
4989 usleep(duration * 1000);
4990 } else {
4991 ast_safe_sleep(chan, duration);
4992 }
4993 }
4994 return ast_senddigit_mf_end(chan);
4995}
int ast_senddigit_mf_begin(struct ast_channel *chan, char digit)
Send an MF digit to a channel.
Definition channel.c:4858
int ast_senddigit_mf_end(struct ast_channel *chan)
End sending an MF digit to a channel.
Definition channel.c:4966
#define DEFAULT_EMULATE_MF_DURATION
Definition channel.c:110

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

Referenced by mf_stream().

◆ ast_senddigit_mf_begin()

int ast_senddigit_mf_begin ( struct ast_channel chan,
char  digit 
)

Send an MF digit to a channel.

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

Definition at line 4858 of file channel.c.

4859{
4860 static const char * const mf_tones[] = {
4861 "1300+1500", /* 0 */
4862 "700+900", /* 1 */
4863 "700+1100", /* 2 */
4864 "900+1100", /* 3 */
4865 "700+1300", /* 4 */
4866 "900+1300", /* 5 */
4867 "1100+1300", /* 6 */
4868 "700+1500", /* 7 */
4869 "900+1500", /* 8 */
4870 "1100+1500", /* 9 */
4871 "1100+1700", /* * (KP) */
4872 "1500+1700", /* # (ST) */
4873 "900+1700", /* A (STP) */
4874 "1300+1700", /* B (ST2P) */
4875 "700+1700" /* C (ST3P) */
4876 };
4877
4878 if (digit >= '0' && digit <='9') {
4879 ast_playtones_start(chan, 0, mf_tones[digit-'0'], 0);
4880 } else if (digit == '*') {
4881 ast_playtones_start(chan, 0, mf_tones[10], 0);
4882 } else if (digit == '#') {
4883 ast_playtones_start(chan, 0, mf_tones[11], 0);
4884 } else if (digit == 'A') {
4885 ast_playtones_start(chan, 0, mf_tones[12], 0);
4886 } else if (digit == 'B') {
4887 ast_playtones_start(chan, 0, mf_tones[13], 0);
4888 } else if (digit == 'C') {
4889 ast_playtones_start(chan, 0, mf_tones[14], 0);
4890 } else {
4891 /* not handled */
4892 ast_log(LOG_WARNING, "Unable to generate MF tone '%c' for '%s'\n", digit, ast_channel_name(chan));
4893 }
4894 return 0;
4895}
static const float mf_tones[]
Definition dsp.c:332

References ast_channel_name(), ast_log, ast_playtones_start(), digit, LOG_WARNING, and mf_tones.

Referenced by ast_senddigit_mf().

◆ ast_senddigit_mf_end()

int ast_senddigit_mf_end ( struct ast_channel chan)

End sending an MF digit to a channel.

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

Definition at line 4966 of file channel.c.

4967{
4968 if (ast_channel_generator(chan)) {
4969 ast_playtones_stop(chan);
4970 return 0;
4971 }
4972 return -1;
4973}

References ast_channel_generator(), and ast_playtones_stop().

Referenced by ast_senddigit_mf(), mf_stream(), and sf_stream().

◆ ast_sendtext()

int ast_sendtext ( struct ast_channel chan,
const char *  text 
)

Sends text to a channel.

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

Write text to a display on a channel

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

Definition at line 4832 of file channel.c.

4833{
4834 struct ast_msg_data *msg;
4835 int rc;
4836 struct ast_msg_data_attribute attrs[] =
4837 {
4838 {
4840 .value = (char *)text,
4841 }
4842 };
4843
4844 if (ast_strlen_zero(text)) {
4845 return 0;
4846 }
4847
4849 if (!msg) {
4850 return -1;
4851 }
4852 rc = ast_sendtext_data(chan, msg);
4853 ast_free(msg);
4854
4855 return rc;
4856}
struct ast_msg_data * ast_msg_data_alloc(enum ast_msg_data_source_type source, struct ast_msg_data_attribute attributes[], size_t count)
Allocates an ast_msg_data structure.
@ AST_MSG_DATA_ATTR_BODY
Definition message.h:458
@ AST_MSG_DATA_SOURCE_TYPE_UNKNOWN
Definition message.h:447
enum ast_msg_data_attribute_type type
Definition message.h:463

References ARRAY_LEN, ast_free, ast_msg_data_alloc(), AST_MSG_DATA_ATTR_BODY, AST_MSG_DATA_SOURCE_TYPE_UNKNOWN, ast_sendtext_data(), ast_strlen_zero(), text, and ast_msg_data_attribute::type.

Referenced by __ast_read(), handle_sendtext(), sendtext_exec(), and sendtext_safe().

◆ ast_sendtext_data()

int ast_sendtext_data ( struct ast_channel chan,
struct ast_msg_data msg 
)

Sends text to a channel in an ast_msg_data structure wrapper with ast_sendtext as fallback.

Since
13.22.0
15.5.0
Parameters
chanchannel to act upon
msgast_msg_data structure

Write text to a display on a channel. If the channel driver doesn't support the send_text_data callback. then the original send_text callback will be used if available.

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

Definition at line 4774 of file channel.c.

4775{
4776 int res = 0;
4777 const char *body = ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_BODY);
4778 const char *content_type = ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_CONTENT_TYPE);
4779
4780 ast_channel_lock(chan);
4781 /* Stop if we're a zombie or need a soft hangup */
4783 ast_channel_unlock(chan);
4784 return -1;
4785 }
4786
4787 CHECK_BLOCKING(chan);
4788 if (ast_channel_tech(chan)->write_text
4789 && (ast_strlen_zero(content_type) || ast_begins_with(content_type, "text/"))
4791 struct ast_frame f;
4792 /* T.140 payload does not include the null byte terminator */
4793 size_t body_len = strlen(body);
4794
4795 /* Process as T.140 text (moved here from ast_sendtext() */
4796 memset(&f, 0, sizeof(f));
4797 f.src = "DIALPLAN";
4798 f.subclass.format = ast_format_t140;
4799 f.frametype = AST_FRAME_TEXT;
4800 f.datalen = body_len;
4801 f.mallocd = AST_MALLOCD_DATA;
4802 f.data.ptr = ast_strdup(body);
4803 if (f.data.ptr) {
4804 res = ast_channel_tech(chan)->write_text(chan, &f);
4805 } else {
4806 res = -1;
4807 }
4808 ast_frfree(&f);
4809 } else if ((ast_channel_tech(chan)->properties & AST_CHAN_TP_SEND_TEXT_DATA)
4810 && ast_channel_tech(chan)->send_text_data) {
4811 /* Send enhanced message to a channel driver that supports it */
4812 ast_debug(1, "Sending TEXT_DATA from '%s' to %s:%s %s\n",
4815 ast_channel_name(chan), body);
4816 res = ast_channel_tech(chan)->send_text_data(chan, msg);
4817 } else if (ast_channel_tech(chan)->send_text
4818 && (ast_strlen_zero(content_type) || ast_begins_with(content_type, "text/"))) {
4819 /* Send the body of an enhanced message to a channel driver that supports only a char str */
4820 ast_debug(1, "Sending TEXT to %s: %s\n", ast_channel_name(chan), body);
4821 res = ast_channel_tech(chan)->send_text(chan, body);
4822 } else {
4823 ast_debug(1, "Channel technology does not support sending content type '%s' on channel '%s'\n",
4824 S_OR(content_type, "text/plain"), ast_channel_name(chan));
4825 res = -1;
4826 }
4828 ast_channel_unlock(chan);
4829 return res;
4830}
static void send_text(unsigned char pos, unsigned char inverse, struct unistimsession *pte, const char *text)
#define CHECK_BLOCKING(c)
Set the blocking indication on the channel.
Definition channel.h:2932
@ AST_CHAN_TP_SEND_TEXT_DATA
Channels have this property if they implement send_text_data.
Definition channel.h:995
@ AST_MEDIA_TYPE_TEXT
Definition codec.h:35
struct ast_format * ast_format_t140
Built-in cached t140 format.
const char * ast_msg_data_get_attribute(struct ast_msg_data *msg, enum ast_msg_data_attribute_type attribute_type)
Get attribute from ast_msg_data.
@ AST_MSG_DATA_ATTR_TO
Definition message.h:455
@ AST_MSG_DATA_ATTR_FROM
Definition message.h:456
@ AST_MSG_DATA_ATTR_CONTENT_TYPE
Definition message.h:457
#define AST_MALLOCD_DATA
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
Checks whether a string begins with another.
Definition strings.h:97
int(*const send_text)(struct ast_channel *chan, const char *text)
Display or transmit text.
Definition channel.h:776
int(*const write_text)(struct ast_channel *chan, struct ast_frame *frame)
Write a text frame, in standard format.
Definition channel.h:809
int(*const send_text_data)(struct ast_channel *chan, struct ast_msg_data *data)
Display or transmit text with data.
Definition channel.h:864

References ast_begins_with(), AST_CHAN_TP_SEND_TEXT_DATA, ast_channel_flags(), ast_channel_lock, ast_channel_name(), ast_channel_nativeformats(), ast_channel_unlock, ast_check_hangup(), ast_clear_flag, ast_debug, AST_FLAG_BLOCKING, AST_FLAG_ZOMBIE, ast_format_cap_has_type(), ast_format_t140, AST_FRAME_TEXT, ast_frfree, AST_MALLOCD_DATA, AST_MEDIA_TYPE_TEXT, AST_MSG_DATA_ATTR_BODY, AST_MSG_DATA_ATTR_CONTENT_TYPE, AST_MSG_DATA_ATTR_FROM, AST_MSG_DATA_ATTR_TO, ast_msg_data_get_attribute(), ast_strdup, ast_strlen_zero(), ast_test_flag, CHECK_BLOCKING, ast_frame::data, ast_frame::datalen, ast_frame_subclass::format, ast_frame::frametype, ast_frame::mallocd, ast_frame::ptr, S_OR, send_text(), ast_channel_tech::send_text, ast_channel_tech::send_text_data, ast_frame::src, ast_frame::subclass, and ast_channel_tech::write_text.

Referenced by __ast_read(), ast_sendtext(), bridge_channel_handle_write(), and sendtext_exec().

◆ ast_set_callerid()

void ast_set_callerid ( struct ast_channel chan,
const char *  cid_num,
const char *  cid_name,
const char *  cid_ani 
)

Set caller ID number, name and ANI and generate AMI event.

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

Definition at line 7370 of file channel.c.

7371{
7372 ast_channel_lock(chan);
7373
7374 if (cid_num) {
7375 ast_channel_caller(chan)->id.number.valid = 1;
7376 ast_free(ast_channel_caller(chan)->id.number.str);
7377 ast_channel_caller(chan)->id.number.str = ast_strdup(cid_num);
7378 }
7379 if (cid_name) {
7380 ast_channel_caller(chan)->id.name.valid = 1;
7381 ast_free(ast_channel_caller(chan)->id.name.str);
7382 ast_channel_caller(chan)->id.name.str = ast_strdup(cid_name);
7383 }
7384 if (cid_ani) {
7386 ast_free(ast_channel_caller(chan)->ani.number.str);
7387 ast_channel_caller(chan)->ani.number.str = ast_strdup(cid_ani);
7388 }
7389
7391
7392 ast_channel_unlock(chan);
7393}

References ast_party_caller::ani, ast_channel_caller(), ast_channel_lock, ast_channel_publish_snapshot(), ast_channel_unlock, ast_free, ast_strdup, ast_party_caller::id, name, ast_party_id::name, ast_party_id::number, ast_party_name::str, ast_party_number::str, ast_party_name::valid, and ast_party_number::valid.

Referenced by __analog_ss_thread(), __ast_request_and_dial(), analog_ss_thread(), ari_channels_handle_originate_with_id(), disa_exec(), handle_setcallerid(), pbx_outgoing_attempt(), privacy_exec(), ring_entry(), and socket_process_helper().

◆ ast_set_hangupsource()

void ast_set_hangupsource ( struct ast_channel chan,
const char *  source,
int  force 
)

Set the source of the hangup in this channel and it's bridge.

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

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

Definition at line 2498 of file channel.c.

2499{
2501
2502 ast_channel_lock(chan);
2503 if (force || ast_strlen_zero(ast_channel_hangupsource(chan))) {
2504 ast_channel_hangupsource_set(chan, source);
2505 }
2506 ast_channel_unlock(chan);
2507
2508 if (bridge) {
2509 ast_channel_lock(bridge);
2510 if (force || ast_strlen_zero(ast_channel_hangupsource(bridge))) {
2511 ast_channel_hangupsource_set(bridge, source);
2512 }
2513 ast_channel_unlock(bridge);
2514 }
2515}
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:10636
const char * ast_channel_hangupsource(const struct ast_channel *chan)
#define ast_channel_cleanup(c)
Cleanup a channel reference.
Definition channel.h:3030

References ast_channel_bridge_peer(), ast_channel_cleanup, ast_channel_hangupsource(), ast_channel_lock, ast_channel_unlock, ast_strlen_zero(), and RAII_VAR.

Referenced by __dahdi_exception(), analog_exception(), call(), chan_pjsip_session_end(), func_channel_write_real(), handle_hangup(), pbx_builtin_hangup(), session_inv_on_media_update(), and set_hangup_source_and_cause().

◆ ast_set_party_id_all()

void ast_set_party_id_all ( struct ast_set_party_id update_id)

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

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

Definition at line 1737 of file channel.c.

1738{
1739 update_id->name = 1;
1740 update_id->number = 1;
1741 update_id->subaddress = 1;
1742}
unsigned char subaddress
Definition channel.h:369
unsigned char number
Definition channel.h:367
unsigned char name
Definition channel.h:365

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

Referenced by set_redirecting().

◆ ast_set_read_format()

int ast_set_read_format ( struct ast_channel chan,
struct ast_format format 
)

Sets read format on channel chan.

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

Definition at line 5785 of file channel.c.

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, 0, 0);
5798
5799 ao2_cleanup(cap);
5800 return res;
5801}
static int set_format(struct ast_channel *chan, struct ast_format_cap *cap_set, const int direction, int interleaved_stereo)
Definition channel.c:5616

References ao2_cleanup, ast_assert, ast_format_cap_alloc, ast_format_cap_append, AST_FORMAT_CAP_FLAG_DEFAULT, NULL, and set_format().

Referenced by __ast_play_and_record(), adsi_transmit_message_full(), alarmreceiver_exec(), ast_bridge_channel_restore_formats(), ast_channel_make_compatible_helper(), audiosocket_exec(), background_detect_exec(), build_conf(), channel_do_masquerade(), conf_run(), dictate_exec(), do_waiting(), eagi_exec(), fax_detect_framehook(), fax_gateway_framehook(), generic_fax_exec(), handle_recordfile(), handle_speechrecognize(), holding_bridge_join(), isAnsweringMachine(), jack_exec(), jingle_interpret_content(), jingle_read(), measurenoise(), meetme_menu_admin_extended(), old_milliwatt_exec(), ooh323_new(), ooh323_rtp_read(), ooh323_set_read_format(), ooh323_set_write_format(), record_exec(), set_caps(), set_read_to_slin(), socket_process_helper(), speech_background(), and unistim_rtp_read().

◆ ast_set_read_format_from_cap()

int ast_set_read_format_from_cap ( struct ast_channel chan,
struct ast_format_cap formats 
)

Sets read format on channel chan from capabilities Set read format for channel to whichever component of "format" is best.

Parameters
chanchannel to change
formatsnew formats to pick from for reading
Returns
Returns 0 on success, -1 on failure

Definition at line 5803 of file channel.c.

5804{
5805 return set_format(chan, cap, 0, 0);
5806}

References set_format().

◆ ast_set_read_format_path()

int ast_set_read_format_path ( struct ast_channel chan,
struct ast_format raw_format,
struct ast_format core_format 
)

Set specific read path on channel.

Since
13.4.0
Parameters
chanChannel to setup read path.
raw_formatFormat to expect from the channel driver.
core_formatWhat the core wants to read.
Precondition
chan is locked
Return values
0on success.
-1on error.

Definition at line 5511 of file channel.c.

5512{
5513 struct ast_trans_pvt *trans_old;
5514 struct ast_trans_pvt *trans_new;
5515
5518 /* Nothing to setup */
5519 return 0;
5520 }
5521
5522 ast_debug(1, "Channel %s setting read format path: %s -> %s\n",
5523 ast_channel_name(chan),
5524 ast_format_get_name(raw_format),
5525 ast_format_get_name(core_format));
5526
5527 /* Setup new translation path. */
5528 if (ast_format_cmp(raw_format, core_format) != AST_FORMAT_CMP_EQUAL) {
5529 trans_new = ast_translator_build_path(core_format, raw_format);
5530 if (!trans_new) {
5531 return -1;
5532 }
5533 } else {
5534 /* No translation needed. */
5535 trans_new = NULL;
5536 }
5537 trans_old = ast_channel_readtrans(chan);
5538 if (trans_old) {
5539 ast_translator_free_path(trans_old);
5540 }
5541 ast_channel_readtrans_set(chan, trans_new);
5542 ast_channel_set_rawreadformat(chan, raw_format);
5543 ast_channel_set_readformat(chan, core_format);
5544 return 0;
5545}
void ast_channel_readtrans_set(struct ast_channel *chan, struct ast_trans_pvt *value)
Default structure for translators, with the basic fields and buffers, all allocated as part of the sa...
Definition translate.h:213
struct ast_trans_pvt * ast_translator_build_path(struct ast_format *dest, struct ast_format *source)
Builds a translator path Build a path (possibly NULL) from source to dest.
Definition translate.c:543

References ast_channel_name(), ast_channel_rawreadformat(), ast_channel_readformat(), ast_channel_readtrans(), ast_channel_readtrans_set(), ast_channel_set_rawreadformat(), ast_channel_set_readformat(), ast_debug, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_get_name(), ast_translator_build_path(), ast_translator_free_path(), and NULL.

Referenced by __ast_read(), chan_pjsip_read_stream(), set_softmix_bridge_data(), and softmix_bridge_write_voice().

◆ ast_set_variables()

void ast_set_variables ( struct ast_channel chan,
struct ast_variable vars 
)

adds a list of channel variables to a channel

Parameters
chanthe channel
varsa linked list of variables
Warning
The channel must not be locked if there's a possibility that a dialplan function would be invoked.

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

Definition at line 8183 of file channel.c.

8184{
8185 struct ast_variable *cur;
8186
8187 for (cur = vars; cur; cur = cur->next) {
8188 pbx_builtin_setvar_helper(chan, cur->name, cur->value);
8189 }
8190}
struct ast_variable * next

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

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

◆ ast_set_write_format()

int ast_set_write_format ( struct ast_channel chan,
struct ast_format format 
)

Sets write format on channel chan.

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

Definition at line 5826 of file channel.c.

5827{
5829 int res;
5830
5831 ast_assert(format != NULL);
5832
5833 if (!cap) {
5834 return -1;
5835 }
5836 ast_format_cap_append(cap, format, 0);
5837
5838 res = set_format(chan, cap, 1, 0);
5839
5840 ao2_cleanup(cap);
5841 return res;
5842}

References ao2_cleanup, ast_assert, ast_format_cap_alloc, ast_format_cap_append, AST_FORMAT_CAP_FLAG_DEFAULT, NULL, and set_format().

Referenced by adsi_transmit_message_full(), alarmreceiver_exec(), ast_bridge_channel_restore_formats(), ast_channel_make_compatible_helper(), ast_channel_start_silence_generator(), ast_channel_stop_silence_generator(), ast_stopstream(), ast_write_stream(), audiosocket_exec(), broadcast_exec(), build_conf(), channel_do_masquerade(), chanspy_exec(), conf_run(), dahdiscan_exec(), extenspy_exec(), fax_gateway_framehook(), generic_fax_exec(), handle_participant_join(), jack_exec(), jingle_interpret_content(), jingle_read(), linear_alloc(), linear_release(), meetme_menu_admin_extended(), moh_alloc(), moh_files_release(), moh_files_write_format_change(), moh_release(), mp3_exec(), old_milliwatt_exec(), ooh323_new(), ooh323_rtp_read(), ooh323_set_write_format(), ooh323_write(), participant_reaction_announcer_join(), playtones_alloc(), playtones_release(), send_waveform_to_channel(), set_caps(), set_softmix_bridge_data(), socket_process_helper(), tonepair_alloc(), tonepair_release(), and unistim_rtp_read().

◆ ast_set_write_format_from_cap()

int ast_set_write_format_from_cap ( struct ast_channel chan,
struct ast_format_cap formats 
)

Sets write format on channel chan Set write format for channel to whichever component of "format" is best.

Parameters
chanchannel to change
formatsnew formats to pick from for writing
Returns
Returns 0 on success, -1 on failure

Definition at line 5844 of file channel.c.

5845{
5846 return set_format(chan, cap, 1, 0);
5847}

References set_format().

Referenced by openstream_internal().

◆ ast_set_write_format_interleaved_stereo()

int ast_set_write_format_interleaved_stereo ( struct ast_channel chan,
struct ast_format format 
)

Sets write format for a channel. All internal data will than be handled in an interleaved format. (needed by binaural opus)

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

Definition at line 5808 of file channel.c.

5809{
5811 int res;
5812
5813 ast_assert(format != NULL);
5814
5815 if (!cap) {
5816 return -1;
5817 }
5818 ast_format_cap_append(cap, format, 0);
5819
5820 res = set_format(chan, cap, 1, 1);
5821
5822 ao2_cleanup(cap);
5823 return res;
5824}

References ao2_cleanup, ast_assert, ast_format_cap_alloc, ast_format_cap_append, AST_FORMAT_CAP_FLAG_DEFAULT, NULL, and set_format().

Referenced by set_softmix_bridge_data(), and softmix_bridge_unsuspend().

◆ ast_set_write_format_path()

int ast_set_write_format_path ( struct ast_channel chan,
struct ast_format core_format,
struct ast_format raw_format 
)

Set specific write path on channel.

Since
13.13.0
Parameters
chanChannel to setup write path.
core_formatWhat the core wants to write.
raw_formatRaw write format.
Precondition
chan is locked
Return values
0on success.
-1on error.

Definition at line 5547 of file channel.c.

5548{
5549 struct ast_trans_pvt *trans_old;
5550 struct ast_trans_pvt *trans_new;
5551
5554 /* Nothing to setup */
5555 return 0;
5556 }
5557
5558 ast_debug(1, "Channel %s setting write format path: %s -> %s\n",
5559 ast_channel_name(chan),
5560 ast_format_get_name(core_format),
5561 ast_format_get_name(raw_format));
5562
5563 /* Setup new translation path. */
5564 if (ast_format_cmp(raw_format, core_format) != AST_FORMAT_CMP_EQUAL) {
5565 trans_new = ast_translator_build_path(raw_format, core_format);
5566 if (!trans_new) {
5567 return -1;
5568 }
5569 } else {
5570 /* No translation needed. */
5571 trans_new = NULL;
5572 }
5573 trans_old = ast_channel_writetrans(chan);
5574 if (trans_old) {
5575 ast_translator_free_path(trans_old);
5576 }
5577 ast_channel_writetrans_set(chan, trans_new);
5578 ast_channel_set_rawwriteformat(chan, raw_format);
5579 ast_channel_set_writeformat(chan, core_format);
5580 return 0;
5581}
void ast_channel_writetrans_set(struct ast_channel *chan, struct ast_trans_pvt *value)

References ast_channel_name(), ast_channel_rawwriteformat(), ast_channel_set_rawwriteformat(), ast_channel_set_writeformat(), ast_channel_writeformat(), ast_channel_writetrans(), ast_channel_writetrans_set(), ast_debug, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_get_name(), ast_translator_build_path(), ast_translator_free_path(), and NULL.

Referenced by chan_pjsip_read_stream().

◆ ast_setstate()

int ast_setstate ( struct ast_channel chan,
enum  ast_channel_state 
)

Change the state of a channel.

Precondition
chan is locked

Definition at line 7422 of file channel.c.

7423{
7424 int oldstate = ast_channel_state(chan);
7425 char name[AST_CHANNEL_NAME], *dashptr;
7426
7427 if (oldstate == state)
7428 return 0;
7429
7430 ast_copy_string(name, ast_channel_name(chan), sizeof(name));
7431 if ((dashptr = strrchr(name, '-'))) {
7432 *dashptr = '\0';
7433 }
7434
7436
7438
7439 /* We have to pass AST_DEVICE_UNKNOWN here because it is entirely possible that the channel driver
7440 * for this channel is using the callback method for device state. If we pass in an actual state here
7441 * we override what they are saying the state is and things go amuck. */
7443
7444 return 0;
7445}

References ast_channel_flags(), AST_CHANNEL_NAME, ast_channel_name(), ast_channel_publish_snapshot(), ast_channel_state_set(), ast_copy_string(), AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, ast_devstate_changed_literal(), AST_DEVSTATE_NOT_CACHABLE, AST_FLAG_DISABLE_DEVSTATE_CACHE, ast_test_flag, and name.

Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_read(), __dahdi_exception(), analog_answer(), analog_call(), analog_callwaiting_deluxe(), analog_exception(), analog_ss_thread(), ast_raw_answer_with_stream_topology(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), chan_pjsip_answer(), chan_pjsip_incoming_response(), console_answer(), dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_indicate(), dahdi_read(), handle_response_ciev(), iax2_call(), indicate_busy(), indicate_congestion(), jingle_action_session_info(), jingle_action_session_initiate(), jingle_call(), mbl_hangup(), my_set_waitingfordt(), onAlerting(), onProgress(), ooh323_answer(), ooh323_new(), refer_incoming_invite_request(), unistim_answer(), unistim_call(), unistim_new(), unistim_ss(), and unreal_queue_frame().

◆ ast_settimeout()

int ast_settimeout ( struct ast_channel c,
unsigned int  rate,
int(*)(const void *data)  func,
void *  data 
)

Enable or disable timer ticks for a channel.

Parameters
cchannel
ratenumber of timer ticks per second
funccallback function
data

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

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

Definition at line 3184 of file channel.c.

3185{
3186 return ast_settimeout_full(c, rate, func, data, 0);
3187}
int ast_settimeout_full(struct ast_channel *c, unsigned int rate, int(*func)(const void *data), void *data, unsigned int is_ao2_obj)
Definition channel.c:3189

References ast_settimeout_full(), c, and ast_channel::data.

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

◆ ast_settimeout_full()

int ast_settimeout_full ( struct ast_channel c,
unsigned int  rate,
int(*)(const void *data)  func,
void *  data,
unsigned int  is_ao2_obj 
)

Definition at line 3189 of file channel.c.

3190{
3191 int res;
3192 unsigned int real_rate = rate, max_rate;
3194
3196
3197 if (ast_channel_timingfd(c) == -1) {
3199 return -1;
3200 }
3201
3202 if (!func) {
3203 rate = 0;
3204 data = NULL;
3205 }
3206
3207 if (rate && rate > (max_rate = ast_timer_get_max_rate(timer))) {
3208 real_rate = max_rate;
3209 }
3210
3211 ast_debug(3, "Scheduling timer at (%u requested / %u actual) timer ticks per second\n", rate, real_rate);
3212
3213 res = ast_timer_set_rate(timer, real_rate);
3214
3217 }
3218
3221
3222 if (data && is_ao2_obj) {
3223 ao2_ref(data, 1);
3225 } else {
3227 }
3228
3229 if (func == NULL && rate == 0 && ast_channel_fdno(c) == AST_TIMING_FD) {
3230 /* Clearing the timing func and setting the rate to 0
3231 * means that we don't want to be reading from the timingfd
3232 * any more. Setting c->fdno to -1 means we won't have any
3233 * errant reads from the timingfd, meaning we won't potentially
3234 * miss any important frames.
3235 */
3237 }
3238
3240
3241 return res;
3242}
void ast_channel_timingdata_set(struct ast_channel *chan, void *value)
void ast_channel_timingfunc_set(struct ast_channel *chan, ast_timing_func_t value)
void * data
Definition timing.c:55
unsigned int ast_timer_get_max_rate(const struct ast_timer *handle)
Get maximum rate supported for a timer.
Definition timing.c:191

References ao2_ref, ast_channel_fdno(), ast_channel_fdno_set(), ast_channel_flags(), ast_channel_lock, ast_channel_timer(), ast_channel_timingdata(), ast_channel_timingdata_set(), ast_channel_timingfd(), ast_channel_timingfunc_set(), ast_channel_unlock, ast_clear_flag, ast_debug, AST_FLAG_TIMINGDATA_IS_AO2_OBJ, ast_set_flag, ast_test_flag, ast_timer_get_max_rate(), ast_timer_set_rate(), AST_TIMING_FD, c, ast_timer::data, NULL, and timer.

Referenced by ast_readaudio_callback(), and ast_settimeout().

◆ ast_softhangup()

int ast_softhangup ( struct ast_channel chan,
int  cause 
)

Softly hangup a channel, lock.

Softly hangup up a channel.

Definition at line 2462 of file channel.c.

2463{
2464 RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
2465 int res;
2466 int tech_cause = 0;
2467
2468 ast_channel_lock(chan);
2469
2470 res = ast_softhangup_nolock(chan, cause);
2471 blob = ast_json_pack("{s: i, s: b}",
2472 "cause", cause,
2473 "soft", 1);
2474
2475 tech_cause = ast_channel_tech_hangupcause(chan);
2476 if (tech_cause) {
2477 ast_json_object_set(blob, "tech_cause", ast_json_integer_create(tech_cause));
2478 }
2479
2481 ast_channel_unlock(chan);
2482
2483 return res;
2484}

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

Referenced by __analog_handle_event(), __ast_module_user_hangup_all(), __ast_pbx_run(), __unload_module(), after_bridge_move_channel(), after_bridge_move_channel_fail(), agent_logoff_request(), agents_sweep(), analog_attempt_transfer(), ast_ari_channels_hangup(), ast_bridge_transfer_attended(), ast_channel_softhangup_cb(), ast_dial_join(), attempt_transfer(), blond_nonfinal_exit(), bridge_channel_attended_transfer(), cc_generic_agent_stop_ringing(), channel_hangup_matches(), conf_free(), dahdi_handle_event(), handle_hangup(), handle_softhangup(), hangup_channel(), retransfer_exit(), rtp_check_timeout(), sla_handle_hold_event(), softhangup_exec(), stasis_app_bridge_moh_stop(), and unload_module().

◆ ast_softhangup_all()

void ast_softhangup_all ( void  )

Soft hangup all active channels.

Since
13.3.0

Definition at line 494 of file channel.c.

495{
497}
struct ast_channel * ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg, void *data, int ao2_flags)
Call a function with every active channel.
Definition channel.c:1336
static int ast_channel_softhangup_cb(void *obj, void *arg, void *data, int flags)
Definition channel.c:485

References ast_channel_callback(), ast_channel_softhangup_cb(), and NULL.

Referenced by can_safely_quit().

◆ ast_softhangup_nolock()

int ast_softhangup_nolock ( struct ast_channel chan,
int  cause 
)

Softly hangup a channel, don't lock.

Softly hangup up a channel (no channel lock)

Definition at line 2449 of file channel.c.

2450{
2451 ast_debug(1, "Soft-Hanging (%#04x) up channel '%s'\n", (unsigned)cause, ast_channel_name(chan));
2452 /* Inform channel driver that we need to be hung up, if it cares */
2455 /* Interrupt any poll call or such */
2457 pthread_kill(ast_channel_blocker(chan), SIGURG);
2458 return 0;
2459}

References ast_channel_blocker(), ast_channel_flags(), ast_channel_name(), ast_channel_softhangup_internal_flag_add(), ast_debug, AST_FLAG_BLOCKING, ast_null_frame, ast_queue_frame(), and ast_test_flag.

Referenced by __analog_handle_event(), app_control_dial(), ast_async_goto(), ast_bridge_join(), ast_channel_softhangup_withcause_locked(), ast_pbx_h_exten_run(), ast_pbx_hangup_handler_run(), ast_softhangup(), attempt_transfer(), dahdi_softhangup_all(), do_monitor(), gosub_run(), internal_bridge_after_cb(), jingle_indicate(), and pbx_builtin_hangup().

◆ ast_state2str()

const char * ast_state2str ( enum ast_channel_state  state)

Gives the string form of a given channel state.

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

Definition at line 637 of file channel.c.

638{
639 char *buf;
640
641 switch (state) {
642 case AST_STATE_DOWN:
643 return "Down";
645 return "Rsrvd";
647 return "OffHook";
649 return "Dialing";
650 case AST_STATE_RING:
651 return "Ring";
653 return "Ringing";
654 case AST_STATE_UP:
655 return "Up";
656 case AST_STATE_BUSY:
657 return "Busy";
659 return "Dialing Offhook";
661 return "Pre-ring";
662 case AST_STATE_MUTE:
663 return "Mute";
664 default:
665 if (!(buf = ast_threadstorage_get(&state2str_threadbuf, STATE2STR_BUFSIZE)))
666 return "Unknown";
667 snprintf(buf, STATE2STR_BUFSIZE, "Unknown (%u)", state);
668 return buf;
669 }
670}
#define STATE2STR_BUFSIZE
Definition channel.c:102
@ AST_STATE_MUTE
@ AST_STATE_DIALING_OFFHOOK
@ AST_STATE_PRERING
@ AST_STATE_OFFHOOK
@ AST_STATE_BUSY
@ AST_STATE_DIALING
@ AST_STATE_RESERVED
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.

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

Referenced by ast_channel_snapshot_to_json(), ast_manager_build_channel_state_string_prefix(), ast_raw_answer_with_stream_topology(), cli_channel_print_body(), func_channel_read(), handle_chanlist(), handle_showchan(), and serialize_showchan().

◆ ast_str2cause()

int ast_str2cause ( const char *  name)

Convert a symbolic hangup cause to number.

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

Definition at line 626 of file channel.c.

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

References ARRAY_LEN, causes, and name.

Referenced by dial_exec_full(), and pbx_builtin_hangup().

◆ AST_THREADSTORAGE_CUSTOM_SCOPE()

AST_THREADSTORAGE_CUSTOM_SCOPE ( state2str_threadbuf  ,
NULL  ,
ast_free_ptr  ,
static   
)

◆ AST_THREADSTORAGE_RAW()

AST_THREADSTORAGE_RAW ( in_intercept_routine  )

Storage to determine if the current thread is running an intercept dialplan routine.

◆ ast_tonepair()

int ast_tonepair ( struct ast_channel chan,
int  freq1,
int  freq2,
int  duration,
int  vol 
)

Play a tone pair for a given amount of time

Definition at line 7636 of file channel.c.

7637{
7638 int res;
7639
7640 if ((res = ast_tonepair_start(chan, freq1, freq2, duration, vol)))
7641 return res;
7642
7643 /* Give us some wiggle room */
7644 while (ast_channel_generatordata(chan) && ast_waitfor(chan, 100) >= 0) {
7645 struct ast_frame *f = ast_read(chan);
7646 if (f)
7647 ast_frfree(f);
7648 else
7649 return -1;
7650 }
7651 return 0;
7652}
int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
Definition channel.c:7618

References ast_channel_generatordata(), ast_frfree, ast_read(), ast_tonepair_start(), ast_waitfor(), tonepair_def::duration, tonepair_def::freq1, tonepair_def::freq2, and tonepair_def::vol.

Referenced by zapateller_exec().

◆ ast_tonepair_start()

int ast_tonepair_start ( struct ast_channel chan,
int  freq1,
int  freq2,
int  duration,
int  vol 
)

Start a tone going

Definition at line 7618 of file channel.c.

7619{
7620 struct tonepair_def d = { 0, };
7621
7622 d.freq1 = freq1;
7623 d.freq2 = freq2;
7624 d.duration = duration;
7625 d.vol = (vol < 1) ? 8192 : vol; /* force invalid to 8192 */
7626 if (ast_activate_generator(chan, &tonepair, &d))
7627 return -1;
7628 return 0;
7629}
static struct ast_generator tonepair
Definition channel.c:7612

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

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

◆ ast_tonepair_stop()

void ast_tonepair_stop ( struct ast_channel chan)

Stop a tone from playing

Definition at line 7631 of file channel.c.

7632{
7634}

References ast_deactivate_generator().

Referenced by sendnoise().

◆ ast_transfer()

int ast_transfer ( struct ast_channel chan,
char *  dest 
)

Transfer a call to dest, if the channel supports transfer.

Transfer a channel (if supported).

Called by:

  • app_transfer
  • the manager interface

Definition at line 6504 of file channel.c.

6505{
6506 int protocol;
6507 return ast_transfer_protocol(chan, dest, &protocol);
6508}
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:6517

References ast_transfer_protocol().

Referenced by app_control_redirect().

◆ ast_transfer_protocol()

int ast_transfer_protocol ( struct ast_channel chan,
char *  dest,
int *  protocol 
)

Transfer a call to dest, if the channel supports transfer.

Transfer a channel (if supported) receieve protocol result.

Called by:

  • app_transfer
  • the manager interface

Definition at line 6517 of file channel.c.

6518{
6519 int res = -1;
6520
6521 if (protocol) {
6522 *protocol = 0;
6523 }
6524
6525 /* Stop if we're a zombie or need a soft hangup */
6526 ast_channel_lock(chan);
6528 if (ast_channel_tech(chan)->transfer) {
6529 res = ast_channel_tech(chan)->transfer(chan, dest);
6530 if (!res)
6531 res = 1;
6532 } else
6533 res = 0;
6534 }
6535 ast_channel_unlock(chan);
6536
6537 if (res <= 0) {
6538 return res;
6539 }
6540
6541 for (;;) {
6542 struct ast_frame *fr;
6543
6544 res = ast_waitfor(chan, -1);
6545
6546 if (res < 0 || !(fr = ast_read(chan))) {
6547 res = -1;
6548 break;
6549 }
6550
6553
6554 if (*message == AST_TRANSFER_SUCCESS) {
6555 res = 1;
6556 } else {
6557 res = -1;
6558 /* Message can contain a protocol specific code
6559 AST_TRANSFER_SUCCESS indicates success
6560 Else, failure. Protocol will be set to the failure reason.
6561 SIP example, 0 is success, else error code 3xx-6xx */
6562 if (protocol) {
6563 *protocol = *message;
6564 }
6565 }
6566
6567 ast_frfree(fr);
6568 break;
6569 }
6570
6571 ast_frfree(fr);
6572 }
6573
6574 return res;
6575}
static int transfer(void *data)
@ AST_TRANSFER_SUCCESS
@ AST_CONTROL_TRANSFER
int(*const transfer)(struct ast_channel *chan, const char *newdest)
Blind transfer other side (see app_transfer.c and ast_transfer()
Definition channel.h:803

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

Referenced by ast_transfer(), and transfer_exec().

◆ ast_transfercapability2str()

char * ast_transfercapability2str ( int  transfercapability) const

Gives the string form of a given transfer capability.

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

Definition at line 673 of file channel.c.

674{
675 switch (transfercapability) {
677 return "SPEECH";
679 return "DIGITAL";
681 return "RESTRICTED_DIGITAL";
683 return "3K1AUDIO";
685 return "DIGITAL_W_TONES";
687 return "VIDEO";
688 default:
689 return "UNKNOWN";
690 }
691}
#define AST_TRANS_CAP_RESTRICTED_DIGITAL
Definition transcap.h:37
#define AST_TRANS_CAP_DIGITAL
Definition transcap.h:36
#define AST_TRANS_CAP_DIGITAL_W_TONES
Definition transcap.h:40
#define AST_TRANS_CAP_SPEECH
Definition transcap.h:35
#define AST_TRANS_CAP_3_1K_AUDIO
Definition transcap.h:38
#define AST_TRANS_CAP_VIDEO
Definition transcap.h:41

References AST_TRANS_CAP_3_1K_AUDIO, AST_TRANS_CAP_DIGITAL, AST_TRANS_CAP_DIGITAL_W_TONES, AST_TRANS_CAP_RESTRICTED_DIGITAL, AST_TRANS_CAP_SPEECH, and AST_TRANS_CAP_VIDEO.

◆ ast_undestroyed_channels()

int ast_undestroyed_channels ( void  )
Returns
the number of channels not yet destroyed

Definition at line 505 of file channel.c.

506{
508}

References ast_atomic_fetchadd_int(), and chancount.

Referenced by wait_for_channels_to_die().

◆ ast_uninstall_music_functions()

void ast_uninstall_music_functions ( void  )

Definition at line 7795 of file channel.c.

7796{
7800}

References ast_moh_cleanup_ptr, ast_moh_start_ptr, ast_moh_stop_ptr, and NULL.

Referenced by unload_module().

◆ ast_unref_namedgroups()

struct ast_namedgroups * ast_unref_namedgroups ( struct ast_namedgroups *  groups)

◆ ast_waitfor()

int ast_waitfor ( struct ast_channel chan,
int  ms 
)

Wait for input on a channel.

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

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

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

Definition at line 3166 of file channel.c.

3167{
3168 if (ms < 0) {
3169 do {
3170 ms = 100000;
3171 ast_waitfor_nandfds(&c, 1, NULL, 0, NULL, NULL, &ms);
3172 } while (!ms);
3173 } else {
3174 ast_waitfor_nandfds(&c, 1, NULL, 0, NULL, NULL, &ms);
3175 }
3176 return ms;
3177}
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:2992

References ast_waitfor_nandfds(), c, and NULL.

Referenced by __adsi_transmit_messages(), __analog_ss_thread(), __ast_answer(), __ast_play_and_record(), __ast_request_and_dial(), adsi_careful_send(), analog_ss_thread(), ast_control_tone(), ast_recvtext(), ast_tonepair(), ast_transfer_protocol(), background_detect_exec(), channel_spy(), conf_flush(), dial_trunk(), dictate_exec(), disa_exec(), disable_t38(), do_broadcast(), do_waiting(), echo_exec(), handle_recordfile(), handle_speechrecognize(), isAnsweringMachine(), jack_exec(), launch_asyncagi(), measurenoise(), moh_channel_thread(), mp3_exec(), read_mf_digits(), read_sf_digits(), receive_dtmf_digits(), receivefax_t38_init(), record_exec(), recordthread(), safe_sleep_conditional(), scan_exec(), send_waveform_to_channel(), sendfax_t38_init(), speech_background(), stasis_app_exec(), stream_echo_perform(), wait_exec(), wait_for_hangup(), waitforring_exec(), and waitstream_core().

◆ ast_waitfor_n()

struct ast_channel * ast_waitfor_n ( struct ast_channel **  chan,
int  n,
int *  ms 
)

Waits for input on a group of channels Wait for input on an array of channels for a given # of milliseconds.

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

Definition at line 3161 of file channel.c.

3162{
3163 return ast_waitfor_nandfds(c, n, NULL, 0, NULL, NULL, ms);
3164}

References ast_waitfor_nandfds(), c, and NULL.

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

◆ ast_waitfor_n_fd()

int ast_waitfor_n_fd ( int *  fds,
int  n,
int *  ms,
int *  exception 
)

Wait for x amount of time on a file descriptor to have input.

Waits for input on an fd.

Definition at line 2984 of file channel.c.

2985{
2986 int winner = -1;
2987 ast_waitfor_nandfds(NULL, 0, fds, n, exception, &winner, ms);
2988 return winner;
2989}

References ast_waitfor_nandfds(), and NULL.

Referenced by dundi_lookup_internal(), dundi_precache_internal(), rfcomm_wait(), and softmix_mixing_loop().

◆ ast_waitfor_nandfds()

struct ast_channel * ast_waitfor_nandfds ( struct ast_channel **  c,
int  n,
int *  fds,
int  nfds,
int *  exception,
int *  outfd,
int *  ms 
)

Wait for x amount of time on a file descriptor to have input.

Waits for activity on a group of channels.

Definition at line 2992 of file channel.c.

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

References ast_add_fd(), ast_alloca, ast_channel_fd(), ast_channel_fd_count(), ast_channel_fdno_set(), ast_channel_flags(), ast_channel_lock, ast_channel_name(), ast_channel_softhangup_internal_flag_add(), ast_channel_unlock, ast_channel_whentohangup(), ast_clear_flag, AST_FLAG_BLOCKING, AST_FLAG_EXCEPTION, ast_poll, ast_set_flag, AST_SOFTHANGUP_TIMEOUT, ast_test_suite_event_notify, ast_tvcmp(), ast_tvdiff_ms(), ast_tvnow(), ast_tvsub(), ast_tvzero(), c, CHECK_BLOCKING, errno, max, and NULL.

Referenced by ast_waitfor(), ast_waitfor_n(), ast_waitfor_n_fd(), ast_waitfordigit_full(), audiosocket_run(), bridge_channel_wait(), conf_run(), eivr_comm(), generic_fax_exec(), run_agi(), wait_for_signal_or_hangup(), and waitstream_core().

◆ ast_waitfordigit()

int ast_waitfordigit ( struct ast_channel c,
int  ms 
)

◆ ast_waitfordigit_full()

int ast_waitfordigit_full ( struct ast_channel c,
int  ms,
const char *  breakon,
int  audiofd,
int  ctrlfd 
)

Wait for a digit Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to monitor for reading.

Parameters
cchannel to wait for a digit on
mshow many milliseconds to wait (<0 for indefinite).
breakonstring of DTMF digits to break upon or NULL for any.
audiofdaudio file descriptor to write to if audio frames are received
ctrlfdcontrol file descriptor to monitor for reading
Returns
Returns 1 if ctrlfd becomes available

Definition at line 3244 of file channel.c.

3245{
3246 struct timeval start = ast_tvnow();
3247 int ms;
3248
3249 /* Stop if we're a zombie or need a soft hangup */
3251 return -1;
3252
3253 /* Only look for the end of DTMF, don't bother with the beginning and don't emulate things */
3255
3256 /* Wait for a digit, no more than timeout_ms milliseconds total.
3257 * Or, wait indefinitely if timeout_ms is <0.
3258 */
3259 while ((ms = ast_remaining_ms(start, timeout_ms))) {
3260 struct ast_channel *rchan;
3261 int outfd = -1;
3262
3263 errno = 0;
3264 /* While ast_waitfor_nandfds tries to help by reducing the timeout by how much was waited,
3265 * it is unhelpful if it waited less than a millisecond.
3266 */
3267 rchan = ast_waitfor_nandfds(&c, 1, &cmdfd, (cmdfd > -1) ? 1 : 0, NULL, &outfd, &ms);
3268
3269 if (!rchan && outfd < 0 && ms) {
3270 if (errno == 0 || errno == EINTR)
3271 continue;
3272 ast_log(LOG_WARNING, "Wait failed (%s)\n", strerror(errno));
3274 return -1;
3275 } else if (outfd > -1) {
3276 /* The FD we were watching has something waiting */
3277 ast_log(LOG_WARNING, "The FD we were waiting for has something waiting. Waitfordigit returning numeric 1\n");
3279 return 1;
3280 } else if (rchan) {
3281 int res;
3282 struct ast_frame *f = ast_read(c);
3283
3284 if (!f) {
3286
3287 return -1;
3288 }
3289
3290 switch (f->frametype) {
3292 break;
3293 case AST_FRAME_DTMF_END:
3294 res = f->subclass.integer;
3295 if (!breakon || strchr(breakon, res)) {
3296 ast_frfree(f);
3298 return res;
3299 }
3300 break;
3301 case AST_FRAME_CONTROL:
3302 switch (f->subclass.integer) {
3303 case AST_CONTROL_HANGUP:
3304 ast_frfree(f);
3306 return -1;
3312 /* Fall-through and treat as if it were a DTMF signal. Items
3313 * that perform stream control will handle this. */
3314 res = f->subclass.integer;
3315 ast_frfree(f);
3317 return res;
3321 case AST_CONTROL_ANSWER:
3327 case AST_CONTROL_HOLD:
3328 case AST_CONTROL_UNHOLD:
3329 case AST_CONTROL_FLASH:
3330 case -1:
3331 /* Unimportant */
3332 break;
3333 default:
3334 ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", f->subclass.integer);
3335 break;
3336 }
3337 break;
3338 case AST_FRAME_VOICE:
3339 /* Write audio if appropriate */
3340 if (audiofd > -1) {
3341 if (write(audiofd, f->data.ptr, f->datalen) < 0) {
3342 ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
3343 }
3344 }
3345 default:
3346 /* Ignore */
3347 break;
3348 }
3349 ast_frfree(f);
3350 }
3351 }
3352
3354
3355 return 0; /* Time is up */
3356}
@ AST_CONTROL_STREAM_RESTART
@ AST_CONTROL_STREAM_SUSPEND
@ AST_CONTROL_STREAM_REVERSE
@ AST_CONTROL_STREAM_STOP
@ AST_CONTROL_STREAM_FORWARD
@ AST_CONTROL_UPDATE_RTP_PEER

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

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

◆ ast_write()

int ast_write ( struct ast_channel chan,
struct ast_frame frame 
)

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

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

Definition at line 5167 of file channel.c.

5168{
5169 return ast_write_stream(chan, -1, fr);
5170}
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:5172

References ast_write_stream().

Referenced by adsi_careful_send(), ast_prod(), ast_readaudio_callback(), ast_readvideo_callback(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), ast_write_video(), audiosocket_run(), conf_queue_dtmf(), conf_run(), dictate_exec(), echo_exec(), fax_gateway_detect_v21(), gen_generate(), generic_fax_exec(), handle_jack_audio(), jb_get_and_deliver(), linear_generator(), manager_send_flash(), milliwatt_generate(), moh_files_generator(), moh_generate(), mp3_exec(), playtones_generator(), send_waveform_to_channel(), silence_generator_generate(), sms_generate(), spandsp_fax_gw_t30_gen(), spy_generate(), spy_generate(), t38_tx_packet_handler(), tonepair_generator(), and wait_for_answer().

◆ ast_write_stream()

int ast_write_stream ( struct ast_channel chan,
int  stream_num,
struct ast_frame frame 
)

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

Parameters
chandestination channel of the frame
stream_numdestination stream on the channel
frameframe that will be written
Returns
It returns 0 on success, -1 on failure.
Note
If -1 is provided as the stream number and a media frame is provided the function will write to the default stream of the type of media.

Definition at line 5172 of file channel.c.

5173{
5174 struct ast_stream *stream = NULL, *default_stream = NULL;
5175 int res = -1;
5176 struct ast_frame *f = NULL;
5177 int count = 0;
5178 int hooked = 0;
5179
5180 /*Deadlock avoidance*/
5181 while(ast_channel_trylock(chan)) {
5182 /*cannot goto done since the channel is not locked*/
5183 if(count++ > 10) {
5184 ast_debug(1, "Deadlock avoided for write to channel '%s'\n", ast_channel_name(chan));
5185 return 0;
5186 }
5187 usleep(1);
5188 }
5189
5190 /* Stop if we're a zombie or need a soft hangup */
5192 goto done;
5193 }
5194
5195 if (stream_num >= 0) {
5196 /* If we were told to write to an explicit stream then allow this frame through, no matter
5197 * if the type is expected or not (a framehook could change)
5198 */
5200 goto done;
5201 }
5203 default_stream = ast_channel_get_default_stream(chan, ast_stream_get_type(stream));
5204 } else if (fr->frametype == AST_FRAME_VOICE || fr->frametype == AST_FRAME_VIDEO || fr->frametype == AST_FRAME_MODEM) {
5205 /* If we haven't been told of a stream then we need to figure out which once we need */
5207
5208 /* Some frame types have a fixed media type */
5209 if (fr->frametype == AST_FRAME_VOICE || fr->frametype == AST_FRAME_VIDEO) {
5211 } else if (fr->frametype == AST_FRAME_MODEM) {
5213 }
5214
5215 /* No stream was specified, so use the default one */
5216 stream = default_stream = ast_channel_get_default_stream(chan, type);
5217 }
5218
5219 /* Perform the framehook write event here. After the frame enters the framehook list
5220 * there is no telling what will happen, how awesome is that!!! */
5221 if ((stream == default_stream) && !(fr = ast_framehook_list_write_event(ast_channel_framehooks(chan), fr))) {
5222 res = 0;
5223 goto done;
5224 }
5225
5226 if (ast_channel_generatordata(chan) && (fr->frametype != AST_FRAME_RTCP) && (!fr->src || strcasecmp(fr->src, "ast_prod"))) {
5229 } else {
5230 if (fr->frametype == AST_FRAME_DTMF_END) {
5231 /* There is a generator running while we're in the middle of a digit.
5232 * It's probably inband DTMF, so go ahead and pass it so it can
5233 * stop the generator */
5234 ast_channel_unlock(chan);
5235 res = ast_senddigit_end(chan, fr->subclass.integer, fr->len);
5236 ast_channel_lock(chan);
5237 } else if (fr->frametype == AST_FRAME_CONTROL
5239 /*
5240 * This is a side case where Echo is basically being called
5241 * and the person put themselves on hold and took themselves
5242 * off hold.
5243 */
5245 fr->datalen);
5246 }
5247 res = 0; /* XXX explain, why 0 ? */
5248 goto done;
5249 }
5250 }
5251 /* High bit prints debugging */
5252 if (ast_channel_fout(chan) & DEBUGCHAN_FLAG)
5253 ast_frame_dump(ast_channel_name(chan), fr, ">>");
5254 switch (fr->frametype) {
5255 case AST_FRAME_CONTROL:
5257 res = 0;
5258 break;
5260 if (ast_channel_audiohooks(chan)) {
5261 struct ast_frame *old_frame = fr;
5263 if (old_frame != fr)
5264 f = fr;
5265 }
5267 ast_channel_unlock(chan);
5268 res = ast_senddigit_begin(chan, fr->subclass.integer);
5269 ast_channel_lock(chan);
5270 break;
5271 case AST_FRAME_DTMF_END:
5272 if (ast_channel_audiohooks(chan)) {
5273 struct ast_frame *new_frame = fr;
5274
5276 if (new_frame != fr) {
5277 ast_frfree(new_frame);
5278 }
5279 }
5281 ast_channel_unlock(chan);
5282 res = ast_senddigit_end(chan, fr->subclass.integer, fr->len);
5283 ast_channel_lock(chan);
5284 break;
5285 case AST_FRAME_TEXT:
5286 CHECK_BLOCKING(chan);
5288 res = (ast_channel_tech(chan)->write_text == NULL) ? 0 :
5289 ast_channel_tech(chan)->write_text(chan, fr);
5290 } else {
5291 res = (ast_channel_tech(chan)->send_text == NULL) ? 0 :
5292 ast_channel_tech(chan)->send_text(chan, (char *) fr->data.ptr);
5293 }
5295 break;
5296 case AST_FRAME_HTML:
5297 CHECK_BLOCKING(chan);
5298 res = (ast_channel_tech(chan)->send_html == NULL) ? 0 :
5299 ast_channel_tech(chan)->send_html(chan, fr->subclass.integer, (char *) fr->data.ptr, fr->datalen);
5301 break;
5302 case AST_FRAME_VIDEO:
5303 /* XXX Handle translation of video codecs one day XXX */
5304 CHECK_BLOCKING(chan);
5305 if (ast_channel_tech(chan)->write_stream) {
5306 if (stream) {
5307 res = ast_channel_tech(chan)->write_stream(chan, ast_stream_get_position(stream), fr);
5308 } else {
5309 res = 0;
5310 }
5311 } else if ((stream == default_stream) && ast_channel_tech(chan)->write_video) {
5312 res = ast_channel_tech(chan)->write_video(chan, fr);
5313 } else {
5314 res = 0;
5315 }
5317 break;
5318 case AST_FRAME_MODEM:
5319 CHECK_BLOCKING(chan);
5320 res = tech_write(chan, stream, default_stream, fr);
5322 break;
5323 case AST_FRAME_VOICE:
5325 apply_plc(chan, fr);
5326 }
5327
5328 f = fr;
5329
5330 /*
5331 * Send frame to audiohooks if present, if frametype is linear (else, later as per
5332 * previous behavior)
5333 */
5334 if ((stream == default_stream) && ast_channel_audiohooks(chan)) {
5336 hooked = 1;
5338 }
5339 }
5340
5341 /* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */
5342 if ((stream == default_stream) && ast_format_cmp(fr->subclass.format, ast_channel_rawwriteformat(chan)) != AST_FORMAT_CMP_EQUAL) {
5344 struct ast_str *codec_buf = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
5345
5346 /*
5347 * We are not setup to write this frame. Things may have changed
5348 * on the peer side of the world and we try to adjust the format to
5349 * make it compatible again. However, bad things can happen if we
5350 * cannot setup a new translation path. Problems range from no
5351 * audio, one-way audio, to garbled audio. The best we can do is
5352 * request the call to hangup since we could not make it compatible.
5353 *
5354 * Being continuously spammed by this message likely indicates a
5355 * problem with the peer because it cannot make up its mind about
5356 * which format to use.
5357 */
5358 ast_debug(1, "Channel %s changing write format from %s to %s, native formats %s\n",
5359 ast_channel_name(chan),
5363 if (ast_set_write_format(chan, fr->subclass.format)) {
5364 /* Could not handle the new write format. Induce a hangup. */
5365 break;
5366 }
5367 }
5368
5369 if (ast_channel_writetrans(chan)) {
5370 struct ast_frame *trans_frame = ast_translate(ast_channel_writetrans(chan), f, 0);
5371 if (trans_frame != f && f != fr) {
5372 /*
5373 * If translate gives us a new frame and so did the audio
5374 * hook then we need to free the one from the audio hook.
5375 */
5376 ast_frfree(f);
5377 }
5378 f = trans_frame;
5379 }
5380 }
5381
5382 if (!f) {
5383 res = 0;
5384 break;
5385 }
5386
5387 if ((stream == default_stream) && ast_channel_audiohooks(chan) && !hooked) {
5388 struct ast_frame *prev = NULL, *new_frame, *cur, *dup;
5389 int freeoldlist = 0;
5390
5391 if (f != fr) {
5392 freeoldlist = 1;
5393 }
5394
5395 /* Since ast_audiohook_write may return a new frame, and the cur frame is
5396 * an item in a list of frames, create a new list adding each cur frame back to it
5397 * regardless if the cur frame changes or not. */
5398 for (cur = f; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
5400
5401 /* if this frame is different than cur, preserve the end of the list,
5402 * free the old frames, and set cur to be the new frame */
5403 if (new_frame != cur) {
5404
5405 /* doing an ast_frisolate here seems silly, but we are not guaranteed the new_frame
5406 * isn't part of local storage, meaning if ast_audiohook_write is called multiple
5407 * times it may override the previous frame we got from it unless we dup it */
5408 if ((dup = ast_frisolate(new_frame))) {
5410 if (freeoldlist) {
5412 ast_frfree(cur);
5413 }
5414 if (new_frame != dup) {
5415 ast_frfree(new_frame);
5416 }
5417 cur = dup;
5418 }
5419 }
5420
5421 /* now, regardless if cur is new or not, add it to the new list,
5422 * if the new list has not started, cur will become the first item. */
5423 if (prev) {
5424 AST_LIST_NEXT(prev, frame_list) = cur;
5425 } else {
5426 f = cur; /* set f to be the beginning of our new list */
5427 }
5428 prev = cur;
5429 }
5430 }
5431
5432 /* the translator on chan->writetrans may have returned multiple frames
5433 from the single frame we passed in; if so, feed each one of them to the
5434 channel, freeing each one after it has been written */
5435 CHECK_BLOCKING(chan);
5436 if ((f != fr) && AST_LIST_NEXT(f, frame_list)) {
5437 struct ast_frame *cur, *next = NULL;
5438 unsigned int skip = 0;
5439
5440 cur = f;
5441 while (cur) {
5444 if (!skip) {
5445 res = tech_write(chan, stream, default_stream, cur);
5446 if (res < 0) {
5448 skip = 1;
5449 } else if (next) {
5450 /* don't do this for the last frame in the list,
5451 as the code outside the loop will do it once
5452 */
5454 }
5455 }
5456 ast_frfree(cur);
5457 cur = next;
5458 }
5459
5460 /* reset f so the code below doesn't attempt to free it */
5461 f = NULL;
5462 } else {
5463 res = tech_write(chan, stream, default_stream, f);
5464 }
5466 break;
5467 case AST_FRAME_NULL:
5468 case AST_FRAME_IAX:
5469 /* Ignore these */
5470 res = 0;
5471 break;
5472 case AST_FRAME_RTCP:
5473 /* RTCP information is on a per-stream basis and only available on multistream capable channels */
5474 CHECK_BLOCKING(chan);
5475 if (ast_channel_tech(chan)->write_stream && stream) {
5476 res = ast_channel_tech(chan)->write_stream(chan, ast_stream_get_position(stream), fr);
5477 } else {
5478 res = 0;
5479 }
5481 break;
5482 default:
5483 /* At this point, fr is the incoming frame and f is NULL. Channels do
5484 * not expect to get NULL as a frame pointer and will segfault. Hence,
5485 * we output the original frame passed in. */
5486 CHECK_BLOCKING(chan);
5487 res = ast_channel_tech(chan)->write(chan, fr);
5489 break;
5490 }
5491
5492 if (f && f != fr)
5493 ast_frfree(f);
5494
5495 /* Consider a write failure to force a soft hangup */
5496 if (res < 0) {
5498 } else {
5500 }
5501done:
5503 /* The list gets recreated if audiohooks are added again later */
5506 }
5507 ast_channel_unlock(chan);
5508 return res;
5509}
@ AST_AUDIOHOOK_DIRECTION_WRITE
Definition audiohook.h:50
static int tech_write(struct ast_channel *chan, struct ast_stream *stream, struct ast_stream *default_stream, struct ast_frame *frame)
Definition channel.c:5155
static void apply_plc(struct ast_channel *chan, struct ast_frame *frame)
Definition channel.c:5129
#define ast_channel_trylock(chan)
Definition channel.h:2985
unsigned int ast_channel_fout(const struct ast_channel *chan)
@ AST_FLAG_WRITE_INT
Definition channel.h:1003
ast_media_type
Types of media.
Definition codec.h:30
@ AST_MEDIA_TYPE_UNKNOWN
Definition codec.h:31
@ AST_MEDIA_TYPE_IMAGE
Definition codec.h:34
#define AST_FORMAT_CAP_NAMES_LEN
Definition format_cap.h:324
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
static void write_stream(struct ogg_vorbis_desc *s, FILE *f)
Write out any pending encoded data.
INT32 integer
Definition lpc10.h:80
int ast_stream_topology_get_count(const struct ast_stream_topology *topology)
Get the number of streams in a topology.
Definition stream.c:768
enum ast_media_type ast_stream_get_type(const struct ast_stream *stream)
Get the media type of a stream.
Definition stream.c:316
#define ast_str_alloca(init_len)
Definition strings.h:848
int(*const write)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format (see frame.h)
Definition channel.h:770
int(*const write_stream)(struct ast_channel *chan, int stream_num, struct ast_frame *frame)
Write a frame on a specific stream, in standard format (see frame.h)
Definition channel.h:773
int(*const write_video)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format.
Definition channel.h:806
struct ast_frame * next
Support for dynamic strings.
Definition strings.h:623

References apply_plc(), ast_audiohook_detach_list(), AST_AUDIOHOOK_DIRECTION_WRITE, ast_audiohook_write_list(), ast_audiohook_write_list_empty(), ast_channel_audiohooks(), ast_channel_audiohooks_set(), ast_channel_flags(), ast_channel_fout(), ast_channel_fout_set(), ast_channel_framehooks(), ast_channel_generatordata(), ast_channel_get_default_stream(), ast_channel_get_stream_topology(), ast_channel_lock, ast_channel_name(), ast_channel_nativeformats(), ast_channel_rawwriteformat(), ast_channel_softhangup_internal_flag_add(), ast_channel_trylock, ast_channel_unlock, ast_channel_writeformat(), ast_channel_writetrans(), ast_check_hangup(), ast_clear_flag, AST_CONTROL_UNHOLD, ast_deactivate_generator(), ast_debug, AST_FLAG_BLOCKING, AST_FLAG_WRITE_INT, AST_FLAG_ZOMBIE, ast_format_cache_is_slinear(), ast_format_cap_get_names(), AST_FORMAT_CAP_NAMES_LEN, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_get_name(), ast_format_get_type(), ast_format_slin, ast_format_t140, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, ast_frame_dump(), AST_FRAME_HTML, AST_FRAME_IAX, AST_FRAME_MODEM, AST_FRAME_NULL, AST_FRAME_RTCP, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_framehook_list_write_event(), ast_frfree, ast_frisolate, AST_LIST_NEXT, AST_MEDIA_TYPE_IMAGE, AST_MEDIA_TYPE_UNKNOWN, ast_opt_generic_plc, ast_senddigit_begin(), ast_senddigit_end(), ast_set_write_format(), AST_SOFTHANGUP_DEV, ast_str_alloca, ast_stream_get_position(), ast_stream_get_type(), ast_stream_topology_get_count(), ast_stream_topology_get_stream(), ast_test_flag, ast_translate(), CHECK_BLOCKING, ast_frame::data, ast_frame::datalen, DEBUGCHAN_FLAG, done, DTMF_SENT, ast_frame_subclass::format, FRAMECOUNT_INC, ast_frame::frametype, indicate_data_internal(), ast_frame_subclass::integer, ast_frame::len, ast_frame::next, NULL, ast_frame::ptr, send_dtmf_begin_event(), send_dtmf_end_event(), ast_channel_tech::send_html, ast_channel_tech::send_text, ast_frame::src, ast_frame::stream_num, ast_frame::subclass, tech_write(), type, ast_channel_tech::write, write_stream(), ast_channel_tech::write_stream, ast_channel_tech::write_text, and ast_channel_tech::write_video.

Referenced by AST_TEST_DEFINE(), AST_TEST_DEFINE(), ast_write(), bridge_channel_handle_write(), and stream_echo_write().

◆ ast_write_video()

int ast_write_video ( struct ast_channel chan,
struct ast_frame frame 
)

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

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

Definition at line 5040 of file channel.c.

5041{
5042 int res;
5043 if (!ast_channel_tech(chan)->write_video)
5044 return 0;
5045 res = ast_write(chan, fr);
5046 if (!res)
5047 res = 1;
5048 return res;
5049}

References ast_write().

◆ calc_monitor_jump()

static int calc_monitor_jump ( int  samples,
int  sample_rate,
int  seek_rate 
)
inlinestatic

calculates the number of samples to jump forward with in a monitor stream.

Note
When using ast_seekstream() with the read and write streams of a monitor, the number of samples to seek forward must be of the same sample rate as the stream or else the jump will not be calculated correctly.
Return values
numberof samples to seek forward after rate conversion.

Definition at line 3528 of file channel.c.

3529{
3530 int diff = sample_rate - seek_rate;
3531
3532 if (diff > 0) {
3533 samples = samples / (float) (sample_rate / seek_rate);
3534 } else if (diff < 0) {
3535 samples = samples * (float) (seek_rate / sample_rate);
3536 }
3537
3538 return samples;
3539}

References ast_frame::samples.

◆ call_forward_inherit()

static void call_forward_inherit ( struct ast_channel new_chan,
struct ast_channel parent,
struct ast_channel orig 
)
static

Definition at line 5893 of file channel.c.

5894{
5896 struct ast_party_redirecting redirecting;
5897
5898 /*
5899 * The parent is not a ZOMBIE or hungup so update it with the
5900 * original channel's redirecting information.
5901 */
5902 ast_party_redirecting_init(&redirecting);
5906 if (ast_channel_redirecting_sub(orig, parent, &redirecting, 0)) {
5907 ast_channel_update_redirecting(parent, &redirecting, NULL);
5908 }
5909 ast_party_redirecting_free(&redirecting);
5910 }
5911
5912 /* Safely inherit variables and datastores from the parent channel. */
5913 ast_channel_lock_both(parent, new_chan);
5914 ast_channel_inherit_variables(parent, new_chan);
5915 ast_channel_datastore_inherit(parent, new_chan);
5917 ast_channel_unlock(new_chan);
5918 ast_channel_unlock(parent);
5919}
int ast_channel_redirecting_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *redirecting_info, int is_frame)
Run a redirecting interception subroutine and update a channel's redirecting information.
Definition channel.c:10451

References ast_channel_datastore_inherit(), ast_channel_flags(), ast_channel_inherit_variables(), ast_channel_lock, ast_channel_lock_both, ast_channel_redirecting(), ast_channel_redirecting_sub(), ast_channel_unlock, ast_channel_update_redirecting(), ast_check_hangup(), AST_FLAG_ZOMBIE, ast_max_forwards_decrement(), ast_party_redirecting_copy(), ast_party_redirecting_free(), ast_party_redirecting_init(), ast_test_flag, NULL, and ast_party_redirecting::orig.

Referenced by ast_call_forward().

◆ channel_cc_params_copy()

static void * channel_cc_params_copy ( void *  data)
static

Definition at line 10496 of file channel.c.

10497{
10498 const struct ast_cc_config_params *src = data;
10500 if (!dest) {
10501 return NULL;
10502 }
10503 ast_cc_copy_config_params(dest, src);
10504 return dest;
10505}

References ast_cc_config_params_init, ast_cc_copy_config_params(), and NULL.

◆ channel_cc_params_destroy()

static void channel_cc_params_destroy ( void *  data)
static

Definition at line 10507 of file channel.c.

10508{
10509 struct ast_cc_config_params *cc_params = data;
10511}

References ast_cc_config_params_destroy().

◆ channel_do_masquerade()

static void channel_do_masquerade ( struct ast_channel original,
struct ast_channel clonechan 
)
static

Masquerade a channel.

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

Definition at line 6881 of file channel.c.

6882{
6883 int x;
6884 int origstate;
6885 unsigned int orig_disablestatecache;
6886 unsigned int clone_disablestatecache;
6887 int visible_indication;
6888 int clone_hold_state;
6889 int moh_is_playing;
6890 struct ast_frame *current;
6891 const struct ast_channel_tech *t;
6892 void *t_pvt;
6893 union {
6895 struct ast_party_dialed dialed;
6896 struct ast_party_caller caller;
6898 struct ast_party_redirecting redirecting;
6899 } exchange;
6900 struct ast_channel *bridged;
6901 struct ast_format *rformat;
6902 struct ast_format *wformat;
6903 struct ast_format *tmp_format;
6904 struct ast_format_cap *tmp_cap;
6905 char tmp_name[AST_CHANNEL_NAME];
6906 char clone_sending_dtmf_digit;
6907 struct timeval clone_sending_dtmf_tv;
6908
6909 ast_debug(3, "Masquerading %s(%u) into the structure of %s(%u)\n",
6910 ast_channel_name(clonechan), ast_channel_state(clonechan),
6911 ast_channel_name(original), ast_channel_state(original));
6912 /* XXX This operation is a bit odd. We're essentially putting the guts of
6913 * the clone channel into the original channel. Start by killing off the
6914 * original channel's backend. While the features are nice, which is the
6915 * reason we're keeping it, it's still awesomely weird. XXX */
6916
6917 /* Indicate to each channel that a masquerade is about to begin. */
6918 x = 1;
6919 ast_indicate_data(original, AST_CONTROL_MASQUERADE_NOTIFY, &x, sizeof(x));
6920 ast_indicate_data(clonechan, AST_CONTROL_MASQUERADE_NOTIFY, &x, sizeof(x));
6921
6922 /*
6923 * The container lock is necessary for proper locking order
6924 * because the channels must be unlinked to change their
6925 * names.
6926 *
6927 * The original and clonechan locks must be held while the
6928 * channel contents are shuffled around for the masquerade.
6929 *
6930 * The masq and masqr pointers need to be left alone until the masquerade
6931 * has restabilized the channels to hold off ast_hangup() and until
6932 * AST_FLAG_ZOMBIE can be set on the clonechan.
6933 */
6935
6936 /* Bump the refs to ensure that they won't disappear on us. */
6937 ast_channel_ref(original);
6938 ast_channel_ref(clonechan);
6939
6940 /*
6941 * Since channel name and unique id will change, and both could be keys
6942 * in the channel storage backend, we need to remove them from the backend.
6943 * We'll add them back in after the changes are compete.
6944 */
6947
6949
6950 moh_is_playing = ast_test_flag(ast_channel_flags(original), AST_FLAG_MOH);
6951 if (moh_is_playing) {
6952 /* Stop MOH on the old original channel. */
6953 ast_moh_stop(original);
6954 }
6955
6956 /*
6957 * Stop any visible indication on the original channel so we can
6958 * transfer it to the clonechan taking the original's place.
6959 */
6960 ast_channel_lock(original);
6961 visible_indication = ast_channel_visible_indication(original);
6962 ast_channel_unlock(original);
6963 ast_indicate(original, -1);
6964
6965 /* Start the masquerade channel contents rearrangement. */
6966 ast_channel_lock_both(original, clonechan);
6967
6968 ast_debug(1, "Actually Masquerading %s(%u) into the structure of %s(%u)\n",
6969 ast_channel_name(clonechan), ast_channel_state(clonechan),
6970 ast_channel_name(original), ast_channel_state(original));
6971
6972 /* When all is said and done force new snapshot segments so they are
6973 * up to date.
6974 */
6977
6978 /*
6979 * Remember the original read/write formats. We turn off any
6980 * translation on either one
6981 */
6982 rformat = ao2_bump(ast_channel_readformat(original));
6983 wformat = ao2_bump(ast_channel_writeformat(original));
6984 free_translation(clonechan);
6985 free_translation(original);
6986
6987 clone_hold_state = ast_channel_hold_state(clonechan);
6988
6989 /* Save the current DTMF digit being sent if any. */
6990 clone_sending_dtmf_digit = ast_channel_sending_dtmf_digit(clonechan);
6991 clone_sending_dtmf_tv = ast_channel_sending_dtmf_tv(clonechan);
6992
6993 /* Swap uniqueid's of the channels. This needs to happen before channel renames,
6994 * so rename events get the proper id's.
6995 */
6997
6998 /* Make sure the Stasis topic on the channel is updated appropriately */
6999 ast_channel_internal_swap_topics(clonechan, original);
7000
7001 /* Swap endpoint forward so channel created with endpoint exchanges its state
7002 * with other channel for proper endpoint cleanup.
7003 */
7004 ast_channel_internal_swap_endpoint_forward(clonechan, original);
7005
7006 /* The old snapshots need to follow the channels so the snapshot update is correct */
7007 ast_channel_internal_swap_snapshots(clonechan, original);
7008
7009 /* Now we swap the endpoints if present */
7010 ast_channel_internal_swap_endpoints(clonechan, original);
7011
7012 /* Swap channel names. This uses ast_channel_name_set directly, so we
7013 * don't get any spurious rename events.
7014 */
7015 ast_copy_string(tmp_name, ast_channel_name(clonechan), sizeof(tmp_name));
7016 ast_channel_name_set(clonechan, ast_channel_name(original));
7017 ast_channel_name_set(original, tmp_name);
7018
7019 /* Swap the technologies */
7020 t = ast_channel_tech(original);
7021 ast_channel_tech_set(original, ast_channel_tech(clonechan));
7022 ast_channel_tech_set(clonechan, t);
7023
7024 t_pvt = ast_channel_tech_pvt(original);
7025 ast_channel_tech_pvt_set(original, ast_channel_tech_pvt(clonechan));
7026 ast_channel_tech_pvt_set(clonechan, t_pvt);
7027
7028 /* Swap the alertpipes */
7029 ast_channel_internal_alertpipe_swap(original, clonechan);
7030
7031 /*
7032 * Swap the readq's. The end result should be this:
7033 *
7034 * 1) All frames should be on the new (original) channel.
7035 * 2) Any frames that were already on the new channel before this
7036 * masquerade need to be at the end of the readq, after all of the
7037 * frames on the old (clone) channel.
7038 * 3) The alertpipe needs to get poked for every frame that was already
7039 * on the new channel, since we are now using the alert pipe from the
7040 * old (clone) channel.
7041 */
7042 {
7043 AST_LIST_HEAD_NOLOCK(, ast_frame) tmp_readq;
7044
7045 AST_LIST_HEAD_INIT_NOLOCK(&tmp_readq);
7046 AST_LIST_APPEND_LIST(&tmp_readq, ast_channel_readq(original), frame_list);
7048
7049 while ((current = AST_LIST_REMOVE_HEAD(&tmp_readq, frame_list))) {
7051 if (ast_channel_alert_write(original)) {
7052 ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
7053 }
7054 }
7055 }
7056
7057 /* Swap the raw formats */
7058 tmp_format = ao2_bump(ast_channel_rawreadformat(original));
7060 ast_channel_set_rawreadformat(clonechan, tmp_format);
7061 ao2_cleanup(tmp_format);
7062
7063 tmp_format = ao2_bump(ast_channel_rawwriteformat(original));
7065 ast_channel_set_rawwriteformat(clonechan, tmp_format);
7066 ao2_cleanup(tmp_format);
7067
7069
7070 /* And of course, so does our current state. Note we need not
7071 call ast_setstate since the event manager doesn't really consider
7072 these separate. We do this early so that the clone has the proper
7073 state of the original channel. */
7074 origstate = ast_channel_state(original);
7075 ast_channel_state_set(original, ast_channel_state(clonechan));
7076 ast_channel_state_set(clonechan, origstate);
7077
7078 /* And the swap the cachable state too. Otherwise we'd start caching
7079 * Local channels and ignoring real ones. */
7080 orig_disablestatecache = ast_test_flag(ast_channel_flags(original), AST_FLAG_DISABLE_DEVSTATE_CACHE);
7081 clone_disablestatecache = ast_test_flag(ast_channel_flags(clonechan), AST_FLAG_DISABLE_DEVSTATE_CACHE);
7082 if (orig_disablestatecache != clone_disablestatecache) {
7083 if (orig_disablestatecache) {
7086 } else {
7089 }
7090 }
7091
7092 /* Keep the same language. */
7093 ast_channel_language_set(original, ast_channel_language(clonechan));
7094
7095 /* Keep the same parkinglot. */
7096 ast_channel_parkinglot_set(original, ast_channel_parkinglot(clonechan));
7097
7098 /* Clear all existing file descriptors */
7100
7101 /* Copy all file descriptors present on clonechan to original */
7102 for (x = 0; x < ast_channel_fd_count(clonechan); x++) {
7103 ast_channel_set_fd(original, x, ast_channel_fd(clonechan, x));
7104 }
7105
7106 ast_app_group_update(clonechan, original);
7107
7108 /* Swap hangup handlers. */
7109 exchange.handlers = *ast_channel_hangup_handlers(original);
7111 *ast_channel_hangup_handlers(clonechan) = exchange.handlers;
7112
7113 /* Call fixup handlers for the clone chan */
7114 if (AST_LIST_FIRST(ast_channel_datastores(clonechan))) {
7115 struct ast_datastore *ds;
7116 /* We use a safe traversal here because some fixup routines actually
7117 * remove the datastore from the list and free them.
7118 */
7120 if (ds->info->chan_fixup) {
7121 ds->info->chan_fixup(ds->data, clonechan, original);
7122 }
7123 }
7125 }
7126
7127 /* Call breakdown handlers for the original chan */
7128 if (AST_LIST_FIRST(ast_channel_datastores(original))) {
7129 struct ast_datastore *ds;
7130 /* We use a safe traversal here because some breakdown routines may
7131 * remove the datastore from the list and free them.
7132 */
7134 if (ds->info->chan_breakdown) {
7135 ds->info->chan_breakdown(ds->data, clonechan, original);
7136 }
7137 }
7139 }
7140
7141 /* Move data stores over */
7142 if (AST_LIST_FIRST(ast_channel_datastores(clonechan))) {
7144 }
7145
7146 /* Move framehooks over */
7147 ast_framehook_list_fixup(clonechan, original);
7148
7149 /* Move audiohooks over */
7150 ast_audiohook_move_all(clonechan, original);
7151
7152 ast_autochan_new_channel(clonechan, original);
7153
7154 clone_variables(original, clonechan);
7155 /* Presence of ADSI capable CPE follows clone */
7156 ast_channel_adsicpe_set(original, ast_channel_adsicpe(clonechan));
7157 /* Bridge remains the same */
7158 /* CDR fields remain the same */
7159 /* XXX What about blocking, softhangup, blocker, and lock and blockproc? XXX */
7160 /* Application and data remain the same */
7161 /* Clone exception becomes real one, as with fdno */
7163 ast_channel_fdno_set(original, ast_channel_fdno(clonechan));
7164 /* Schedule context remains the same */
7165 /* Stream stuff stays the same */
7166 /* Keep the original state. The fixup code will need to work with it most likely */
7167
7168 /*
7169 * Just swap the whole structures, nevermind the allocations,
7170 * they'll work themselves out.
7171 */
7172 exchange.dialed = *ast_channel_dialed(original);
7173 ast_channel_dialed_set(original, ast_channel_dialed(clonechan));
7174 ast_channel_dialed_set(clonechan, &exchange.dialed);
7175
7176 /* Reset any earlier private caller id representations */
7177 ast_party_id_reset(&ast_channel_caller(original)->priv);
7178 ast_party_id_reset(&ast_channel_caller(clonechan)->priv);
7179
7180 exchange.caller = *ast_channel_caller(original);
7181 ast_channel_caller_set(original, ast_channel_caller(clonechan));
7182 ast_channel_caller_set(clonechan, &exchange.caller);
7183
7184 /* Reset any earlier private connected id representations */
7185 ast_party_id_reset(&ast_channel_connected(original)->priv);
7186 ast_party_id_reset(&ast_channel_connected(clonechan)->priv);
7187
7188 exchange.connected = *ast_channel_connected(original);
7190 ast_channel_connected_set(clonechan, &exchange.connected);
7191
7192 /* Reset any earlier private redirecting orig, from or to representations */
7193 ast_party_id_reset(&ast_channel_redirecting(original)->priv_orig);
7194 ast_party_id_reset(&ast_channel_redirecting(clonechan)->priv_orig);
7195 ast_party_id_reset(&ast_channel_redirecting(original)->priv_from);
7196 ast_party_id_reset(&ast_channel_redirecting(clonechan)->priv_from);
7197 ast_party_id_reset(&ast_channel_redirecting(original)->priv_to);
7198 ast_party_id_reset(&ast_channel_redirecting(clonechan)->priv_to);
7199
7200 exchange.redirecting = *ast_channel_redirecting(original);
7202 ast_channel_redirecting_set(clonechan, &exchange.redirecting);
7203
7205
7206 /* Restore original timing file descriptor */
7208
7209 /* Our native formats are different now */
7211 if (tmp_cap) {
7213 ast_channel_nativeformats_set(original, tmp_cap);
7214 ao2_ref(tmp_cap, -1);
7215 }
7216
7217 /* Context, extension, priority, app data, jump table, remain the same */
7218 /* pvt switches. pbx stays the same, as does next */
7219
7220 /* Set the write format */
7221 ast_set_write_format(original, wformat);
7222
7223 /* Set the read format */
7224 ast_set_read_format(original, rformat);
7225
7226 /* Copy the music class */
7227 ast_channel_musicclass_set(original, ast_channel_musicclass(clonechan));
7228
7229 /* copy over accuntcode and set peeraccount across the bridge */
7230 ast_channel_accountcode_set(original, S_OR(ast_channel_accountcode(clonechan), ""));
7231
7232 /* copy over userfield */
7233 ast_channel_userfield_set(original, ast_channel_userfield(clonechan));
7234
7235 ast_debug(1, "Putting channel %s in %s/%s formats\n", ast_channel_name(original),
7236 ast_format_get_name(wformat), ast_format_get_name(rformat));
7237
7238 /* Fixup the original clonechan's physical side */
7239 if (ast_channel_tech(original)->fixup && ast_channel_tech(original)->fixup(clonechan, original)) {
7240 ast_log(LOG_WARNING, "Channel type '%s' could not fixup channel %s, strange things may happen. (clonechan)\n",
7241 ast_channel_tech(original)->type, ast_channel_name(original));
7242 }
7243
7244 /* Fixup the original original's physical side */
7245 if (ast_channel_tech(clonechan)->fixup && ast_channel_tech(clonechan)->fixup(original, clonechan)) {
7246 ast_log(LOG_WARNING, "Channel type '%s' could not fixup channel %s, strange things may happen. (original)\n",
7247 ast_channel_tech(clonechan)->type, ast_channel_name(clonechan));
7248 }
7249
7250 ast_channel_internal_swap_stream_topology(original, clonechan);
7251
7252 /*
7253 * Now, at this point, the "clone" channel is totally F'd up.
7254 * We mark it as a zombie so nothing tries to touch it.
7255 *
7256 * This must be done before we unlock clonechan to prevent
7257 * setting up another masquerade on the clonechan.
7258 */
7260 ast_queue_frame(clonechan, &ast_null_frame);
7261
7262 ast_channel_unlock(original);
7263 ast_channel_unlock(clonechan);
7264
7265 /*
7266 * Indicate to each channel that a masquerade is complete.
7267 *
7268 * We can still do this to clonechan even though it is a
7269 * zombie because ast_indicate_data() will explicitly pass
7270 * this control and ast_hangup() is held off until the
7271 * ast_channel_masq() and ast_channel_masqr() pointers are
7272 * cleared.
7273 */
7274 x = 0;
7275 ast_indicate_data(original, AST_CONTROL_MASQUERADE_NOTIFY, &x, sizeof(x));
7276 ast_indicate_data(clonechan, AST_CONTROL_MASQUERADE_NOTIFY, &x, sizeof(x));
7277
7279
7280 if (clone_hold_state == AST_CONTROL_HOLD) {
7281 ast_debug(1, "Channel %s simulating UNHOLD for masquerade.\n",
7282 ast_channel_name(original));
7284 }
7285 if (clone_sending_dtmf_digit) {
7286 /*
7287 * The clonechan was sending a DTMF digit that was not completed
7288 * before the masquerade.
7289 */
7290 ast_channel_end_dtmf(original, clone_sending_dtmf_digit, clone_sending_dtmf_tv,
7291 "masquerade");
7292 }
7293
7294 /*
7295 * If an indication is currently playing, maintain it on the
7296 * channel that is taking the place of original.
7297 *
7298 * This is needed because the masquerade is swapping out the
7299 * internals of the channel, and the new channel private data
7300 * needs to be made aware of the current visible indication
7301 * (RINGING, CONGESTION, etc.)
7302 */
7303 if (visible_indication) {
7304 if (visible_indication == AST_CONTROL_HOLD) {
7305 const char *latest_musicclass;
7306 int len;
7307
7308 ast_channel_lock(original);
7309 latest_musicclass = ast_strdupa(ast_channel_latest_musicclass(original));
7310 ast_channel_unlock(original);
7311 if (ast_strlen_zero(latest_musicclass)) {
7312 latest_musicclass = NULL;
7313 len = 0;
7314 } else {
7315 len = strlen(latest_musicclass) + 1;
7316 }
7317 ast_indicate_data(original, visible_indication, latest_musicclass, len);
7318 } else {
7319 ast_indicate(original, visible_indication);
7320 }
7321 }
7322
7323 /*
7324 * If MOH was playing on the original channel then it needs to be
7325 * maintained on the channel that is replacing it.
7326 */
7327 if (moh_is_playing) {
7328 /* Start MOH on the new original channel. */
7329 ast_moh_start(original, NULL, NULL);
7330 }
7331
7332 ast_channel_lock(original);
7333
7334 /* Signal any blocker */
7336 pthread_kill(ast_channel_blocker(original), SIGURG);
7337 }
7338
7339 ast_debug(1, "Done Masquerading %s (%u)\n", ast_channel_name(original), ast_channel_state(original));
7340 ast_channel_unlock(original);
7341
7342 if ((bridged = ast_channel_bridge_peer(original))) {
7344 ast_channel_unref(bridged);
7345 }
7347
7348 /* Now that the operation is complete, we can clear the masq
7349 * and masqr fields of both channels.
7350 */
7351 ast_channel_lock_both(original, clonechan);
7352 ast_channel_masq_set(original, NULL);
7353 ast_channel_masqr_set(clonechan, NULL);
7354 ast_channel_unlock(original);
7355 ast_channel_unlock(clonechan);
7356
7358 CHANNELSTORAGE_API(current_channel_storage_instance, insert, clonechan, 0, 0);
7361
7362 /* Release our held safety references. */
7363 ast_channel_unref(original);
7364 ast_channel_unref(clonechan);
7365
7366 ao2_cleanup(rformat);
7367 ao2_cleanup(wformat);
7368}
void ast_audiohook_move_all(struct ast_channel *old_chan, struct ast_channel *new_chan)
Move all audiohooks from one channel to another.
Definition audiohook.c:709
void ast_autochan_new_channel(struct ast_channel *old_chan, struct ast_channel *new_chan)
Switch what channel autochans point to.
Definition autochan.c:86
void ast_bridge_notify_masquerade(struct ast_channel *chan)
Notify bridging that this channel was just masqueraded.
Definition bridge.c:1511
void ast_channel_end_dtmf(struct ast_channel *chan, char digit, struct timeval start, const char *why)
Simulate a DTMF end on a broken bridge channel.
Definition channel.c:10941
static void clone_variables(struct ast_channel *original, struct ast_channel *clonechan)
Clone channel variables from 'clone' channel into 'original' channel.
Definition channel.c:6846
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
Definition channel.c:7802
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
Definition channel.c:7812
void ast_party_id_reset(struct ast_party_id *id)
Destroy and initialize the given party id structure.
Definition channel.c:1883
void ast_channel_internal_alertpipe_swap(struct ast_channel *chan1, struct ast_channel *chan2)
Swap the interal alertpipe between two channels.
void ast_channel_caller_set(struct ast_channel *chan, struct ast_party_caller *value)
void ast_channel_dialed_set(struct ast_channel *chan, struct ast_party_dialed *value)
const char * ast_channel_latest_musicclass(const struct ast_channel *chan)
struct ast_flags * ast_channel_snapshot_segment_flags(struct ast_channel *chan)
void ast_channel_internal_swap_endpoint_forward(struct ast_channel *a, struct ast_channel *b)
Swap endpoint_forward between two channels.
const char * ast_channel_musicclass(const struct ast_channel *chan)
struct timeval ast_channel_sending_dtmf_tv(const struct ast_channel *chan)
void ast_channel_redirecting_set(struct ast_channel *chan, struct ast_party_redirecting *value)
#define ast_channel_ref(c)
Increase channel reference count.
Definition channel.h:3008
void ast_channel_softhangup_internal_flag_set(struct ast_channel *chan, int value)
void ast_channel_internal_swap_endpoints(struct ast_channel *a, struct ast_channel *b)
Swap endpoints between two channels.
const char * ast_channel_userfield(const struct ast_channel *chan)
const char * ast_channel_parkinglot(const struct ast_channel *chan)
ast_channel_adsicpe
Definition channel.h:888
void ast_channel_internal_swap_topics(struct ast_channel *a, struct ast_channel *b)
Swap topics beteween two channels.
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
void ast_channel_internal_swap_uniqueid_and_linkedid(struct ast_channel *a, struct ast_channel *b)
Swap uniqueid and linkedid beteween two channels.
int ast_channel_hold_state(const struct ast_channel *chan)
const char * ast_channel_language(const struct ast_channel *chan)
void ast_channel_connected_set(struct ast_channel *chan, struct ast_party_connected_line *value)
void ast_channel_internal_swap_snapshots(struct ast_channel *a, struct ast_channel *b)
Swap snapshots beteween two channels.
@ AST_FLAG_MOH
Definition channel.h:1011
int ast_channel_visible_indication(const struct ast_channel *chan)
struct ast_hangup_handler_list * ast_channel_hangup_handlers(struct ast_channel *chan)
void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value)
void ast_channel_internal_swap_stream_topology(struct ast_channel *chan1, struct ast_channel *chan2)
int ast_format_cap_append_from_cap(struct ast_format_cap *dst, const struct ast_format_cap *src, enum ast_media_type type)
Append the formats of provided type in src to dst.
Definition format_cap.c:269
void ast_framehook_list_fixup(struct ast_channel *old_chan, struct ast_channel *new_chan)
This is used by the channel API during a masquerade operation to move all mobile framehooks from the ...
Definition framehook.c:223
int ast_app_group_update(struct ast_channel *oldchan, struct ast_channel *newchan)
Update all group counting for a channel to a new one.
Definition main/app.c:2301
void(* chan_fixup)(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan)
Fix up channel references on the masquerading channel.
Definition datastore.h:48
void(* chan_breakdown)(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan)
Fix up channel references on the channel being masqueraded into.
Definition datastore.h:60
Caller Party information.
Definition channel.h:420
Dialed/Called Party information.
Definition channel.h:380
static const struct ast_aeap_message_handler handlers[]
Definition test_aeap.c:135
#define AST_FLAGS_ALL
Definition utils.h:217

References ao2_bump, ao2_cleanup, ao2_ref, ast_app_group_update(), ast_audiohook_move_all(), ast_autochan_new_channel(), ast_bridge_notify_masquerade(), ast_channel_accountcode(), ast_channel_adsicpe_set(), ast_channel_alert_write(), ast_channel_blocker(), ast_channel_bridge_peer(), ast_channel_caller(), ast_channel_caller_set(), ast_channel_connected(), ast_channel_connected_set(), ast_channel_datastores(), ast_channel_dialed(), ast_channel_dialed_set(), ast_channel_end_dtmf(), ast_channel_fd(), ast_channel_fd_count(), ast_channel_fdno(), ast_channel_fdno_set(), ast_channel_flags(), ast_channel_hangup_handlers(), ast_channel_hold_state(), ast_channel_internal_alertpipe_swap(), ast_channel_internal_fd_clear_all(), ast_channel_internal_swap_endpoint_forward(), ast_channel_internal_swap_endpoints(), ast_channel_internal_swap_snapshots(), ast_channel_internal_swap_stream_topology(), ast_channel_internal_swap_topics(), ast_channel_internal_swap_uniqueid_and_linkedid(), ast_channel_language(), ast_channel_latest_musicclass(), ast_channel_lock, ast_channel_lock_both, ast_channel_masq_set(), ast_channel_masqr_set(), ast_channel_musicclass(), AST_CHANNEL_NAME, ast_channel_name(), ast_channel_name_set(), ast_channel_nativeformats(), ast_channel_nativeformats_set(), ast_channel_parkinglot(), ast_channel_publish_snapshot(), ast_channel_rawreadformat(), ast_channel_rawwriteformat(), ast_channel_readformat(), ast_channel_readq(), ast_channel_redirecting(), ast_channel_redirecting_set(), ast_channel_ref, ast_channel_sending_dtmf_digit(), ast_channel_sending_dtmf_tv(), ast_channel_set_fd(), ast_channel_set_rawreadformat(), ast_channel_set_rawwriteformat(), ast_channel_snapshot_segment_flags(), ast_channel_softhangup_internal_flag_set(), ast_channel_state_set(), ast_channel_tech_pvt(), ast_channel_tech_pvt_set(), ast_channel_tech_set(), ast_channel_timingfd(), ast_channel_unlock, ast_channel_unref, ast_channel_userfield(), ast_channel_visible_indication(), ast_channel_writeformat(), ast_clear_flag, AST_CONTROL_HOLD, AST_CONTROL_MASQUERADE_NOTIFY, AST_CONTROL_SRCCHANGE, AST_CONTROL_UNHOLD, ast_copy_string(), ast_debug, AST_FLAG_BLOCKING, AST_FLAG_DISABLE_DEVSTATE_CACHE, AST_FLAG_EXCEPTION, AST_FLAG_MOH, AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, AST_FLAGS_ALL, ast_format_cap_alloc, ast_format_cap_append_from_cap(), AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_get_name(), ast_framehook_list_fixup(), ast_indicate(), ast_indicate_data(), AST_LIST_APPEND_LIST, AST_LIST_FIRST, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_HEAD_NOLOCK, AST_LIST_INSERT_TAIL, AST_LIST_REMOVE_HEAD, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log, AST_MEDIA_TYPE_UNKNOWN, ast_moh_start(), ast_moh_stop(), ast_null_frame, ast_party_id_reset(), ast_queue_frame(), ast_set_flag, ast_set_read_format(), ast_set_write_format(), AST_SOFTHANGUP_DEV, ast_strdupa, ast_strlen_zero(), ast_test_flag, AST_TIMING_FD, ast_channel::caller, ast_datastore_info::chan_breakdown, ast_datastore_info::chan_fixup, CHANNELSTORAGE_API, clone_variables(), connected, ast_channel::connected, current, current_channel_storage_instance, ast_datastore::data, ast_channel::dialed, ast_datastore::entry, errno, free_translation(), handlers, ast_datastore::info, len(), LOG_WARNING, NULL, ast_channel::redirecting, remove, S_OR, and type.

Referenced by ast_channel_move().

◆ channel_feature_hooks_set_full()

static int channel_feature_hooks_set_full ( struct ast_channel chan,
struct ast_bridge_features features,
int  replace 
)
static

Definition at line 10986 of file channel.c.

10987{
10988 struct ast_datastore *datastore;
10989 struct ast_bridge_features *ds_features;
10990
10992 if (datastore) {
10993 ds_features = datastore->data;
10994 if (replace) {
10995 ast_bridge_features_cleanup(ds_features);
10996 ast_bridge_features_init(ds_features);
10997 }
10998 if (features) {
10999 ast_bridge_features_merge(ds_features, features);
11000 }
11001 return 0;
11002 }
11003
11005 if (!datastore) {
11006 return -1;
11007 }
11008
11009 ds_features = ast_bridge_features_new();
11010 if (!ds_features) {
11011 ast_datastore_free(datastore);
11012 return -1;
11013 }
11014
11015 if (features) {
11016 ast_bridge_features_merge(ds_features, features);
11017 }
11018 datastore->data = ds_features;
11019 ast_channel_datastore_add(chan, datastore);
11020 return 0;
11021}
int ast_bridge_features_init(struct ast_bridge_features *features)
Initialize bridge features structure.
Definition bridge.c:3699
struct ast_bridge_features * ast_bridge_features_new(void)
Allocate a new bridge features struct.
Definition bridge.c:3762
void ast_bridge_features_merge(struct ast_bridge_features *into, const struct ast_bridge_features *from)
Merge one ast_bridge_features into another.
Definition bridge.c:3674
void ast_bridge_features_cleanup(struct ast_bridge_features *features)
Clean up the contents of a bridge features structure.
Definition bridge.c:3732
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
Structure that contains features information.

References ast_bridge_features_cleanup(), ast_bridge_features_init(), ast_bridge_features_merge(), ast_bridge_features_new(), ast_channel_datastore_add(), ast_channel_datastore_find(), ast_datastore_alloc, ast_datastore_free(), bridge_features_info, ast_datastore::data, NULL, and replace().

Referenced by ast_channel_feature_hooks_append(), and ast_channel_feature_hooks_replace().

◆ channel_get_external_vars()

static struct varshead * channel_get_external_vars ( struct external_vars channelvars,
struct ast_channel chan 
)
static

Definition at line 7945 of file channel.c.

7947{
7948 RAII_VAR(struct varshead *, ret, NULL, ao2_cleanup);
7949 RAII_VAR(struct ast_str *, tmp, NULL, ast_free);
7950 struct manager_channel_variable *mcv;
7952
7953 if (AST_LIST_EMPTY(channelvars)) {
7954 return NULL;
7955 }
7956
7957 ret = ao2_alloc(sizeof(*ret), varshead_dtor);
7958 tmp = ast_str_create(16);
7959
7960 if (!ret || !tmp) {
7961 return NULL;
7962 }
7963
7964 AST_LIST_TRAVERSE(channelvars, mcv, entry) {
7965 const char *val = NULL;
7966 struct ast_var_t *var;
7967
7968 if (mcv->isfunc) {
7969 if (ast_func_read2(chan, mcv->name, &tmp, 0) == 0) {
7970 val = ast_str_buffer(tmp);
7971 } else {
7973 "Error invoking function %s\n", mcv->name);
7974 }
7975 } else {
7976 val = pbx_builtin_getvar_helper(chan, mcv->name);
7977 }
7978
7979 var = ast_var_assign(mcv->name, val ? val : "");
7980 if (!var) {
7981 return NULL;
7982 }
7983
7985 }
7986
7987 ao2_ref(ret, +1);
7988 return ret;
7989
7990}
#define AST_RWLIST_INSERT_TAIL
#define SCOPED_LOCK(varname, lock, lockfunc, unlockfunc)
Scoped Locks.
Definition lock.h:590
int ast_func_read2(struct ast_channel *chan, const char *function, struct ast_str **str, ssize_t maxlen)
executes a read operation on a function
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition strings.h:659
List of channel variables to append to all channel-related events.
Definition channel.c:7832
struct manager_channel_variable::@349 entry

References ao2_alloc, ao2_cleanup, ao2_ref, ast_free, ast_func_read2(), AST_LIST_EMPTY, AST_LIST_TRAVERSE, ast_log, AST_RWLIST_INSERT_TAIL, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_str_buffer(), ast_str_create, ast_var_assign, ast_var_t::entries, manager_channel_variable::entry, manager_channel_variable::isfunc, lock, LOG_ERROR, manager_channel_variable::name, NULL, pbx_builtin_getvar_helper(), RAII_VAR, SCOPED_LOCK, var, and varshead_dtor().

Referenced by ast_channel_get_ari_vars(), and ast_channel_get_manager_vars().

◆ channel_has_external_vars()

static int channel_has_external_vars ( struct external_vars channelvars)
static

Definition at line 7853 of file channel.c.

7854{
7855 int vars_present;
7856
7857 AST_RWLIST_RDLOCK(channelvars);
7858 vars_present = !AST_LIST_EMPTY(channelvars);
7859 AST_RWLIST_UNLOCK(channelvars);
7860
7861 return vars_present;
7862}

References AST_LIST_EMPTY, AST_RWLIST_RDLOCK, and AST_RWLIST_UNLOCK.

Referenced by ast_channel_has_ari_vars(), and ast_channel_has_manager_vars().

◆ channel_req_accountcodes()

static void channel_req_accountcodes ( struct ast_channel chan,
const struct ast_channel requestor,
enum ast_channel_requestor_relationship  relationship,
int  precious 
)
static

Definition at line 6395 of file channel.c.

6396{
6397 /*
6398 * The primary reason for the existence of this function is
6399 * so local channels can propagate accountcodes to the ;2
6400 * channel before ast_call().
6401 *
6402 * The secondary reason is to propagate the CHANNEL(peeraccount)
6403 * value set before Dial, FollowMe, and Queue while maintaining
6404 * the historic straight across accountcode propagation as a
6405 * fallback.
6406 */
6407 switch (relationship) {
6409 /* Crossover the requestor's accountcode and peeraccount */
6410 if (!precious || ast_strlen_zero(ast_channel_accountcode(chan))) {
6411 /*
6412 * The newly created channel does not have an accountcode
6413 * or we don't care.
6414 */
6415 if (!ast_strlen_zero(ast_channel_peeraccount(requestor))) {
6416 /*
6417 * Set it to the requestor's peeraccount. This allows the
6418 * dialplan to indicate the accountcode to use when dialing
6419 * by setting CHANNEL(peeraccount).
6420 */
6421 ast_channel_accountcode_set(chan, ast_channel_peeraccount(requestor));
6422 } else if (!precious
6423 && !ast_strlen_zero(ast_channel_accountcode(requestor))) {
6424 /*
6425 * Fallback to the historic propagation and set it to the
6426 * requestor's accountcode.
6427 */
6428 ast_channel_accountcode_set(chan, ast_channel_accountcode(requestor));
6429 }
6430 }
6431 if (!ast_strlen_zero(ast_channel_accountcode(requestor))) {
6432 ast_channel_peeraccount_set(chan, ast_channel_accountcode(requestor));
6433 }
6434 break;
6436 /* Pass the requestor's accountcode and peeraccount straight. */
6437 if (!precious || ast_strlen_zero(ast_channel_accountcode(chan))) {
6438 /*
6439 * The newly created channel does not have an accountcode
6440 * or we don't care.
6441 */
6442 if (!ast_strlen_zero(ast_channel_accountcode(requestor))) {
6443 ast_channel_accountcode_set(chan, ast_channel_accountcode(requestor));
6444 }
6445 }
6446 if (!ast_strlen_zero(ast_channel_peeraccount(requestor))) {
6447 ast_channel_peeraccount_set(chan, ast_channel_peeraccount(requestor));
6448 }
6449 break;
6450 }
6451}
const char * ast_channel_peeraccount(const struct ast_channel *chan)

References ast_channel_accountcode(), ast_channel_peeraccount(), AST_CHANNEL_REQUESTOR_BRIDGE_PEER, AST_CHANNEL_REQUESTOR_REPLACEMENT, and ast_strlen_zero().

Referenced by ast_channel_req_accountcodes(), and ast_channel_req_accountcodes_precious().

◆ channel_set_external_vars()

static void channel_set_external_vars ( struct external_vars channelvars,
size_t  varc,
char **  vars 
)
static

Definition at line 7874 of file channel.c.

7875{
7876 size_t i;
7877
7878 free_external_channelvars(channelvars);
7879 AST_RWLIST_WRLOCK(channelvars);
7880 for (i = 0; i < varc; ++i) {
7881 const char *var = vars[i];
7882 struct manager_channel_variable *mcv;
7883 if (!(mcv = ast_calloc(1, sizeof(*mcv) + strlen(var) + 1))) {
7884 break;
7885 }
7886 strcpy(mcv->name, var); /* SAFE */
7887 if (strchr(var, '(')) {
7888 mcv->isfunc = 1;
7889 }
7890 AST_RWLIST_INSERT_TAIL(channelvars, mcv, entry);
7891 }
7892 AST_RWLIST_UNLOCK(channelvars);
7893
7894}
static void free_external_channelvars(struct external_vars *channelvars)
Definition channel.c:7843

References ast_calloc, AST_RWLIST_INSERT_TAIL, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, manager_channel_variable::entry, free_external_channelvars(), manager_channel_variable::isfunc, manager_channel_variable::name, and var.

Referenced by ast_channel_set_ari_vars(), and ast_channel_set_manager_vars().

◆ channel_set_intercept_mode()

static void channel_set_intercept_mode ( int  in_intercept_mode)
static

Definition at line 10390 of file channel.c.

10391{
10392 int status;
10393
10394 status = ast_threadstorage_set_ptr(&in_intercept_routine,
10395 in_intercept_mode ? &(int) { 1 } : NULL);
10396 if (status) {
10397 ast_log(LOG_ERROR, "Failed to set dialplan intercept mode\n");
10398 }
10399}
jack_status_t status
Definition app_jack.c:149
int ast_threadstorage_set_ptr(struct ast_threadstorage *ts, void *ptr)
Set a raw pointer from threadstorage.

References ast_log, ast_threadstorage_set_ptr(), LOG_ERROR, NULL, and status.

Referenced by ast_channel_connected_line_sub(), and ast_channel_redirecting_sub().

◆ channels_shutdown()

static void channels_shutdown ( void  )
static

◆ clone_variables()

static void clone_variables ( struct ast_channel original,
struct ast_channel clonechan 
)
static

Clone channel variables from 'clone' channel into 'original' channel.

All variables except those related to app_groupcount are cloned. Variables are actually removed from 'clone' channel, presumably because it will subsequently be destroyed.

Note
Assumes locks will be in place on both channels when called.

Definition at line 6846 of file channel.c.

6847{
6848 struct ast_var_t *current, *newvar;
6849 /* Append variables from clone channel into original channel */
6850 /* XXX Is this always correct? We have to in order to keep MACROS working XXX */
6852
6853 /* then, dup the varshead list into the clone */
6854
6856 newvar = ast_var_assign(current->name, current->value);
6857 if (newvar)
6859 }
6860}

References ast_channel_varshead(), AST_LIST_APPEND_LIST, AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_var_assign, current, and ast_var_t::entries.

Referenced by channel_do_masquerade().

◆ complete_channeltypes()

static char * complete_channeltypes ( struct ast_cli_args a)
static

Definition at line 304 of file channel.c.

305{
306 struct chanlist *cl;
307 int wordlen;
308
309 if (a->pos != 3) {
310 return NULL;
311 }
312
313 wordlen = strlen(a->word);
314
317 if (!strncasecmp(a->word, cl->tech->type, wordlen)) {
319 }
320 }
322
323 return NULL;
324}
int ast_cli_completion_add(char *value)
Add a result to a request for completion options.
Definition main/cli.c:2845

References a, ast_cli_completion_add(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_strdup, chanlist::list, NULL, and chanlist::tech.

Referenced by handle_cli_core_show_channeltype().

◆ deactivate_generator_nolock()

static void deactivate_generator_nolock ( struct ast_channel chan)
static

◆ deactivate_silence_generator()

static int deactivate_silence_generator ( struct ast_channel chan)
static

Definition at line 8255 of file channel.c.

8256{
8257 ast_channel_lock(chan);
8258
8259 if (!ast_channel_generatordata(chan)) {
8260 ast_debug(1, "Trying to stop silence generator when there is no generator on '%s'\n",
8261 ast_channel_name(chan));
8262 ast_channel_unlock(chan);
8263 return 0;
8264 }
8266 ast_debug(1, "Trying to stop silence generator when it is not the current generator on '%s'\n",
8267 ast_channel_name(chan));
8268 ast_channel_unlock(chan);
8269 return 0;
8270 }
8272
8273 ast_channel_unlock(chan);
8274
8275 return 1;
8276}

References ast_channel_generator(), ast_channel_generatordata(), ast_channel_lock, ast_channel_name(), ast_channel_unlock, ast_debug, deactivate_generator_nolock(), and silence_generator.

Referenced by ast_channel_stop_silence_generator().

◆ destroy_hooks()

static void destroy_hooks ( struct ast_channel chan)
static

Definition at line 2529 of file channel.c.

2530{
2531 if (ast_channel_audiohooks(chan)) {
2534 }
2535
2537}
int ast_framehook_list_destroy(struct ast_channel *chan)
This is used by the channel API to detach and destroy all framehooks on a channel during channel dest...
Definition framehook.c:206

References ast_audiohook_detach_list(), ast_channel_audiohooks(), ast_channel_audiohooks_set(), ast_framehook_list_destroy(), and NULL.

Referenced by ast_hangup().

◆ do_ids_conflict()

static int do_ids_conflict ( const struct ast_assigned_ids assignedids,
int  rdlock 
)
static

Definition at line 711 of file channel.c.

712{
713 struct ast_channel *conflict;
714
715 if (!assignedids) {
716 return 0;
717 }
718
719 if (!ast_strlen_zero(assignedids->uniqueid)) {
721 get_by_uniqueid, assignedids->uniqueid, rdlock);
722 if (conflict) {
723 ast_log(LOG_ERROR, "Channel Unique ID '%s' already in use by channel %s(%p)\n",
724 assignedids->uniqueid, ast_channel_name(conflict), conflict);
725 ast_channel_unref(conflict);
726 return 1;
727 }
728 }
729
730 if (!ast_strlen_zero(assignedids->uniqueid2)) {
732 get_by_uniqueid, assignedids->uniqueid2, rdlock);
733 if (conflict) {
734 ast_log(LOG_ERROR, "Channel Unique ID2 '%s' already in use by channel %s(%p)\n",
735 assignedids->uniqueid2, ast_channel_name(conflict), conflict);
736 ast_channel_unref(conflict);
737 return 1;
738 }
739 }
740
741 return 0;
742}
const char * uniqueid2
Definition channel.h:608
const char * uniqueid
Definition channel.h:607

References ast_channel_name(), ast_channel_unref, ast_log, ast_strlen_zero(), CHANNELSTORAGE_API, current_channel_storage_instance, get_by_uniqueid(), LOG_ERROR, ast_assigned_ids::uniqueid, and ast_assigned_ids::uniqueid2.

Referenced by __ast_channel_alloc_ap().

◆ dtmf_direction_to_string()

static const char * dtmf_direction_to_string ( enum DtmfDirection  direction)
static

Definition at line 3363 of file channel.c.

3364{
3365 switch (direction) {
3366 case DTMF_RECEIVED:
3367 return "Received";
3368 case DTMF_SENT:
3369 return "Sent";
3370 }
3371
3372 return "?";
3373}

References DTMF_RECEIVED, and DTMF_SENT.

Referenced by send_dtmf_begin_event(), and send_dtmf_end_event().

◆ features_destroy()

static void features_destroy ( void *  obj)
static

Definition at line 10965 of file channel.c.

10966{
10968}
void ast_bridge_features_destroy(struct ast_bridge_features *features)
Destroy an allocated bridge features struct.
Definition bridge.c:3753

References ast_bridge_features_destroy().

◆ free_external_channelvars()

static void free_external_channelvars ( struct external_vars channelvars)
static

Definition at line 7843 of file channel.c.

7844{
7846 AST_RWLIST_WRLOCK(channelvars);
7847 while ((var = AST_RWLIST_REMOVE_HEAD(channelvars, entry))) {
7848 ast_free(var);
7849 }
7850 AST_RWLIST_UNLOCK(channelvars);
7851}
#define AST_RWLIST_REMOVE_HEAD

References ast_free, AST_RWLIST_REMOVE_HEAD, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, manager_channel_variable::entry, and var.

Referenced by channel_set_external_vars(), and channels_shutdown().

◆ free_translation()

static void free_translation ( struct ast_channel clonechan)
static

◆ generator_force()

static int generator_force ( const void *  data)
static

Definition at line 2920 of file channel.c.

2921{
2922 /* Called if generator doesn't have data */
2923 void *tmp;
2924 int res;
2925 int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples) = NULL;
2926 struct ast_channel *chan = (struct ast_channel *)data;
2927
2928 ast_channel_lock(chan);
2929 tmp = ast_channel_generatordata(chan);
2931 if (ast_channel_generator(chan))
2932 generate = ast_channel_generator(chan)->generate;
2933 ast_channel_unlock(chan);
2934
2935 if (!tmp || !generate) {
2936 return 0;
2937 }
2938
2939 res = generate(chan, tmp, 0, ast_format_get_sample_rate(ast_channel_writeformat(chan)) / 50);
2940
2941 ast_channel_lock(chan);
2942 if (ast_channel_generator(chan) && generate == ast_channel_generator(chan)->generate) {
2944 }
2945 ast_channel_unlock(chan);
2946
2947 if (res) {
2948 ast_debug(1, "Auto-deactivating generator\n");
2950 }
2951
2952 return 0;
2953}

References ast_channel_generator(), ast_channel_generatordata(), ast_channel_generatordata_set(), ast_channel_lock, ast_channel_unlock, ast_channel_writeformat(), ast_deactivate_generator(), ast_debug, ast_format_get_sample_rate(), ast_channel::data, ast_generator::generate, and NULL.

Referenced by ast_activate_generator().

◆ generator_write_format_change()

static void generator_write_format_change ( struct ast_channel chan)
static

Definition at line 2908 of file channel.c.

2909{
2910 struct ast_generator *generator;
2911
2912 ast_channel_lock(chan);
2913 generator = ast_channel_generator(chan);
2914 if (generator && generator->write_format_change) {
2915 generator->write_format_change(chan, ast_channel_generatordata(chan));
2916 }
2917 ast_channel_unlock(chan);
2918}
void(* write_format_change)(struct ast_channel *chan, void *data)
Definition channel.h:240

References ast_channel_generator(), ast_channel_generatordata(), ast_channel_lock, ast_channel_unlock, and ast_generator::write_format_change.

Referenced by set_format().

◆ handle_cause()

static void handle_cause ( int  cause,
int *  outstate 
)
static

Definition at line 5872 of file channel.c.

5873{
5874 if (outstate) {
5875 /* compute error and return */
5876 if (cause == AST_CAUSE_BUSY)
5877 *outstate = AST_CONTROL_BUSY;
5878 else if (cause == AST_CAUSE_CONGESTION)
5879 *outstate = AST_CONTROL_CONGESTION;
5880 else
5881 *outstate = 0;
5882 }
5883}
#define AST_CAUSE_CONGESTION
Definition causes.h:153
#define AST_CAUSE_BUSY
Definition causes.h:149

References AST_CAUSE_BUSY, AST_CAUSE_CONGESTION, AST_CONTROL_BUSY, and AST_CONTROL_CONGESTION.

Referenced by __ast_request_and_dial(), and ast_call_forward().

◆ handle_cli_core_show_channeltype()

static char * handle_cli_core_show_channeltype ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Show details about a channel driver - CLI command.

Definition at line 327 of file channel.c.

328{
329 struct chanlist *cl = NULL;
331
332 switch (cmd) {
333 case CLI_INIT:
334 e->command = "core show channeltype";
335 e->usage =
336 "Usage: core show channeltype <name>\n"
337 " Show details about the specified channel type, <name>.\n";
338 return NULL;
339 case CLI_GENERATE:
340 return complete_channeltypes(a);
341 }
342
343 if (a->argc != 4)
344 return CLI_SHOWUSAGE;
345
347
348 AST_RWLIST_TRAVERSE(&backends, cl, list) {
349 if (!strncasecmp(cl->tech->type, a->argv[3], strlen(cl->tech->type)))
350 break;
351 }
352
353
354 if (!cl) {
355 ast_cli(a->fd, "\n%s is not a registered channel driver.\n", a->argv[3]);
357 return CLI_FAILURE;
358 }
359
360 ast_cli(a->fd,
361 "-- Info about channel driver: %s --\n"
362 " Device State: %s\n"
363 "Presence State: %s\n"
364 " Indication: %s\n"
365 " Transfer : %s\n"
366 " Capabilities: %s\n"
367 " Digit Begin: %s\n"
368 " Digit End: %s\n"
369 " Send HTML : %s\n"
370 " Image Support: %s\n"
371 " Text Support: %s\n",
372 cl->tech->type,
373 (cl->tech->devicestate) ? "yes" : "no",
374 (cl->tech->presencestate) ? "yes" : "no",
375 (cl->tech->indicate) ? "yes" : "no",
376 (cl->tech->transfer) ? "yes" : "no",
377 ast_format_cap_get_names(cl->tech->capabilities, &codec_buf),
378 (cl->tech->send_digit_begin) ? "yes" : "no",
379 (cl->tech->send_digit_end) ? "yes" : "no",
380 (cl->tech->send_html) ? "yes" : "no",
381 (cl->tech->send_image) ? "yes" : "no",
382 (cl->tech->send_text) ? "yes" : "no"
383
384 );
385
387
388 return CLI_SUCCESS;
389}
static char * complete_channeltypes(struct ast_cli_args *a)
Definition channel.c:304
#define CLI_SHOWUSAGE
Definition cli.h:45
#define CLI_SUCCESS
Definition cli.h:44
void ast_cli(int fd, const char *fmt,...)
Definition clicompat.c:6
@ CLI_INIT
Definition cli.h:152
@ CLI_GENERATE
Definition cli.h:153
#define CLI_FAILURE
Definition cli.h:46
char * command
Definition cli.h:186
const char * usage
Definition cli.h:177

References a, ast_cli(), ast_format_cap_get_names(), AST_FORMAT_CAP_NAMES_LEN, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_str_alloca, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_channeltypes(), NULL, chanlist::tech, and ast_cli_entry::usage.

◆ handle_cli_core_show_channeltypes()

static char * handle_cli_core_show_channeltypes ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Show channel types - CLI command.

Definition at line 262 of file channel.c.

263{
264#define FORMAT "%-15.15s %-40.40s %-13.13s %-13.13s %-13.13s %-13.13s\n"
265 struct chanlist *cl;
266 int count_chan = 0;
267
268 switch (cmd) {
269 case CLI_INIT:
270 e->command = "core show channeltypes";
271 e->usage =
272 "Usage: core show channeltypes\n"
273 " Lists available channel types registered in your\n"
274 " Asterisk server.\n";
275 return NULL;
276 case CLI_GENERATE:
277 return NULL;
278 }
279
280 if (a->argc != 3)
281 return CLI_SHOWUSAGE;
282
283 ast_cli(a->fd, FORMAT, "Type", "Description", "Devicestate", "Presencestate", "Indications", "Transfer");
284 ast_cli(a->fd, FORMAT, "-------------", "-------------", "-------------", "-------------", "-------------", "-------------");
285
288 ast_cli(a->fd, FORMAT, cl->tech->type, cl->tech->description,
289 (cl->tech->devicestate) ? "yes" : "no",
290 (cl->tech->presencestate) ? "yes" : "no",
291 (cl->tech->indicate) ? "yes" : "no",
292 (cl->tech->transfer) ? "yes" : "no");
293 count_chan++;
294 }
296
297 ast_cli(a->fd, "----------\n%d channel drivers registered.\n", count_chan);
298
299 return CLI_SUCCESS;
300
301#undef FORMAT
302}
#define FORMAT

References a, ast_cli(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, FORMAT, chanlist::list, NULL, chanlist::tech, and ast_cli_entry::usage.

◆ indicate_connected_line()

static int indicate_connected_line ( struct ast_channel chan,
const void *  data,
size_t  datalen 
)
static

Definition at line 4423 of file channel.c.

4424{
4425 struct ast_party_connected_line *chan_connected = ast_channel_connected(chan);
4426 struct ast_party_connected_line *chan_indicated = ast_channel_connected_indicated(chan);
4428 unsigned char current[1024];
4429 unsigned char proposed[1024];
4430 int current_size;
4431 int proposed_size;
4432 int res;
4433
4435 res = ast_connected_line_parse_data(data, datalen, &connected);
4436 if (!res) {
4438 }
4440 if (res) {
4441 return -1;
4442 }
4443
4444 current_size = ast_connected_line_build_data(current, sizeof(current),
4445 chan_indicated, NULL);
4446 proposed_size = ast_connected_line_build_data(proposed, sizeof(proposed),
4447 chan_connected, NULL);
4448 if (current_size == -1 || proposed_size == -1) {
4449 return -1;
4450 }
4451
4452 if (current_size == proposed_size && !memcmp(current, proposed, current_size)) {
4453 ast_debug(1, "%s: Dropping redundant connected line update \"%s\" <%s>.\n",
4454 ast_channel_name(chan),
4455 S_COR(chan_connected->id.name.valid, chan_connected->id.name.str, ""),
4456 S_COR(chan_connected->id.number.valid, chan_connected->id.number.str, ""));
4457 return -1;
4458 }
4459
4460 ast_party_connected_line_copy(chan_indicated, chan_connected);
4461 return 0;
4462}
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition strings.h:87

References ast_channel_connected(), ast_channel_connected_indicated(), ast_channel_name(), ast_channel_set_connected_line(), ast_connected_line_build_data(), ast_connected_line_parse_data(), ast_debug, ast_party_connected_line_copy(), ast_party_connected_line_free(), ast_party_connected_line_set_init(), connected, current, ast_party_connected_line::id, ast_party_id::name, NULL, ast_party_id::number, S_COR, ast_party_name::str, ast_party_number::str, ast_party_name::valid, and ast_party_number::valid.

Referenced by indicate_data_internal().

◆ indicate_data_internal()

static int indicate_data_internal ( struct ast_channel chan,
int  _condition,
const void *  data,
size_t  datalen 
)
static
Note
If we compare the enumeration type, which does not have any negative constants, the compiler may optimize this code away. Therefore, we must perform an integer comparison here.

Definition at line 4492 of file channel.c.

4493{
4494 /* By using an enum, we'll get compiler warnings for values not handled
4495 * in switch statements. */
4496 enum ast_control_frame_type condition = _condition;
4497 struct ast_tone_zone_sound *ts = NULL;
4498 const struct ast_control_t38_parameters *t38_parameters;
4499 int res;
4500
4501 switch (condition) {
4503 if (indicate_connected_line(chan, data, datalen)) {
4504 res = 0;
4505 return res;
4506 }
4507 break;
4509 if (indicate_redirecting(chan, data, datalen)) {
4510 res = 0;
4511 return res;
4512 }
4513 break;
4514 case AST_CONTROL_HOLD:
4515 case AST_CONTROL_UNHOLD:
4516 ast_channel_hold_state_set(chan, _condition);
4517 break;
4519 t38_parameters = data;
4520 switch (t38_parameters->request_response) {
4522 case AST_T38_NEGOTIATED:
4524 break;
4526 case AST_T38_TERMINATED:
4527 case AST_T38_REFUSED:
4529 break;
4530 default:
4531 break;
4532 }
4533 break;
4534 default:
4535 break;
4536 }
4537
4538 if (is_visible_indication(condition)) {
4539 /* A new visible indication is requested. */
4540 ast_channel_visible_indication_set(chan, _condition);
4541 } else if (condition == AST_CONTROL_UNHOLD || _condition < 0) {
4542 /* Visible indication is cleared/stopped. */
4544 }
4545
4546 if (ast_channel_tech(chan)->indicate) {
4547 /* See if the channel driver can handle this condition. */
4548 res = ast_channel_tech(chan)->indicate(chan, _condition, data, datalen);
4549 } else {
4550 res = -1;
4551 }
4552
4553 if (!res) {
4554 /* The channel driver successfully handled this indication */
4555 res = 0;
4556 return res;
4557 }
4558
4559 /* The channel driver does not support this indication, let's fake
4560 * it by doing our own tone generation if applicable. */
4561
4562 /*!\note If we compare the enumeration type, which does not have any
4563 * negative constants, the compiler may optimize this code away.
4564 * Therefore, we must perform an integer comparison here. */
4565 if (_condition < 0) {
4566 /* Stop any tones that are playing */
4567 ast_playtones_stop(chan);
4568 res = 0;
4569 return res;
4570 }
4571
4572 /* Handle conditions that we have tones for. */
4573 switch (condition) {
4575 /* deprecated T.38 control frame */
4576 res = -1;
4577 return res;
4579 /* there is no way to provide 'default' behavior for these
4580 * control frames, so we need to return failure, but there
4581 * is also no value in the log message below being emitted
4582 * since failure to handle these frames is not an 'error'
4583 * so just return right now. in addition, we want to return
4584 * whatever value the channel driver returned, in case it
4585 * has some meaning.*/
4586 return res;
4588 ts = ast_get_indication_tone(ast_channel_zone(chan), "ring");
4589 /* It is common practice for channel drivers to return -1 if trying
4590 * to indicate ringing on a channel which is up. The idea is to let the
4591 * core generate the ringing inband. However, we don't want the
4592 * warning message about not being able to handle the specific indication
4593 * to print nor do we want ast_indicate_data to return an "error" for this
4594 * condition
4595 */
4596 if (ast_channel_state(chan) == AST_STATE_UP) {
4597 res = 0;
4598 }
4599 break;
4600 case AST_CONTROL_BUSY:
4601 ts = ast_get_indication_tone(ast_channel_zone(chan), "busy");
4602 break;
4605 ts = ast_get_indication_tone(ast_channel_zone(chan), "congestion");
4606 break;
4608 ast_channel_hangupcause_hash_set(chan, data, datalen);
4609 res = 0;
4610 break;
4618 case AST_CONTROL_OPTION:
4619 case AST_CONTROL_WINK:
4620 case AST_CONTROL_FLASH:
4623 case AST_CONTROL_ANSWER:
4624 case AST_CONTROL_HANGUP:
4625 case AST_CONTROL_RING:
4626 case AST_CONTROL_HOLD:
4627 case AST_CONTROL_UNHOLD:
4631 case AST_CONTROL_CC:
4633 case AST_CONTROL_AOC:
4635 case AST_CONTROL_MCID:
4651 /* Nothing left to do for these. */
4652 res = 0;
4653 break;
4654 }
4655
4656 if (ts) {
4657 /* We have a tone to play, yay. */
4658 ast_debug(1, "Driver for channel '%s' does not support indication %u, emulating it\n", ast_channel_name(chan), condition);
4659 res = ast_playtones_start(chan, 0, ts->data, 1);
4660 if (!res) {
4661 ast_test_suite_event_notify("RINGING_INBAND",
4662 "Channel: %s\r\n",
4663 ast_channel_name(chan));
4664 }
4666 }
4667
4668 if (res) {
4669 /* not handled */
4670 ast_log(LOG_WARNING, "Unable to handle indication %u for '%s'\n", condition, ast_channel_name(chan));
4671 }
4672
4673 return res;
4674}
static int indicate_connected_line(struct ast_channel *chan, const void *data, size_t datalen)
Definition channel.c:4423
static int indicate_redirecting(struct ast_channel *chan, const void *data, size_t datalen)
Definition channel.c:4478
static int attribute_const is_visible_indication(enum ast_control_frame_type condition)
Definition channel.c:4303
void ast_channel_visible_indication_set(struct ast_channel *chan, int value)
void ast_channel_set_is_t38_active_nolock(struct ast_channel *chan, int is_t38_active)
Variant of ast_channel_set_is_t38_active. Use this if the channel is already locked prior to calling.
@ AST_T38_TERMINATED
@ AST_T38_REQUEST_TERMINATE
@ AST_T38_NEGOTIATED
@ AST_T38_REQUEST_NEGOTIATE
ast_control_frame_type
Internal control frame subtype field values.
@ AST_CONTROL_RECORD_CANCEL
@ AST_CONTROL_STREAM_TOPOLOGY_SOURCE_CHANGED
@ AST_CONTROL_OFFHOOK
@ AST_CONTROL_RADIO_UNKEY
@ AST_CONTROL_TAKEOFFHOOK
@ AST_CONTROL_T38_PARAMETERS
@ AST_CONTROL_RECORD_STOP
@ AST_CONTROL_PLAYBACK_BEGIN
@ AST_CONTROL_RECORD_MUTE
@ AST_CONTROL_RADIO_KEY
@ AST_CONTROL_OPTION
@ AST_CONTROL_RECORD_SUSPEND
@ _XXX_AST_CONTROL_T38
static struct ast_tone_zone_sound * ast_tone_zone_sound_unref(struct ast_tone_zone_sound *ts)
Release a reference to an ast_tone_zone_sound.
struct ast_tone_zone_sound * ast_get_indication_tone(const struct ast_tone_zone *zone, const char *indication)
Locate a tone zone sound.
enum ast_control_t38 request_response
Description of a tone.
Definition indications.h:35
const char * data
Description of a tone.
Definition indications.h:52

References _XXX_AST_CONTROL_T38, ast_channel_hangupcause_hash_set(), ast_channel_hold_state_set(), ast_channel_name(), ast_channel_set_is_t38_active_nolock(), ast_channel_visible_indication_set(), ast_channel_zone(), AST_CONTROL_ANSWER, AST_CONTROL_AOC, AST_CONTROL_BUSY, AST_CONTROL_CC, AST_CONTROL_CONGESTION, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_END_OF_Q, AST_CONTROL_FLASH, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_INCOMPLETE, AST_CONTROL_MASQUERADE_NOTIFY, AST_CONTROL_MCID, AST_CONTROL_OFFHOOK, AST_CONTROL_OPTION, AST_CONTROL_PLAYBACK_BEGIN, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_PVT_CAUSE_CODE, AST_CONTROL_RADIO_KEY, AST_CONTROL_RADIO_UNKEY, AST_CONTROL_READ_ACTION, AST_CONTROL_RECORD_CANCEL, AST_CONTROL_RECORD_MUTE, AST_CONTROL_RECORD_STOP, AST_CONTROL_RECORD_SUSPEND, AST_CONTROL_REDIRECTING, AST_CONTROL_RING, 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_STREAM_TOPOLOGY_CHANGED, AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE, AST_CONTROL_STREAM_TOPOLOGY_SOURCE_CHANGED, AST_CONTROL_T38_PARAMETERS, AST_CONTROL_TAKEOFFHOOK, AST_CONTROL_TRANSFER, AST_CONTROL_UNHOLD, AST_CONTROL_UPDATE_RTP_PEER, AST_CONTROL_VIDUPDATE, AST_CONTROL_WINK, ast_debug, ast_get_indication_tone(), ast_log, ast_playtones_start(), ast_playtones_stop(), AST_STATE_UP, AST_T38_NEGOTIATED, AST_T38_REFUSED, AST_T38_REQUEST_NEGOTIATE, AST_T38_REQUEST_TERMINATE, AST_T38_TERMINATED, ast_test_suite_event_notify, ast_tone_zone_sound_unref(), ast_tone_zone_sound::data, indicate(), ast_channel_tech::indicate, indicate_connected_line(), indicate_redirecting(), is_visible_indication(), LOG_WARNING, NULL, and ast_control_t38_parameters::request_response.

Referenced by ast_indicate_data(), and ast_write_stream().

◆ indicate_redirecting()

static int indicate_redirecting ( struct ast_channel chan,
const void *  data,
size_t  datalen 
)
static

Definition at line 4478 of file channel.c.

4479{
4480 struct ast_party_redirecting redirecting;
4481 int res;
4482
4484 res = ast_redirecting_parse_data(data, datalen, &redirecting);
4485 if (!res) {
4486 ast_channel_set_redirecting(chan, &redirecting, NULL);
4487 }
4488 ast_party_redirecting_free(&redirecting);
4489 return res ? -1 : 0;
4490}
void ast_channel_set_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Set the redirecting id information in the Asterisk channel.
Definition channel.c:9187
void ast_party_redirecting_set_init(struct ast_party_redirecting *init, const struct ast_party_redirecting *guide)
Initialize the given redirecting id structure using the given guide for a set update operation.
Definition channel.c:2140

References ast_channel_redirecting(), ast_channel_set_redirecting(), ast_party_redirecting_free(), ast_party_redirecting_set_init(), ast_redirecting_parse_data(), and NULL.

Referenced by indicate_data_internal().

◆ internal_channel_set_current_storage_driver()

int internal_channel_set_current_storage_driver ( const char *  driver_name)

Definition at line 8047 of file channel.c.

8048{
8049 if (ast_fully_booted) {
8050 ast_log(LOG_ERROR, "Cannot change channel storage driver after Asterisk has started\n");
8051 return -1;
8052 }
8055 return 0;
8056 }
8058 "Invalid channel storage backend '%s' specified. Attempting to use default '%s'.\n",
8059 driver_name, AST_CHANNELSTORAGE_DEFAULT_TYPE);
8062 return 0;
8063 }
8064 ast_log(LOG_ERROR, "Unable to find default channel storage backend '%s'.\n",
8066 return -1;
8067}
const struct ast_channelstorage_driver * ast_channelstorage_get_driver(const char *driver_name)
#define ast_fully_booted
Definition options.h:127

References AST_CHANNELSTORAGE_DEFAULT_TYPE, ast_channelstorage_get_driver(), ast_fully_booted, ast_log, current_channel_storage_driver, LOG_ERROR, and LOG_WARNING.

Referenced by ast_channel_open_storage(), and load_asterisk_conf().

◆ is_visible_indication()

static int attribute_const is_visible_indication ( enum ast_control_frame_type  condition)
static

Definition at line 4303 of file channel.c.

4304{
4305 /* Don't include a default case here so that we get compiler warnings
4306 * when a new type is added. */
4307
4308 switch (condition) {
4316 case AST_CONTROL_OPTION:
4317 case AST_CONTROL_WINK:
4318 case AST_CONTROL_FLASH:
4321 case AST_CONTROL_ANSWER:
4322 case AST_CONTROL_HANGUP:
4328 case AST_CONTROL_CC:
4330 case AST_CONTROL_AOC:
4332 case AST_CONTROL_MCID:
4349 break;
4350
4353 case AST_CONTROL_BUSY:
4355 case AST_CONTROL_RING:
4356 case AST_CONTROL_HOLD:
4357 /* You can hear these */
4358 return 1;
4359
4360 case AST_CONTROL_UNHOLD:
4361 /* This is a special case. You stop hearing this. */
4362 break;
4363 }
4364
4365 return 0;
4366}

References _XXX_AST_CONTROL_T38, AST_CONTROL_ANSWER, AST_CONTROL_AOC, AST_CONTROL_BUSY, AST_CONTROL_CC, AST_CONTROL_CONGESTION, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_END_OF_Q, AST_CONTROL_FLASH, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_INCOMPLETE, AST_CONTROL_MASQUERADE_NOTIFY, AST_CONTROL_MCID, AST_CONTROL_OFFHOOK, AST_CONTROL_OPTION, AST_CONTROL_PLAYBACK_BEGIN, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_PVT_CAUSE_CODE, AST_CONTROL_RADIO_KEY, AST_CONTROL_RADIO_UNKEY, AST_CONTROL_READ_ACTION, AST_CONTROL_RECORD_CANCEL, AST_CONTROL_RECORD_MUTE, AST_CONTROL_RECORD_STOP, AST_CONTROL_RECORD_SUSPEND, AST_CONTROL_REDIRECTING, AST_CONTROL_RING, 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_STREAM_TOPOLOGY_CHANGED, AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE, AST_CONTROL_STREAM_TOPOLOGY_SOURCE_CHANGED, AST_CONTROL_T38_PARAMETERS, AST_CONTROL_TAKEOFFHOOK, AST_CONTROL_TRANSFER, AST_CONTROL_UNHOLD, AST_CONTROL_UPDATE_RTP_PEER, AST_CONTROL_VIDUPDATE, and AST_CONTROL_WINK.

Referenced by indicate_data_internal().

◆ kill_exception()

static struct ast_frame * kill_exception ( struct ast_channel chan)
static

Definition at line 402 of file channel.c.

403{
404 /* Hangup channel. */
405 return NULL;
406}

References NULL.

◆ kill_fixup()

static int kill_fixup ( struct ast_channel oldchan,
struct ast_channel newchan 
)
static

Definition at line 414 of file channel.c.

415{
416 /* No problem fixing up the channel. */
417 return 0;
418}

◆ kill_hangup()

static int kill_hangup ( struct ast_channel chan)
static

Definition at line 420 of file channel.c.

421{
423 return 0;
424}

References ast_channel_tech_pvt_set(), and NULL.

◆ kill_read()

static struct ast_frame * kill_read ( struct ast_channel chan)
static

Definition at line 396 of file channel.c.

397{
398 /* Hangup channel. */
399 return NULL;
400}

References NULL.

◆ kill_write()

static int kill_write ( struct ast_channel chan,
struct ast_frame frame 
)
static

Definition at line 408 of file channel.c.

409{
410 /* Hangup channel. */
411 return -1;
412}

◆ moh_cleanup()

static void moh_cleanup ( struct ast_channel chan)
static

Definition at line 7823 of file channel.c.

7824{
7826 ast_moh_cleanup_ptr(chan);
7827}

References ast_moh_cleanup_ptr.

Referenced by ast_channel_destructor().

◆ namedgroup_cmp_cb()

static int namedgroup_cmp_cb ( void *  obj,
void *  arg,
int  flags 
)
static

Comparison function used for named group container.

Definition at line 7695 of file channel.c.

7696{
7697 const struct namedgroup_member *an = obj;
7698 const struct namedgroup_member *bn = arg;
7699
7700 return strcmp(an->name, bn->name) ? 0 : CMP_MATCH | CMP_STOP;
7701}
@ CMP_MATCH
Definition astobj2.h:1027
@ CMP_STOP
Definition astobj2.h:1028

References CMP_MATCH, CMP_STOP, and namedgroup_member::name.

Referenced by ast_get_namedgroups().

◆ namedgroup_hash_cb()

static int namedgroup_hash_cb ( const void *  obj,
const int  flags 
)
static

Hashing function used for named group container.

Definition at line 7704 of file channel.c.

7705{
7706 const struct namedgroup_member *member = obj;
7707
7708 return member->hash;
7709}

Referenced by ast_get_namedgroups().

◆ namedgroup_match()

static int namedgroup_match ( void *  obj,
void *  arg,
int  flags 
)
static

Definition at line 8148 of file channel.c.

8149{
8150 void *match;
8151
8152 match = ao2_find(arg, obj, OBJ_POINTER);
8154
8155 return match ? CMP_MATCH | CMP_STOP : 0;
8156}

References ao2_cleanup, ao2_find, CMP_MATCH, CMP_STOP, match(), and OBJ_POINTER.

Referenced by ast_namedgroups_intersect().

◆ party_id_build_data()

static int party_id_build_data ( unsigned char *  data,
size_t  datalen,
const struct ast_party_id id,
const char *  label,
const struct ast_party_id_ies ies,
const struct ast_set_party_id update 
)
static

Definition at line 8645 of file channel.c.

8648{
8649 size_t length;
8650 size_t pos = 0;
8651 int res;
8652
8653 /*
8654 * The size of integer values must be fixed in case the frame is
8655 * shipped to another machine.
8656 */
8657
8658 if (!update || update->name) {
8659 res = party_name_build_data(data + pos, datalen - pos, &id->name, label,
8660 &ies->name);
8661 if (res < 0) {
8662 return -1;
8663 }
8664 pos += res;
8665 }
8666
8667 if (!update || update->number) {
8668 res = party_number_build_data(data + pos, datalen - pos, &id->number, label,
8669 &ies->number);
8670 if (res < 0) {
8671 return -1;
8672 }
8673 pos += res;
8674 }
8675
8676 if (!update || update->subaddress) {
8677 res = party_subaddress_build_data(data + pos, datalen - pos, &id->subaddress,
8678 label, &ies->subaddress);
8679 if (res < 0) {
8680 return -1;
8681 }
8682 pos += res;
8683 }
8684
8685 /* *************** Party id user tag **************************** */
8686 if (id->tag) {
8687 length = strlen(id->tag);
8688 if (datalen < pos + (sizeof(data[0]) * 2) + length) {
8689 ast_log(LOG_WARNING, "No space left for %s tag\n", label);
8690 return -1;
8691 }
8692 data[pos++] = ies->tag;
8693 data[pos++] = length;
8694 memcpy(data + pos, id->tag, length);
8695 pos += length;
8696 }
8697
8698 /* *************** Party id combined presentation *************** */
8699 if (ies->combined_presentation && (!update || update->number)) {
8700 int presentation;
8701
8702 if (!update || update->name) {
8703 presentation = ast_party_id_presentation(id);
8704 } else {
8705 /*
8706 * We must compromise because not all the information is available
8707 * to determine a combined presentation value.
8708 * We will only send the number presentation instead.
8709 */
8710 presentation = id->number.presentation;
8711 }
8712
8713 if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8714 ast_log(LOG_WARNING, "No space left for %s combined presentation\n", label);
8715 return -1;
8716 }
8717 data[pos++] = ies->combined_presentation;
8718 data[pos++] = 1;
8719 data[pos++] = presentation;
8720 }
8721
8722 return pos;
8723}
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
Definition channel.c:1808
static int party_subaddress_build_data(unsigned char *data, size_t datalen, const struct ast_party_subaddress *subaddress, const char *label, const struct ast_party_subaddress_ies *ies)
Definition channel.c:8564
static int party_name_build_data(unsigned char *data, size_t datalen, const struct ast_party_name *name, const char *label, const struct ast_party_name_ies *ies)
Definition channel.c:8416
static int party_number_build_data(unsigned char *data, size_t datalen, const struct ast_party_number *number, const char *label, const struct ast_party_number_ies *ies)
Definition channel.c:8490
struct ast_party_subaddress_ies subaddress
Subscriber subaddress ies.
Definition channel.c:8620
int combined_presentation
Combined name and number presentation ie.
Definition channel.c:8627
struct ast_party_number_ies number
Subscriber phone number ies.
Definition channel.c:8618
int tag
User party id tag ie.
Definition channel.c:8622

References ast_log, ast_party_id_presentation(), ast_party_id_ies::combined_presentation, id, LOG_WARNING, ast_party_id_ies::name, ast_party_id_ies::number, party_name_build_data(), party_number_build_data(), party_subaddress_build_data(), ast_party_id_ies::subaddress, ast_party_id_ies::tag, and update().

Referenced by ast_connected_line_build_data(), and ast_redirecting_build_data().

◆ party_name_build_data()

static int party_name_build_data ( unsigned char *  data,
size_t  datalen,
const struct ast_party_name name,
const char *  label,
const struct ast_party_name_ies ies 
)
static

Definition at line 8416 of file channel.c.

8417{
8418 size_t length;
8419 size_t pos = 0;
8420
8421 /*
8422 * The size of integer values must be fixed in case the frame is
8423 * shipped to another machine.
8424 */
8425 if (name->str) {
8426 length = strlen(name->str);
8427 if (datalen < pos + (sizeof(data[0]) * 2) + length) {
8428 ast_log(LOG_WARNING, "No space left for %s name\n", label);
8429 return -1;
8430 }
8431 data[pos++] = ies->str;
8432 data[pos++] = length;
8433 memcpy(data + pos, name->str, length);
8434 pos += length;
8435 }
8436
8437 if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8438 ast_log(LOG_WARNING, "No space left for %s name char set\n", label);
8439 return -1;
8440 }
8441 data[pos++] = ies->char_set;
8442 data[pos++] = 1;
8443 data[pos++] = name->char_set;
8444
8445 if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8446 ast_log(LOG_WARNING, "No space left for %s name presentation\n", label);
8447 return -1;
8448 }
8449 data[pos++] = ies->presentation;
8450 data[pos++] = 1;
8451 data[pos++] = name->presentation;
8452
8453 if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8454 ast_log(LOG_WARNING, "No space left for %s name valid\n", label);
8455 return -1;
8456 }
8457 data[pos++] = ies->valid;
8458 data[pos++] = 1;
8459 data[pos++] = name->valid;
8460
8461 return pos;
8462}
int char_set
Character set ie.
Definition channel.c:8395
int presentation
presentation-indicator ie
Definition channel.c:8397
int valid
valid/present ie
Definition channel.c:8399

References ast_log, ast_party_name_ies::char_set, LOG_WARNING, name, ast_party_name_ies::presentation, ast_party_name_ies::str, and ast_party_name_ies::valid.

Referenced by party_id_build_data().

◆ party_number_build_data()

static int party_number_build_data ( unsigned char *  data,
size_t  datalen,
const struct ast_party_number number,
const char *  label,
const struct ast_party_number_ies ies 
)
static

Definition at line 8490 of file channel.c.

8491{
8492 size_t length;
8493 size_t pos = 0;
8494
8495 /*
8496 * The size of integer values must be fixed in case the frame is
8497 * shipped to another machine.
8498 */
8499 if (number->str) {
8500 length = strlen(number->str);
8501 if (datalen < pos + (sizeof(data[0]) * 2) + length) {
8502 ast_log(LOG_WARNING, "No space left for %s number\n", label);
8503 return -1;
8504 }
8505 data[pos++] = ies->str;
8506 data[pos++] = length;
8507 memcpy(data + pos, number->str, length);
8508 pos += length;
8509 }
8510
8511 if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8512 ast_log(LOG_WARNING, "No space left for %s numbering plan\n", label);
8513 return -1;
8514 }
8515 data[pos++] = ies->plan;
8516 data[pos++] = 1;
8517 data[pos++] = number->plan;
8518
8519 if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8520 ast_log(LOG_WARNING, "No space left for %s number presentation\n", label);
8521 return -1;
8522 }
8523 data[pos++] = ies->presentation;
8524 data[pos++] = 1;
8525 data[pos++] = number->presentation;
8526
8527 if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8528 ast_log(LOG_WARNING, "No space left for %s number valid\n", label);
8529 return -1;
8530 }
8531 data[pos++] = ies->valid;
8532 data[pos++] = 1;
8533 data[pos++] = number->valid;
8534
8535 return pos;
8536}
int presentation
presentation-indicator ie
Definition channel.c:8471
int str
Subscriber phone number ie.
Definition channel.c:8467
int valid
valid/present ie
Definition channel.c:8473
int plan
Type-Of-Number and Numbering-Plan ie.
Definition channel.c:8469

References ast_log, LOG_WARNING, ast_party_number_ies::plan, ast_party_number_ies::presentation, ast_party_number_ies::str, and ast_party_number_ies::valid.

Referenced by party_id_build_data().

◆ party_subaddress_build_data()

static int party_subaddress_build_data ( unsigned char *  data,
size_t  datalen,
const struct ast_party_subaddress subaddress,
const char *  label,
const struct ast_party_subaddress_ies ies 
)
static

Definition at line 8564 of file channel.c.

8565{
8566 size_t length;
8567 size_t pos = 0;
8568
8569 /*
8570 * The size of integer values must be fixed in case the frame is
8571 * shipped to another machine.
8572 */
8573 if (subaddress->str) {
8574 length = strlen(subaddress->str);
8575 if (datalen < pos + (sizeof(data[0]) * 2) + length) {
8576 ast_log(LOG_WARNING, "No space left for %s subaddress\n", label);
8577 return -1;
8578 }
8579 data[pos++] = ies->str;
8580 data[pos++] = length;
8581 memcpy(data + pos, subaddress->str, length);
8582 pos += length;
8583 }
8584
8585 if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8586 ast_log(LOG_WARNING, "No space left for %s type of subaddress\n", label);
8587 return -1;
8588 }
8589 data[pos++] = ies->type;
8590 data[pos++] = 1;
8591 data[pos++] = subaddress->type;
8592
8593 if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8595 "No space left for %s subaddress odd-even indicator\n", label);
8596 return -1;
8597 }
8598 data[pos++] = ies->odd_even_indicator;
8599 data[pos++] = 1;
8600 data[pos++] = subaddress->odd_even_indicator;
8601
8602 if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8603 ast_log(LOG_WARNING, "No space left for %s subaddress valid\n", label);
8604 return -1;
8605 }
8606 data[pos++] = ies->valid;
8607 data[pos++] = 1;
8608 data[pos++] = subaddress->valid;
8609
8610 return pos;
8611}
int str
subaddress ie.
Definition channel.c:8541
int odd_even_indicator
odd/even indicator ie
Definition channel.c:8545
int valid
valid/present ie
Definition channel.c:8547
int type
subaddress type ie
Definition channel.c:8543

References ast_log, LOG_WARNING, ast_party_subaddress::odd_even_indicator, ast_party_subaddress_ies::odd_even_indicator, ast_party_subaddress::str, ast_party_subaddress_ies::str, ast_party_subaddress::type, ast_party_subaddress_ies::type, ast_party_subaddress::valid, and ast_party_subaddress_ies::valid.

Referenced by party_id_build_data().

◆ plc_ds_destroy()

static void plc_ds_destroy ( void *  data)
static

Definition at line 5064 of file channel.c.

5065{
5066 struct plc_ds *plc = data;
5067 ast_free(plc->samples_buf);
5068 ast_free(plc);
5069}

References ast_free, and plc_ds::samples_buf.

◆ queue_dtmf_readq()

static void queue_dtmf_readq ( struct ast_channel chan,
struct ast_frame f 
)
inlinestatic

Definition at line 3483 of file channel.c.

3484{
3485 struct ast_frame *fr = ast_channel_dtmff(chan);
3486
3489 fr->len = f->len;
3490
3491 /* The only time this function will be called is for a frame that just came
3492 * out of the channel driver. So, we want to stick it on the tail of the
3493 * readq. */
3494
3495 ast_queue_frame(chan, fr);
3496}

References ast_channel_dtmff(), AST_FRAME_DTMF_END, ast_queue_frame(), ast_frame::frametype, ast_frame_subclass::integer, ast_frame::len, and ast_frame::subclass.

Referenced by __ast_read().

◆ redirecting_reason_build_data()

static int redirecting_reason_build_data ( unsigned char *  data,
size_t  datalen,
const struct ast_party_redirecting_reason reason,
const char *  label,
const struct ast_party_redirecting_reason_ies ies 
)
static

Definition at line 9303 of file channel.c.

9306{
9307 size_t length;
9308 size_t pos = 0;
9309 int32_t value;
9310
9311 if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) {
9312 ast_log(LOG_WARNING, "No space left for %s code\n", label);
9313 return -1;
9314 }
9315 data[pos++] = ies->code;
9316 data[pos++] = sizeof(value);
9317 value = htonl(reason->code);
9318 memcpy(data + pos, &value, sizeof(value));
9319 pos += sizeof(value);
9320
9321 if (reason->str) {
9322 length = strlen(reason->str);
9323 if (datalen < pos + (sizeof(data[0]) * 2) + length) {
9324 ast_log(LOG_WARNING, "No space left for %s string\n", label);
9325 return -1;
9326 }
9327 data[pos++] = ies->str;
9328 data[pos++] = length;
9329 memcpy(data + pos, reason->str, length);
9330 pos += length;
9331 }
9332
9333 return pos;
9334}

References ast_log, ast_party_redirecting_reason::code, ast_party_redirecting_reason_ies::code, LOG_WARNING, ast_party_redirecting_reason::str, ast_party_redirecting_reason_ies::str, and value.

Referenced by ast_redirecting_build_data().

◆ request_channel()

static struct ast_channel * request_channel ( const char *  type,
struct ast_format_cap request_cap,
struct ast_stream_topology topology,
const struct ast_assigned_ids assignedids,
const struct ast_channel requestor,
const char *  addr,
int *  cause 
)
static

Definition at line 6238 of file channel.c.

6240{
6241 struct chanlist *chan;
6242 struct ast_channel *c = NULL;
6243 int res;
6244 int foo;
6245
6246 if (!cause)
6247 cause = &foo;
6248 *cause = AST_CAUSE_NOTDEFINED;
6249
6251 ast_log(LOG_WARNING, "Unable to lock technology backend list\n");
6252 return NULL;
6253 }
6254
6255 AST_RWLIST_TRAVERSE(&backends, chan, list) {
6256 if (strcasecmp(type, chan->tech->type)) {
6257 continue;
6258 }
6259
6260 break;
6261 }
6262
6264
6265 if (!chan) {
6266 ast_log(LOG_WARNING, "No channel type registered for '%s'\n", type);
6267 *cause = AST_CAUSE_NOSUCHDRIVER;
6268 return NULL;
6269 }
6270
6271 /* Allow either format capabilities or stream topology to be provided and adapt */
6272 if (chan->tech->requester_with_stream_topology) {
6273 struct ast_stream_topology *tmp_converted_topology = NULL;
6274
6275 if (!topology && request_cap) {
6276 /* Turn the requested capabilities into a stream topology */
6277 topology = tmp_converted_topology = ast_stream_topology_create_from_format_cap(request_cap);
6278 }
6279
6280 c = chan->tech->requester_with_stream_topology(type, topology, assignedids, requestor, addr, cause);
6281
6282 ast_stream_topology_free(tmp_converted_topology);
6283 } else if (chan->tech->requester) {
6284 struct ast_format_cap *tmp_converted_cap = NULL;
6285 struct ast_format_cap *tmp_cap;
6286 RAII_VAR(struct ast_format *, tmp_fmt, NULL, ao2_cleanup);
6287 RAII_VAR(struct ast_format *, best_audio_fmt, NULL, ao2_cleanup);
6288 struct ast_format_cap *joint_cap;
6289
6290 if (!request_cap && topology) {
6291 /* Turn the request stream topology into capabilities */
6292 request_cap = tmp_converted_cap = ast_stream_topology_get_formats(topology);
6293 }
6294
6295 /* find the best audio format to use */
6297 if (!tmp_cap) {
6299 return NULL;
6300 }
6301
6303 if (!ast_format_cap_empty(tmp_cap)) {
6304 /* We have audio - is it possible to connect the various calls to each other?
6305 (Avoid this check for calls without audio, like text+video calls)
6306 */
6307 res = ast_translator_best_choice(tmp_cap, chan->tech->capabilities, &tmp_fmt, &best_audio_fmt);
6308 ao2_ref(tmp_cap, -1);
6309 if (res < 0) {
6310 struct ast_str *tech_codecs = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
6311 struct ast_str *request_codecs = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
6312
6313 ast_log(LOG_WARNING, "No translator path exists for channel type %s (native %s) to %s\n", type,
6314 ast_format_cap_get_names(chan->tech->capabilities, &tech_codecs),
6315 ast_format_cap_get_names(request_cap, &request_codecs));
6317 ao2_cleanup(tmp_converted_cap);
6318 return NULL;
6319 }
6320 }
6321
6322 /* XXX Only the audio format calculated as being the best for translation
6323 * purposes is used for the request. This is because we don't have the ability
6324 * to signal to the initiator which one of their codecs that was offered is
6325 * the one that was selected, particularly in a chain of Local channels.
6326 */
6328 if (!joint_cap) {
6329 ao2_cleanup(tmp_converted_cap);
6330 return NULL;
6331 }
6334 if (best_audio_fmt) { /* text+video call? then, this is NULL */
6335 ast_format_cap_append(joint_cap, best_audio_fmt, 0);
6336 }
6337 ao2_cleanup(tmp_converted_cap);
6338
6339 c = chan->tech->requester(type, joint_cap, assignedids, requestor, addr, cause);
6340 ao2_ref(joint_cap, -1);
6341 }
6342
6343 if (!c) {
6344 return NULL;
6345 }
6346
6347 if (requestor) {
6348 ast_callid callid;
6349
6350 ast_channel_lock_both(c, (struct ast_channel *) requestor);
6351
6352 /* Set the newly created channel's callid to the same as the requestor. */
6353 callid = ast_channel_callid(requestor);
6354 if (callid) {
6355 ast_channel_callid_set(c, callid);
6356 }
6357
6359 ast_channel_unlock((struct ast_channel *) requestor);
6360 }
6361
6362 if (set_security_requirements(requestor, c)) {
6363 ast_log(LOG_WARNING, "Setting security requirements failed\n");
6364 ast_hangup(c);
6366 return NULL;
6367 }
6368
6369 /* no need to generate a Newchannel event here; it is done in the channel_alloc call */
6370 return c;
6371}
#define AST_CAUSE_BEARERCAPABILITY_NOTAVAIL
Definition causes.h:130
#define AST_CAUSE_NOTDEFINED
Definition causes.h:155
#define AST_CAUSE_NOSUCHDRIVER
Definition causes.h:156
static int set_security_requirements(const struct ast_channel *requestor, struct ast_channel *out)
Definition channel.c:6198
void ast_channel_callid_set(struct ast_channel *chan, ast_callid value)
int ast_format_cap_empty(const struct ast_format_cap *cap)
Determine if a format cap has no formats in it.
Definition format_cap.c:744
void ast_format_cap_remove_by_type(struct ast_format_cap *cap, enum ast_media_type type)
Remove all formats matching a specific format type.
Definition format_cap.c:523
void ast_stream_topology_free(struct ast_stream_topology *topology)
Unreference and destroy a stream topology.
Definition stream.c:746
struct ast_stream_topology * ast_stream_topology_create_from_format_cap(struct ast_format_cap *cap)
A helper function that, given a format capabilities structure, creates a topology and separates the m...
Definition stream.c:851
struct ast_format_cap * ast_stream_topology_get_formats(struct ast_stream_topology *topology)
Create a format capabilities structure representing the topology.
Definition stream.c:933

References ao2_cleanup, ao2_ref, AST_CAUSE_BEARERCAPABILITY_NOTAVAIL, AST_CAUSE_NOSUCHDRIVER, AST_CAUSE_NOTDEFINED, ast_channel_callid(), ast_channel_callid_set(), ast_channel_lock_both, ast_channel_unlock, ast_format_cap_alloc, ast_format_cap_append, ast_format_cap_append_from_cap(), ast_format_cap_empty(), AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_cap_get_names(), AST_FORMAT_CAP_NAMES_LEN, ast_format_cap_remove_by_type(), ast_hangup(), ast_log, AST_MEDIA_TYPE_AUDIO, AST_MEDIA_TYPE_UNKNOWN, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_str_alloca, ast_stream_topology_create_from_format_cap(), ast_stream_topology_free(), ast_stream_topology_get_formats(), ast_translator_best_choice(), c, chanlist::chan, LOG_WARNING, NULL, RAII_VAR, set_security_requirements(), chanlist::tech, and type.

Referenced by ast_request(), and ast_request_with_stream_topology().

◆ safe_sleep_conditional()

static int safe_sleep_conditional ( struct ast_channel chan,
int  timeout_ms,
int(*)(void *)  cond,
void *  data,
unsigned int  generate_silence 
)
static

Wait, look for hangups and condition arg.

Definition at line 1485 of file channel.c.

1486{
1487 struct ast_frame *f;
1488 struct ast_silence_generator *silgen = NULL;
1489 int res = 0;
1490 struct timeval start;
1491 int ms;
1492 AST_LIST_HEAD_NOLOCK(, ast_frame) deferred_frames;
1493
1494 AST_LIST_HEAD_INIT_NOLOCK(&deferred_frames);
1495
1496 /* If no other generator is present, start silencegen while waiting */
1497 if (generate_silence && ast_opt_transmit_silence && !ast_channel_generatordata(chan)) {
1499 }
1500
1501 start = ast_tvnow();
1502 while ((ms = ast_remaining_ms(start, timeout_ms))) {
1503 struct ast_frame *dup_f = NULL;
1504
1505 if (cond && ((*cond)(data) == 0)) {
1506 break;
1507 }
1508 ms = ast_waitfor(chan, ms);
1509 if (ms < 0) {
1510 res = -1;
1511 break;
1512 }
1513 if (ms > 0) {
1514 f = ast_read(chan);
1515 if (!f) {
1516 res = -1;
1517 break;
1518 }
1519
1520 if (!ast_is_deferrable_frame(f)) {
1521 ast_frfree(f);
1522 continue;
1523 }
1524
1525 if ((dup_f = ast_frisolate(f))) {
1526 if (dup_f != f) {
1527 ast_frfree(f);
1528 }
1529 AST_LIST_INSERT_HEAD(&deferred_frames, dup_f, frame_list);
1530 }
1531 }
1532 }
1533
1534 /* stop silgen if present */
1535 if (silgen) {
1537 }
1538
1539 /* We need to free all the deferred frames, but we only need to
1540 * queue the deferred frames if there was no error and no
1541 * hangup was received
1542 */
1543 ast_channel_lock(chan);
1544 while ((f = AST_LIST_REMOVE_HEAD(&deferred_frames, frame_list))) {
1545 if (!res) {
1546 ast_queue_frame_head(chan, f);
1547 }
1548 ast_frfree(f);
1549 }
1550 ast_channel_unlock(chan);
1551
1552 return res;
1553}
int ast_is_deferrable_frame(const struct ast_frame *frame)
Should we keep this frame for later?
Definition channel.c:1454

References ast_channel_generatordata(), ast_channel_lock, ast_channel_start_silence_generator(), ast_channel_stop_silence_generator(), ast_channel_unlock, ast_frfree, ast_frisolate, ast_is_deferrable_frame(), AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_HEAD_NOLOCK, AST_LIST_INSERT_HEAD, AST_LIST_REMOVE_HEAD, ast_opt_transmit_silence, ast_queue_frame_head(), ast_read(), ast_remaining_ms(), ast_tvnow(), ast_waitfor(), cond, ast_frame::data, and NULL.

Referenced by ast_safe_sleep(), ast_safe_sleep_conditional(), and ast_safe_sleep_without_silence().

◆ send_dtmf_begin_event()

static void send_dtmf_begin_event ( struct ast_channel chan,
enum DtmfDirection  direction,
const char  digit 
)
static

Definition at line 3375 of file channel.c.

3377{
3378 RAII_VAR(struct ast_json *, channel_blob, NULL, ast_json_unref);
3379 char digit_str[] = { digit, '\0' };
3380
3381 channel_blob = ast_json_pack("{ s: s, s: s }",
3382 "digit", digit_str,
3383 "direction", dtmf_direction_to_string(direction));
3384
3385 if (channel_blob) {
3387 }
3388}
static const char * dtmf_direction_to_string(enum DtmfDirection direction)
Definition channel.c:3363
struct stasis_message_type * ast_channel_dtmf_begin_type(void)
Message type for when DTMF begins on a channel.

References ast_channel_dtmf_begin_type(), ast_channel_publish_blob(), ast_json_pack(), ast_json_unref(), digit, dtmf_direction_to_string(), NULL, and RAII_VAR.

Referenced by __ast_read(), and ast_write_stream().

◆ send_dtmf_end_event()

static void send_dtmf_end_event ( struct ast_channel chan,
enum DtmfDirection  direction,
const char  digit,
long  duration_ms 
)
static

Definition at line 3390 of file channel.c.

3392{
3393 RAII_VAR(struct ast_json *, channel_blob, NULL, ast_json_unref);
3394 RAII_VAR(struct ast_json *, cel_blob, NULL, ast_json_unref);
3395 char digit_str[] = { digit, '\0' };
3396
3397 channel_blob = ast_json_pack("{ s: s, s: s, s: I }",
3398 "digit", digit_str,
3399 "direction", dtmf_direction_to_string(direction),
3400 "duration_ms", (ast_json_int_t)duration_ms);
3401
3402 if (channel_blob) {
3404 }
3405
3406 cel_blob = ast_json_pack("{ s: s, s: { s: s, s: I }}",
3408 "extra",
3409 "digit", digit_str,
3410 "duration_ms", (ast_json_int_t)duration_ms);
3411
3412 if (cel_blob) {
3413 ast_cel_publish_event(chan, AST_CEL_DTMF, cel_blob);
3414 } else {
3415 ast_log(LOG_WARNING, "Unable to build extradata for DTMF CEL event on channel %s", ast_channel_name(chan));
3416 }
3417}
void ast_cel_publish_event(struct ast_channel *chan, enum ast_cel_event_type event_type, struct ast_json *blob)
Publish a CEL event.
Definition cel.c:1762
@ AST_CEL_DTMF
A DTMF digit was processed.
Definition cel.h:86
struct stasis_message_type * ast_channel_dtmf_end_type(void)
Message type for when DTMF ends on a channel.
AST_JSON_INT_T ast_json_int_t
Primarily used to cast when packing to an "I" type.
Definition json.h:87

References AST_CEL_DTMF, ast_cel_publish_event(), ast_channel_dtmf_end_type(), ast_channel_name(), ast_channel_publish_blob(), ast_json_pack(), ast_json_unref(), ast_log, digit, dtmf_direction_to_string(), LOG_WARNING, NULL, and RAII_VAR.

Referenced by __ast_read(), and ast_write_stream().

◆ send_flash_event()

static void send_flash_event ( struct ast_channel chan)
static

Definition at line 3419 of file channel.c.

3420{
3422}
struct stasis_message_type * ast_channel_flash_type(void)
Message type for when a hook flash occurs on a channel.

References ast_channel_flash_type(), ast_channel_publish_blob(), and NULL.

Referenced by __ast_read().

◆ send_wink_event()

static void send_wink_event ( struct ast_channel chan)
static

Definition at line 3424 of file channel.c.

3425{
3427}
struct stasis_message_type * ast_channel_wink_type(void)
Message type for when a wink occurs on a channel.

References ast_channel_publish_blob(), ast_channel_wink_type(), and NULL.

Referenced by __ast_read().

◆ set_channel_answer_time()

static void set_channel_answer_time ( struct ast_channel chan)
static

Definition at line 2627 of file channel.c.

2628{
2630 struct timeval answertime;
2631
2632 answertime = ast_tvnow();
2633 ast_channel_answertime_set(chan, &answertime);
2634 }
2635}
void ast_channel_answertime_set(struct ast_channel *chan, struct timeval *value)

References ast_channel_answertime(), ast_channel_answertime_set(), ast_tvnow(), and ast_tvzero().

Referenced by __ast_read(), and ast_raw_answer_with_stream_topology().

◆ set_format()

static int set_format ( struct ast_channel chan,
struct ast_format_cap cap_set,
const int  direction,
int  interleaved_stereo 
)
static

Definition at line 5616 of file channel.c.

5617{
5618 struct ast_trans_pvt *trans_pvt;
5619 struct ast_format_cap *cap_native;
5620 const struct set_format_access *access;
5621 struct ast_format *rawformat;
5622 struct ast_format *format;
5623 RAII_VAR(struct ast_format *, best_set_fmt, NULL, ao2_cleanup);
5624 RAII_VAR(struct ast_format *, best_native_fmt, NULL, ao2_cleanup);
5625 int res;
5626
5627 if (!direction) {
5628 /* reading */
5629 access = &set_format_access_read;
5630 } else {
5631 /* writing */
5632 access = &set_format_access_write;
5633 }
5634
5636 if (!best_set_fmt) {
5637 /*
5638 * Not setting any audio formats?
5639 * Assume a call without any sounds (video, text)
5640 */
5641 return 0;
5642 }
5643
5644 /* See if the underlying channel driver is capable of performing transcoding for us */
5645 res = ast_channel_setoption(chan, access->setoption,
5646 &best_set_fmt, sizeof(best_set_fmt), 0);
5647 if (!res) {
5648 ast_debug(1, "Channel driver natively set channel %s to %s format %s\n",
5649 ast_channel_name(chan), access->direction, ast_format_get_name(best_set_fmt));
5650
5651 ast_channel_lock(chan);
5653 if (!cap_native
5654 || ast_format_cap_append(cap_native, best_set_fmt, 0)) {
5655 ast_channel_unlock(chan);
5656 ao2_cleanup(cap_native);
5657 return -1;
5658 }
5659 ast_channel_nativeformats_set(chan, cap_native);
5660 ao2_cleanup(cap_native);
5661 access->set_format(chan, best_set_fmt);
5662 access->set_rawformat(chan, best_set_fmt);
5663
5664 trans_pvt = access->get_trans(chan);
5665 if (trans_pvt) {
5666 ast_translator_free_path(trans_pvt);
5667 access->set_trans(chan, NULL);
5668 }
5669 ast_channel_unlock(chan);
5670
5671 /* If there is a generator on the channel, it needs to know about this
5672 * change if it is the write format. */
5673 if (direction && ast_channel_generatordata(chan)) {
5675 }
5676
5677 return 0;
5678 }
5679
5680 ast_channel_lock(chan);
5681
5682 format = access->get_format(chan);
5683 rawformat = access->get_rawformat(chan);
5684 ast_assert(format != NULL);
5685 ast_assert(rawformat != NULL);
5686
5687 cap_native = ast_channel_nativeformats(chan);
5688 if (ast_format_cap_empty(cap_native)) {
5689 ast_channel_unlock(chan);
5690 ast_log(LOG_ERROR, "Unable to set format because channel %s supports no formats\n",
5691 ast_channel_name(chan));
5692 return -1;
5693 }
5694
5695 /* Find a translation path from the native format to one of the desired formats */
5696 if (!direction) {
5697 /* reading */
5698 res = ast_translator_best_choice(cap_set, cap_native, &best_set_fmt, &best_native_fmt);
5699 } else {
5700 /* writing */
5701 res = ast_translator_best_choice(cap_native, cap_set, &best_native_fmt, &best_set_fmt);
5702 }
5703 if (res < 0) {
5704 struct ast_str *codec_native = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
5705 struct ast_str *codec_set = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
5706
5707 ast_format_cap_get_names(cap_native, &codec_native);
5708 ast_channel_unlock(chan);
5709 ast_format_cap_get_names(cap_set, &codec_set);
5710
5711 ast_log(LOG_WARNING, "Unable to find a codec translation path: %s -> %s\n",
5712 ast_str_buffer(direction ? codec_set : codec_native),
5713 ast_str_buffer(direction ? codec_native : codec_set));
5714 return -1;
5715 }
5716
5717 /* Now we have a good choice for both. */
5718 trans_pvt = access->get_trans(chan);
5719 if ((ast_format_cmp(rawformat, best_native_fmt) != AST_FORMAT_CMP_NOT_EQUAL) &&
5720 (ast_format_cmp(format, best_set_fmt) != AST_FORMAT_CMP_NOT_EQUAL) &&
5721 ((ast_format_cmp(rawformat, format) != AST_FORMAT_CMP_NOT_EQUAL) || access->get_trans(chan))) {
5722 /* the channel is already in these formats, so nothing to do, unless the interleaved format is not set correctly */
5723 if (trans_pvt != NULL) {
5724 if (trans_pvt->interleaved_stereo == interleaved_stereo) {
5725 ast_channel_unlock(chan);
5726 return 0;
5727 }
5728 }
5729 }
5730
5731 /* Free any translation we have right now */
5732 if (trans_pvt) {
5733 ast_translator_free_path(trans_pvt);
5734 access->set_trans(chan, NULL);
5735 }
5736
5737 /* Build a translation path from the raw format to the desired format */
5738 if (ast_format_cmp(best_set_fmt, best_native_fmt) != AST_FORMAT_CMP_NOT_EQUAL) {
5739 /*
5740 * If we were able to swap the native format to the format that
5741 * has been requested, then there is no need to try to build
5742 * a translation path.
5743 */
5744 res = 0;
5745 } else {
5746 if (!direction) {
5747 /* reading */
5748 trans_pvt = ast_translator_build_path(best_set_fmt, best_native_fmt);
5749 if (trans_pvt) {
5750 trans_pvt->interleaved_stereo = 0;
5751 }
5752 } else {
5753 /* writing */
5754 trans_pvt = ast_translator_build_path(best_native_fmt, best_set_fmt);
5755 if (trans_pvt) {
5756 trans_pvt->interleaved_stereo = interleaved_stereo;
5757 }
5758 }
5759 access->set_trans(chan, trans_pvt);
5760 res = trans_pvt ? 0 : -1;
5761 }
5762
5763 if (!res) {
5764 access->set_format(chan, best_set_fmt);
5765 access->set_rawformat(chan, best_native_fmt);
5766
5767 ast_debug(1, "Channel %s setting %s format path: %s -> %s\n",
5768 ast_channel_name(chan),
5769 access->direction,
5770 ast_format_get_name(direction ? best_set_fmt : best_native_fmt),
5771 ast_format_get_name(direction ? best_native_fmt : best_set_fmt));
5772 }
5773
5774 ast_channel_unlock(chan);
5775
5776 /* If there is a generator on the channel, it needs to know about this
5777 * change if it is the write format. */
5778 if (direction && ast_channel_generatordata(chan)) {
5780 }
5781
5782 return res;
5783}
static void generator_write_format_change(struct ast_channel *chan)
Definition channel.c:2908
int ast_channel_setoption(struct ast_channel *chan, int option, void *data, int datalen, int block)
Sets an option on a channel.
Definition channel.c:7458
static const struct set_format_access set_format_access_write
Definition channel.c:5605
static const struct set_format_access set_format_access_read
Definition channel.c:5594
struct ast_format * ast_format_cap_get_best_by_type(const struct ast_format_cap *cap, enum ast_media_type type)
Get the most preferred format for a particular media type.
Definition format_cap.c:417
int interleaved_stereo
Definition translate.h:238
struct ast_format *(* get_format)(struct ast_channel *chan)
Definition channel.c:5587
void(* set_trans)(struct ast_channel *chan, struct ast_trans_pvt *value)
Definition channel.c:5586
void(* set_rawformat)(struct ast_channel *chan, struct ast_format *format)
Definition channel.c:5590
struct ast_trans_pvt *(* get_trans)(const struct ast_channel *chan)
Definition channel.c:5585
void(* set_format)(struct ast_channel *chan, struct ast_format *format)
Definition channel.c:5588
const char * direction
Definition channel.c:5584
struct ast_format *(* get_rawformat)(struct ast_channel *chan)
Definition channel.c:5589

References ao2_cleanup, ast_assert, ast_channel_generatordata(), ast_channel_lock, ast_channel_name(), ast_channel_nativeformats(), ast_channel_nativeformats_set(), ast_channel_setoption(), ast_channel_unlock, ast_debug, ast_format_cap_alloc, ast_format_cap_append, ast_format_cap_empty(), AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_cap_get_best_by_type(), ast_format_cap_get_names(), AST_FORMAT_CAP_NAMES_LEN, ast_format_cmp(), AST_FORMAT_CMP_NOT_EQUAL, ast_format_get_name(), ast_log, AST_MEDIA_TYPE_AUDIO, ast_str_alloca, ast_str_buffer(), ast_translator_best_choice(), ast_translator_build_path(), ast_translator_free_path(), set_format_access::direction, generator_write_format_change(), set_format_access::get_format, set_format_access::get_rawformat, set_format_access::get_trans, ast_trans_pvt::interleaved_stereo, LOG_ERROR, LOG_WARNING, NULL, RAII_VAR, set_format_access::set_format, set_format_access_read, set_format_access_write, set_format_access::set_rawformat, set_format_access::set_trans, and set_format_access::setoption.

Referenced by ast_set_read_format(), ast_set_read_format_from_cap(), ast_set_write_format(), ast_set_write_format_from_cap(), and ast_set_write_format_interleaved_stereo().

◆ set_security_requirements()

static int set_security_requirements ( const struct ast_channel requestor,
struct ast_channel out 
)
static

Definition at line 6198 of file channel.c.

6199{
6200 int ops[2][2] = {
6203 };
6204 int i;
6205 struct ast_channel *r = (struct ast_channel *) requestor; /* UGLY */
6206 struct ast_datastore *ds;
6207
6208 if (!requestor || !out) {
6209 return 0;
6210 }
6211
6214 struct ast_secure_call_store *encrypt = ds->data;
6215 ops[0][1] = encrypt->signaling;
6216 ops[1][1] = encrypt->media;
6217 } else {
6219 return 0;
6220 }
6222
6223 for (i = 0; i < 2; i++) {
6224 if (ops[i][1]) {
6225 if (ast_channel_setoption(out, ops[i][0], &ops[i][1], sizeof(ops[i][1]), 0)) {
6226 /* We require a security feature, but the channel won't provide it */
6227 return -1;
6228 }
6229 } else {
6230 /* We don't care if we can't clear the option on a channel that doesn't support it */
6231 ast_channel_setoption(out, ops[i][0], &ops[i][1], sizeof(ops[i][1]), 0);
6232 }
6233 }
6234
6235 return 0;
6236}
const struct ast_datastore_info secure_call_info
#define AST_OPTION_SECURE_MEDIA
#define AST_OPTION_SECURE_SIGNALING
FILE * out
Definition utils/frame.c:33

References ast_channel_datastore_find(), ast_channel_lock, ast_channel_setoption(), ast_channel_unlock, AST_OPTION_SECURE_MEDIA, AST_OPTION_SECURE_SIGNALING, ast_datastore::data, ast_secure_call_store::media, NULL, out, secure_call_info, and ast_secure_call_store::signaling.

Referenced by request_channel().

◆ should_skip_dtmf()

static int should_skip_dtmf ( struct ast_channel chan)
inlinestatic

Determine whether or not we should ignore DTMF in the readq.

Definition at line 3501 of file channel.c.

3502{
3504 /* We're in the middle of emulating a digit, or DTMF has been
3505 * explicitly deferred. Skip this digit, then. */
3506 return 1;
3507 }
3508
3509 if (!ast_tvzero(*ast_channel_dtmf_tv(chan)) &&
3511 /* We're not in the middle of a digit, but it hasn't been long enough
3512 * since the last digit, so we'll have to skip DTMF for now. */
3513 return 1;
3514 }
3515
3516 return 0;
3517}

References ast_channel_dtmf_tv(), ast_channel_flags(), AST_FLAG_DEFER_DTMF, AST_FLAG_EMULATE_DTMF, AST_MIN_DTMF_GAP, ast_test_flag, ast_tvdiff_ms(), ast_tvnow(), and ast_tvzero().

Referenced by __ast_read().

◆ should_trigger_dtmf_emulating()

static int should_trigger_dtmf_emulating ( struct ast_channel chan)
inlinestatic

Determine whether or not we have to trigger dtmf emulating using 50 fps timer events especially when no voice frames are received during dtmf processing (direct media or muted sender case using SIP INFO)

Definition at line 2855 of file channel.c.

2856{
2858 /* We're in the middle of emulating a digit, or DTMF has been
2859 * explicitly deferred. Trigger dtmf with periodic 50 pfs timer events, then. */
2860 return 1;
2861 }
2862
2863 if (!ast_tvzero(*ast_channel_dtmf_tv(chan)) &&
2865 /*
2866 * We're not in the middle of a digit, but it hasn't been long enough
2867 * since the last digit, so we'll have to trigger DTMF further on.
2868 * Using 2 times AST_MIN_DTMF_GAP to trigger readq reading for possible
2869 * buffered next dtmf event
2870 */
2871 return 1;
2872 }
2873
2874 return 0;
2875}

References ast_channel_dtmf_tv(), ast_channel_flags(), AST_FLAG_DEFER_DTMF, AST_FLAG_EMULATE_DTMF, AST_MIN_DTMF_GAP, ast_test_flag, ast_tvdiff_ms(), ast_tvnow(), and ast_tvzero().

Referenced by __ast_read(), and ast_deactivate_generator().

◆ silence_generator_alloc()

static void * silence_generator_alloc ( struct ast_channel chan,
void *  data 
)
static

Definition at line 8192 of file channel.c.

8193{
8194 /* just store the data pointer in the channel structure */
8195 return data;
8196}

◆ silence_generator_generate()

static int silence_generator_generate ( struct ast_channel chan,
void *  data,
int  len,
int  samples 
)
static

Definition at line 8203 of file channel.c.

8204{
8205 short buf[samples];
8206 struct ast_frame frame = {
8208 .data.ptr = buf,
8209 .samples = samples,
8210 .datalen = sizeof(buf),
8211 };
8213
8214 memset(buf, 0, sizeof(buf));
8215
8216 if (ast_write(chan, &frame))
8217 return -1;
8218
8219 return 0;
8220}

References ast_format_slin, AST_FRAME_VOICE, ast_write(), buf, ast_frame_subclass::format, ast_frame::frametype, ast_frame::samples, and ast_frame::subclass.

◆ silence_generator_release()

static void silence_generator_release ( struct ast_channel chan,
void *  data 
)
static

Definition at line 8198 of file channel.c.

8199{
8200 /* nothing to do */
8201}

◆ suppress_datastore_destroy_cb()

static void suppress_datastore_destroy_cb ( void *  data)
static

Definition at line 10776 of file channel.c.

10777{
10778 ao2_cleanup(data);
10779}

References ao2_cleanup.

◆ suppress_framehook_destroy_cb()

static void suppress_framehook_destroy_cb ( void *  data)
static

Definition at line 10786 of file channel.c.

10787{
10788 ao2_cleanup(data);
10789}

References ao2_cleanup.

Referenced by ast_channel_suppress().

◆ suppress_framehook_event_cb()

static struct ast_frame * suppress_framehook_event_cb ( struct ast_channel chan,
struct ast_frame frame,
enum ast_framehook_event  event,
void *  data 
)
static

Definition at line 10804 of file channel.c.

10805{
10806 struct suppress_data *suppress = data;
10807 int suppress_frame = 0;
10808
10809 if (!frame) {
10810 return NULL;
10811 }
10812
10813 if (frame->frametype != suppress->frametype) {
10814 return frame;
10815 }
10816
10818 suppress_frame = 1;
10819 } else if (event == AST_FRAMEHOOK_EVENT_WRITE && (suppress->direction & AST_MUTE_DIRECTION_WRITE)) {
10820 suppress_frame = 1;
10821 }
10822
10823 if (suppress_frame) {
10824 switch (frame->frametype) {
10825 case AST_FRAME_VOICE:
10827 ast_frfree(frame);
10828 }
10829 frame = &ast_null_frame;
10830 break;
10831 default:
10832 break;
10833 }
10834 }
10835
10836 return frame;
10837}
#define AST_MUTE_DIRECTION_READ
Definition channel.h:4831
#define AST_MUTE_DIRECTION_WRITE
Definition channel.h:4832
@ AST_FRAMEHOOK_EVENT_WRITE
Definition framehook.h:153
@ AST_FRAMEHOOK_EVENT_READ
Definition framehook.h:152

References AST_FRAME_VOICE, AST_FRAMEHOOK_EVENT_READ, AST_FRAMEHOOK_EVENT_WRITE, ast_frfree, AST_MUTE_DIRECTION_READ, AST_MUTE_DIRECTION_WRITE, ast_null_frame, suppress_data::direction, ast_frame::frametype, suppress_data::frametype, and NULL.

Referenced by ast_channel_suppress().

◆ suppress_framehook_fixup_cb()

static void suppress_framehook_fixup_cb ( void *  data,
int  framehook_id,
struct ast_channel old_chan,
struct ast_channel new_chan 
)
static

Definition at line 10797 of file channel.c.

10798{
10799 struct suppress_data *suppress = data;
10800
10801 suppress->framehook_id = framehook_id;
10802}

References suppress_data::framehook_id.

Referenced by ast_channel_suppress().

◆ suppress_get_datastore_information()

static const struct ast_datastore_info * suppress_get_datastore_information ( enum ast_frame_type  frametype)
static

Definition at line 10839 of file channel.c.

10840{
10841 switch (frametype) {
10842 case AST_FRAME_VOICE:
10844 default:
10845 return NULL;
10846 }
10847}
static const struct ast_datastore_info suppress_datastore_voice
Definition channel.c:10781

References AST_FRAME_VOICE, NULL, and suppress_datastore_voice.

Referenced by ast_channel_suppress(), and ast_channel_unsuppress().

◆ tech_write()

static int tech_write ( struct ast_channel chan,
struct ast_stream stream,
struct ast_stream default_stream,
struct ast_frame frame 
)
static

Definition at line 5155 of file channel.c.

5157{
5158 if (ast_channel_tech(chan)->write_stream) {
5159 return stream ? ast_channel_tech(chan)->write_stream(
5160 chan, ast_stream_get_position(stream), frame) : 0;
5161 }
5162
5163 return ((stream == default_stream) && ast_channel_tech(chan)->write) ?
5164 ast_channel_tech(chan)->write(chan, frame) : 0;
5165}

References ast_stream_get_position(), ast_channel_tech::write, write_stream(), and ast_channel_tech::write_stream.

Referenced by ast_write_stream().

◆ tonepair_alloc()

static void * tonepair_alloc ( struct ast_channel chan,
void *  params 
)
static

Definition at line 7534 of file channel.c.

7535{
7536 struct tonepair_state *ts;
7537 struct tonepair_def *td = params;
7538
7539 if (!(ts = ast_calloc(1, sizeof(*ts)))) {
7540 return NULL;
7541 }
7542
7545 ast_log(LOG_WARNING, "Unable to set '%s' to signed linear format (write)\n", ast_channel_name(chan));
7547 ts = NULL;
7548 } else {
7549 ts->fac1 = 2.0 * cos(2.0 * M_PI * (td->freq1 / 8000.0)) * 32768.0;
7550 ts->v1_1 = 0;
7551 ts->v2_1 = sin(-4.0 * M_PI * (td->freq1 / 8000.0)) * td->vol;
7552 ts->v3_1 = sin(-2.0 * M_PI * (td->freq1 / 8000.0)) * td->vol;
7553 ts->v2_1 = 0;
7554 ts->fac2 = 2.0 * cos(2.0 * M_PI * (td->freq2 / 8000.0)) * 32768.0;
7555 ts->v2_2 = sin(-4.0 * M_PI * (td->freq2 / 8000.0)) * td->vol;
7556 ts->v3_2 = sin(-2.0 * M_PI * (td->freq2 / 8000.0)) * td->vol;
7557 ts->duration = td->duration;
7558 ts->modulate = 0;
7559 }
7560 /* Let interrupts interrupt :) */
7562 return ts;
7563}
unsigned int cos
Definition chan_iax2.c:393
static void tonepair_release(struct ast_channel *chan, void *params)
Definition channel.c:7523
#define M_PI
Definition resample.c:83
struct ast_format * origwfmt
Definition channel.c:7514

References ao2_bump, ast_calloc, ast_channel_flags(), ast_channel_name(), ast_channel_writeformat(), AST_FLAG_WRITE_INT, ast_format_slin, ast_log, ast_set_flag, ast_set_write_format(), cos, tonepair_def::duration, tonepair_state::duration, tonepair_state::fac1, tonepair_state::fac2, tonepair_def::freq1, tonepair_def::freq2, LOG_WARNING, M_PI, tonepair_state::modulate, NULL, tonepair_state::origwfmt, tonepair_release(), tonepair_state::v1_1, tonepair_state::v2_1, tonepair_state::v2_2, tonepair_state::v3_1, tonepair_state::v3_2, and tonepair_def::vol.

◆ tonepair_generator()

static int tonepair_generator ( struct ast_channel chan,
void *  data,
int  len,
int  samples 
)
static

Definition at line 7565 of file channel.c.

7566{
7567 struct tonepair_state *ts = data;
7568 int x;
7569
7570 /* we need to prepare a frame with 16 * timelen samples as we're
7571 * generating SLIN audio
7572 */
7573 len = samples * 2;
7574
7575 if (len > sizeof(ts->data) / 2 - 1) {
7576 ast_log(LOG_WARNING, "Can't generate that much data!\n");
7577 return -1;
7578 }
7579 memset(&ts->f, 0, sizeof(ts->f));
7580 for (x=0;x<len/2;x++) {
7581 ts->v1_1 = ts->v2_1;
7582 ts->v2_1 = ts->v3_1;
7583 ts->v3_1 = (ts->fac1 * ts->v2_1 >> 15) - ts->v1_1;
7584
7585 ts->v1_2 = ts->v2_2;
7586 ts->v2_2 = ts->v3_2;
7587 ts->v3_2 = (ts->fac2 * ts->v2_2 >> 15) - ts->v1_2;
7588 if (ts->modulate) {
7589 int p;
7590 p = ts->v3_2 - 32768;
7591 if (p < 0) p = -p;
7592 p = ((p * 9) / 10) + 1;
7593 ts->data[x] = (ts->v3_1 * p) >> 15;
7594 } else
7595 ts->data[x] = ts->v3_1 + ts->v3_2;
7596 }
7599 ts->f.datalen = len;
7600 ts->f.samples = samples;
7602 ts->f.data.ptr = ts->data;
7603 ast_write(chan, &ts->f);
7604 ts->pos += x;
7605 if (ts->duration > 0) {
7606 if (ts->pos >= ts->duration * 8)
7607 return -1;
7608 }
7609 return 0;
7610}
struct ast_frame f
Definition channel.c:7518
short data[4000]
Definition channel.c:7520

References ast_format_slin, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log, ast_write(), ast_frame::data, tonepair_state::data, ast_frame::datalen, tonepair_state::duration, tonepair_state::f, tonepair_state::fac1, tonepair_state::fac2, ast_frame_subclass::format, ast_frame::frametype, len(), LOG_WARNING, tonepair_state::modulate, ast_frame::offset, tonepair_state::pos, ast_frame::ptr, ast_frame::samples, ast_frame::subclass, tonepair_state::v1_1, tonepair_state::v1_2, tonepair_state::v2_1, tonepair_state::v2_2, tonepair_state::v3_1, and tonepair_state::v3_2.

◆ tonepair_release()

static void tonepair_release ( struct ast_channel chan,
void *  params 
)
static

Definition at line 7523 of file channel.c.

7524{
7525 struct tonepair_state *ts = params;
7526
7527 if (chan) {
7528 ast_set_write_format(chan, ts->origwfmt);
7529 }
7530 ao2_cleanup(ts->origwfmt);
7531 ast_free(ts);
7532}

References ao2_cleanup, ast_free, ast_set_write_format(), and tonepair_state::origwfmt.

Referenced by tonepair_alloc().

◆ varshead_dtor()

static void varshead_dtor ( void *  obj)
static

Destructor for lists of variables.

Parameters
objAO2 object.

Definition at line 7910 of file channel.c.

7911{
7912 struct varshead *head = obj;
7913 struct ast_var_t *var;
7914
7915 while ((var = AST_RWLIST_REMOVE_HEAD(head, entries))) {
7917 }
7918}

References AST_RWLIST_REMOVE_HEAD, ast_var_delete(), ast_var_t::entries, and var.

Referenced by ast_channel_get_vars(), and channel_get_external_vars().

Variable Documentation

◆ ami_vars

struct external_vars ami_vars
static

◆ ari_vars

struct external_vars ari_vars
static

◆ ast_kill_tech

const struct ast_channel_tech ast_kill_tech

Kill the channel channel driver technology descriptor.

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

Note
Used by DTMF atxfer and zombie channels.

Definition at line 435 of file channel.c.

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

◆ ast_moh_cleanup_ptr

void(* ast_moh_cleanup_ptr) (struct ast_channel *) ( struct ast_channel ) = NULL
static

◆ ast_moh_start_ptr

int(* ast_moh_start_ptr) (struct ast_channel *, const char *, const char *) ( struct ast_channel ,
const char *  ,
const char *   
) = NULL
static

◆ ast_moh_stop_ptr

void(* ast_moh_stop_ptr) (struct ast_channel *) ( struct ast_channel ) = NULL
static

◆ backends

◆ bridge_features_info

const struct ast_datastore_info bridge_features_info
static
Initial value:
= {
.type = "bridge-features",
.destroy = features_destroy,
}
static void features_destroy(void *obj)
Definition channel.c:10965

Definition at line 10970 of file channel.c.

10970 {
10971 .type = "bridge-features",
10972 .destroy = features_destroy,
10973};

Referenced by ast_channel_feature_hooks_get(), and channel_feature_hooks_set_full().

◆ causes

const struct causes_map causes[]
static

Definition at line 137 of file channel.c.

137 {
138 { AST_CAUSE_UNALLOCATED, "UNALLOCATED", "Unallocated (unassigned) number" },
139 { AST_CAUSE_NO_ROUTE_TRANSIT_NET, "NO_ROUTE_TRANSIT_NET", "No route to specified transmit network" },
140 { AST_CAUSE_NO_ROUTE_DESTINATION, "NO_ROUTE_DESTINATION", "No route to destination" },
141 { AST_CAUSE_MISDIALLED_TRUNK_PREFIX, "MISDIALLED_TRUNK_PREFIX", "Misdialed trunk prefix" },
142 { AST_CAUSE_CHANNEL_UNACCEPTABLE, "CHANNEL_UNACCEPTABLE", "Channel unacceptable" },
143 { AST_CAUSE_CALL_AWARDED_DELIVERED, "CALL_AWARDED_DELIVERED", "Call awarded and being delivered in an established channel" },
144 { AST_CAUSE_PRE_EMPTED, "PRE_EMPTED", "Pre-empted" },
145 { AST_CAUSE_NUMBER_PORTED_NOT_HERE, "NUMBER_PORTED_NOT_HERE", "Number ported elsewhere" },
146 { AST_CAUSE_NORMAL_CLEARING, "NORMAL_CLEARING", "Normal Clearing" },
147 { AST_CAUSE_USER_BUSY, "USER_BUSY", "User busy" },
148 { AST_CAUSE_NO_USER_RESPONSE, "NO_USER_RESPONSE", "No user responding" },
149 { AST_CAUSE_NO_ANSWER, "NO_ANSWER", "User alerting, no answer" },
150 { AST_CAUSE_SUBSCRIBER_ABSENT, "SUBSCRIBER_ABSENT", "Subscriber absent" },
151 { AST_CAUSE_CALL_REJECTED, "CALL_REJECTED", "Call Rejected" },
152 { AST_CAUSE_NUMBER_CHANGED, "NUMBER_CHANGED", "Number changed" },
153 { AST_CAUSE_REDIRECTED_TO_NEW_DESTINATION, "REDIRECTED_TO_NEW_DESTINATION", "Redirected to new destination" },
154 { AST_CAUSE_ANSWERED_ELSEWHERE, "ANSWERED_ELSEWHERE", "Answered elsewhere" },
155 { AST_CAUSE_DESTINATION_OUT_OF_ORDER, "DESTINATION_OUT_OF_ORDER", "Destination out of order" },
156 { AST_CAUSE_INVALID_NUMBER_FORMAT, "INVALID_NUMBER_FORMAT", "Invalid number format" },
157 { AST_CAUSE_FACILITY_REJECTED, "FACILITY_REJECTED", "Facility rejected" },
158 { AST_CAUSE_RESPONSE_TO_STATUS_ENQUIRY, "RESPONSE_TO_STATUS_ENQUIRY", "Response to STATus ENQuiry" },
159 { AST_CAUSE_NORMAL_UNSPECIFIED, "NORMAL_UNSPECIFIED", "Normal, unspecified" },
160 { AST_CAUSE_NORMAL_CIRCUIT_CONGESTION, "NORMAL_CIRCUIT_CONGESTION", "Circuit/channel congestion" },
161 { AST_CAUSE_NETWORK_OUT_OF_ORDER, "NETWORK_OUT_OF_ORDER", "Network out of order" },
162 { AST_CAUSE_NORMAL_TEMPORARY_FAILURE, "NORMAL_TEMPORARY_FAILURE", "Temporary failure" },
163 { AST_CAUSE_SWITCH_CONGESTION, "SWITCH_CONGESTION", "Switching equipment congestion" },
164 { AST_CAUSE_ACCESS_INFO_DISCARDED, "ACCESS_INFO_DISCARDED", "Access information discarded" },
165 { AST_CAUSE_REQUESTED_CHAN_UNAVAIL, "REQUESTED_CHAN_UNAVAIL", "Requested channel not available" },
166 { AST_CAUSE_FACILITY_NOT_SUBSCRIBED, "FACILITY_NOT_SUBSCRIBED", "Facility not subscribed" },
167 { AST_CAUSE_OUTGOING_CALL_BARRED, "OUTGOING_CALL_BARRED", "Outgoing call barred" },
168 { AST_CAUSE_INCOMING_CALL_BARRED, "INCOMING_CALL_BARRED", "Incoming call barred" },
169 { AST_CAUSE_BEARERCAPABILITY_NOTAUTH, "BEARERCAPABILITY_NOTAUTH", "Bearer capability not authorized" },
170 { AST_CAUSE_BEARERCAPABILITY_NOTAVAIL, "BEARERCAPABILITY_NOTAVAIL", "Bearer capability not available" },
171 { AST_CAUSE_BEARERCAPABILITY_NOTIMPL, "BEARERCAPABILITY_NOTIMPL", "Bearer capability not implemented" },
172 { AST_CAUSE_CHAN_NOT_IMPLEMENTED, "CHAN_NOT_IMPLEMENTED", "Channel not implemented" },
173 { AST_CAUSE_FACILITY_NOT_IMPLEMENTED, "FACILITY_NOT_IMPLEMENTED", "Facility not implemented" },
174 { AST_CAUSE_INVALID_CALL_REFERENCE, "INVALID_CALL_REFERENCE", "Invalid call reference value" },
175 { AST_CAUSE_INCOMPATIBLE_DESTINATION, "INCOMPATIBLE_DESTINATION", "Incompatible destination" },
176 { AST_CAUSE_INVALID_MSG_UNSPECIFIED, "INVALID_MSG_UNSPECIFIED", "Invalid message unspecified" },
177 { AST_CAUSE_MANDATORY_IE_MISSING, "MANDATORY_IE_MISSING", "Mandatory information element is missing" },
178 { AST_CAUSE_MESSAGE_TYPE_NONEXIST, "MESSAGE_TYPE_NONEXIST", "Message type nonexist." },
179 { AST_CAUSE_WRONG_MESSAGE, "WRONG_MESSAGE", "Wrong message" },
180 { AST_CAUSE_IE_NONEXIST, "IE_NONEXIST", "Info. element nonexist or not implemented" },
181 { AST_CAUSE_INVALID_IE_CONTENTS, "INVALID_IE_CONTENTS", "Invalid information element contents" },
182 { AST_CAUSE_WRONG_CALL_STATE, "WRONG_CALL_STATE", "Message not compatible with call state" },
183 { AST_CAUSE_RECOVERY_ON_TIMER_EXPIRE, "RECOVERY_ON_TIMER_EXPIRE", "Recover on timer expiry" },
184 { AST_CAUSE_MANDATORY_IE_LENGTH_ERROR, "MANDATORY_IE_LENGTH_ERROR", "Mandatory IE length error" },
185 { AST_CAUSE_PROTOCOL_ERROR, "PROTOCOL_ERROR", "Protocol error, unspecified" },
186 { AST_CAUSE_INTERWORKING, "INTERWORKING", "Interworking, unspecified" },
187};
#define AST_CAUSE_SWITCH_CONGESTION
Definition causes.h:123
#define AST_CAUSE_NUMBER_PORTED_NOT_HERE
Definition causes.h:105
#define AST_CAUSE_INVALID_IE_CONTENTS
Definition causes.h:141
#define AST_CAUSE_UNALLOCATED
Definition causes.h:98
#define AST_CAUSE_INTERWORKING
Definition causes.h:146
#define AST_CAUSE_PROTOCOL_ERROR
Definition causes.h:145
#define AST_CAUSE_NUMBER_CHANGED
Definition causes.h:112
#define AST_CAUSE_CALL_AWARDED_DELIVERED
Definition causes.h:103
#define AST_CAUSE_INVALID_NUMBER_FORMAT
Definition causes.h:116
#define AST_CAUSE_OUTGOING_CALL_BARRED
Definition causes.h:127
#define AST_CAUSE_CHAN_NOT_IMPLEMENTED
Definition causes.h:132
#define AST_CAUSE_WRONG_MESSAGE
Definition causes.h:139
#define AST_CAUSE_INCOMPATIBLE_DESTINATION
Definition causes.h:135
#define AST_CAUSE_BEARERCAPABILITY_NOTAUTH
Definition causes.h:129
#define AST_CAUSE_DESTINATION_OUT_OF_ORDER
Definition causes.h:115
#define AST_CAUSE_NO_USER_RESPONSE
Definition causes.h:108
#define AST_CAUSE_NORMAL_TEMPORARY_FAILURE
Definition causes.h:122
#define AST_CAUSE_MESSAGE_TYPE_NONEXIST
Definition causes.h:138
#define AST_CAUSE_MANDATORY_IE_LENGTH_ERROR
Definition causes.h:144
#define AST_CAUSE_REDIRECTED_TO_NEW_DESTINATION
Definition causes.h:113
#define AST_CAUSE_FACILITY_NOT_SUBSCRIBED
Definition causes.h:126
#define AST_CAUSE_BEARERCAPABILITY_NOTIMPL
Definition causes.h:131
#define AST_CAUSE_WRONG_CALL_STATE
Definition causes.h:142
#define AST_CAUSE_PRE_EMPTED
Definition causes.h:104
#define AST_CAUSE_REQUESTED_CHAN_UNAVAIL
Definition causes.h:125
#define AST_CAUSE_NORMAL_CIRCUIT_CONGESTION
Definition causes.h:120
#define AST_CAUSE_CHANNEL_UNACCEPTABLE
Definition causes.h:102
#define AST_CAUSE_CALL_REJECTED
Definition causes.h:111
#define AST_CAUSE_SUBSCRIBER_ABSENT
Definition causes.h:110
#define AST_CAUSE_NETWORK_OUT_OF_ORDER
Definition causes.h:121
#define AST_CAUSE_INVALID_CALL_REFERENCE
Definition causes.h:134
#define AST_CAUSE_FACILITY_REJECTED
Definition causes.h:117
#define AST_CAUSE_ANSWERED_ELSEWHERE
Definition causes.h:114
#define AST_CAUSE_NORMAL_UNSPECIFIED
Definition causes.h:119
#define AST_CAUSE_FACILITY_NOT_IMPLEMENTED
Definition causes.h:133
#define AST_CAUSE_INCOMING_CALL_BARRED
Definition causes.h:128
#define AST_CAUSE_MANDATORY_IE_MISSING
Definition causes.h:137
#define AST_CAUSE_ACCESS_INFO_DISCARDED
Definition causes.h:124
#define AST_CAUSE_RECOVERY_ON_TIMER_EXPIRE
Definition causes.h:143
#define AST_CAUSE_NO_ROUTE_TRANSIT_NET
Definition causes.h:99
#define AST_CAUSE_RESPONSE_TO_STATUS_ENQUIRY
Definition causes.h:118
#define AST_CAUSE_NO_ROUTE_DESTINATION
Definition causes.h:100
#define AST_CAUSE_INVALID_MSG_UNSPECIFIED
Definition causes.h:136
#define AST_CAUSE_NORMAL_CLEARING
Definition causes.h:106
#define AST_CAUSE_MISDIALLED_TRUNK_PREFIX
Definition causes.h:101
#define AST_CAUSE_IE_NONEXIST
Definition causes.h:140
#define AST_CAUSE_USER_BUSY
Definition causes.h:107

Referenced by ast_cause2str(), ast_str2cause(), and dump_cause().

◆ cc_channel_datastore_info

const struct ast_datastore_info cc_channel_datastore_info
static
Initial value:
= {
.type = "Call Completion",
.duplicate = channel_cc_params_copy,
}
static void * channel_cc_params_copy(void *data)
Definition channel.c:10496
static void channel_cc_params_destroy(void *data)
Definition channel.c:10507

Definition at line 10513 of file channel.c.

10513 {
10514 .type = "Call Completion",
10515 .duplicate = channel_cc_params_copy,
10516 .destroy = channel_cc_params_destroy,
10517};

Referenced by ast_channel_cc_params_init(), and ast_channel_get_cc_config_params().

◆ chancount

int chancount
static

◆ channel_move_lock

ast_mutex_t channel_move_lock = AST_MUTEX_INIT_VALUE
static

Mutex that prevents multiple ast_channel_move() operations from occurring simultaneously. This is necessary since the involved channels have to be locked and unlocked throughout the move operation.

The most important data being protected are the masq and masqr data on channels. We don't want them getting criss-crossed due to multiple moves mucking with them.

Definition at line 10736 of file channel.c.

Referenced by ast_channel_move().

◆ cli_channel

struct ast_cli_entry cli_channel[]
static
Initial value:
= {
{ .handler = handle_cli_core_show_channeltypes , .summary = "List available channel types" ,},
{ .handler = handle_cli_core_show_channeltype , .summary = "Give more details on that channel type" ,}
}
static char * handle_cli_core_show_channeltype(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Show details about a channel driver - CLI command.
Definition channel.c:327
static char * handle_cli_core_show_channeltypes(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Show channel types - CLI command.
Definition channel.c:262

Definition at line 391 of file channel.c.

391 {
392 AST_CLI_DEFINE(handle_cli_core_show_channeltypes, "List available channel types"),
393 AST_CLI_DEFINE(handle_cli_core_show_channeltype, "Give more details on that channel type")
394};
#define AST_CLI_DEFINE(fn, txt,...)
Definition cli.h:197

Referenced by ast_channels_init(), and channels_shutdown().

◆ global_fin

unsigned long global_fin

The current value of the debug flags is stored in the two variables global_fin and global_fout (declared in main/channel.c)

Definition at line 99 of file channel.c.

Referenced by __ast_channel_alloc_ap(), and handle_core_set_debug_channel().

◆ global_fout

unsigned long global_fout

Definition at line 99 of file channel.c.

Referenced by __ast_channel_alloc_ap().

◆ null_tech

const struct ast_channel_tech null_tech
static
Initial value:
= {
.type = "NULL",
.description = "Null channel (should not see this)",
}

Definition at line 703 of file channel.c.

703 {
704 .type = "NULL",
705 .description = "Null channel (should not see this)",
706};

Referenced by __ast_channel_alloc_ap().

◆ plc_ds_info

const struct ast_datastore_info plc_ds_info
static
Initial value:
= {
.type = "plc",
.destroy = plc_ds_destroy,
}
static void plc_ds_destroy(void *data)
Definition channel.c:5064

Definition at line 5071 of file channel.c.

5071 {
5072 .type = "plc",
5073 .destroy = plc_ds_destroy,
5074};

Referenced by apply_plc().

◆ set_format_access_read

const struct set_format_access set_format_access_read
static

Definition at line 5594 of file channel.c.

5594 {
5595 .direction = "read",
5596 .get_trans = ast_channel_readtrans,
5597 .set_trans = ast_channel_readtrans_set,
5598 .get_format = ast_channel_readformat,
5599 .set_format = ast_channel_set_readformat,
5600 .get_rawformat = ast_channel_rawreadformat,
5601 .set_rawformat = ast_channel_set_rawreadformat,
5602 .setoption = AST_OPTION_FORMAT_READ,
5603};
#define AST_OPTION_FORMAT_READ

Referenced by set_format().

◆ set_format_access_write

const struct set_format_access set_format_access_write
static

Definition at line 5605 of file channel.c.

5605 {
5606 .direction = "write",
5607 .get_trans = ast_channel_writetrans,
5608 .set_trans = ast_channel_writetrans_set,
5609 .get_format = ast_channel_writeformat,
5610 .set_format = ast_channel_set_writeformat,
5611 .get_rawformat = ast_channel_rawwriteformat,
5612 .set_rawformat = ast_channel_set_rawwriteformat,
5613 .setoption = AST_OPTION_FORMAT_WRITE,
5614};
#define AST_OPTION_FORMAT_WRITE

Referenced by set_format().

◆ silence_generator

struct ast_generator silence_generator
static
Initial value:
= {
}
static int silence_generator_generate(struct ast_channel *chan, void *data, int len, int samples)
Definition channel.c:8203
static void silence_generator_release(struct ast_channel *chan, void *data)
Definition channel.c:8198
static void * silence_generator_alloc(struct ast_channel *chan, void *data)
Definition channel.c:8192

Definition at line 8222 of file channel.c.

8222 {
8223 .alloc = silence_generator_alloc,
8224 .release = silence_generator_release,
8225 .generate = silence_generator_generate,
8226};

Referenced by ast_channel_start_silence_generator(), and deactivate_silence_generator().

◆ suppress_datastore_voice

const struct ast_datastore_info suppress_datastore_voice
static
Initial value:
= {
.type = "suppressvoice",
}
static void suppress_datastore_destroy_cb(void *data)
Definition channel.c:10776

Definition at line 10781 of file channel.c.

10781 {
10782 .type = "suppressvoice",
10784};

Referenced by suppress_get_datastore_information().

◆ surrogate_tech

const struct ast_channel_tech surrogate_tech
static
Initial value:
= {
.type = "Surrogate",
.description = "Surrogate channel used to pull channel from an application",
.properties = AST_CHAN_TP_INTERNAL,
}
@ AST_CHAN_TP_INTERNAL
Channels with this particular technology are an implementation detail of Asterisk and should generall...
Definition channel.h:991

Channel technology used to extract a channel from a running application. The channel created with this technology will be immediately hung up - most external applications won't ever want to see this.

Definition at line 697 of file channel.c.

697 {
698 .type = "Surrogate",
699 .description = "Surrogate channel used to pull channel from an application",
700 .properties = AST_CHAN_TP_INTERNAL,
701};

Referenced by ast_channels_init(), and channels_shutdown().

◆ tonepair

struct ast_generator tonepair
static
Initial value:
= {
.alloc = tonepair_alloc,
.release = tonepair_release,
.generate = tonepair_generator,
}
static int tonepair_generator(struct ast_channel *chan, void *data, int len, int samples)
Definition channel.c:7565
static void * tonepair_alloc(struct ast_channel *chan, void *params)
Definition channel.c:7534

Definition at line 7612 of file channel.c.

7612 {
7613 .alloc = tonepair_alloc,
7614 .release = tonepair_release,
7615 .generate = tonepair_generator,
7616};

Referenced by ast_tonepair_start().