Wed Jan 8 2020 09:50:08

Asterisk developer's documentation


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/musiconhold.h"
#include "asterisk/say.h"
#include "asterisk/file.h"
#include "asterisk/cli.h"
#include "asterisk/translate.h"
#include "asterisk/manager.h"
#include "asterisk/cel.h"
#include "asterisk/chanvars.h"
#include "asterisk/linkedlists.h"
#include "asterisk/indications.h"
#include "asterisk/monitor.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/data.h"
#include "asterisk/features.h"
#include "asterisk/test.h"

Go to the source code of this file.

Data Structures

struct  ast_channel_iterator
 
struct  ast_epoll_data
 
struct  ast_party_id_ies
 
struct  ast_party_name_ies
 
struct  ast_party_number_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  plc_ds
 
struct  tonepair_def
 
struct  tonepair_state
 
struct  xfer_masquerade_ds
 

Macros

#define AST_DEFAULT_EMULATE_DTMF_DURATION   100
 
#define AST_MIN_DTMF_DURATION   80
 
#define AST_MIN_DTMF_GAP   45
 
#define DATA_EXPORT_CHANNEL(MEMBER)
 
#define FORMAT   "%-10.10s %-40.40s %-12.12s %-12.12s %-12.12s\n"
 
#define NUM_CHANNEL_BUCKETS   1567
 
#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
}
 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, 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
}
 Element identifiers for redirecting indication frame data. More...
 

Functions

int __ast_answer (struct ast_channel *chan, unsigned int delay, int cdr_answer)
 Answer a channel, with a selectable delay before returning. More...
 
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. More...
 
struct ast_channel__ast_channel_alloc (int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const char *linkedid, const int amaflag, const char *file, int line, const char *function, const char *name_fmt,...)
 Create a channel structure. More...
 
static struct ast_channel
*attribute_malloc 
__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 char *linkedid, const int amaflag, const char *file, int line, const char *function, const char *name_fmt, va_list ap1, va_list ap2)
 Create a new channel structure. More...
 
static int __ast_channel_masquerade (struct ast_channel *original, struct ast_channel *clonechan, struct ast_datastore *xfer_ds)
 
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)
 
struct ast_channel__ast_request_and_dial (const char *type, format_t format, const struct ast_channel *requestor, void *data, 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. More...
 
static void __init_state2str_threadbuf (void)
 
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 More...
 
int ast_answer (struct ast_channel *chan)
 Answer a channel. More...
 
void ast_begin_shutdown (int hangup)
 
format_t ast_best_codec (format_t fmts)
 Pick the best audio codec. More...
 
struct ast_channelast_bridged_channel (struct ast_channel *chan)
 Find bridged channel. More...
 
int ast_call (struct ast_channel *chan, char *addr, int timeout)
 Make a call. More...
 
struct ast_channelast_call_forward (struct ast_channel *caller, struct ast_channel *orig, int *timeout, format_t format, struct outgoing_helper *oh, int *outstate)
 Forwards a call to a new channel specified by the original channel's call_forward str. If possible, the new forwarded channel is created and returned while the original one is terminated. More...
 
void ast_cancel_shutdown (void)
 Cancel a shutdown in progress. More...
 
const char * ast_cause2str (int cause)
 Gives the string form of a given hangup cause. More...
 
void ast_change_name (struct ast_channel *chan, const char *newname)
 Change channel name. More...
 
struct ast_channelast_channel_alloc (int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const char *linkedid, const int amaflag, const char *name_fmt,...)
 
enum ast_bridge_result ast_channel_bridge (struct ast_channel *c0, struct ast_channel *c1, struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc)
 Bridge two channels together. More...
 
struct ast_channelast_channel_callback (ao2_callback_data_fn *cb_fn, void *arg, void *data, int ao2_flags)
 Call a function with every active channel. More...
 
int ast_channel_cc_params_init (struct ast_channel *chan, const struct ast_cc_config_params *base_params)
 Set up datastore with CCSS parameters for a channel. More...
 
static void ast_channel_change_linkedid (struct ast_channel *chan, const char *linkedid)
 
void ast_channel_clear_softhangup (struct ast_channel *chan, int flag)
 Clear a set of softhangup flags from a channel. More...
 
static int ast_channel_cmp_cb (void *obj, void *arg, int flags)
 
int ast_channel_cmpwhentohangup (struct ast_channel *chan, time_t offset)
 Compare a offset with the settings of when to hang a channel up. More...
 
int ast_channel_cmpwhentohangup_tv (struct ast_channel *chan, struct timeval offset)
 Compare a offset with when to hangup channel. More...
 
int ast_channel_connected_line_macro (struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *connected_info, int is_caller, int is_frame)
 Run a connected line interception macro and update a channel's connected line information. More...
 
int ast_channel_data_add_structure (struct ast_data *tree, struct ast_channel *chan, int add_bridged)
 Insert into an astdata tree, the channel structure. More...
 
int ast_channel_data_cmp_structure (const struct ast_data_search *tree, struct ast_channel *chan, const char *structure_name)
 Compare to channel structures using the data api. More...
 
int ast_channel_datastore_add (struct ast_channel *chan, struct ast_datastore *datastore)
 Add a datastore to a channel. More...
 
struct ast_datastoreast_channel_datastore_alloc (const struct ast_datastore_info *info, const char *uid)
 Create a channel data store object. More...
 
struct ast_datastoreast_channel_datastore_find (struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
 Find a datastore on a channel. More...
 
int ast_channel_datastore_free (struct ast_datastore *datastore)
 Free a channel data store object. More...
 
int ast_channel_datastore_inherit (struct ast_channel *from, struct ast_channel *to)
 Inherit datastores from a parent to a child. More...
 
int ast_channel_datastore_remove (struct ast_channel *chan, struct ast_datastore *datastore)
 Remove a datastore from a channel. More...
 
int ast_channel_defer_dtmf (struct ast_channel *chan)
 Set defer DTMF flag on channel. More...
 
static void ast_channel_destructor (void *obj)
 Free a channel structure. More...
 
int ast_channel_early_bridge (struct ast_channel *c0, struct ast_channel *c1)
 Bridge two channels together (early) More...
 
struct ast_channelast_channel_get_by_exten (const char *exten, const char *context)
 Find a channel by extension and context. More...
 
struct ast_channelast_channel_get_by_name (const char *name)
 Find a channel by name. More...
 
struct ast_channelast_channel_get_by_name_prefix (const char *name, size_t name_len)
 Find a channel by a name prefix. More...
 
int ast_channel_get_cc_agent_type (struct ast_channel *chan, char *agent_type, size_t size)
 Find the appropriate CC agent type to use given a channel. More...
 
struct ast_cc_config_paramsast_channel_get_cc_config_params (struct ast_channel *chan)
 Get the CCSS parameters from a channel. More...
 
int ast_channel_get_device_name (struct ast_channel *chan, char *device_name, size_t name_buffer_length)
 Get a device name given its channel structure. More...
 
static struct ast_channelast_channel_get_full (const char *name, size_t name_len, const char *exten, const char *context)
 
static int ast_channel_hash_cb (const void *obj, const int flags)
 
void ast_channel_inherit_variables (const struct ast_channel *parent, struct ast_channel *child)
 Inherits channel variable from parent to child channel. More...
 
struct ast_channel_iteratorast_channel_iterator_all_new (void)
 Create a new channel iterator. More...
 
struct ast_channel_iteratorast_channel_iterator_by_exten_new (const char *exten, const char *context)
 Create a new channel iterator based on extension. More...
 
struct ast_channel_iteratorast_channel_iterator_by_name_new (const char *name, size_t name_len)
 Create a new channel iterator based on name. More...
 
struct ast_channel_iteratorast_channel_iterator_destroy (struct ast_channel_iterator *i)
 Destroy a channel iterator. More...
 
struct ast_channelast_channel_iterator_next (struct ast_channel_iterator *i)
 Get the next channel for a channel iterator. More...
 
int ast_channel_make_compatible (struct ast_channel *chan, struct ast_channel *peer)
 Makes two channel formats compatible. More...
 
static int ast_channel_make_compatible_helper (struct ast_channel *from, struct ast_channel *to)
 Set up translation from one channel to another. More...
 
int ast_channel_masquerade (struct ast_channel *original, struct ast_channel *clone)
 Weird function made for call transfers. More...
 
int ast_channel_queryoption (struct ast_channel *chan, int option, void *data, int *datalen, int block)
 Checks the value of an option. More...
 
void ast_channel_queue_connected_line_update (struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
 Queue a connected line update frame on a channel. More...
 
void ast_channel_queue_redirecting_update (struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
 Queue a redirecting update frame on a channel. More...
 
const char * ast_channel_reason2str (int reason)
 return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument More...
 
int ast_channel_redirecting_macro (struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *redirecting_info, int is_caller, int is_frame)
 Run a redirecting interception macro and update a channel's redirecting information. More...
 
int ast_channel_register (const struct ast_channel_tech *tech)
 Register a new telephony channel in Asterisk. More...
 
struct ast_channelast_channel_release (struct ast_channel *chan)
 Unlink and release reference to a channel. More...
 
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. More...
 
int ast_channel_sendurl (struct ast_channel *chan, const char *url)
 Sends a URL on a given link Send URL on link. More...
 
void ast_channel_set_caller (struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update)
 Set the caller id information in the Asterisk channel. More...
 
void ast_channel_set_caller_event (struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update)
 Set the caller id information in the Asterisk channel and generate an AMI event if the caller id name or number changed. More...
 
void ast_channel_set_connected_line (struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
 Set the connected line information in the Asterisk channel. More...
 
void ast_channel_set_fd (struct ast_channel *chan, int which, int fd)
 
void ast_channel_set_linkgroup (struct ast_channel *chan, struct ast_channel *peer)
 Propagate the oldest linkedid between associated channels. More...
 
void ast_channel_set_redirecting (struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
 Set the redirecting id information in the Asterisk channel. More...
 
int ast_channel_setoption (struct ast_channel *chan, int option, void *data, int datalen, int block)
 Sets an option on a channel. More...
 
void ast_channel_setwhentohangup (struct ast_channel *chan, time_t offset)
 Set when to hang a channel up. More...
 
void ast_channel_setwhentohangup_tv (struct ast_channel *chan, struct timeval offset)
 Set when to hangup channel. More...
 
static int ast_channel_softhangup_cb (void *obj, void *arg, int flags)
 
struct ast_silence_generatorast_channel_start_silence_generator (struct ast_channel *chan)
 Starts a silence generator on the given channel. More...
 
void ast_channel_stop_silence_generator (struct ast_channel *chan, struct ast_silence_generator *state)
 Stops a previously-started silence generator on the given channel. More...
 
int ast_channel_supports_html (struct ast_channel *chan)
 Checks for HTML support on a channel. More...
 
int ast_channel_transfer_masquerade (struct ast_channel *target_chan, const struct ast_party_connected_line *target_id, int target_held, struct ast_channel *transferee_chan, const struct ast_party_connected_line *transferee_id, int transferee_held)
 Setup a masquerade to transfer a call. More...
 
void ast_channel_undefer_dtmf (struct ast_channel *chan)
 Unset defer DTMF flag on channel. More...
 
void ast_channel_unregister (const struct ast_channel_tech *tech)
 Unregister channel driver. More...
 
void ast_channel_update_connected_line (struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
 Indicate that the connected line information has changed. More...
 
void ast_channel_update_redirecting (struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
 Indicate that the redirecting id has changed. More...
 
void ast_channels_init (void)
 
struct ast_variableast_channeltype_list (void)
 return an ast_variable list of channeltypes More...
 
int ast_check_hangup (struct ast_channel *chan)
 Checks to see if a channel is needing hang up. More...
 
int ast_check_hangup_locked (struct ast_channel *chan)
 
int ast_connected_line_build_data (unsigned char *data, size_t datalen, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
 Build the connected line information data frame. More...
 
void ast_connected_line_copy_from_caller (struct ast_party_connected_line *dest, const struct ast_party_caller *src)
 Copy the caller information to the connected line information. More...
 
void ast_connected_line_copy_to_caller (struct ast_party_caller *dest, const struct ast_party_connected_line *src)
 Copy the connected line information to the caller information. More...
 
int ast_connected_line_parse_data (const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected)
 Parse connected line indication frame data. More...
 
 AST_DATA_STRUCTURE (ast_channel, DATA_EXPORT_CHANNEL)
 
void ast_deactivate_generator (struct ast_channel *chan)
 
int ast_do_masquerade (struct ast_channel *original)
 Masquerade a channel. More...
 
struct ast_channelast_dummy_channel_alloc (void)
 Create a fake channel structure. More...
 
static void ast_dummy_channel_destructor (void *obj)
 Free a dummy channel structure. More...
 
static enum ast_bridge_result ast_generic_bridge (struct ast_channel *c0, struct ast_channel *c1, struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc)
 
struct ast_channel_techast_get_channel_tech (const char *name)
 Get handle to channel driver based on name. More...
 
ast_group_t ast_get_group (const char *s)
 
int ast_hangup (struct ast_channel *chan)
 Hangup a channel. More...
 
int ast_indicate (struct ast_channel *chan, int condition)
 Indicates condition of channel. More...
 
int ast_indicate_data (struct ast_channel *chan, int _condition, const void *data, size_t datalen)
 Indicates condition of channel, with payload. More...
 
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_internal_timing_enabled (struct ast_channel *chan)
 Check if the channel can run in internal timing mode. More...
 
int ast_is_deferrable_frame (const struct ast_frame *frame)
 Should we keep this frame for later? More...
 
void ast_moh_cleanup (struct ast_channel *chan)
 
int ast_moh_start (struct ast_channel *chan, const char *mclass, const char *interpclass)
 Turn on music on hold on a given channel. More...
 
void ast_moh_stop (struct ast_channel *chan)
 Turn off music on hold on a given channel. More...
 
void ast_party_caller_copy (struct ast_party_caller *dest, const struct ast_party_caller *src)
 Copy the source caller information to the destination caller. More...
 
void ast_party_caller_free (struct ast_party_caller *doomed)
 Destroy the caller party contents. More...
 
void ast_party_caller_init (struct ast_party_caller *init)
 Initialize the given caller structure. More...
 
void ast_party_caller_set (struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update)
 Set the caller information based on another caller source. More...
 
void ast_party_caller_set_init (struct ast_party_caller *init, const struct ast_party_caller *guide)
 Initialize the given caller structure using the given guide for a set update operation. More...
 
void ast_party_connected_line_collect_caller (struct ast_party_connected_line *connected, struct ast_party_caller *caller)
 Collect the caller party information into a connected line structure. More...
 
void ast_party_connected_line_copy (struct ast_party_connected_line *dest, const struct ast_party_connected_line *src)
 Copy the source connected line information to the destination connected line. More...
 
void ast_party_connected_line_free (struct ast_party_connected_line *doomed)
 Destroy the connected line information contents. More...
 
void ast_party_connected_line_init (struct ast_party_connected_line *init)
 Initialize the given connected line structure. More...
 
void ast_party_connected_line_set (struct ast_party_connected_line *dest, const struct ast_party_connected_line *src, const struct ast_set_party_connected_line *update)
 Set the connected line information based on another connected line source. More...
 
void ast_party_connected_line_set_init (struct ast_party_connected_line *init, const struct ast_party_connected_line *guide)
 Initialize the given connected line structure using the given guide for a set update operation. More...
 
void ast_party_dialed_copy (struct ast_party_dialed *dest, const struct ast_party_dialed *src)
 Copy the source dialed party information to the destination dialed party. More...
 
void ast_party_dialed_free (struct ast_party_dialed *doomed)
 Destroy the dialed party contents. More...
 
void ast_party_dialed_init (struct ast_party_dialed *init)
 Initialize the given dialed structure. More...
 
void ast_party_dialed_set (struct ast_party_dialed *dest, const struct ast_party_dialed *src)
 Set the dialed information based on another dialed source. More...
 
void ast_party_dialed_set_init (struct ast_party_dialed *init, const struct ast_party_dialed *guide)
 Initialize the given dialed structure using the given guide for a set update operation. More...
 
void ast_party_id_copy (struct ast_party_id *dest, const struct ast_party_id *src)
 Copy the source party id information to the destination party id. More...
 
void ast_party_id_free (struct ast_party_id *doomed)
 Destroy the party id contents. More...
 
void ast_party_id_init (struct ast_party_id *init)
 Initialize the given party id structure. More...
 
int ast_party_id_presentation (const struct ast_party_id *id)
 Determine the overall presentation value for the given party. More...
 
void ast_party_id_set (struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update)
 Set the source party id information into the destination party id. More...
 
void ast_party_id_set_init (struct ast_party_id *init, const struct ast_party_id *guide)
 Initialize the given party id structure using the given guide for a set update operation. More...
 
void ast_party_name_copy (struct ast_party_name *dest, const struct ast_party_name *src)
 Copy the source party name information to the destination party name. More...
 
void ast_party_name_free (struct ast_party_name *doomed)
 Destroy the party name contents. More...
 
void ast_party_name_init (struct ast_party_name *init)
 Initialize the given name structure. More...
 
void ast_party_name_set (struct ast_party_name *dest, const struct ast_party_name *src)
 Set the source party name information into the destination party name. More...
 
void ast_party_name_set_init (struct ast_party_name *init, const struct ast_party_name *guide)
 Initialize the given party name structure using the given guide for a set update operation. More...
 
void ast_party_number_copy (struct ast_party_number *dest, const struct ast_party_number *src)
 Copy the source party number information to the destination party number. More...
 
void ast_party_number_free (struct ast_party_number *doomed)
 Destroy the party number contents. More...
 
void ast_party_number_init (struct ast_party_number *init)
 Initialize the given number structure. More...
 
void ast_party_number_set (struct ast_party_number *dest, const struct ast_party_number *src)
 Set the source party number information into the destination party number. More...
 
void ast_party_number_set_init (struct ast_party_number *init, const struct ast_party_number *guide)
 Initialize the given party number structure using the given guide for a set update operation. More...
 
void ast_party_redirecting_copy (struct ast_party_redirecting *dest, const struct ast_party_redirecting *src)
 Copy the source redirecting information to the destination redirecting. More...
 
void ast_party_redirecting_free (struct ast_party_redirecting *doomed)
 Destroy the redirecting information contents. More...
 
void ast_party_redirecting_init (struct ast_party_redirecting *init)
 Initialize the given redirecting structure. More...
 
void ast_party_redirecting_set (struct ast_party_redirecting *dest, const struct ast_party_redirecting *src, const struct ast_set_party_redirecting *update)
 Set the redirecting information based on another redirecting source. More...
 
void ast_party_redirecting_set_init (struct ast_party_redirecting *init, const struct ast_party_redirecting *guide)
 Initialize the given redirecting id structure using the given guide for a set update operation. More...
 
void ast_party_subaddress_copy (struct ast_party_subaddress *dest, const struct ast_party_subaddress *src)
 Copy the source party subaddress information to the destination party subaddress. More...
 
void ast_party_subaddress_free (struct ast_party_subaddress *doomed)
 Destroy the party subaddress contents. More...
 
void ast_party_subaddress_init (struct ast_party_subaddress *init)
 Initialize the given subaddress structure. More...
 
void ast_party_subaddress_set (struct ast_party_subaddress *dest, const struct ast_party_subaddress *src)
 Set the source party subaddress information into the destination party subaddress. More...
 
void ast_party_subaddress_set_init (struct ast_party_subaddress *init, const struct ast_party_subaddress *guide)
 Initialize the given party subaddress structure using the given guide for a set update operation. More...
 
int ast_plc_reload (void)
 Reload genericplc configuration value from codecs.conf. More...
 
void ast_poll_channel_add (struct ast_channel *chan0, struct ast_channel *chan1)
 
void ast_poll_channel_del (struct ast_channel *chan0, struct ast_channel *chan1)
 
char * ast_print_group (char *buf, int buflen, ast_group_t group)
 Print call group and pickup group —. More...
 
int ast_prod (struct ast_channel *chan)
 Send empty audio to prime a channel driver. More...
 
int ast_queue_control (struct ast_channel *chan, enum ast_control_frame_type control)
 Queue a control frame. More...
 
int ast_queue_control_data (struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen)
 Queue a control frame with payload. More...
 
int ast_queue_frame (struct ast_channel *chan, struct ast_frame *fin)
 Queue one or more frames to a channel's frame queue. More...
 
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. More...
 
int ast_queue_hangup (struct ast_channel *chan)
 Queue a hangup frame for channel. More...
 
int ast_queue_hangup_with_cause (struct ast_channel *chan, int cause)
 Queue a hangup frame for channel. More...
 
int ast_raw_answer (struct ast_channel *chan, int cdr_answer)
 Answer a channel. More...
 
struct ast_frameast_read (struct ast_channel *chan)
 Reads a frame. More...
 
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. More...
 
int ast_readstring (struct ast_channel *c, char *s, int len, int timeout, int ftimeout, char *enders)
 Reads multiple digits. More...
 
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. More...
 
char * ast_recvtext (struct ast_channel *chan, int timeout)
 Receives a text string from a channel Read a string of text from a channel. More...
 
int ast_redirecting_build_data (unsigned char *data, size_t datalen, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
 Build the redirecting id data frame. More...
 
int ast_redirecting_parse_data (const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting)
 Parse redirecting indication frame data. More...
 
struct ast_channelast_request (const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
 Requests a channel. More...
 
struct ast_channelast_request_and_dial (const char *type, format_t format, const struct ast_channel *requestor, void *data, 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. More...
 
int ast_safe_sleep (struct ast_channel *chan, int ms)
 Wait, look for hangups. More...
 
int ast_safe_sleep_conditional (struct ast_channel *chan, int timeout_ms, int(*cond)(void *), void *data)
 Wait, look for hangups and condition arg. More...
 
int ast_say_character_str (struct ast_channel *chan, const char *str, const char *ints, const char *lang)
 
int ast_say_digit_str (struct ast_channel *chan, const char *str, const char *ints, const char *lang)
 says digits of a string More...
 
int ast_say_digits (struct ast_channel *chan, int num, const char *ints, const char *lang)
 says digits More...
 
int ast_say_digits_full (struct ast_channel *chan, int num, const char *ints, const char *lang, int audiofd, int ctrlfd)
 
int ast_say_enumeration (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options)
 says an enumeration More...
 
int ast_say_number (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options)
 says a number More...
 
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. More...
 
int ast_senddigit_begin (struct ast_channel *chan, char digit)
 Send a DTMF digit to a channel. More...
 
int ast_senddigit_end (struct ast_channel *chan, char digit, unsigned int duration)
 Send a DTMF digit to a channel. More...
 
int ast_sendtext (struct ast_channel *chan, const char *text)
 Sends text to a channel. More...
 
void ast_set_callerid (struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani)
 Set caller ID number, name and ANI and generate AMI event. More...
 
void ast_set_hangupsource (struct ast_channel *chan, const char *source, int force)
 Set the source of the hangup in this channel and it's bridge. More...
 
static void ast_set_owners_and_peers (struct ast_channel *chan1, struct ast_channel *chan2)
 
int ast_set_read_format (struct ast_channel *chan, format_t fmt)
 Sets read format on channel chan Set read format for channel to whichever component of "format" is best. More...
 
void ast_set_variables (struct ast_channel *chan, struct ast_variable *vars)
 adds a list of channel variables to a channel More...
 
int ast_set_write_format (struct ast_channel *chan, format_t fmt)
 Sets write format on channel chan Set write format for channel to whichever component of "format" is best. More...
 
int ast_setstate (struct ast_channel *chan, enum ast_channel_state state)
 Change the state of a channel. More...
 
int ast_settimeout (struct ast_channel *c, unsigned int rate, int(*func)(const void *data), void *data)
 Enable or disable timer ticks for a channel. More...
 
int ast_settimeout_full (struct ast_channel *c, unsigned int rate, int(*func)(const void *data), void *data, unsigned int is_ao2_obj)
 
int ast_shutting_down (void)
 Returns non-zero if Asterisk is being shut down. More...
 
int ast_softhangup (struct ast_channel *chan, int cause)
 Softly hangup a channel, lock. More...
 
int ast_softhangup_nolock (struct ast_channel *chan, int cause)
 Softly hangup a channel, don't lock. More...
 
const char * ast_state2str (enum ast_channel_state state)
 Gives the string form of a given channel state. More...
 
int ast_str2cause (const char *name)
 Convert a symbolic hangup cause to number. More...
 
int ast_tonepair (struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
 
int ast_tonepair_start (struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
 
void ast_tonepair_stop (struct ast_channel *chan)
 
int ast_transfer (struct ast_channel *chan, char *dest)
 Transfer a call to dest, if the channel supports transfer. More...
 
char * ast_transfercapability2str (int transfercapability)
 Gives the string form of a given transfer capability. More...
 
int ast_undestroyed_channels (void)
 
void ast_uninstall_music_functions (void)
 
int ast_waitfor (struct ast_channel *c, int ms)
 Wait for input on a channel. More...
 
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. More...
 
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. More...
 
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. More...
 
int ast_waitfordigit (struct ast_channel *c, int ms)
 Waits for a digit. More...
 
int ast_waitfordigit_full (struct ast_channel *c, int timeout_ms, 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. More...
 
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. More...
 
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. More...
 
static void bridge_play_sounds (struct ast_channel *c0, struct ast_channel *c1)
 
static void bridge_playfile (struct ast_channel *chan, struct ast_channel *peer, const char *sound, int remain)
 
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. More...
 
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_data_add_flags (struct ast_data *tree, struct ast_channel *chan)
 
static struct
ast_channel_iterator
channel_iterator_search (const char *name, size_t name_len, const char *exten, const char *context)
 
const char * channelreloadreason2txt (enum channelreloadreason reason)
 Convert enum channelreloadreason to text string for manager event. More...
 
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. More...
 
static char * complete_channeltypes (struct ast_cli_args *a)
 
static int data_channels_provider_handler (const struct ast_data_search *search, struct ast_data *root)
 
static int data_channeltypes_provider_handler (const struct ast_data_search *search, struct ast_data *data_root)
 
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 void free_translation (struct ast_channel *clonechan)
 
static int generator_force (const void *data)
 
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. More...
 
static char * handle_cli_core_show_channeltypes (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 Show channel types - CLI command. More...
 
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 manager_bridge_event (int onoff, int type, struct ast_channel *c0, struct ast_channel *c1)
 Send manager event for bridge link and unlink events. More...
 
static void masquerade_colp_transfer (struct ast_channel *transferee, struct xfer_masquerade_ds *colp)
 
static const char * oldest_linkedid (const char *a, const char *b)
 
static void party_connected_line_copy_transfer (struct ast_party_connected_line *dest, const struct ast_party_connected_line *src)
 
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 void report_new_callerid (struct ast_channel *chan)
 
static void send_dtmf_event (struct ast_channel *chan, const char *direction, const char digit, const char *begin, const char *end)
 
static int set_format (struct ast_channel *chan, format_t fmt, format_t *rawformat, format_t *format, struct ast_trans_pvt **trans, const int direction)
 
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. More...
 
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 * 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 update_bridge_vars (struct ast_channel *c0, struct ast_channel *c1)
 
static void xfer_ds_destroy (void *data)
 

Variables

struct ast_channel_tech ast_kill_tech
 Kill the channel channel driver technology descriptor. More...
 
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 = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, 1 } , }
 
static struct causes_map causes []
 
static struct ast_datastore_info cc_channel_datastore_info
 
static int chancount
 
static struct ast_data_entry channel_providers []
 
static struct ao2_containerchannels
 All active channels on the system. More...
 
static struct ast_data_handler channels_provider
 
static struct ast_data_handler channeltypes_provider
 
static struct ast_cli_entry cli_channel []
 
unsigned long global_fin
 
unsigned long global_fout
 
static struct ast_channel_tech null_tech
 
static struct ast_datastore_info plc_ds_info
 
static int shutting_down
 Prevent new channel allocation if shutting down. More...
 
static struct ast_generator silence_generator
 
static struct ast_threadstorage state2str_threadbuf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_state2str_threadbuf , .custom_init = NULL , }
 
static struct ast_generator tonepair
 
static int uniqueint
 
static struct ast_datastore_info xfer_ds_info
 

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

#define AST_DEFAULT_EMULATE_DTMF_DURATION   100

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

Definition at line 111 of file channel.c.

Referenced by __ast_read(), and ast_senddigit().

#define AST_MIN_DTMF_DURATION   80

Minimum allowed digit length - 80ms

Definition at line 114 of file channel.c.

Referenced by __ast_read().

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

Referenced by __ast_read(), and should_skip_dtmf().

#define DATA_EXPORT_CHANNEL (   MEMBER)

Definition at line 164 of file channel.c.

#define FORMAT   "%-10.10s %-40.40s %-12.12s %-12.12s %-12.12s\n"
#define NUM_CHANNEL_BUCKETS   1567

Definition at line 148 of file channel.c.

Referenced by ast_channels_init().

#define STATE2STR_BUFSIZE   32

Definition at line 107 of file channel.c.

Referenced by ast_state2str().

Enumeration Type Documentation

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 

Definition at line 8806 of file channel.c.

8806  {
8810  AST_CONNECTED_LINE_ID_PRESENTATION,/* Combined number and name presentation. */
8823 };
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 
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 

Definition at line 9127 of file channel.c.

9127  {
9159 };
AST_REDIRECTING_REASON
redirecting reason codes.
Definition: callerid.h:390

Function Documentation

int __ast_answer ( struct ast_channel chan,
unsigned int  delay,
int  cdr_answer 
)

Answer a channel, with a selectable delay before returning.

Parameters
chanchannel to answer
delaymaximum amount of time to wait for incoming media
cdr_answerflag to control whether any associated CDR should be marked as 'answered'

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

References ast_channel::_state, ast_channel_lock, ast_channel_unlock, AST_CONTROL_HANGUP, ast_debug, 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_TEXT, 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(), errno, frames, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, MAX, ast_channel::name, and ast_frame::subclass.

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

2983 {
2984  int res = 0;
2985  enum ast_channel_state old_state;
2986 
2987  old_state = chan->_state;
2988  if ((res = ast_raw_answer(chan, cdr_answer))) {
2989  return res;
2990  }
2991 
2992  switch (old_state) {
2993  case AST_STATE_RINGING:
2994  case AST_STATE_RING:
2995  /* wait for media to start flowing, but don't wait any longer
2996  * than 'delay' or 500 milliseconds, whichever is longer
2997  */
2998  do {
3000  struct ast_frame *cur, *new;
3001  int timeout_ms = MAX(delay, 500);
3002  unsigned int done = 0;
3003  struct timeval start;
3004 
3005  AST_LIST_HEAD_INIT_NOLOCK(&frames);
3006 
3007  start = ast_tvnow();
3008  for (;;) {
3009  int ms = ast_remaining_ms(start, timeout_ms);
3010  ms = ast_waitfor(chan, ms);
3011  if (ms < 0) {
3012  ast_log(LOG_WARNING, "Error condition occurred when polling channel %s for a voice frame: %s\n", chan->name, strerror(errno));
3013  res = -1;
3014  break;
3015  }
3016  if (ms == 0) {
3017  ast_debug(2, "Didn't receive a media frame from %s within %u ms of answering. Continuing anyway\n", chan->name, MAX(delay, 500));
3018  break;
3019  }
3020  cur = ast_read(chan);
3021  if (!cur || ((cur->frametype == AST_FRAME_CONTROL) &&
3022  (cur->subclass.integer == AST_CONTROL_HANGUP))) {
3023  if (cur) {
3024  ast_frfree(cur);
3025  }
3026  res = -1;
3027  ast_debug(2, "Hangup of channel %s detected in answer routine\n", chan->name);
3028  break;
3029  }
3030 
3031  if ((new = ast_frisolate(cur)) != cur) {
3032  ast_frfree(cur);
3033  }
3034 
3035  AST_LIST_INSERT_HEAD(&frames, new, frame_list);
3036 
3037  /* if a specific delay period was requested, continue
3038  * until that delay has passed. don't stop just because
3039  * incoming media has arrived.
3040  */
3041  if (delay) {
3042  continue;
3043  }
3044 
3045  switch (new->frametype) {
3046  /* all of these frametypes qualify as 'media' */
3047  case AST_FRAME_VOICE:
3048  case AST_FRAME_VIDEO:
3049  case AST_FRAME_TEXT:
3050  case AST_FRAME_DTMF_BEGIN:
3051  case AST_FRAME_DTMF_END:
3052  case AST_FRAME_IMAGE:
3053  case AST_FRAME_HTML:
3054  case AST_FRAME_MODEM:
3055  done = 1;
3056  break;
3057  case AST_FRAME_CONTROL:
3058  case AST_FRAME_IAX:
3059  case AST_FRAME_NULL:
3060  case AST_FRAME_CNG:
3061  break;
3062  }
3063 
3064  if (done) {
3065  break;
3066  }
3067  }
3068 
3069  if (res == 0) {
3070  ast_channel_lock(chan);
3071  while ((cur = AST_LIST_REMOVE_HEAD(&frames, frame_list))) {
3072  ast_queue_frame_head(chan, cur);
3073  ast_frfree(cur);
3074  }
3075  ast_channel_unlock(chan);
3076  }
3077  } while (0);
3078  break;
3079  default:
3080  break;
3081  }
3082 
3083  return res;
3084 }
union ast_frame_subclass subclass
Definition: frame.h:146
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define LOG_WARNING
Definition: logger.h:144
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4383
ast_channel_state
ast_channel states
Definition: channelstate.h:35
for(;;)
Definition: ast_expr2.c:2460
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
struct ast_frame * ast_frisolate(struct ast_frame *fr)
Makes a frame independent of any static storage.
Definition: frame.c:391
static int frames
Definition: iax2-parser.c:49
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
#define MAX(a, b)
Definition: utils.h:228
int ast_raw_answer(struct ast_channel *chan, int cdr_answer)
Answer a channel.
Definition: channel.c:2930
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:818
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
Definition: linkedlists.h:224
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
Definition: utils.c:1615
enum ast_channel_state _state
Definition: channel.h:839
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: linkedlists.h:696
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int errno
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
Definition: linkedlists.h:666
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3539
Data structure associated with a single frame of data.
Definition: frame.h:142
enum ast_frame_type frametype
Definition: frame.h:144
#define ast_frfree(fr)
Definition: frame.h:583
int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to the head of a channel&#39;s frame queue.
Definition: channel.c:1563
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 6223 of file channel.c.

References ast_manager_event, ast_string_field_set, EVENT_FLAG_CALL, name, ast_channel::name, and ast_channel::uniqueid.

Referenced by ast_change_name(), and ast_do_masquerade().

6224 {
6225  ast_manager_event(chan, EVENT_FLAG_CALL, "Rename", "Channel: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", chan->name, newname, chan->uniqueid);
6226  ast_string_field_set(chan, name, newname);
6227 }
const ast_string_field uniqueid
Definition: channel.h:787
#define EVENT_FLAG_CALL
Definition: manager.h:72
#define ast_manager_event(chan, category, event, contents,...)
Definition: manager.h:221
const ast_string_field name
Definition: channel.h:787
static const char name[]
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:344
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 char *  linkedid,
const int  amaflag,
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.

Definition at line 1366 of file channel.c.

References __ast_channel_alloc_ap().

1372 {
1373  va_list ap1, ap2;
1374  struct ast_channel *result;
1375 
1376  va_start(ap1, name_fmt);
1377  va_start(ap2, name_fmt);
1378  result = __ast_channel_alloc_ap(needqueue, state, cid_num, cid_name, acctcode, exten, context,
1379  linkedid, amaflag, file, line, function, name_fmt, ap1, ap2);
1380  va_end(ap1);
1381  va_end(ap2);
1382 
1383  return result;
1384 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:109
Main Channel structure associated with a channel.
Definition: channel.h:742
const ast_string_field linkedid
Definition: channel.h:787
static char cid_num[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:157
static char cid_name[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:158
static struct ast_channel *attribute_malloc __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 char *linkedid, const int amaflag, const char *file, int line, const char *function, const char *name_fmt, va_list ap1, va_list ap2)
Create a new channel structure.
Definition: channel.c:1130
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:107
static struct ast_channel* attribute_malloc __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 char *  linkedid,
const int  amaflag,
const char *  file,
int  line,
const char *  function,
const char *  name_fmt,
va_list  ap1,
va_list  ap2 
)
static

Create a new channel structure.

Definition at line 1130 of file channel.c.

References __ao2_alloc_debug(), ast_channel::_state, accountcode, ast_channel::accountcode, ast_channel::alertpipe, ast_channel::amaflags, ao2_alloc, ao2_link, ARRAY_LEN, AST_ALERT_FD, ast_atomic_fetchadd_int(), ast_cdr_alloc(), ast_cdr_init(), ast_cdr_start(), AST_CEL_CHANNEL_START, ast_cel_report_event(), ast_channel_destructor(), ast_channel_set_fd(), ast_channel_unref, ast_config_AST_SYSTEM_NAME, ast_copy_string(), ast_default_accountcode, ast_default_amaflags, ast_get_channel_tech(), AST_LIST_HEAD_INIT_NOLOCK, ast_log(), ast_manager_event, ast_party_caller_init(), ast_party_connected_line_init(), ast_party_dialed_init(), ast_party_redirecting_init(), ast_state2str(), ast_strdup, ast_strdupa, ast_string_field_build, ast_string_field_build_va, ast_string_field_init, ast_string_field_set, ast_strlen_zero(), ast_timer_fd(), ast_timer_get_name(), ast_timer_open(), AST_TIMING_FD, ast_channel::autochans, ast_channel::caller, ast_channel::cdr, channels, ast_channel::connected, ast_channel::context, ast_channel::datastores, defaultlanguage, ast_channel::dialed, errno, EVENT_FLAG_CALL, ast_channel::exten, ast_channel::fds, ast_channel::fin, chanlist::flags, ast_channel::fout, global_fin, global_fout, ast_party_caller::id, language, LOG_WARNING, name, ast_party_id::name, ast_channel::name, null_tech, ast_party_id::number, ast_channel::priority, ast_channel::redirecting, S_OR, ast_channel::sched, sched_context_create(), state, ast_party_name::str, ast_party_number::str, ast_channel::streamid, chanlist::tech, ast_channel::tech, ast_channel::timer, ast_channel::timingfd, ast_channel::uniqueid, ast_party_name::valid, ast_party_number::valid, and ast_channel::varshead.

Referenced by __ast_channel_alloc(), and ast_channel_alloc().

1134 {
1135  struct ast_channel *tmp;
1136  int x;
1137  int flags;
1138  struct varshead *headp;
1139  char *tech = "", *tech2 = NULL;
1140 
1141  /* If shutting down, don't allocate any new channels */
1142  if (shutting_down) {
1143  ast_log(LOG_WARNING, "Channel allocation failed: Refusing due to active shutdown\n");
1144  return NULL;
1145  }
1146 
1147 #if defined(REF_DEBUG)
1148  tmp = __ao2_alloc_debug(sizeof(*tmp), ast_channel_destructor, "", file, line,
1149  function, 1);
1150 #elif defined(__AST_DEBUG_MALLOC)
1151  tmp = __ao2_alloc_debug(sizeof(*tmp), ast_channel_destructor, "", file, line,
1152  function, 0);
1153 #else
1154  tmp = ao2_alloc(sizeof(*tmp), ast_channel_destructor);
1155 #endif
1156  if (!tmp) {
1157  /* Channel structure allocation failure. */
1158  return NULL;
1159  }
1160 
1161  /*
1162  * Init file descriptors to unopened state so
1163  * the destructor can know not to close them.
1164  */
1165  tmp->timingfd = -1;
1166  for (x = 0; x < ARRAY_LEN(tmp->alertpipe); ++x) {
1167  tmp->alertpipe[x] = -1;
1168  }
1169  for (x = 0; x < ARRAY_LEN(tmp->fds); ++x) {
1170  tmp->fds[x] = -1;
1171  }
1172 #ifdef HAVE_EPOLL
1173  tmp->epfd = epoll_create(25);
1174 #endif
1175 
1176  if (!(tmp->sched = sched_context_create())) {
1177  ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n");
1178  return ast_channel_unref(tmp);
1179  }
1180 
1185 
1186  if (cid_name) {
1187  tmp->caller.id.name.valid = 1;
1188  tmp->caller.id.name.str = ast_strdup(cid_name);
1189  if (!tmp->caller.id.name.str) {
1190  return ast_channel_unref(tmp);
1191  }
1192  }
1193  if (cid_num) {
1194  tmp->caller.id.number.valid = 1;
1196  if (!tmp->caller.id.number.str) {
1197  return ast_channel_unref(tmp);
1198  }
1199  }
1200 
1201  if ((tmp->timer = ast_timer_open())) {
1202  if (strcmp(ast_timer_get_name(tmp->timer), "timerfd")) {
1203  needqueue = 0;
1204  }
1205  tmp->timingfd = ast_timer_fd(tmp->timer);
1206  }
1207 
1208  if (needqueue) {
1209  if (pipe(tmp->alertpipe)) {
1210  ast_log(LOG_WARNING, "Channel allocation failed: Can't create alert pipe! Try increasing max file descriptors with ulimit -n\n");
1211  return ast_channel_unref(tmp);
1212  } else {
1213  flags = fcntl(tmp->alertpipe[0], F_GETFL);
1214  if (fcntl(tmp->alertpipe[0], F_SETFL, flags | O_NONBLOCK) < 0) {
1215  ast_log(LOG_WARNING, "Channel allocation failed: Unable to set alertpipe nonblocking! (%d: %s)\n", errno, strerror(errno));
1216  return ast_channel_unref(tmp);
1217  }
1218  flags = fcntl(tmp->alertpipe[1], F_GETFL);
1219  if (fcntl(tmp->alertpipe[1], F_SETFL, flags | O_NONBLOCK) < 0) {
1220  ast_log(LOG_WARNING, "Channel allocation failed: Unable to set alertpipe nonblocking! (%d: %s)\n", errno, strerror(errno));
1221  return ast_channel_unref(tmp);
1222  }
1223  }
1224  }
1225 
1226  /*
1227  * This is the last place the channel constructor can fail.
1228  *
1229  * The destructor takes advantage of this fact to ensure that the
1230  * AST_CEL_CHANNEL_END is not posted if we have not posted the
1231  * AST_CEL_CHANNEL_START yet.
1232  */
1233  if ((ast_string_field_init(tmp, 128))) {
1234  return ast_channel_unref(tmp);
1235  }
1236 
1237  /* Always watch the alertpipe */
1238  ast_channel_set_fd(tmp, AST_ALERT_FD, tmp->alertpipe[0]);
1239  /* And timing pipe */
1241 
1242  /* Initial state */
1243  tmp->_state = state;
1244 
1245  tmp->streamid = -1;
1246 
1247  tmp->fin = global_fin;
1248  tmp->fout = global_fout;
1249 
1251  ast_string_field_build(tmp, uniqueid, "%li.%d", (long) time(NULL),
1253  } else {
1254  ast_string_field_build(tmp, uniqueid, "%s-%li.%d", ast_config_AST_SYSTEM_NAME,
1255  (long) time(NULL), ast_atomic_fetchadd_int(&uniqueint, 1));
1256  }
1257 
1258  if (!ast_strlen_zero(linkedid)) {
1259  ast_string_field_set(tmp, linkedid, linkedid);
1260  } else {
1261  ast_string_field_set(tmp, linkedid, tmp->uniqueid);
1262  }
1263 
1264  if (!ast_strlen_zero(name_fmt)) {
1265  char *slash, *slash2;
1266  /* Almost every channel is calling this function, and setting the name via the ast_string_field_build() call.
1267  * And they all use slightly different formats for their name string.
1268  * This means, to set the name here, we have to accept variable args, and call the string_field_build from here.
1269  * This means, that the stringfields must have a routine that takes the va_lists directly, and
1270  * uses them to build the string, instead of forming the va_lists internally from the vararg ... list.
1271  * This new function was written so this can be accomplished.
1272  */
1273  ast_string_field_build_va(tmp, name, name_fmt, ap1, ap2);
1274  tech = ast_strdupa(tmp->name);
1275  if ((slash = strchr(tech, '/'))) {
1276  if ((slash2 = strchr(slash + 1, '/'))) {
1277  tech2 = slash + 1;
1278  *slash2 = '\0';
1279  }
1280  *slash = '\0';
1281  }
1282  } else {
1283  /*
1284  * Start the string with '-' so it becomes an empty string
1285  * in the destructor.
1286  */
1287  ast_string_field_set(tmp, name, "-**Unknown**");
1288  }
1289 
1290  /* Reminder for the future: under what conditions do we NOT want to track cdrs on channels? */
1291 
1292  /* These 4 variables need to be set up for the cdr_init() to work right */
1293  if (amaflag)
1294  tmp->amaflags = amaflag;
1295  else
1297 
1298  if (!ast_strlen_zero(acctcode))
1299  ast_string_field_set(tmp, accountcode, acctcode);
1300  else
1302 
1303  if (!ast_strlen_zero(context))
1304  ast_copy_string(tmp->context, context, sizeof(tmp->context));
1305  else
1306  strcpy(tmp->context, "default");
1307 
1308  if (!ast_strlen_zero(exten))
1309  ast_copy_string(tmp->exten, exten, sizeof(tmp->exten));
1310  else
1311  strcpy(tmp->exten, "s");
1312 
1313  tmp->priority = 1;
1314 
1315  tmp->cdr = ast_cdr_alloc();
1316  ast_cdr_init(tmp->cdr, tmp);
1317  ast_cdr_start(tmp->cdr);
1318 
1320  ast_cel_report_event(tmp, AST_CEL_CHANNEL_START, NULL, NULL, NULL);
1321 
1322  headp = &tmp->varshead;
1324 
1326 
1328 
1330 
1331  tmp->tech = &null_tech;
1332 
1333  ao2_link(channels, tmp);
1334 
1335  /*
1336  * And now, since the channel structure is built, and has its name, let's
1337  * call the manager event generator with this Newchannel event. This is the
1338  * proper and correct place to make this call, but you sure do have to pass
1339  * a lot of data into this func to do it here!
1340  */
1341  if (ast_get_channel_tech(tech) || (tech2 && ast_get_channel_tech(tech2))) {
1342  ast_manager_event(tmp, EVENT_FLAG_CALL, "Newchannel",
1343  "Channel: %s\r\n"
1344  "ChannelState: %d\r\n"
1345  "ChannelStateDesc: %s\r\n"
1346  "CallerIDNum: %s\r\n"
1347  "CallerIDName: %s\r\n"
1348  "AccountCode: %s\r\n"
1349  "Exten: %s\r\n"
1350  "Context: %s\r\n"
1351  "Uniqueid: %s\r\n",
1352  tmp->name,
1353  state,
1355  S_OR(cid_num, ""),
1356  S_OR(cid_name, ""),
1357  tmp->accountcode,
1358  S_OR(exten, ""),
1359  S_OR(context, ""),
1360  tmp->uniqueid);
1361  }
1362 
1363  return tmp;
1364 }
enum sip_cc_notify_state state
Definition: chan_sip.c:842
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
Definition: channel.c:2308
static char accountcode[AST_MAX_ACCOUNT_CODE]
Definition: chan_iax2.c:383
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:109
Main Channel structure associated with a channel.
Definition: channel.h:742
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
#define ao2_link(arg1, arg2)
Definition: astobj2.h:785
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
#define ast_string_field_build_va(x, field, fmt, args1, args2)
Set a field to a complex (built) value.
Definition: stringfields.h:391
int priority
Definition: channel.h:841
int timingfd
Definition: channel.h:838
struct ast_channel_tech * ast_get_channel_tech(const char *name)
Get a channel technology structure by name.
Definition: channel.c:960
const ast_string_field uniqueid
Definition: channel.h:787
static struct ast_channel_tech null_tech
Definition: channel.c:1120
#define ast_strdup(a)
Definition: astmm.h:109
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2502
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
char context[AST_MAX_CONTEXT]
Definition: channel.h:868
#define LOG_WARNING
Definition: logger.h:144
int ast_cel_report_event(struct ast_channel *chan, enum ast_cel_event_type event_type, const char *userdefevname, const char *extra, struct ast_channel *peer2)
Report a channel event.
Definition: cel.c:645
unsigned int fout
Definition: channel.h:847
struct ast_timer * timer
Definition: channel.h:866
unsigned long global_fin
Definition: channel.c:104
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Definition: channel.h:814
channel birth
Definition: cel.h:50
#define EVENT_FLAG_CALL
Definition: manager.h:72
struct ast_timer * ast_timer_open(void)
Open a timer.
Definition: timing.c:123
char * str
Subscriber name (Malloced)
Definition: channel.h:214
unsigned long global_fout
Definition: channel.c:104
static int uniqueint
Definition: channel.c:101
struct ast_cdr * cdr
Definition: channel.h:766
int alertpipe[2]
Definition: channel.h:851
const char * ast_state2str(enum ast_channel_state)
Gives the string form of a given channel state.
Definition: channel.c:1007
int ast_default_amaflags
Definition: cdr.c:59
static char cid_num[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:157
#define AST_ALERT_FD
Definition: channel.h:163
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return * the previous value of *p. This can be used to handle reference co...
Definition: lock.h:603
char defaultlanguage[]
Definition: asterisk.c:227
#define ast_manager_event(chan, category, event, contents,...)
Definition: manager.h:221
const char * ast_config_AST_SYSTEM_NAME
Definition: asterisk.c:273
unsigned int flags
Definition: channel.h:850
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
void * __ao2_alloc_debug(const size_t data_size, ao2_destructor_fn destructor_fn, char *tag, const char *file, int line, const char *funcname, int ref_debug)
Definition: astobj2.c:335
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Definition: stringfields.h:249
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
char ast_default_accountcode[AST_MAX_ACCOUNT_CODE]
Definition: cdr.c:60
struct sched_context * sched
Definition: channel.h:756
static char language[MAX_LANGUAGE]
Definition: chan_alsa.c:108
int streamid
Definition: channel.h:835
int fds[AST_MAX_FDS]
Definition: channel.h:829
struct ast_party_dialed dialed
Dialed/Called information.
Definition: channel.h:797
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
void ast_cdr_start(struct ast_cdr *cdr)
Start a call.
Definition: cdr.c:727
void ast_party_dialed_init(struct ast_party_dialed *init)
Initialize the given dialed structure.
Definition: channel.c:2219
static int shutting_down
Prevent new channel allocation if shutting down.
Definition: channel.c:99
unsigned int fin
Definition: channel.h:845
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:197
#define AST_TIMING_FD
Definition: channel.h:164
enum ast_channel_state _state
Definition: channel.h:839
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:430
int errno
struct ast_channel::datastores datastores
static const char name[]
int ast_timer_fd(const struct ast_timer *handle)
Get a poll()-able file descriptor for a timer.
Definition: timing.c:158
#define ast_string_field_build(x, field, fmt, args...)
Set a field to a complex (built) value.
Definition: stringfields.h:367
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
Definition: channel.c:2631
static char cid_name[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:158
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
Definition: linkedlists.h:666
struct sched_context * sched_context_create(void)
New schedule context.
Definition: sched.c:246
static int chancount
Definition: channel.c:102
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:77
void ast_party_redirecting_init(struct ast_party_redirecting *init)
Initialize the given redirecting structure.
Definition: channel.c:2359
const ast_string_field accountcode
Definition: channel.h:787
static void ast_channel_destructor(void *obj)
Free a channel structure.
Definition: channel.c:2403
struct ast_channel::autochans autochans
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:107
const char * ast_timer_get_name(const struct ast_timer *handle)
Get name of timer in use.
Definition: timing.c:217
void ast_party_caller_init(struct ast_party_caller *init)
Initialize the given caller structure.
Definition: channel.c:2269
int amaflags
Definition: channel.h:843
struct ast_channel_tech * tech
Definition: channel.h:743
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
int ast_cdr_init(struct ast_cdr *cdr, struct ast_channel *chan)
Initialize based on a channel.
Definition: cdr.c:897
struct varshead varshead
Definition: channel.h:817
struct ast_cdr * ast_cdr_alloc(void)
Allocate a CDR record.
Definition: cdr.c:499
char exten[AST_MAX_EXTENSION]
Definition: channel.h:869
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:344
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
static int __ast_channel_masquerade ( struct ast_channel original,
struct ast_channel clonechan,
struct ast_datastore xfer_ds 
)
static

Definition at line 5987 of file channel.c.

References ast_channel::_bridge, ast_bridged_channel(), ast_channel_datastore_add(), ast_channel_lock_both, ast_channel_trylock, ast_channel_unlock, ast_debug, AST_FLAG_ZOMBIE, ast_log(), ast_null_frame, ast_queue_frame(), ast_test_flag, ast_channel_tech::get_base_channel, LOG_WARNING, ast_channel::masq, ast_channel::masqr, ast_channel::name, and ast_channel::tech.

Referenced by ast_channel_masquerade(), and ast_channel_transfer_masquerade().

5988 {
5989  int res = -1;
5990  struct ast_channel *final_orig, *final_clone, *base;
5991 
5992  for (;;) {
5993  final_orig = original;
5994  final_clone = clonechan;
5995 
5996  ast_channel_lock_both(original, clonechan);
5997 
5998  if (ast_test_flag(original, AST_FLAG_ZOMBIE)
5999  || ast_test_flag(clonechan, AST_FLAG_ZOMBIE)) {
6000  /* Zombies! Run! */
6002  "Can't setup masquerade. One or both channels is dead. (%s <-- %s)\n",
6003  original->name, clonechan->name);
6004  ast_channel_unlock(clonechan);
6005  ast_channel_unlock(original);
6006  return -1;
6007  }
6008 
6009  /*
6010  * Each of these channels may be sitting behind a channel proxy
6011  * (i.e. chan_agent) and if so, we don't really want to
6012  * masquerade it, but its proxy
6013  */
6014  if (original->_bridge
6015  && (original->_bridge != ast_bridged_channel(original))
6016  && (original->_bridge->_bridge != original)) {
6017  final_orig = original->_bridge;
6018  }
6019  if (clonechan->_bridge
6020  && (clonechan->_bridge != ast_bridged_channel(clonechan))
6021  && (clonechan->_bridge->_bridge != clonechan)) {
6022  final_clone = clonechan->_bridge;
6023  }
6024  if (final_clone->tech->get_base_channel
6025  && (base = final_clone->tech->get_base_channel(final_clone))) {
6026  final_clone = base;
6027  }
6028 
6029  if ((final_orig != original) || (final_clone != clonechan)) {
6030  /*
6031  * Lots and lots of deadlock avoidance. The main one we're
6032  * competing with is ast_write(), which locks channels
6033  * recursively, when working with a proxy channel.
6034  */
6035  if (ast_channel_trylock(final_orig)) {
6036  ast_channel_unlock(clonechan);
6037  ast_channel_unlock(original);
6038 
6039  /* Try again */
6040  continue;
6041  }
6042  if (ast_channel_trylock(final_clone)) {
6043  ast_channel_unlock(final_orig);
6044  ast_channel_unlock(clonechan);
6045  ast_channel_unlock(original);
6046 
6047  /* Try again */
6048  continue;
6049  }
6050  ast_channel_unlock(clonechan);
6051  ast_channel_unlock(original);
6052  original = final_orig;
6053  clonechan = final_clone;
6054 
6055  if (ast_test_flag(original, AST_FLAG_ZOMBIE)
6056  || ast_test_flag(clonechan, AST_FLAG_ZOMBIE)) {
6057  /* Zombies! Run! */
6059  "Can't setup masquerade. One or both channels is dead. (%s <-- %s)\n",
6060  original->name, clonechan->name);
6061  ast_channel_unlock(clonechan);
6062  ast_channel_unlock(original);
6063  return -1;
6064  }
6065  }
6066  break;
6067  }
6068 
6069  if (original == clonechan) {
6070  ast_log(LOG_WARNING, "Can't masquerade channel '%s' into itself!\n", original->name);
6071  ast_channel_unlock(clonechan);
6072  ast_channel_unlock(original);
6073  return -1;
6074  }
6075 
6076  ast_debug(1, "Planning to masquerade channel %s into the structure of %s\n",
6077  clonechan->name, original->name);
6078 
6079  if (!original->masqr && !original->masq && !clonechan->masq && !clonechan->masqr) {
6080  original->masq = clonechan;
6081  clonechan->masqr = original;
6082  if (xfer_ds) {
6083  ast_channel_datastore_add(original, xfer_ds);
6084  }
6085  ast_queue_frame(original, &ast_null_frame);
6086  ast_queue_frame(clonechan, &ast_null_frame);
6087  ast_debug(1, "Done planning to masquerade channel %s into the structure of %s\n", clonechan->name, original->name);
6088  res = 0;
6089  } else if (original->masq) {
6090  ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
6091  original->masq->name, original->name);
6092  } else if (original->masqr) {
6093  /* not yet as a previously planned masq hasn't yet happened */
6094  ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
6095  original->name, original->masqr->name);
6096  } else if (clonechan->masq) {
6097  ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
6098  clonechan->masq->name, clonechan->name);
6099  } else { /* (clonechan->masqr) */
6100  ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
6101  clonechan->name, clonechan->masqr->name);
6102  }
6103 
6104  ast_channel_unlock(clonechan);
6105  ast_channel_unlock(original);
6106 
6107  return res;
6108 }
struct ast_channel * masqr
Definition: channel.h:752
Main Channel structure associated with a channel.
Definition: channel.h:742
struct ast_channel * masq
Definition: channel.h:751
struct ast_frame ast_null_frame
Definition: frame.c:131
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define LOG_WARNING
Definition: logger.h:144
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
struct ast_channel * _bridge
Definition: channel.h:748
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
Definition: channel.c:7160
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
struct ast_channel *(* get_base_channel)(struct ast_channel *chan)
Retrieve base channel (agent and local)
Definition: channel.h:606
#define ast_channel_unlock(chan)
Definition: channel.h:2467
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition: channel.h:2473
#define ast_channel_trylock(chan)
Definition: channel.h:2468
struct ast_channel_tech * tech
Definition: channel.h:743
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition: channel.c:2590
static int __ast_queue_frame ( struct ast_channel chan,
struct ast_frame fin,
int  head,
struct ast_frame after 
)
static

Definition at line 1438 of file channel.c.

References ast_channel::alertpipe, ast_channel_lock, ast_channel_unlock, AST_CONTROL_END_OF_Q, AST_CONTROL_HANGUP, 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(), ast_channel::blocker, errno, f, frames, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, ast_channel::name, ast_channel::readq, ast_frame::subclass, ast_channel::timer, and ast_channel::timingfd.

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

1439 {
1440  struct ast_frame *f;
1441  struct ast_frame *cur;
1442  unsigned int new_frames = 0;
1443  unsigned int new_voice_frames = 0;
1444  unsigned int queued_frames = 0;
1445  unsigned int queued_voice_frames = 0;
1447 
1448  ast_channel_lock(chan);
1449 
1450  /*
1451  * Check the last frame on the queue if we are queuing the new
1452  * frames after it.
1453  */
1454  cur = AST_LIST_LAST(&chan->readq);
1455  if (cur && cur->frametype == AST_FRAME_CONTROL && !head && (!after || after == cur)) {
1456  switch (cur->subclass.integer) {
1457  case AST_CONTROL_END_OF_Q:
1458  if (fin->frametype == AST_FRAME_CONTROL
1459  && fin->subclass.integer == AST_CONTROL_HANGUP) {
1460  /*
1461  * Destroy the end-of-Q marker frame so we can queue the hangup
1462  * frame in its place.
1463  */
1464  AST_LIST_REMOVE(&chan->readq, cur, frame_list);
1465  ast_frfree(cur);
1466 
1467  /*
1468  * This has degenerated to a normal queue append anyway. Since
1469  * we just destroyed the last frame in the queue we must make
1470  * sure that "after" is NULL or bad things will happen.
1471  */
1472  after = NULL;
1473  break;
1474  }
1475  /* Fall through */
1476  case AST_CONTROL_HANGUP:
1477  /* Don't queue anything. */
1478  ast_channel_unlock(chan);
1479  return 0;
1480  default:
1481  break;
1482  }
1483  }
1484 
1485  /* Build copies of all the new frames and count them */
1486  AST_LIST_HEAD_INIT_NOLOCK(&frames);
1487  for (cur = fin; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
1488  if (!(f = ast_frdup(cur))) {
1489  if (AST_LIST_FIRST(&frames)) {
1490  ast_frfree(AST_LIST_FIRST(&frames));
1491  }
1492  ast_channel_unlock(chan);
1493  return -1;
1494  }
1495 
1496  AST_LIST_INSERT_TAIL(&frames, f, frame_list);
1497  new_frames++;
1498  if (f->frametype == AST_FRAME_VOICE) {
1499  new_voice_frames++;
1500  }
1501  }
1502 
1503  /* Count how many frames exist on the queue */
1504  AST_LIST_TRAVERSE(&chan->readq, cur, frame_list) {
1505  queued_frames++;
1506  if (cur->frametype == AST_FRAME_VOICE) {
1507  queued_voice_frames++;
1508  }
1509  }
1510 
1511  if ((queued_frames + new_frames > 128 || queued_voice_frames + new_voice_frames > 96)) {
1512  int count = 0;
1513  ast_log(LOG_WARNING, "Exceptionally long %squeue length queuing to %s\n", queued_frames + new_frames > 128 ? "" : "voice ", chan->name);
1514  AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->readq, cur, frame_list) {
1515  /* Save the most recent frame */
1516  if (!AST_LIST_NEXT(cur, frame_list)) {
1517  break;
1518  } else if (cur->frametype == AST_FRAME_VOICE || cur->frametype == AST_FRAME_VIDEO || cur->frametype == AST_FRAME_NULL) {
1519  if (++count > 64) {
1520  break;
1521  }
1523  ast_frfree(cur);
1524  }
1525  }
1527  }
1528 
1529  if (after) {
1530  AST_LIST_INSERT_LIST_AFTER(&chan->readq, &frames, after, frame_list);
1531  } else {
1532  if (head) {
1533  AST_LIST_APPEND_LIST(&frames, &chan->readq, frame_list);
1534  AST_LIST_HEAD_INIT_NOLOCK(&chan->readq);
1535  }
1536  AST_LIST_APPEND_LIST(&chan->readq, &frames, frame_list);
1537  }
1538 
1539  if (chan->alertpipe[1] > -1) {
1540  int blah[new_frames];
1541 
1542  memset(blah, 1, sizeof(blah));
1543  if (write(chan->alertpipe[1], &blah, sizeof(blah)) != (sizeof(blah))) {
1544  ast_log(LOG_WARNING, "Unable to write to alert pipe on %s (qlen = %u): %s!\n",
1545  chan->name, queued_frames, strerror(errno));
1546  }
1547  } else if (chan->timingfd > -1) {
1548  ast_timer_enable_continuous(chan->timer);
1549  } else if (ast_test_flag(chan, AST_FLAG_BLOCKING)) {
1550  pthread_kill(chan->blocker, SIGURG);
1551  }
1552 
1553  ast_channel_unlock(chan);
1554 
1555  return 0;
1556 }
union ast_frame_subclass subclass
Definition: frame.h:146
#define AST_LIST_INSERT_LIST_AFTER(head, list, elm, field)
Inserts a whole list after a specific entry in a list.
Definition: linkedlists.h:797
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
Definition: linkedlists.h:420
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define LOG_WARNING
Definition: logger.h:144
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
Definition: linkedlists.h:438
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
Definition: linkedlists.h:841
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:600
static int frames
Definition: iax2-parser.c:49
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:554
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
Definition: linkedlists.h:224
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:716
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.
Definition: linkedlists.h:428
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int errno
static struct ast_format f[]
Definition: format_g726.c:181
if(yyss+yystacksize-1<=yyssp)
Definition: ast_expr2.c:1874
int ast_timer_enable_continuous(const struct ast_timer *handle)
Enable continuous mode.
Definition: timing.c:181
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
Definition: linkedlists.h:666
Data structure associated with a single frame of data.
Definition: frame.h:142
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:528
enum ast_frame_type frametype
Definition: frame.h:144
#define ast_frfree(fr)
Definition: frame.h:583
struct ast_frame * ast_frdup(const struct ast_frame *fr)
Copies a frame.
Definition: frame.c:474
#define AST_LIST_APPEND_LIST(head, list, field)
Appends a whole list to the tail of a list.
Definition: linkedlists.h:768
static struct ast_frame* __ast_read ( struct ast_channel chan,
int  dropaudio 
)
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 3836 of file channel.c.

References __ast_queue_frame(), ast_channel::_softhangup, ast_channel::_state, ast_control_read_action_payload::action, ast_channel::alertpipe, ao2_ref, ast_audiohook_detach_list(), AST_AUDIOHOOK_DIRECTION_READ, ast_audiohook_write_list(), ast_audiohook_write_list_empty(), ast_bridged_channel(), AST_CEL_ANSWER, ast_cel_report_event(), ast_channel_connected_line_macro(), ast_channel_lock, ast_channel_unlock, 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_HANGUP, AST_CONTROL_READ_ACTION, ast_deactivate_generator(), ast_debug, AST_DEFAULT_EMULATE_DTMF_DURATION, ast_do_masquerade(), AST_FLAG_DEFER_DTMF, AST_FLAG_EMULATE_DTMF, AST_FLAG_END_DTMF_ONLY, AST_FLAG_EXCEPTION, AST_FLAG_IN_DTMF, AST_FLAG_OUTGOING, AST_FLAG_TIMINGDATA_IS_AO2_OBJ, AST_FLAG_ZOMBIE, ast_format_rate(), 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_VOICE, ast_framehook_list_read_event(), ast_frfree, AST_GENERATOR_FD, ast_getformatname(), ast_getformatname_multiple(), ast_indicate_data(), 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_DURATION, AST_MIN_DTMF_GAP, AST_MONITOR_RUNNING, 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_seekstream(), ast_set_flag, ast_setstate(), AST_SOFTHANGUP_DEV, AST_STATE_UP, 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(), ast_writestream(), ast_channel::audiohooks, ast_channel::blocker, calc_monitor_jump(), ast_frame_subclass::codec, ast_channel::connected, ast_frame::data, DEBUGCHAN_FLAG, ast_generator::digit, ast_channel::dtmf_tv, ast_channel::dtmff, ast_channel::emulate_dtmf_digit, ast_channel::emulate_dtmf_duration, errno, ast_channel_tech::exception, f, ast_channel::fdno, ast_channel::fds, ast_channel::fin, chanlist::flags, ast_filestream::fmt, ast_format::format, FRAMECOUNT_INC, ast_channel::framehooks, ast_frame::frametype, ast_generator::generate, ast_channel::generator, ast_channel::generatordata, ast_channel::hangupcause, if(), ast_channel::insmpl, ast_frame_subclass::integer, ast_frame::len, LOG_DTMF, LOG_ERROR, LOG_NOTICE, LOG_WARNING, ast_channel::masq, ast_channel::monitor, ast_channel::music_state, ast_channel::name, ast_channel::nativeformats, ast_channel::outsmpl, 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_monitor::read_stream, ast_channel::readq, ast_channel::readtrans, ast_frame::samples, SEEK_FORCECUR, send_dtmf_event(), should_skip_dtmf(), ast_channel_monitor::state, ast_frame::subclass, ast_channel::tech, ast_channel::timer, ast_channel::timingdata, ast_channel::timingfd, ast_channel::timingfunc, and ast_frame::uint32.

Referenced by ast_read(), and ast_read_noaudio().

3837 {
3838  struct ast_frame *f = NULL; /* the return value */
3839  int blah;
3840  int prestate;
3841  int cause = 0;
3842 
3843  /* this function is very long so make sure there is only one return
3844  * point at the end (there are only two exceptions to this).
3845  */
3846 
3847  if (chan->masq) {
3848  ast_do_masquerade(chan);
3849  return &ast_null_frame;
3850  }
3851 
3852  /* if here, no masq has happened, lock the channel and proceed */
3853  ast_channel_lock(chan);
3854 
3855  /* Stop if we're a zombie or need a soft hangup */
3856  if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
3857  if (chan->generator)
3859 
3860  /*
3861  * It is possible for chan->_softhangup to be set and there
3862  * still be control frames that need to be read. Instead of
3863  * just going to 'done' in the case of ast_check_hangup(), we
3864  * need to queue the end-of-Q frame so that it can mark the end
3865  * of the read queue. If there are frames to be read,
3866  * ast_queue_control() will be called repeatedly, but will only
3867  * queue the first end-of-Q frame.
3868  */
3869  if (chan->_softhangup) {
3871  } else {
3872  goto done;
3873  }
3874  } else {
3875 #ifdef AST_DEVMODE
3876  /*
3877  * The ast_waitfor() code records which of the channel's file
3878  * descriptors reported that data is available. In theory,
3879  * ast_read() should only be called after ast_waitfor() reports
3880  * that a channel has data available for reading. However,
3881  * there still may be some edge cases throughout the code where
3882  * ast_read() is called improperly. This can potentially cause
3883  * problems, so if this is a developer build, make a lot of
3884  * noise if this happens so that it can be addressed.
3885  *
3886  * One of the potential problems is blocking on a dead channel.
3887  */
3888  if (chan->fdno == -1) {
3890  "ast_read() on chan '%s' called with no recorded file descriptor.\n",
3891  chan->name);
3892  }
3893 #endif
3894  }
3895 
3896  prestate = chan->_state;
3897  if (chan->timingfd > -1 && chan->fdno == AST_TIMING_FD) {
3898  enum ast_timer_event res;
3899 
3901 
3902  res = ast_timer_get_event(chan->timer);
3903 
3904  switch (res) {
3906  if (ast_timer_ack(chan->timer, 1) < 0) {
3907  ast_log(LOG_ERROR, "Failed to acknoweldge timer in ast_read\n");
3908  goto done;
3909  }
3910 
3911  if (chan->timingfunc) {
3912  /* save a copy of func/data before unlocking the channel */
3913  int (*func)(const void *) = chan->timingfunc;
3914  void *data = chan->timingdata;
3915  int got_ref = 0;
3917  ao2_ref(data, 1);
3918  got_ref = 1;
3919  }
3920  chan->fdno = -1;
3921  ast_channel_unlock(chan);
3922  func(data);
3923  if (got_ref) {
3924  ao2_ref(data, -1);
3925  }
3926  } else {
3927  ast_timer_set_rate(chan->timer, 0);
3928  chan->fdno = -1;
3929  ast_channel_unlock(chan);
3930  }
3931 
3932  /* cannot 'goto done' because the channel is already unlocked */
3933  return &ast_null_frame;
3934 
3936  if (AST_LIST_EMPTY(&chan->readq) ||
3939  }
3940  break;
3941  }
3942 
3943  } else if (chan->fds[AST_GENERATOR_FD] > -1 && chan->fdno == AST_GENERATOR_FD) {
3944  /* if the AST_GENERATOR_FD is set, call the generator with args
3945  * set to -1 so it can do whatever it needs to.
3946  */
3947  void *tmp = chan->generatordata;
3948  chan->generatordata = NULL; /* reset to let ast_write get through */
3949  chan->generator->generate(chan, tmp, -1, -1);
3950  chan->generatordata = tmp;
3951  f = &ast_null_frame;
3952  chan->fdno = -1;
3953  goto done;
3954  }
3955 
3956  /* Read and ignore anything on the alertpipe, but read only
3957  one sizeof(blah) per frame that we send from it */
3958  if (chan->alertpipe[0] > -1) {
3959  int flags = fcntl(chan->alertpipe[0], F_GETFL);
3960  /* For some odd reason, the alertpipe occasionally loses nonblocking status,
3961  * which immediately causes a deadlock scenario. Detect and prevent this. */
3962  if ((flags & O_NONBLOCK) == 0) {
3963  ast_log(LOG_ERROR, "Alertpipe on channel %s lost O_NONBLOCK?!!\n", chan->name);
3964  if (fcntl(chan->alertpipe[0], F_SETFL, flags | O_NONBLOCK) < 0) {
3965  ast_log(LOG_WARNING, "Unable to set alertpipe nonblocking! (%d: %s)\n", errno, strerror(errno));
3966  f = &ast_null_frame;
3967  goto done;
3968  }
3969  }
3970  if (read(chan->alertpipe[0], &blah, sizeof(blah)) < 0) {
3971  if (errno != EINTR && errno != EAGAIN)
3972  ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno));
3973  }
3974  }
3975 
3976 
3977  /* Check for pending read queue */
3978  if (!AST_LIST_EMPTY(&chan->readq)) {
3979  int skip_dtmf = should_skip_dtmf(chan);
3980 
3982  /* We have to be picky about which frame we pull off of the readq because
3983  * there are cases where we want to leave DTMF frames on the queue until
3984  * some later time. */
3985 
3986  if ( (f->frametype == AST_FRAME_DTMF_BEGIN || f->frametype == AST_FRAME_DTMF_END) && skip_dtmf) {
3987  continue;
3988  }
3989 
3991  break;
3992  }
3994 
3995  if (!f) {
3996  /* There were no acceptable frames on the readq. */
3997  f = &ast_null_frame;
3998  if (chan->alertpipe[0] > -1) {
3999  int poke = 0;
4000  /* Restore the state of the alertpipe since we aren't ready for any
4001  * of the frames in the readq. */
4002  if (write(chan->alertpipe[1], &poke, sizeof(poke)) != sizeof(poke)) {
4003  ast_log(LOG_ERROR, "Failed to write to alertpipe: %s\n", strerror(errno));
4004  }
4005  }
4006  }
4007 
4008  /* Interpret hangup and end-of-Q frames to return NULL */
4009  /* XXX why not the same for frames from the channel ? */
4010  if (f->frametype == AST_FRAME_CONTROL) {
4011  switch (f->subclass.integer) {
4012  case AST_CONTROL_HANGUP:
4014  cause = f->data.uint32;
4015  /* Fall through */
4016  case AST_CONTROL_END_OF_Q:
4017  ast_frfree(f);
4018  f = NULL;
4019  break;
4020  default:
4021  break;
4022  }
4023  }
4024  } else {
4025  chan->blocker = pthread_self();
4026  if (ast_test_flag(chan, AST_FLAG_EXCEPTION)) {
4027  if (chan->tech->exception)
4028  f = chan->tech->exception(chan);
4029  else {
4030  ast_log(LOG_WARNING, "Exception flag set on '%s', but no exception handler\n", chan->name);
4031  f = &ast_null_frame;
4032  }
4033  /* Clear the exception flag */
4035  } else if (chan->tech && chan->tech->read)
4036  f = chan->tech->read(chan);
4037  else
4038  ast_log(LOG_WARNING, "No read routine on channel %s\n", chan->name);
4039  }
4040 
4041  /*
4042  * Reset the recorded file descriptor that triggered this read so that we can
4043  * easily detect when ast_read() is called without properly using ast_waitfor().
4044  */
4045  chan->fdno = -1;
4046 
4047  /* Perform the framehook read event here. After the frame enters the framehook list
4048  * there is no telling what will happen, <insert mad scientist laugh here>!!! */
4050 
4051  if (f) {
4052  struct ast_frame *readq_tail = AST_LIST_LAST(&chan->readq);
4053  struct ast_control_read_action_payload *read_action_payload;
4055 
4056  /* if the channel driver returned more than one frame, stuff the excess
4057  into the readq for the next ast_read call
4058  */
4059  if (AST_LIST_NEXT(f, frame_list)) {
4062  AST_LIST_NEXT(f, frame_list) = NULL;
4063  }
4064 
4065  switch (f->frametype) {
4066  case AST_FRAME_CONTROL:
4067  if (f->subclass.integer == AST_CONTROL_ANSWER) {
4068  if (!ast_test_flag(chan, AST_FLAG_OUTGOING)) {
4069  ast_debug(1, "Ignoring answer on an inbound call!\n");
4070  ast_frfree(f);
4071  f = &ast_null_frame;
4072  } else if (prestate == AST_STATE_UP && ast_bridged_channel(chan)) {
4073  ast_debug(1, "Dropping duplicate answer!\n");
4074  ast_frfree(f);
4075  f = &ast_null_frame;
4076  } else {
4077  /* Answer the CDR */
4078  ast_setstate(chan, AST_STATE_UP);
4079  /* removed a call to ast_cdr_answer(chan->cdr) from here. */
4080  ast_cel_report_event(chan, AST_CEL_ANSWER, NULL, NULL, NULL);
4081  }
4082  } else if (f->subclass.integer == AST_CONTROL_READ_ACTION) {
4083  read_action_payload = f->data.ptr;
4084  switch (read_action_payload->action) {
4088  if (ast_connected_line_parse_data(read_action_payload->payload,
4089  read_action_payload->payload_size, &connected)) {
4091  break;
4092  }
4093  ast_channel_unlock(chan);
4094  if (ast_channel_connected_line_macro(NULL, chan, &connected, 1, 0)) {
4096  read_action_payload->payload,
4097  read_action_payload->payload_size);
4098  }
4100  ast_channel_lock(chan);
4101  break;
4102  }
4103  ast_frfree(f);
4104  f = &ast_null_frame;
4105  }
4106  break;
4107  case AST_FRAME_DTMF_END:
4108  send_dtmf_event(chan, "Received", f->subclass.integer, "No", "Yes");
4109  ast_log(LOG_DTMF, "DTMF end '%c' received on %s, duration %ld ms\n", f->subclass.integer, chan->name, f->len);
4110  /* Queue it up if DTMF is deferred, or if DTMF emulation is forced. */
4112  queue_dtmf_readq(chan, f);
4113  ast_frfree(f);
4114  f = &ast_null_frame;
4115  } else if (!ast_test_flag(chan, AST_FLAG_IN_DTMF | AST_FLAG_END_DTMF_ONLY)) {
4116  if (!ast_tvzero(chan->dtmf_tv) &&
4118  /* If it hasn't been long enough, defer this digit */
4119  queue_dtmf_readq(chan, f);
4120  ast_frfree(f);
4121  f = &ast_null_frame;
4122  } else {
4123  /* There was no begin, turn this into a begin and send the end later */
4126  chan->emulate_dtmf_digit = f->subclass.integer;
4127  chan->dtmf_tv = ast_tvnow();
4128  if (f->len) {
4129  if (f->len > AST_MIN_DTMF_DURATION)
4130  chan->emulate_dtmf_duration = f->len;
4131  else
4133  } else
4135  ast_log(LOG_DTMF, "DTMF begin emulation of '%c' with duration %u queued on %s\n", f->subclass.integer, chan->emulate_dtmf_duration, chan->name);
4136  }
4137  if (chan->audiohooks) {
4138  struct ast_frame *old_frame = f;
4139  /*!
4140  * \todo XXX It is possible to write a digit to the audiohook twice
4141  * if the digit was originally read while the channel was in autoservice. */
4143  if (old_frame != f)
4144  ast_frfree(old_frame);
4145  }
4146  } else {
4147  struct timeval now = ast_tvnow();
4148  if (ast_test_flag(chan, AST_FLAG_IN_DTMF)) {
4149  ast_log(LOG_DTMF, "DTMF end accepted with begin '%c' on %s\n", f->subclass.integer, chan->name);
4151  if (!f->len)
4152  f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
4153 
4154  /* detect tones that were received on
4155  * the wire with durations shorter than
4156  * AST_MIN_DTMF_DURATION and set f->len
4157  * to the actual duration of the DTMF
4158  * frames on the wire. This will cause
4159  * dtmf emulation to be triggered later
4160  * on.
4161  */
4162  if (ast_tvdiff_ms(now, chan->dtmf_tv) < AST_MIN_DTMF_DURATION) {
4163  f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
4164  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, chan->name);
4165  }
4166  } else if (!f->len) {
4167  ast_log(LOG_DTMF, "DTMF end accepted without begin '%c' on %s\n", f->subclass.integer, chan->name);
4169  }
4171  ast_log(LOG_DTMF, "DTMF end '%c' has duration %ld but want minimum %d, emulating on %s\n", f->subclass.integer, f->len, AST_MIN_DTMF_DURATION, chan->name);
4173  chan->emulate_dtmf_digit = f->subclass.integer;
4175  ast_frfree(f);
4176  f = &ast_null_frame;
4177  } else {
4178  ast_log(LOG_DTMF, "DTMF end passthrough '%c' on %s\n", f->subclass.integer, chan->name);
4179  if (f->len < AST_MIN_DTMF_DURATION) {
4181  }
4182  chan->dtmf_tv = now;
4183  }
4184  if (chan->audiohooks) {
4185  struct ast_frame *old_frame = f;
4187  if (old_frame != f)
4188  ast_frfree(old_frame);
4189  }
4190  }
4191  break;
4192  case AST_FRAME_DTMF_BEGIN:
4193  send_dtmf_event(chan, "Received", f->subclass.integer, "Yes", "No");
4194  ast_log(LOG_DTMF, "DTMF begin '%c' received on %s\n", f->subclass.integer, chan->name);
4196  (!ast_tvzero(chan->dtmf_tv) &&
4198  ast_log(LOG_DTMF, "DTMF begin ignored '%c' on %s\n", f->subclass.integer, chan->name);
4199  ast_frfree(f);
4200  f = &ast_null_frame;
4201  } else {
4203  chan->dtmf_tv = ast_tvnow();
4204  ast_log(LOG_DTMF, "DTMF begin passthrough '%c' on %s\n", f->subclass.integer, chan->name);
4205  }
4206  break;
4207  case AST_FRAME_NULL:
4208  /* The EMULATE_DTMF flag must be cleared here as opposed to when the duration
4209  * is reached , because we want to make sure we pass at least one
4210  * voice frame through before starting the next digit, to ensure a gap
4211  * between DTMF digits. */
4212  if (ast_test_flag(chan, AST_FLAG_EMULATE_DTMF)) {
4213  struct timeval now = ast_tvnow();
4214  if (!chan->emulate_dtmf_duration) {
4216  chan->emulate_dtmf_digit = 0;
4217  } else if (ast_tvdiff_ms(now, chan->dtmf_tv) >= chan->emulate_dtmf_duration) {
4218  chan->emulate_dtmf_duration = 0;
4219  ast_frfree(f);
4220  f = &chan->dtmff;
4222  f->subclass.integer = chan->emulate_dtmf_digit;
4223  f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
4224  chan->dtmf_tv = now;
4226  chan->emulate_dtmf_digit = 0;
4227  ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass.integer, chan->name);
4228  if (chan->audiohooks) {
4229  struct ast_frame *old_frame = f;
4231  if (old_frame != f) {
4232  ast_frfree(old_frame);
4233  }
4234  }
4235  }
4236  }
4237  break;
4238  case AST_FRAME_VOICE:
4239  /* The EMULATE_DTMF flag must be cleared here as opposed to when the duration
4240  * is reached , because we want to make sure we pass at least one
4241  * voice frame through before starting the next digit, to ensure a gap
4242  * between DTMF digits. */
4245  chan->emulate_dtmf_digit = 0;
4246  }
4247 
4248  if (dropaudio || ast_test_flag(chan, AST_FLAG_IN_DTMF)) {
4249  if (dropaudio)
4250  ast_read_generator_actions(chan, f);
4251  ast_frfree(f);
4252  f = &ast_null_frame;
4253  }
4254 
4256  struct timeval now = ast_tvnow();
4257  if (ast_tvdiff_ms(now, chan->dtmf_tv) >= chan->emulate_dtmf_duration) {
4258  chan->emulate_dtmf_duration = 0;
4259  ast_frfree(f);
4260  f = &chan->dtmff;
4262  f->subclass.integer = chan->emulate_dtmf_digit;
4263  f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
4264  chan->dtmf_tv = now;
4265  if (chan->audiohooks) {
4266  struct ast_frame *old_frame = f;
4268  if (old_frame != f)
4269  ast_frfree(old_frame);
4270  }
4271  ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass.integer, chan->name);
4272  } else {
4273  /* Drop voice frames while we're still in the middle of the digit */
4274  ast_frfree(f);
4275  f = &ast_null_frame;
4276  }
4277  } else if ((f->frametype == AST_FRAME_VOICE) && !(f->subclass.codec & chan->nativeformats)) {
4278  /* This frame is not one of the current native formats -- drop it on the floor */
4279  char to[200];
4280  ast_log(LOG_NOTICE, "Dropping incompatible voice frame on %s of format %s since our native format has changed to %s\n",
4281  chan->name, ast_getformatname(f->subclass.codec), ast_getformatname_multiple(to, sizeof(to), chan->nativeformats));
4282  ast_frfree(f);
4283  f = &ast_null_frame;
4284  } else if ((f->frametype == AST_FRAME_VOICE)) {
4285  /* Send frame to audiohooks if present */
4286  if (chan->audiohooks) {
4287  struct ast_frame *old_frame = f;
4289  if (old_frame != f)
4290  ast_frfree(old_frame);
4291  }
4292  if (chan->monitor && chan->monitor->read_stream ) {
4293  /* XXX what does this do ? */
4294 #ifndef MONITOR_CONSTANT_DELAY
4295  int jump = chan->outsmpl - chan->insmpl - 4 * f->samples;
4296  if (jump >= 0) {
4298  if (ast_seekstream(chan->monitor->read_stream, jump, SEEK_FORCECUR) == -1)
4299  ast_log(LOG_WARNING, "Failed to perform seek in monitoring read stream, synchronization between the files may be broken\n");
4300  chan->insmpl += (chan->outsmpl - chan->insmpl) + f->samples;
4301  } else
4302  chan->insmpl+= f->samples;
4303 #else
4305  if (jump - MONITOR_DELAY >= 0) {
4306  if (ast_seekstream(chan->monitor->read_stream, jump - f->samples, SEEK_FORCECUR) == -1)
4307  ast_log(LOG_WARNING, "Failed to perform seek in monitoring read stream, synchronization between the files may be broken\n");
4308  chan->insmpl += chan->outsmpl - chan->insmpl;
4309  } else
4310  chan->insmpl += f->samples;
4311 #endif
4312  if (chan->monitor->state == AST_MONITOR_RUNNING) {
4313  if (ast_writestream(chan->monitor->read_stream, f) < 0)
4314  ast_log(LOG_WARNING, "Failed to write data to channel monitor read stream\n");
4315  }
4316  }
4317 
4318  if (chan->readtrans && (f = ast_translate(chan->readtrans, f, 1)) == NULL) {
4319  f = &ast_null_frame;
4320  }
4321 
4322  /* it is possible for the translation process on chan->readtrans to have
4323  produced multiple frames from the single input frame we passed it; if
4324  this happens, queue the additional frames *before* the frames we may
4325  have queued earlier. if the readq was empty, put them at the head of
4326  the queue, and if it was not, put them just after the frame that was
4327  at the end of the queue.
4328  */
4329  if (AST_LIST_NEXT(f, frame_list)) {
4330  if (!readq_tail) {
4332  } else {
4333  __ast_queue_frame(chan, AST_LIST_NEXT(f, frame_list), 0, readq_tail);
4334  }
4336  AST_LIST_NEXT(f, frame_list) = NULL;
4337  }
4338 
4339  /* Run generator sitting on the line if timing device not available
4340  * and synchronous generation of outgoing frames is necessary */
4341  ast_read_generator_actions(chan, f);
4342  }
4343  break;
4344  default:
4345  /* Just pass it on! */
4346  break;
4347  }
4348  } else {
4349  /* Make sure we always return NULL in the future */
4350  if (!chan->_softhangup) {
4352  }
4353  if (cause)
4354  chan->hangupcause = cause;
4355  if (chan->generator)
4357  /* We no longer End the CDR here */
4358  }
4359 
4360  /* High bit prints debugging */
4361  if (chan->fin & DEBUGCHAN_FLAG)
4362  ast_frame_dump(chan->name, f, "<<");
4363  chan->fin = FRAMECOUNT_INC(chan->fin);
4364 
4365 done:
4366  if (chan->music_state && chan->generator && chan->generator->digit && f && f->frametype == AST_FRAME_DTMF_END)
4367  chan->generator->digit(chan, f->subclass.integer);
4368 
4370  /* The list gets recreated if audiohooks are added again later */
4372  chan->audiohooks = NULL;
4373  }
4374  ast_channel_unlock(chan);
4375  return f;
4376 }
void * music_state
Definition: channel.h:745
union ast_frame_subclass subclass
Definition: frame.h:146
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
Definition: channel.c:2308
#define ast_channel_lock(chan)
Definition: channel.h:2466
struct ast_channel * masq
Definition: channel.h:751
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
Definition: linkedlists.h:420
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame with payload.
Definition: channel.c:1601
struct ast_frame ast_null_frame
Definition: frame.c:131
void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
Definition: frame.c:778
static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, int head, struct ast_frame *after)
Definition: channel.c:1438
int timingfd
Definition: channel.h:838
#define DEBUGCHAN_FLAG
Definition: channel.h:648
static int calc_monitor_jump(int samples, int sample_rate, int seek_rate)
calculates the number of samples to jump forward with in a monitor stream.
Definition: channel.c:3823
#define ast_test_flag(p, flag)
Definition: utils.h:63
char emulate_dtmf_digit
Definition: channel.h:872
void * ptr
Definition: frame.h:160
#define AST_DEFAULT_EMULATE_DTMF_DURATION
Definition: channel.c:111
int ast_audiohook_write_list_empty(struct ast_audiohook_list *audiohook_list)
determines if a audiohook_list is empty or not.
Definition: audiohook.c:744
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define LOG_WARNING
Definition: logger.h:144
ast_timer_event
Definition: timing.h:57
int ast_cel_report_event(struct ast_channel *chan, enum ast_cel_event_type event_type, const char *userdefevname, const char *extra, struct ast_channel *peer2)
Report a channel event.
Definition: cel.c:645
struct ast_timer * timer
Definition: channel.h:866
#define AST_MIN_DTMF_GAP
Definition: channel.c:118
struct ast_generator * generator
Definition: channel.h:747
unsigned int emulate_dtmf_duration
Definition: channel.h:857
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:100
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
Definition: linkedlists.h:438
struct ast_frame *(*const read)(struct ast_channel *chan)
Read a frame, in standard format (see frame.h)
Definition: channel.h:551
unsigned long outsmpl
Definition: channel.h:827
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:4447
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
static force_inline int ast_format_rate(format_t format)
Get the sample rate for a given format.
Definition: frame.h:809
static int should_skip_dtmf(struct ast_channel *chan)
Determine whether or not we should ignore DTMF in the readq.
Definition: channel.c:3796
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
Definition: linkedlists.h:449
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:328
format_t nativeformats
Definition: channel.h:852
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:90
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition: channel.c:2353
int alertpipe[2]
Definition: channel.h:851
int ast_channel_connected_line_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *connected_info, int caller, int frame)
Run a connected line interception macro and update a channel&#39;s connected line information.
Definition: channel.c:9618
static void send_dtmf_event(struct ast_channel *chan, const char *direction, const char digit, const char *begin, const char *end)
Definition: channel.c:3709
format_t codec
Definition: frame.h:137
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:600
struct ast_frame dtmff
Definition: channel.h:816
format_t format
Definition: mod_format.h:47
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
int ast_timer_disable_continuous(const struct ast_timer *handle)
Disable continuous mode.
Definition: timing.c:190
struct ast_audiohook_list * audiohooks
Definition: channel.h:764
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:554
#define ao2_ref(o, delta)
Definition: astobj2.h:472
struct ast_format * fmt
Definition: mod_format.h:102
#define AST_GENERATOR_FD
Definition: channel.h:166
struct ast_frame *(*const exception)(struct ast_channel *chan)
Handle an exception, reading a frame.
Definition: channel.h:566
int(* timingfunc)(const void *data)
Definition: channel.h:759
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
int fds[AST_MAX_FDS]
Definition: channel.h:829
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:8886
int ast_timer_ack(const struct ast_timer *handle, unsigned int quantity)
Acknowledge a timer event.
Definition: timing.c:172
char * ast_getformatname(format_t format)
Get the name of a format.
Definition: frame.c:578
#define LOG_ERROR
Definition: logger.h:155
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:762
unsigned int fin
Definition: channel.h:845
unsigned long insmpl
Definition: channel.h:826
struct ast_framehook_list * framehooks
Definition: channel.h:765
#define AST_TIMING_FD
Definition: channel.h:164
enum ast_channel_state _state
Definition: channel.h:839
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
Definition: channel.c:7160
Connected Line/Party information.
Definition: channel.h:401
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
void * timingdata
Definition: channel.h:760
int _softhangup
Definition: channel.h:832
enum ast_frame_read_action action
Definition: frame.h:375
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.
Definition: linkedlists.h:428
#define LOG_NOTICE
Definition: logger.h:133
int ast_seekstream(struct ast_filestream *fs, off_t sample_offset, int whence)
Seeks into stream.
Definition: file.c:879
struct ast_filestream * read_stream
Definition: monitor.h:41
#define AST_MIN_DTMF_DURATION
Definition: channel.c:114
int fdno
Definition: channel.h:834
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int errno
#define SEEK_FORCECUR
Definition: file.h:50
unsigned int flags
Definition: frame.h:166
static struct ast_format f[]
Definition: format_g726.c:181
#define FRAMECOUNT_INC(x)
Definition: channel.h:651
int ast_timer_set_rate(const struct ast_timer *handle, unsigned int rate)
Set the timing tick rate.
Definition: timing.c:163
if(yyss+yystacksize-1<=yyssp)
Definition: ast_expr2.c:1874
#define ast_clear_flag(p, flag)
Definition: utils.h:77
int(* generate)(struct ast_channel *chan, void *data, int len, int samples)
Definition: channel.h:186
#define LOG_DTMF
Definition: logger.h:177
void ast_deactivate_generator(struct ast_channel *chan)
Definition: channel.c:3107
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:2316
A ringing phone is answered.
Definition: cel.h:56
int ast_writestream(struct ast_filestream *fs, struct ast_frame *f)
Writes a frame to a stream.
Definition: file.c:150
pthread_t blocker
Definition: channel.h:790
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Definition: channel.c:7119
char * ast_getformatname_multiple(char *buf, size_t size, format_t format)
Get the names of a set of formats.
Definition: frame.c:591
Data structure associated with a single frame of data.
Definition: frame.h:142
int hangupcause
Definition: channel.h:849
static int connected
Definition: cdr_pgsql.c:57
struct timeval dtmf_tv
Definition: channel.h:822
uint32_t uint32
Definition: frame.h:160
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:528
enum ast_frame_type frametype
Definition: frame.h:144
struct ast_trans_pvt * readtrans
Definition: channel.h:763
#define ast_frfree(fr)
Definition: frame.h:583
struct ast_channel_monitor * monitor
Definition: channel.h:769
unsigned char payload[0]
Definition: frame.h:381
static void queue_dtmf_readq(struct ast_channel *chan, struct ast_frame *f)
Definition: channel.c:3778
enum ast_timer_event ast_timer_get_event(const struct ast_timer *handle)
Retrieve timing event.
Definition: timing.c:199
enum AST_MONITORING_STATE state
Definition: monitor.h:49
int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to the head of a channel&#39;s frame queue.
Definition: channel.c:1563
union ast_frame::@172 data
struct ast_channel_tech * tech
Definition: channel.h:743
struct ast_channel::@156 readq
int ast_audiohook_detach_list(struct ast_audiohook_list *audiohook_list)
Detach audiohooks from list and destroy said list.
Definition: audiohook.c:418
long len
Definition: frame.h:170
static void ast_read_generator_actions(struct ast_channel *chan, struct ast_frame *f)
Definition: channel.c:3722
void * generatordata
Definition: channel.h:746
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&#39;s framehook list.
Definition: framehook.c:185
int ast_do_masquerade(struct ast_channel *chan)
Start masquerading a channel.
Definition: channel.c:6546
int samples
Definition: frame.h:150
void(* digit)(struct ast_channel *chan, char digit)
Definition: channel.h:188
struct ast_channel* __ast_request_and_dial ( const char *  type,
format_t  format,
const struct ast_channel requestor,
void *  data,
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
formatrequested channel format
requestorchannel requesting data
datadata to pass to the channel requester
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 5456 of file channel.c.

References ast_channel::_state, outgoing_helper::account, ast_call(), ast_call_forward(), AST_CAUSE_NO_ANSWER, ast_cdr_alloc(), ast_cdr_answer(), ast_cdr_busy(), ast_cdr_disposition(), ast_cdr_end(), ast_cdr_failed(), AST_CDR_FLAG_ORIGINATED, ast_cdr_init(), ast_cdr_setaccount(), ast_cdr_setapp(), ast_cdr_start(), ast_cdr_update(), ast_channel_datastore_inherit(), ast_channel_inherit_variables(), ast_channel_lock, ast_channel_lock_both, ast_channel_set_connected_line(), 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_REDIRECTING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_CONTROL_UNHOLD, AST_CONTROL_VIDUPDATE, ast_copy_string(), AST_FRAME_CONTROL, ast_frfree, ast_hangup(), ast_log(), 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(), ast_channel::call_forward, ast_channel::cdr, chanlist::chan, outgoing_helper::cid_name, outgoing_helper::cid_num, ast_channel::connected, ast_channel::context, outgoing_helper::context, ast_channel::exten, outgoing_helper::exten, f, ast_frame::frametype, handle_cause(), ast_channel::hangupcause, ast_party_connected_line::id, ast_frame_subclass::integer, LOG_NOTICE, ast_party_id::name, ast_party_id::number, outgoing_helper::parent_channel, ast_party_name::presentation, ast_party_number::presentation, ast_channel::priority, outgoing_helper::priority, ast_party_name::str, ast_party_number::str, ast_frame::subclass, ast_party_name::valid, ast_party_number::valid, and outgoing_helper::vars.

Referenced by ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_request_and_dial(), and parkandannounce_exec().

5457 {
5458  int dummy_outstate;
5459  int cause = 0;
5460  struct ast_channel *chan;
5461  int res = 0;
5462  int last_subclass = 0;
5464 
5465  if (outstate)
5466  *outstate = 0;
5467  else
5468  outstate = &dummy_outstate; /* make outstate always a valid pointer */
5469 
5470  chan = ast_request(type, format, requestor, data, &cause);
5471  if (!chan) {
5472  ast_log(LOG_NOTICE, "Unable to request channel %s/%s\n", type, (char *)data);
5473  handle_cause(cause, outstate);
5474  return NULL;
5475  }
5476 
5477  if (oh) {
5478  if (oh->vars) {
5479  ast_set_variables(chan, oh->vars);
5480  }
5481  if (!ast_strlen_zero(oh->cid_num) && !ast_strlen_zero(oh->cid_name)) {
5482  /*
5483  * Use the oh values instead of the function parameters for the
5484  * outgoing CallerID.
5485  */
5486  cid_num = oh->cid_num;
5487  cid_name = oh->cid_name;
5488  }
5489  if (oh->parent_channel) {
5490  /* Safely inherit variables and datastores from the parent channel. */
5495  ast_channel_unlock(chan);
5496  }
5497  if (oh->account) {
5498  ast_channel_lock(chan);
5499  ast_cdr_setaccount(chan, oh->account);
5500  ast_channel_unlock(chan);
5501  }
5502  }
5503 
5504  /*
5505  * I seems strange to set the CallerID on an outgoing call leg
5506  * to whom we are calling, but this function's callers are doing
5507  * various Originate methods. This call leg goes to the local
5508  * user. Once the local user answers, the dialplan needs to be
5509  * able to access the CallerID from the CALLERID function as if
5510  * the local user had placed this call.
5511  */
5513 
5516  if (cid_num) {
5517  connected.id.number.valid = 1;
5518  connected.id.number.str = (char *) cid_num;
5519  connected.id.number.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
5520  }
5521  if (cid_name) {
5522  connected.id.name.valid = 1;
5523  connected.id.name.str = (char *) cid_name;
5525  }
5527 
5528  if (ast_call(chan, data, 0)) { /* ast_call failed... */
5529  ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, (char *)data);
5530  } else {
5531  struct timeval start = ast_tvnow();
5532  res = 1; /* mark success in case chan->_state is already AST_STATE_UP */
5533  while (timeout && chan->_state != AST_STATE_UP) {
5534  struct ast_frame *f;
5535  int ms = ast_remaining_ms(start, timeout);
5536 
5537  res = ast_waitfor(chan, ms);
5538  if (res == 0) { /* timeout, treat it like ringing */
5539  *outstate = AST_CONTROL_RINGING;
5540  break;
5541  }
5542  if (res < 0) /* error or done */
5543  break;
5544  if (!ast_strlen_zero(chan->call_forward)) {
5545  if (!(chan = ast_call_forward(NULL, chan, NULL, format, oh, outstate))) {
5546  return NULL;
5547  }
5548  continue;
5549  }
5550 
5551  f = ast_read(chan);
5552  if (!f) {
5553  *outstate = AST_CONTROL_HANGUP;
5554  res = 0;
5555  break;
5556  }
5557  if (f->frametype == AST_FRAME_CONTROL) {
5558  switch (f->subclass.integer) {
5559  case AST_CONTROL_RINGING: /* record but keep going */
5560  *outstate = f->subclass.integer;
5561  break;
5562 
5563  case AST_CONTROL_BUSY:
5564  ast_cdr_busy(chan->cdr);
5565  *outstate = f->subclass.integer;
5566  timeout = 0;
5567  break;
5568 
5570  ast_cdr_failed(chan->cdr);
5571  *outstate = AST_CONTROL_CONGESTION;
5572  timeout = 0;
5573  break;
5574 
5576  ast_cdr_failed(chan->cdr);
5577  *outstate = f->subclass.integer;
5578  timeout = 0;
5579  break;
5580 
5581  case AST_CONTROL_ANSWER:
5582  ast_cdr_answer(chan->cdr);
5583  *outstate = f->subclass.integer;
5584  timeout = 0; /* trick to force exit from the while() */
5585  break;
5586 
5587  /* Ignore these */
5588  case AST_CONTROL_PROGRESS:
5590  case AST_CONTROL_HOLD:
5591  case AST_CONTROL_UNHOLD:
5592  case AST_CONTROL_VIDUPDATE:
5593  case AST_CONTROL_SRCUPDATE:
5594  case AST_CONTROL_SRCCHANGE:
5597  case AST_CONTROL_CC:
5598  case -1: /* Ignore -- just stopping indications */
5599  break;
5600 
5601  default:
5602  ast_log(LOG_NOTICE, "Don't know what to do with control frame %d\n", f->subclass.integer);
5603  }
5604  last_subclass = f->subclass.integer;
5605  }
5606  ast_frfree(f);
5607  }
5608  }
5609 
5610  /* Final fixups */
5611  if (oh) {
5612  if (!ast_strlen_zero(oh->context))
5613  ast_copy_string(chan->context, oh->context, sizeof(chan->context));
5614  if (!ast_strlen_zero(oh->exten))
5615  ast_copy_string(chan->exten, oh->exten, sizeof(chan->exten));
5616  if (oh->priority)
5617  chan->priority = oh->priority;
5618  }
5619  if (chan->_state == AST_STATE_UP)
5620  *outstate = AST_CONTROL_ANSWER;
5621 
5622  if (res <= 0) {
5623  ast_channel_lock(chan);
5624  if (AST_CONTROL_RINGING == last_subclass) {
5626  }
5627  if (!chan->cdr && (chan->cdr = ast_cdr_alloc())) {
5628  ast_cdr_init(chan->cdr, chan);
5629  }
5630  if (chan->cdr) {
5631  char tmp[256];
5632 
5633  snprintf(tmp, sizeof(tmp), "%s/%s", type, (char *)data);
5634  ast_cdr_setapp(chan->cdr, "Dial", tmp);
5635  ast_cdr_update(chan);
5636  ast_cdr_start(chan->cdr);
5637  ast_cdr_end(chan->cdr);
5638  /* If the cause wasn't handled properly */
5639  if (ast_cdr_disposition(chan->cdr, chan->hangupcause)) {
5640  ast_cdr_failed(chan->cdr);
5641  }
5642  }
5643  ast_channel_unlock(chan);
5644  ast_hangup(chan);
5645  chan = NULL;
5646  }
5647  return chan;
5648 }
int ast_cdr_disposition(struct ast_cdr *cdr, int cause)
Save the result of the call based on the AST_CAUSE_*.
Definition: cdr.c:790
union ast_frame_subclass subclass
Definition: frame.h:146
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2804
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:7051
#define ast_channel_lock(chan)
Definition: channel.h:2466
Main Channel structure associated with a channel.
Definition: channel.h:742
const char * cid_num
Definition: channel.h:1002
void ast_cdr_failed(struct ast_cdr *cdr)
Fail a call.
Definition: cdr.c:764
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
int priority
Definition: channel.h:841
struct ast_channel * parent_channel
Definition: channel.h:1006
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:2329
void ast_cdr_end(struct ast_cdr *cdr)
End a call.
Definition: cdr.c:933
char context[AST_MAX_CONTEXT]
Definition: channel.h:868
#define ast_set_flag(p, flag)
Definition: utils.h:70
int ast_cdr_setaccount(struct ast_channel *chan, const char *account)
Set account code, will generate AMI event.
Definition: cdr.c:990
void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars)
adds a list of channel variables to a channel
Definition: channel.c:8261
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4383
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
struct ast_cdr * cdr
Definition: channel.h:766
#define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED
Definition: callerid.h:329
static char cid_num[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:157
struct ast_variable * vars
Definition: channel.h:1005
int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to)
Inherit datastores from a parent to a child.
Definition: channel.c:2573
const char * exten
Definition: channel.h:1000
const char * cid_name
Definition: channel.h:1003
struct ast_channel * ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, format_t format, struct outgoing_helper *oh, int *outstate)
Forwards a call to a new channel specified by the original channel&#39;s call_forward str...
Definition: channel.c:5386
const char * account
Definition: channel.h:1004
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
static void handle_cause(int cause, int *outstate)
Definition: channel.c:5336
void ast_cdr_answer(struct ast_cdr *cdr)
Answer a call.
Definition: cdr.c:737
#define AST_CAUSE_NO_ANSWER
Definition: causes.h:108
int ast_cdr_update(struct ast_channel *chan)
Update CDR on a channel.
Definition: cdr.c:1083
void ast_cdr_start(struct ast_cdr *cdr)
Start a call.
Definition: cdr.c:727
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
Definition: utils.c:1615
const ast_string_field call_forward
Definition: channel.h:787
enum ast_channel_state _state
Definition: channel.h:839
Connected Line/Party information.
Definition: channel.h:401
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define LOG_NOTICE
Definition: logger.h:133
#define ast_channel_unlock(chan)
Definition: channel.h:2467
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:6241
static struct ast_format f[]
Definition: format_g726.c:181
void ast_cdr_setapp(struct ast_cdr *cdr, const char *app, const char *data)
Set the last executed application.
Definition: cdr.c:822
int ast_call(struct ast_channel *chan, char *addr, int timeout)
Make a call.
Definition: channel.c:5761
static const char type[]
Definition: chan_nbs.c:57
static char cid_name[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:158
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition: channel.h:2473
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3539
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
const char * context
Definition: channel.h:999
Data structure associated with a single frame of data.
Definition: frame.h:142
int hangupcause
Definition: channel.h:849
static int connected
Definition: cdr_pgsql.c:57
enum ast_frame_type frametype
Definition: frame.h:144
#define ast_frfree(fr)
Definition: frame.h:583
struct ast_channel * ast_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *status)
Requests a channel.
Definition: channel.c:5695
static snd_pcm_format_t format
Definition: chan_alsa.c:93
union ast_frame::@172 data
int ast_cdr_init(struct ast_cdr *cdr, struct ast_channel *chan)
Initialize based on a channel.
Definition: cdr.c:897
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:8458
struct ast_cdr * ast_cdr_alloc(void)
Allocate a CDR record.
Definition: cdr.c:499
char exten[AST_MAX_EXTENSION]
Definition: channel.h:869
void ast_cdr_busy(struct ast_cdr *cdr)
Busy a call.
Definition: cdr.c:753
static void __init_state2str_threadbuf ( void  )
static

Definition at line 106 of file channel.c.

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

Definition at line 4837 of file channel.c.

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

4838 {
4839  int num_new_samples = frame->samples;
4840  struct plc_ds *plc = datastore->data;
4841 
4842  /* As a general note, let me explain the somewhat odd calculations used when taking
4843  * the frame offset into account here. According to documentation in frame.h, the frame's
4844  * offset field indicates the number of bytes that the audio is offset. The plc->samples_buf
4845  * is not an array of bytes, but rather an array of 16-bit integers since it holds SLIN
4846  * samples. So I had two choices to make here with the offset.
4847  *
4848  * 1. Make the offset AST_FRIENDLY_OFFSET bytes. The main downside for this is that
4849  * I can't just add AST_FRIENDLY_OFFSET to the plc->samples_buf and have the pointer
4850  * arithmetic come out right. I would have to do some odd casting or division for this to
4851  * work as I wanted.
4852  * 2. Make the offset AST_FRIENDLY_OFFSET * 2 bytes. This allows the pointer arithmetic
4853  * to work out better with the plc->samples_buf. The downside here is that the buffer's
4854  * allocation contains an extra 64 bytes of unused space.
4855  *
4856  * I decided to go with option 2. This is why in the calloc statement and the statement that
4857  * sets the frame's offset, AST_FRIENDLY_OFFSET is multiplied by 2.
4858  */
4859 
4860  /* If this audio frame has no samples to fill in, ignore it */
4861  if (!num_new_samples) {
4862  return;
4863  }
4864 
4865  /* First, we need to be sure that our buffer is large enough to accomodate
4866  * the samples we need to fill in. This will likely only occur on the first
4867  * frame we write.
4868  */
4869  if (plc->num_samples < num_new_samples) {
4870  ast_free(plc->samples_buf);
4871  plc->samples_buf = ast_calloc(1, (num_new_samples * sizeof(*plc->samples_buf)) + (AST_FRIENDLY_OFFSET * 2));
4872  if (!plc->samples_buf) {
4873  ast_channel_datastore_remove(chan, datastore);
4874  ast_datastore_free(datastore);
4875  return;
4876  }
4877  plc->num_samples = num_new_samples;
4878  }
4879 
4880  if (frame->datalen == 0) {
4882  frame->data.ptr = plc->samples_buf + AST_FRIENDLY_OFFSET;
4883  frame->datalen = num_new_samples * 2;
4884  frame->offset = AST_FRIENDLY_OFFSET * 2;
4885  } else {
4886  plc_rx(&plc->plc_state, frame->data.ptr, frame->samples);
4887  }
4888 }
int offset
Definition: frame.h:156
void * ptr
Definition: frame.h:160
plc_state_t plc_state
Definition: channel.c:4822
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 ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Definition: datastore.c:65
int16_t * samples_buf
Definition: channel.c:4817
#define AST_FRIENDLY_OFFSET
Offset into a frame&#39;s data buffer.
Definition: frame.h:204
int datalen
Definition: frame.h:148
#define ast_free(a)
Definition: astmm.h:97
size_t num_samples
Definition: channel.c:4821
void * data
Definition: datastore.h:56
#define ast_calloc(a, b)
Definition: astmm.h:82
int plc_rx(plc_state_t *s, int16_t amp[], int len)
Process a block of received audio samples.
Definition: plc.c:132
union ast_frame::@172 data
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
Definition: channel.c:2599
int samples
Definition: frame.h:150
static void apply_plc ( struct ast_channel chan,
struct ast_frame frame 
)
static

Definition at line 4890 of file channel.c.

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

Referenced by ast_write().

4891 {
4892  struct ast_datastore *datastore;
4893  struct plc_ds *plc;
4894 
4895  datastore = ast_channel_datastore_find(chan, &plc_ds_info, NULL);
4896  if (datastore) {
4897  plc = datastore->data;
4898  adjust_frame_for_plc(chan, frame, datastore);
4899  return;
4900  }
4901 
4902  datastore = ast_datastore_alloc(&plc_ds_info, NULL);
4903  if (!datastore) {
4904  return;
4905  }
4906  plc = ast_calloc(1, sizeof(*plc));
4907  if (!plc) {
4908  ast_datastore_free(datastore);
4909  return;
4910  }
4911  datastore->data = plc;
4912  ast_channel_datastore_add(chan, datastore);
4913  adjust_frame_for_plc(chan, frame, datastore);
4914 }
static void adjust_frame_for_plc(struct ast_channel *chan, struct ast_frame *frame, struct ast_datastore *datastore)
Definition: channel.c:4837
static struct ast_datastore_info plc_ds_info
Definition: channel.c:4832
Structure for a data store object.
Definition: datastore.h:54
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:2604
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Definition: datastore.c:65
struct ast_datastore * ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
Definition: datastore.c:98
void * data
Definition: datastore.h:56
#define ast_calloc(a, b)
Definition: astmm.h:82
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition: channel.c:2590
int ast_activate_generator ( struct ast_channel chan,
struct ast_generator gen,
void *  params 
)

Activate a given generator

Definition at line 3148 of file channel.c.

References ast_generator::alloc, ast_channel_lock, ast_channel_unlock, ast_prod(), ast_settimeout(), gen, ast_channel::generator, generator_force(), ast_channel::generatordata, and ast_generator::release.

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

3149 {
3150  int res = 0;
3151 
3152  ast_channel_lock(chan);
3153  if (chan->generatordata) {
3154  struct ast_generator *generator_old = chan->generator;
3155 
3156  if (generator_old && generator_old->release) {
3157  generator_old->release(chan, chan->generatordata);
3158  }
3159  chan->generatordata = NULL;
3160  }
3161  if (gen->alloc && !(chan->generatordata = gen->alloc(chan, params))) {
3162  res = -1;
3163  }
3164  if (!res) {
3165  ast_settimeout(chan, 50, generator_force, chan);
3166  chan->generator = gen;
3167  }
3168  ast_channel_unlock(chan);
3169 
3170  ast_prod(chan);
3171 
3172  return res;
3173 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
struct ast_generator * generator
Definition: channel.h:747
int ast_prod(struct ast_channel *chan)
Send empty audio to prime a channel driver.
Definition: channel.c:4784
static struct ast_generator gen
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:3557
void(* release)(struct ast_channel *chan, void *data)
Definition: channel.h:181
#define ast_channel_unlock(chan)
Definition: channel.h:2467
void *(* alloc)(struct ast_channel *chan, void *params)
Definition: channel.h:180
static int generator_force(const void *data)
Definition: channel.c:3114
void * generatordata
Definition: channel.h:746
int ast_active_channels ( void  )

returns number of active/allocated channels

Returns
number of channels available for lookup

Definition at line 848 of file channel.c.

References ao2_container_count(), and channels.

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

849 {
850  return channels ? ao2_container_count(channels) : 0;
851 }
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
Definition: astobj2.c:470
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:197
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 3086 of file channel.c.

References __ast_answer().

Referenced by action_bridge(), agi_exec_full(), alarmreceiver_exec(), answer_trunk_chan(), app_exec(), ast_control_streamfile(), ast_do_pickup(), ast_pickup_call(), auth_exec(), background_detect_exec(), bridge_exec(), builtin_parkcall(), common_exec(), conf_exec(), count_exec(), dahdiras_exec(), dial_exec_full(), dictate_exec(), directory_exec(), disa_exec(), eivr_comm(), handle_answer(), ices_exec(), login_exec(), minivm_accmess_exec(), minivm_greet_exec(), minivm_record_exec(), old_milliwatt_exec(), park_call_exec(), parked_call_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(), transmit(), vm_exec(), vm_execmain(), waitfor_exec(), and zapateller_exec().

3087 {
3088  return __ast_answer(chan, 0, 1);
3089 }
int __ast_answer(struct ast_channel *chan, unsigned int delay, int cdr_answer)
Answer a channel, with a selectable delay before returning.
Definition: channel.c:2982
void ast_begin_shutdown ( int  hangup)

Initiate system shutdown – prevents new channels from being allocated.

Parameters
hangupIf "hangup" is non-zero, all existing channels will receive soft hangups

Definition at line 838 of file channel.c.

References ao2_callback, ast_channel_softhangup_cb(), channels, OBJ_MULTIPLE, and OBJ_NODATA.

Referenced by can_safely_quit().

839 {
840  shutting_down = 1;
841 
842  if (hangup) {
844  }
845 }
#define ao2_callback(c, flags, cb_fn, arg)
Definition: astobj2.h:910
static int ast_channel_softhangup_cb(void *obj, void *arg, int flags)
Definition: channel.c:829
static int shutting_down
Prevent new channel allocation if shutting down.
Definition: channel.c:99
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:197
format_t ast_best_codec ( format_t  fmts)

Pick the best audio codec.

Pick the best codec Choose the best codec... Uhhh... Yah.

Okay, ulaw is used by all telephony equipment, so start with it

Unless of course, you're a silly European, so then prefer ALAW

G.722 is better then all below, but not as common as the above... so give ulaw and alaw priority

Okay, well, signed linear is easy to translate into other stuff

G.726 is standard ADPCM, in RFC3551 packing order

G.726 is standard ADPCM, in AAL2 packing order

ADPCM has great sound quality and is still pretty easy to translate

Okay, we're down to vocoders now, so pick GSM because it's small and easier to translate and sounds pretty good

iLBC is not too bad

Speex is free, but computationally more expensive than GSM

Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough to use it

G.729a is faster than 723 and slightly less expensive

Down to G.723.1 which is proprietary but at least designed for voice

Definition at line 1062 of file channel.c.

References ARRAY_LEN, AST_FORMAT_ADPCM, AST_FORMAT_ALAW, AST_FORMAT_AUDIO_MASK, AST_FORMAT_G719, AST_FORMAT_G722, AST_FORMAT_G723_1, AST_FORMAT_G726, AST_FORMAT_G726_AAL2, AST_FORMAT_G729A, AST_FORMAT_GSM, AST_FORMAT_ILBC, AST_FORMAT_LPC10, AST_FORMAT_SIREN14, AST_FORMAT_SIREN7, AST_FORMAT_SLINEAR, AST_FORMAT_SLINEAR16, AST_FORMAT_SPEEX, AST_FORMAT_SPEEX16, AST_FORMAT_TESTLAW, AST_FORMAT_ULAW, ast_getformatname_multiple(), ast_log(), LOG_WARNING, and prefs.

Referenced by __oh323_new(), agent_call(), ast_codec_choose(), ast_iax2_new(), ast_speech_new(), bridge_make_compatible(), builtin_atxfer(), echo_exec(), findmeexec(), gtalk_new(), handle_open_receive_channel_ack_message(), iax2_request(), jingle_new(), local_new(), login_exec(), mgcp_new(), multicast_rtp_request(), set_format(), sip_new(), skinny_new(), skinny_set_rtp_peer(), socket_process(), start_rtp(), transmit_connect(), and unistim_new().

1063 {
1064  /* This just our opinion, expressed in code. We are asked to choose
1065  the best codec to use, given no information */
1066  int x;
1067  static const format_t prefs[] =
1068  {
1069  /*! Okay, ulaw is used by all telephony equipment, so start with it */
1071  /*! Unless of course, you're a silly European, so then prefer ALAW */
1077  /*! G.722 is better then all below, but not as common as the above... so give ulaw and alaw priority */
1079  /*! Okay, well, signed linear is easy to translate into other stuff */
1082  /*! G.726 is standard ADPCM, in RFC3551 packing order */
1084  /*! G.726 is standard ADPCM, in AAL2 packing order */
1086  /*! ADPCM has great sound quality and is still pretty easy to translate */
1088  /*! Okay, we're down to vocoders now, so pick GSM because it's small and easier to
1089  translate and sounds pretty good */
1091  /*! iLBC is not too bad */
1093  /*! Speex is free, but computationally more expensive than GSM */
1096  /*! Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough
1097  to use it */
1099  /*! G.729a is faster than 723 and slightly less expensive */
1101  /*! Down to G.723.1 which is proprietary but at least designed for voice */
1103  };
1104  char buf[512];
1105 
1106  /* Strip out video */
1107  fmts &= AST_FORMAT_AUDIO_MASK;
1108 
1109  /* Find the first preferred codec in the format given */
1110  for (x = 0; x < ARRAY_LEN(prefs); x++) {
1111  if (fmts & prefs[x])
1112  return prefs[x];
1113  }
1114 
1115  ast_log(LOG_WARNING, "Don't know any of %s formats\n", ast_getformatname_multiple(buf, sizeof(buf), fmts));
1116 
1117  return 0;
1118 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
#define AST_FORMAT_G723_1
Definition: frame.h:242
#define LOG_WARNING
Definition: logger.h:144
#define AST_FORMAT_G729A
Definition: frame.h:258
#define AST_FORMAT_LPC10
Definition: frame.h:256
#define AST_FORMAT_ALAW
Definition: frame.h:248
#define AST_FORMAT_SPEEX
Definition: frame.h:260
#define AST_FORMAT_G726
Definition: frame.h:264
#define AST_FORMAT_G726_AAL2
Definition: frame.h:250
#define AST_FORMAT_SLINEAR16
Definition: frame.h:272
#define AST_FORMAT_SIREN7
Definition: frame.h:268
int64_t format_t
Definition: frame_defs.h:32
static struct ast_codec_pref prefs
Definition: chan_iax2.c:258
#define AST_FORMAT_ULAW
Definition: frame.h:246
#define AST_FORMAT_TESTLAW
Definition: frame.h:303
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define AST_FORMAT_AUDIO_MASK
Definition: frame.h:274
#define AST_FORMAT_SIREN14
Definition: frame.h:270
#define AST_FORMAT_SLINEAR
Definition: frame.h:254
#define AST_FORMAT_G719
Definition: frame.h:299
#define AST_FORMAT_ADPCM
Definition: frame.h:252
char * ast_getformatname_multiple(char *buf, size_t size, format_t format)
Get the names of a set of formats.
Definition: frame.c:591
#define AST_FORMAT_G722
Definition: frame.h:266
#define AST_FORMAT_ILBC
Definition: frame.h:262
#define AST_FORMAT_GSM
Definition: frame.h:244
#define AST_FORMAT_SPEEX16
Definition: frame.h:301
struct ast_channel* ast_bridged_channel ( struct ast_channel chan)

Find bridged channel.

Note
This function does not return a reference to the bridged channel. The reason for this is mostly historical. It should return a reference, but it will take a lot of work to make the code base account for that. So, for now, the old rules still apply for how to handle this function. If this function is being used from the channel thread that owns the channel, then a reference is already held, and channel locking is not required to guarantee that the channel will stay around. If this function is used outside of the associated channel thread, the channel parameter 'chan' MUST be locked before calling this function. Also, 'chan' must remain locked for the entire time that the result of this function is being used.
Parameters
chanCurrent channel
Returns
A pointer to the bridged channel

Definition at line 7160 of file channel.c.

References ast_channel::_bridge, ast_channel_tech::bridged_channel, and ast_channel::tech.

Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_channel_masquerade(), __ast_read(), __dahdi_exception(), _skinny_show_lines(), action_agents(), action_coreshowchannels(), agents_data_provider_get(), agents_show(), agents_show_online(), analog_attempt_transfer(), analog_exception(), analog_hangup(), analog_ss_thread(), ast_bridge_call(), ast_cel_report_event(), ast_channel_data_add_structure(), ast_channel_set_linkgroup(), ast_do_masquerade(), ast_rtp_instance_set_stats_vars(), ast_set_hangupsource(), ast_var_channel_bridge(), ast_var_channels_table(), attempt_transfer(), cb_events(), channel_spy(), check_bridge(), common_exec(), console_transfer(), create_jb(), dahdi_handle_event(), dahdi_hangup(), export_aoc_vars(), func_channel_read(), get_refer_info(), handle_chanlist(), handle_hd_hf(), handle_invite_replaces(), handle_request(), handle_request_bye(), handle_request_info(), handle_request_refer(), handle_showchan(), handle_soft_key_event_message(), handle_stimulus_message(), key_call(), key_dial_page(), local_attended_transfer(), local_queryoption(), mgcp_hangup(), mgcp_ss(), misdn_attempt_transfer(), mixmonitor_thread(), my_get_sigpvt_bridged_channel(), park_call_full(), pri_dchannel(), schedule_delivery(), serialize_showchan(), sig_pri_attempt_transfer(), sip_get_rtp_peer(), sip_get_trtp_peer(), sip_get_udptl_peer(), sip_get_vrtp_peer(), sip_hangup(), sip_set_rtp_peer(), skinny_transfer(), socket_process(), start_spying(), startmon(), TransferCallStep1(), and unistim_hangup().

7161 {
7162  struct ast_channel *bridged;
7163  bridged = chan->_bridge;
7164  if (bridged && bridged->tech->bridged_channel)
7165  bridged = bridged->tech->bridged_channel(chan, bridged);
7166  return bridged;
7167 }
Main Channel structure associated with a channel.
Definition: channel.h:742
struct ast_channel * _bridge
Definition: channel.h:748
struct ast_channel *(*const bridged_channel)(struct ast_channel *chan, struct ast_channel *bridge)
Find bridged channel.
Definition: channel.h:597
struct ast_channel_tech * tech
Definition: channel.h:743
int ast_call ( struct ast_channel chan,
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 (Should be treated as const char *)
timeouttime to wait on for connect

Place a call, take no longer than timeout ms.

Returns
-1 on failure, 0 on not enough time (does not automatically stop ringing), and the number of seconds the connect took otherwise.

Definition at line 5761 of file channel.c.

References AST_CDR_FLAG_DIALED, ast_channel_lock, ast_channel_unlock, ast_check_hangup(), AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, ast_set_flag, ast_test_flag, ast_channel_tech::call, ast_channel::cdr, and ast_channel::tech.

Referenced by __ast_request_and_dial(), ast_call_forward(), begin_dial_channel(), dial_exec_full(), dial_transfer(), do_forward(), do_idle_thread(), feature_request_and_dial(), findmeexec(), play_sound_file(), ring_entry(), and wait_for_answer().

5762 {
5763  /* Place an outgoing call, but don't wait any longer than timeout ms before returning.
5764  If the remote end does not answer within the timeout, then do NOT hang up, but
5765  return anyway. */
5766  int res = -1;
5767  /* Stop if we're a zombie or need a soft hangup */
5768  ast_channel_lock(chan);
5769  if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) {
5770  if (chan->cdr) {
5772  }
5773  if (chan->tech->call)
5774  res = chan->tech->call(chan, addr, timeout);
5776  }
5777  ast_channel_unlock(chan);
5778  return res;
5779 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define ast_set_flag(p, flag)
Definition: utils.h:70
struct ast_cdr * cdr
Definition: channel.h:766
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int(*const call)(struct ast_channel *chan, char *addr, int timeout)
Call a given phone number (address, etc), but don&#39;t take longer than timeout seconds to do so...
Definition: channel.h:542
struct ast_channel_tech * tech
Definition: channel.h:743
struct ast_channel* ast_call_forward ( struct ast_channel caller,
struct ast_channel orig,
int *  timeout,
format_t  format,
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
formatrequested channel format
ohoutgoing helper used with original channel
outstatereason why unsuccessful (if uncuccessful)
Returns
Returns the forwarded call's ast_channel on success or NULL on failure

Definition at line 5386 of file channel.c.

References outgoing_helper::account, accountcode, ast_channel::accountcode, ast_call(), AST_CDR_FLAG_ORIGINATED, ast_cdr_setaccount(), ast_channel_lock, ast_channel_lock_both, ast_channel_unlock, ast_copy_flags, ast_copy_string(), ast_hangup(), ast_log(), ast_party_connected_line_copy(), ast_party_redirecting_copy(), ast_request(), ast_set_variables(), ast_string_field_set, ast_channel::call_forward, call_forward_inherit(), ast_channel::cdr, ast_channel::connected, ast_channel::context, ast_channel::data, handle_cause(), LOG_NOTICE, outgoing_helper::parent_channel, pbx_builtin_getvar_helper(), ast_channel::redirecting, S_OR, type, and outgoing_helper::vars.

Referenced by __ast_request_and_dial(), and feature_request_and_dial().

5387 {
5388  char tmpchan[256];
5389  struct ast_channel *new_chan = NULL;
5390  char *data, *type;
5391  int cause = 0;
5392  int res;
5393 
5394  /* gather data and request the new forward channel */
5395  ast_copy_string(tmpchan, orig->call_forward, sizeof(tmpchan));
5396  if ((data = strchr(tmpchan, '/'))) {
5397  *data++ = '\0';
5398  type = tmpchan;
5399  } else {
5400  const char *forward_context;
5401  ast_channel_lock(orig);
5402  forward_context = pbx_builtin_getvar_helper(orig, "FORWARD_CONTEXT");
5403  snprintf(tmpchan, sizeof(tmpchan), "%s@%s", orig->call_forward, S_OR(forward_context, orig->context));
5404  ast_channel_unlock(orig);
5405  data = tmpchan;
5406  type = "Local";
5407  }
5408  if (!(new_chan = ast_request(type, format, orig, data, &cause))) {
5409  ast_log(LOG_NOTICE, "Unable to create channel for call forward to '%s/%s' (cause = %d)\n", type, data, cause);
5410  handle_cause(cause, outstate);
5411  ast_hangup(orig);
5412  return NULL;
5413  }
5414 
5415  /* Copy/inherit important information into new channel */
5416  if (oh) {
5417  if (oh->vars) {
5418  ast_set_variables(new_chan, oh->vars);
5419  }
5420  if (oh->parent_channel) {
5421  call_forward_inherit(new_chan, oh->parent_channel, orig);
5422  }
5423  if (oh->account) {
5424  ast_channel_lock(new_chan);
5425  ast_cdr_setaccount(new_chan, oh->account);
5426  ast_channel_unlock(new_chan);
5427  }
5428  } else if (caller) { /* no outgoing helper so use caller if available */
5429  call_forward_inherit(new_chan, caller, orig);
5430  }
5431 
5432  ast_channel_lock_both(orig, new_chan);
5433  ast_copy_flags(new_chan->cdr, orig->cdr, AST_CDR_FLAG_ORIGINATED);
5434  ast_string_field_set(new_chan, accountcode, orig->accountcode);
5437  ast_channel_unlock(new_chan);
5438  ast_channel_unlock(orig);
5439 
5440  /* call new channel */
5441  res = ast_call(new_chan, data, 0);
5442  if (timeout) {
5443  *timeout = res;
5444  }
5445  if (res) {
5446  ast_log(LOG_NOTICE, "Unable to call forward to channel %s/%s\n", type, (char *)data);
5447  ast_hangup(orig);
5448  ast_hangup(new_chan);
5449  return NULL;
5450  }
5451  ast_hangup(orig);
5452 
5453  return new_chan;
5454 }
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2804
static char accountcode[AST_MAX_ACCOUNT_CODE]
Definition: chan_iax2.c:383
#define ast_channel_lock(chan)
Definition: channel.h:2466
Main Channel structure associated with a channel.
Definition: channel.h:742
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
struct ast_channel * parent_channel
Definition: channel.h:1006
char context[AST_MAX_CONTEXT]
Definition: channel.h:868
int ast_cdr_setaccount(struct ast_channel *chan, const char *account)
Set account code, will generate AMI event.
Definition: cdr.c:990
void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars)
adds a list of channel variables to a channel
Definition: channel.c:8261
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Definition: channel.h:814
struct ast_cdr * cdr
Definition: channel.h:766
#define ast_copy_flags(dest, src, flagz)
Definition: utils.h:84
const char * data
Definition: channel.h:755
struct ast_variable * vars
Definition: channel.h:1005
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
Definition: pbx.c:10475
const char * account
Definition: channel.h:1004
static void handle_cause(int cause, int *outstate)
Definition: channel.c:5336
const ast_string_field call_forward
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define LOG_NOTICE
Definition: logger.h:133
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int ast_call(struct ast_channel *chan, char *addr, int timeout)
Make a call.
Definition: channel.c:5761
static const char type[]
Definition: chan_nbs.c:57
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition: channel.h:2473
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:2316
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:77
static void call_forward_inherit(struct ast_channel *new_chan, struct ast_channel *parent, struct ast_channel *orig)
Definition: channel.c:5359
const ast_string_field accountcode
Definition: channel.h:787
struct ast_channel * ast_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *status)
Requests a channel.
Definition: channel.c:5695
static snd_pcm_format_t format
Definition: chan_alsa.c:93
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:2367
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:344
void ast_cancel_shutdown ( void  )

Cancel a shutdown in progress.

Cancels an existing shutdown and returns to normal operation

Definition at line 859 of file channel.c.

Referenced by handle_abort_shutdown().

860 {
861  shutting_down = 0;
862 }
static int shutting_down
Prevent new channel allocation if shutting down.
Definition: channel.c:99
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 980 of file channel.c.

References ARRAY_LEN, causes, and causes_map::desc.

Referenced by __transmit_response(), ast_channel_data_add_structure(), ast_do_masquerade(), ast_hangup(), dial_exec_full(), findmeexec(), sip_hangup(), and transmit_request_with_auth().

981 {
982  int x;
983 
984  for (x = 0; x < ARRAY_LEN(causes); x++) {
985  if (causes[x].cause == cause)
986  return causes[x].desc;
987  }
988 
989  return "Unknown";
990 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static struct causes_map causes[]
Definition: channel.c:209
const char * desc
Definition: channel.c:206
void ast_change_name ( struct ast_channel chan,
const char *  newname 
)

Change channel name.

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

Definition at line 6229 of file channel.c.

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

Referenced by update_name().

6230 {
6231  /* We must re-link, as the hash value will change here. */
6232  ao2_lock(channels);
6233  ast_channel_lock(chan);
6234  ao2_unlink(channels, chan);
6235  __ast_change_name_nolink(chan, newname);
6236  ao2_link(channels, chan);
6237  ast_channel_unlock(chan);
6239 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define ao2_link(arg1, arg2)
Definition: astobj2.h:785
#define ao2_unlock(a)
Definition: astobj2.h:497
#define ao2_lock(a)
Definition: astobj2.h:488
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:197
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:6223
#define ast_channel_unlock(chan)
Definition: channel.h:2467
#define ao2_unlink(arg1, arg2)
Definition: astobj2.h:817
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 char *  linkedid,
const int  amaflag,
const char *  name_fmt,
  ... 
)

Definition at line 9825 of file channel.c.

References __ast_channel_alloc_ap().

Referenced by __oh323_new(), action_bridge(), agent_new(), alsa_new(), ast_async_goto(), ast_iax2_new(), ast_pbx_outgoing_exten(), bridge_exec(), bridge_request(), builtin_atxfer(), check_goto_on_transfer(), console_new(), dahdi_new(), do_notify(), gtalk_new(), iax_park(), jingle_new(), local_new(), masq_park_call(), mgcp_new(), misdn_new(), multicast_rtp_request(), nbs_new(), oss_new(), phone_new(), sip_new(), sip_park(), skinny_new(), and unistim_new().

9830 {
9831  va_list ap1, ap2;
9832  struct ast_channel *result;
9833 
9834 
9835  va_start(ap1, name_fmt);
9836  va_start(ap2, name_fmt);
9837  result = __ast_channel_alloc_ap(needqueue, state, cid_num, cid_name, acctcode, exten, context,
9838  linkedid, amaflag, __FILE__, __LINE__, __FUNCTION__, name_fmt, ap1, ap2);
9839  va_end(ap1);
9840  va_end(ap2);
9841 
9842  return result;
9843 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:109
Main Channel structure associated with a channel.
Definition: channel.h:742
const ast_string_field linkedid
Definition: channel.h:787
static char cid_num[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:157
static char cid_name[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:158
static struct ast_channel *attribute_malloc __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 char *linkedid, const int amaflag, const char *file, int line, const char *function, const char *name_fmt, va_list ap1, va_list ap2)
Create a new channel structure.
Definition: channel.c:1130
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:107
enum ast_bridge_result ast_channel_bridge ( struct ast_channel c0,
struct ast_channel c1,
struct ast_bridge_config config,
struct ast_frame **  fo,
struct ast_channel **  rc 
)

Bridge two channels together.

Parameters
c0first channel to bridge
c1second channel to bridge
configconfig for the channels
fodestination frame(?)
rcdestination channel(?)

Bridge two channels (c0 and c1) together. If an important frame occurs, we return that frame in *rf (remember, it could be NULL) and which channel (0 or 1) in rc

Definition at line 7506 of file channel.c.

References ast_channel::_bridge, ast_channel::_softhangup, AST_BRIDGE_COMPLETE, AST_BRIDGE_FAILED, AST_BRIDGE_FAILED_NOWARN, AST_BRIDGE_RETRY, ast_channel_clear_softhangup(), ast_channel_lock_both, ast_channel_make_compatible(), ast_channel_unlock, ast_check_hangup(), ast_check_hangup_locked(), ast_clear_flag, AST_CONTROL_SRCUPDATE, ast_debug, AST_FEATURE_PLAY_WARNING, AST_FEATURE_WARNING_ACTIVE, AST_FLAG_END_DTMF_ONLY, AST_FLAG_NBRIDGE, AST_FLAG_ZOMBIE, ast_framehook_list_is_empty(), ast_generic_bridge(), ast_indicate(), ast_log(), ast_manager_event_multichan, ast_samp2tv(), ast_set_flag, ast_set_owners_and_peers(), AST_SOFTHANGUP_UNBRIDGE, ast_test_flag, ast_test_suite_event_notify, ast_tvadd(), ast_tvdiff_ms(), ast_tvnow(), ast_tvsub(), ast_tvzero(), ast_verb, ast_channel::audiohooks, ast_channel_tech::bridge, bridge_play_sounds(), bridge_playfile(), ast_channel::caller, ast_bridge_config::end_sound, EVENT_FLAG_CALL, ast_bridge_config::feature_start_time, ast_bridge_config::feature_timer, ast_bridge_config::features_callee, ast_bridge_config::features_caller, ast_bridge_config::flags, ast_channel::framehooks, ast_channel::generator, ast_party_caller::id, LOG_WARNING, manager_bridge_event(), ast_channel::masq, ast_channel::masqr, ast_channel::monitor, ast_channel::name, ast_channel::nativeformats, ast_bridge_config::nexteventts, ast_party_id::number, ast_bridge_config::play_warning, ast_channel::readformat, S_COR, ast_channel_tech::send_digit_begin, ast_bridge_config::start_sound, ast_bridge_config::start_time, ast_party_number::str, ast_channel::tech, ast_bridge_config::timelimit, ast_channel::uniqueid, update_bridge_vars(), ast_party_number::valid, ast_bridge_config::warning_freq, ast_bridge_config::warning_sound, and ast_channel::writeformat.

Referenced by ast_bridge_call().

7508 {
7509  struct ast_channel *chans[2] = { c0, c1 };
7511  format_t o0nativeformats;
7512  format_t o1nativeformats;
7513  long time_left_ms=0;
7514  char caller_warning = 0;
7515  char callee_warning = 0;
7516 
7517  *fo = NULL;
7518 
7519  if (c0->_bridge) {
7520  ast_log(LOG_WARNING, "%s is already in a bridge with %s\n",
7521  c0->name, c0->_bridge->name);
7522  return -1;
7523  }
7524  if (c1->_bridge) {
7525  ast_log(LOG_WARNING, "%s is already in a bridge with %s\n",
7526  c1->name, c1->_bridge->name);
7527  return -1;
7528  }
7529 
7530  /* Stop if we're a zombie or need a soft hangup */
7533  return -1;
7534 
7535  caller_warning = ast_test_flag(&config->features_caller, AST_FEATURE_PLAY_WARNING);
7536  callee_warning = ast_test_flag(&config->features_callee, AST_FEATURE_PLAY_WARNING);
7537 
7538  if (ast_tvzero(config->start_time)) {
7539  config->start_time = ast_tvnow();
7540  if (config->start_sound) {
7541  if (caller_warning) {
7542  bridge_playfile(c0, c1, config->start_sound, config->timelimit / 1000);
7543  }
7544  if (callee_warning) {
7545  bridge_playfile(c1, c0, config->start_sound, config->timelimit / 1000);
7546  }
7547  }
7548  }
7549 
7550  /* Keep track of bridge */
7551  ast_channel_lock_both(c0, c1);
7552  c0->_bridge = c1;
7553  c1->_bridge = c0;
7554  ast_channel_unlock(c0);
7555  ast_channel_unlock(c1);
7556 
7557  ast_set_owners_and_peers(c0, c1);
7558 
7559  o0nativeformats = c0->nativeformats;
7560  o1nativeformats = c1->nativeformats;
7561 
7562  if (config->feature_timer && !ast_tvzero(config->nexteventts)) {
7563  config->nexteventts = ast_tvadd(config->feature_start_time, ast_samp2tv(config->feature_timer, 1000));
7564  } else if (config->timelimit) {
7565  time_left_ms = config->timelimit - ast_tvdiff_ms(ast_tvnow(), config->start_time);
7566  config->nexteventts = ast_tvadd(config->start_time, ast_samp2tv(config->timelimit, 1000));
7567  if ((caller_warning || callee_warning) && config->play_warning) {
7568  long next_warn = config->play_warning;
7569  if (time_left_ms < config->play_warning && config->warning_freq > 0) {
7570  /* At least one warning was played, which means we are returning after feature */
7571  long warns_passed = (config->play_warning - time_left_ms) / config->warning_freq;
7572  /* It is 'warns_passed * warning_freq' NOT '(warns_passed + 1) * warning_freq',
7573  because nexteventts will be updated once again in the 'if (!to)' block */
7574  next_warn = config->play_warning - warns_passed * config->warning_freq;
7575  }
7576  config->nexteventts = ast_tvsub(config->nexteventts, ast_samp2tv(next_warn, 1000));
7577  }
7578  } else {
7579  config->nexteventts.tv_sec = 0;
7580  config->nexteventts.tv_usec = 0;
7581  }
7582 
7583  if (!c0->tech->send_digit_begin)
7585  if (!c1->tech->send_digit_begin)
7587  manager_bridge_event(1, 1, c0, c1);
7588 
7589  /* Before we enter in and bridge these two together tell them both the source of audio has changed */
7592 
7593  for (/* ever */;;) {
7594  struct timeval now = { 0, };
7595  int to;
7596 
7597  to = -1;
7598 
7599  if (!ast_tvzero(config->nexteventts)) {
7600  now = ast_tvnow();
7601  to = ast_tvdiff_ms(config->nexteventts, now);
7602  if (to <= 0) {
7603  if (!config->timelimit) {
7604  res = AST_BRIDGE_COMPLETE;
7605  break;
7606  }
7607  to = 0;
7608  }
7609  }
7610 
7611  if (config->timelimit) {
7612  time_left_ms = config->timelimit - ast_tvdiff_ms(now, config->start_time);
7613  if (time_left_ms < 0) {
7614  time_left_ms = 0;
7615  }
7616 
7617  if (time_left_ms < to) {
7618  to = time_left_ms;
7619  }
7620 
7621  if (time_left_ms <= 0) {
7622  if (caller_warning && config->end_sound)
7623  bridge_playfile(c0, c1, config->end_sound, 0);
7624  if (callee_warning && config->end_sound)
7625  bridge_playfile(c1, c0, config->end_sound, 0);
7626  *fo = NULL;
7627  res = AST_BRIDGE_COMPLETE;
7628  ast_test_suite_event_notify("BRIDGE_TIMELIMIT", "Channel1: %s\r\nChannel2: %s", c0->name, c1->name);
7629  break;
7630  }
7631 
7632  if (!to) {
7633  if (time_left_ms >= 5000 && config->warning_sound && config->play_warning && ast_test_flag(config, AST_FEATURE_WARNING_ACTIVE)) {
7634  int t = (time_left_ms + 500) / 1000; /* round to nearest second */
7635  if (caller_warning)
7636  bridge_playfile(c0, c1, config->warning_sound, t);
7637  if (callee_warning)
7638  bridge_playfile(c1, c0, config->warning_sound, t);
7639  }
7640 
7641  if (config->warning_freq && (time_left_ms > (config->warning_freq + 5000))) {
7642  config->nexteventts = ast_tvadd(config->nexteventts, ast_samp2tv(config->warning_freq, 1000));
7643  } else {
7644  config->nexteventts = ast_tvadd(config->start_time, ast_samp2tv(config->timelimit, 1000));
7645  }
7646  }
7648  }
7649 
7650  if ((c0->_softhangup | c1->_softhangup) & AST_SOFTHANGUP_UNBRIDGE) {/* Bit operators are intentional. */
7653  }
7656  }
7657  ast_channel_lock_both(c0, c1);
7658  c0->_bridge = c1;
7659  c1->_bridge = c0;
7660  ast_channel_unlock(c0);
7661  ast_channel_unlock(c1);
7662  ast_debug(1, "Unbridge signal received. Ending native bridge.\n");
7663  continue;
7664  }
7665 
7666  /* Stop if we're a zombie or need a soft hangup */
7669  *fo = NULL;
7670  res = AST_BRIDGE_COMPLETE;
7671  ast_debug(1, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n",
7672  c0->name, c1->name,
7673  ast_test_flag(c0, AST_FLAG_ZOMBIE) ? "Yes" : "No",
7674  ast_check_hangup(c0) ? "Yes" : "No",
7675  ast_test_flag(c1, AST_FLAG_ZOMBIE) ? "Yes" : "No",
7676  ast_check_hangup(c1) ? "Yes" : "No");
7677  break;
7678  }
7679 
7680  update_bridge_vars(c0, c1);
7681 
7682  bridge_play_sounds(c0, c1);
7683 
7684  if (c0->tech->bridge &&
7685  /* if < 1 ms remains use generic bridging for accurate timing */
7686  (!config->timelimit || to > 1000 || to == -1) &&
7687  (c0->tech->bridge == c1->tech->bridge) &&
7688  !c0->monitor && !c1->monitor &&
7689  !c0->audiohooks && !c1->audiohooks &&
7691  !c0->masq && !c0->masqr && !c1->masq && !c1->masqr) {
7692  int timeoutms = to - 1000 > 0 ? to - 1000 : to;
7693  /* Looks like they share a bridge method and nothing else is in the way */
7696  if ((res = c0->tech->bridge(c0, c1, config->flags, fo, rc, timeoutms)) == AST_BRIDGE_COMPLETE) {
7697  ast_manager_event_multichan(EVENT_FLAG_CALL, "Unlink", 2, chans,
7698  "Channel1: %s\r\n"
7699  "Channel2: %s\r\n"
7700  "Uniqueid1: %s\r\n"
7701  "Uniqueid2: %s\r\n"
7702  "CallerID1: %s\r\n"
7703  "CallerID2: %s\r\n",
7704  c0->name, c1->name,
7705  c0->uniqueid, c1->uniqueid,
7706  S_COR(c0->caller.id.number.valid, c0->caller.id.number.str, "<unknown>"),
7707  S_COR(c1->caller.id.number.valid, c1->caller.id.number.str, "<unknown>"));
7708 
7709  ast_debug(1, "Returning from native bridge, channels: %s, %s\n", c0->name, c1->name);
7710 
7713 
7714  if ((c0->_softhangup | c1->_softhangup) & AST_SOFTHANGUP_UNBRIDGE) {/* Bit operators are intentional. */
7715  continue;
7716  }
7717 
7718  ast_channel_lock_both(c0, c1);
7719  c0->_bridge = NULL;
7720  c1->_bridge = NULL;
7721  ast_channel_unlock(c0);
7722  ast_channel_unlock(c1);
7723  return res;
7724  } else {
7727  }
7728  switch (res) {
7729  case AST_BRIDGE_RETRY:
7730  if (config->play_warning) {
7732  }
7733  continue;
7734  default:
7735  ast_verb(3, "Native bridging %s and %s ended\n", c0->name, c1->name);
7736  /* fallthrough */
7738  break;
7739  }
7740  }
7741 
7742  if (((c0->writeformat != c1->readformat) || (c0->readformat != c1->writeformat) ||
7743  (c0->nativeformats != o0nativeformats) || (c1->nativeformats != o1nativeformats)) &&
7744  !(c0->generator || c1->generator)) {
7745  if (ast_channel_make_compatible(c0, c1)) {
7746  ast_log(LOG_WARNING, "Can't make %s and %s compatible\n", c0->name, c1->name);
7747  manager_bridge_event(0, 1, c0, c1);
7748  return AST_BRIDGE_FAILED;
7749  }
7750  o0nativeformats = c0->nativeformats;
7751  o1nativeformats = c1->nativeformats;
7752  }
7753 
7754  update_bridge_vars(c0, c1);
7755 
7756  res = ast_generic_bridge(c0, c1, config, fo, rc);
7757  if (res != AST_BRIDGE_RETRY) {
7758  break;
7759  } else if (config->feature_timer) {
7760  /* feature timer expired but has not been updated, sending to ast_bridge_call to do so */
7761  break;
7762  }
7763  }
7764 
7767 
7768  /* Now that we have broken the bridge the source will change yet again */
7771 
7772  ast_channel_lock_both(c0, c1);
7773  c0->_bridge = NULL;
7774  c1->_bridge = NULL;
7775  ast_channel_unlock(c0);
7776  ast_channel_unlock(c1);
7777 
7778  ast_manager_event_multichan(EVENT_FLAG_CALL, "Unlink", 2, chans,
7779  "Channel1: %s\r\n"
7780  "Channel2: %s\r\n"
7781  "Uniqueid1: %s\r\n"
7782  "Uniqueid2: %s\r\n"
7783  "CallerID1: %s\r\n"
7784  "CallerID2: %s\r\n",
7785  c0->name, c1->name,
7786  c0->uniqueid, c1->uniqueid,
7787  S_COR(c0->caller.id.number.valid, c0->caller.id.number.str, "<unknown>"),
7788  S_COR(c1->caller.id.number.valid, c1->caller.id.number.str, "<unknown>"));
7789  ast_debug(1, "Bridge stops bridging channels %s and %s\n", c0->name, c1->name);
7790 
7791  return res;
7792 }
struct ast_channel * masqr
Definition: channel.h:752
Main Channel structure associated with a channel.
Definition: channel.h:742
long feature_timer
Definition: channel.h:980
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
struct ast_channel * masq
Definition: channel.h:751
static void bridge_play_sounds(struct ast_channel *c0, struct ast_channel *c1)
Definition: channel.c:7478
struct timeval feature_start_time
Definition: channel.h:979
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
const ast_string_field uniqueid
Definition: channel.h:787
struct ast_flags features_callee
Definition: channel.h:976
format_t writeformat
Definition: channel.h:854
#define ast_test_flag(p, flag)
Definition: utils.h:63
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4393
int(*const send_digit_begin)(struct ast_channel *chan, char digit)
Start sending a literal DTMF digit.
Definition: channel.h:528
#define ast_set_flag(p, flag)
Definition: utils.h:70
int ast_check_hangup_locked(struct ast_channel *chan)
Definition: channel.c:820
int ast_framehook_list_is_empty(struct ast_framehook_list *framehooks)
Determine if an framehook list is empty or not.
Definition: framehook.c:172
#define LOG_WARNING
Definition: logger.h:144
struct ast_generator * generator
Definition: channel.h:747
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:100
#define EVENT_FLAG_CALL
Definition: manager.h:72
struct timeval nexteventts
Definition: channel.h:978
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
format_t nativeformats
Definition: channel.h:852
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:90
static void update_bridge_vars(struct ast_channel *c0, struct ast_channel *c1)
Definition: channel.c:7441
#define ast_verb(level,...)
Definition: logger.h:243
const char * start_sound
Definition: channel.h:986
static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct ast_channel *c1, struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc)
Definition: channel.c:7203
static void manager_bridge_event(int onoff, int type, struct ast_channel *c0, struct ast_channel *c1)
Send manager event for bridge link and unlink events.
Definition: channel.c:7421
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
unsigned int flags
Definition: channel.h:987
void ast_channel_clear_softhangup(struct ast_channel *chan, int flag)
Clear a set of softhangup flags from a channel.
Definition: channel.c:2707
struct timeval start_time
Definition: channel.h:977
struct ast_audiohook_list * audiohooks
Definition: channel.h:764
const char * end_sound
Definition: channel.h:985
#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:83
struct timeval ast_samp2tv(unsigned int _nsamp, unsigned int _rate)
Returns a timeval corresponding to the duration of n samples at rate r. Useful to convert samples to ...
Definition: time.h:191
struct ast_channel * _bridge
Definition: channel.h:748
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
struct ast_flags features_caller
Definition: channel.h:975
#define ast_test_suite_event_notify(s, f,...)
Definition: test.h:184
enum ast_bridge_result(*const bridge)(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms)
Bridge two channels of the same type together.
Definition: channel.h:569
static void bridge_playfile(struct ast_channel *chan, struct ast_channel *peer, const char *sound, int remain)
Definition: channel.c:7169
static void ast_set_owners_and_peers(struct ast_channel *chan1, struct ast_channel *chan2)
Definition: channel.c:6430
int64_t format_t
Definition: frame_defs.h:32
struct ast_framehook_list * framehooks
Definition: channel.h:765
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
Definition: utils.c:1587
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int _softhangup
Definition: channel.h:832
#define ast_channel_unlock(chan)
Definition: channel.h:2467
#define ast_clear_flag(p, flag)
Definition: utils.h:77
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition: channel.h:2473
int ast_channel_make_compatible(struct ast_channel *c0, struct ast_channel *c1)
Makes two channel formats compatible.
Definition: channel.c:5970
format_t readformat
Definition: channel.h:853
#define ast_manager_event_multichan(category, event, nchans, chans, contents,...)
Definition: manager.h:226
struct timeval ast_tvsub(struct timeval a, struct timeval b)
Returns the difference of two timevals a - b.
Definition: utils.c:1601
const char * warning_sound
Definition: channel.h:984
struct ast_channel_monitor * monitor
Definition: channel.h:769
struct ast_channel_tech * tech
Definition: channel.h:743
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
ast_bridge_result
Definition: channel.h:168
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
struct ast_channel* ast_channel_callback ( ao2_callback_data_fn cb_fn,
void *  arg,
void *  data,
int  ao2_flags 
)

Call a function with every active channel.

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

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

Definition at line 1634 of file channel.c.

References ao2_callback_data, and channels.

Referenced by ast_pickup_call(), handle_core_set_debug_channel(), my_ast_get_channel_by_name_locked(), pickup_by_group(), pickup_by_mark(), pickup_by_part(), and state_notify_build_xml().

1636 {
1637  return ao2_callback_data(channels, ao2_flags, cb_fn, arg, data);
1638 }
#define ao2_callback_data(arg1, arg2, arg3, arg4, arg5)
Definition: astobj2.h:943
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:197
int ast_channel_cc_params_init ( struct ast_channel chan,
const struct ast_cc_config_params base_params 
)

Set up datastore with CCSS parameters for a channel.

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

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

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

Definition at line 9731 of file channel.c.

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

Referenced by ast_channel_get_cc_config_params(), dahdi_new(), local_call(), local_request(), and sip_new().

9733 {
9734  struct ast_cc_config_params *cc_params;
9735  struct ast_datastore *cc_datastore;
9736 
9737  if (!(cc_params = ast_cc_config_params_init())) {
9738  return -1;
9739  }
9740 
9741  if (!(cc_datastore = ast_datastore_alloc(&cc_channel_datastore_info, NULL))) {
9742  ast_cc_config_params_destroy(cc_params);
9743  return -1;
9744  }
9745 
9746  if (base_params) {
9747  ast_cc_copy_config_params(cc_params, base_params);
9748  }
9749  cc_datastore->data = cc_params;
9750  ast_channel_datastore_add(chan, cc_datastore);
9751  return 0;
9752 }
void ast_cc_config_params_destroy(struct ast_cc_config_params *params)
Free memory from CCSS configuration params.
Definition: ccss.c:579
Structure for a data store object.
Definition: datastore.h:54
#define ast_cc_config_params_init()
Allocate and initialize an ast_cc_config_params structure.
Definition: ccss.h:135
struct ast_datastore * ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
Definition: datastore.c:98
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:741
void * data
Definition: datastore.h:56
static struct ast_datastore_info cc_channel_datastore_info
Definition: channel.c:9725
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition: channel.c:2590
static void ast_channel_change_linkedid ( struct ast_channel chan,
const char *  linkedid 
)
static

Set the channel's linkedid to the given string, and also check to see if the channel's old linkedid is now being retired

Definition at line 6370 of file channel.c.

References ast_assert, ast_cel_check_retire_linkedid(), ast_cel_linkedid_ref(), ast_string_field_set, and ast_channel::linkedid.

Referenced by ast_channel_set_linkgroup().

6371 {
6372  ast_assert(linkedid != NULL);
6373  /* if the linkedid for this channel is being changed from something, check... */
6374  if (!strcmp(chan->linkedid, linkedid)) {
6375  return;
6376  }
6377 
6379  ast_string_field_set(chan, linkedid, linkedid);
6380  ast_cel_linkedid_ref(linkedid);
6381 }
void ast_cel_check_retire_linkedid(struct ast_channel *chan)
Check and potentially retire a Linked ID.
Definition: cel.c:429
#define ast_assert(a)
Definition: utils.h:738
const ast_string_field linkedid
Definition: channel.h:787
int ast_cel_linkedid_ref(const char *linkedid)
Inform CEL that a new linkedid is being used.
Definition: cel.c:597
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:344
void ast_channel_clear_softhangup ( struct ast_channel chan,
int  flag 
)

Clear a set of softhangup flags from a channel.

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

Parameters
chanthe channel to clear the flag on
flagthe flag or flags to clear
Returns
Nothing.

Definition at line 2707 of file channel.c.

References ast_channel::_softhangup, ast_channel_lock, 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, ast_channel::readq, and ast_frame::subclass.

Referenced by __ast_pbx_run(), ast_channel_bridge(), ast_generic_bridge(), check_goto_on_transfer(), and collect_digits().

2708 {
2709  ast_channel_lock(chan);
2710 
2711  chan->_softhangup &= ~flag;
2712 
2713  if (!chan->_softhangup) {
2714  struct ast_frame *fr;
2715 
2716  /* If we have completely cleared the softhangup flag,
2717  * then we need to fully abort the hangup process. This requires
2718  * pulling the END_OF_Q frame out of the channel frame queue if it
2719  * still happens to be there. */
2720 
2721  fr = AST_LIST_LAST(&chan->readq);
2722  if (fr && fr->frametype == AST_FRAME_CONTROL &&
2724  AST_LIST_REMOVE(&chan->readq, fr, frame_list);
2725  ast_frfree(fr);
2726  }
2727  }
2728 
2729  ast_channel_unlock(chan);
2730 }
union ast_frame_subclass subclass
Definition: frame.h:146
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
Definition: linkedlists.h:841
int _softhangup
Definition: channel.h:832
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.
Definition: linkedlists.h:428
#define ast_channel_unlock(chan)
Definition: channel.h:2467
Data structure associated with a single frame of data.
Definition: frame.h:142
enum ast_frame_type frametype
Definition: frame.h:144
#define ast_frfree(fr)
Definition: frame.h:583
struct ast_channel::@156 readq
static int ast_channel_cmp_cb ( void *  obj,
void *  arg,
int  flags 
)
static

Definition at line 1720 of file channel.c.

References ast_channel_lock, ast_channel_unlock, ast_strlen_zero(), CMP_MATCH, ast_channel::context, ast_channel::exten, ast_channel::macrocontext, ast_channel::macroexten, ast_channel::name, and ast_channel::uniqueid.

Referenced by ast_channels_init().

1721 {
1722  struct ast_channel *chan = obj, *cmp_args = arg;
1723  size_t name_len;
1724  int ret = CMP_MATCH;
1725 
1726  /* This is sort of a hack. Basically, we're using an arbitrary field
1727  * in ast_channel to pass the name_len for a prefix match. If this
1728  * gets changed, then the uses of ao2_find() must be changed, too. */
1729  name_len = cmp_args->rings;
1730 
1731  ast_channel_lock(chan);
1732 
1733  if (!ast_strlen_zero(cmp_args->name)) { /* match by name */
1734  if ((!name_len && strcasecmp(chan->name, cmp_args->name)) ||
1735  (name_len && strncasecmp(chan->name, cmp_args->name, name_len))) {
1736  ret = 0; /* name match failed */
1737  }
1738  } else if (!ast_strlen_zero(cmp_args->exten)) {
1739  if (cmp_args->context && strcasecmp(chan->context, cmp_args->context) &&
1740  strcasecmp(chan->macrocontext, cmp_args->context)) {
1741  ret = 0; /* context match failed */
1742  }
1743  if (ret && strcasecmp(chan->exten, cmp_args->exten) &&
1744  strcasecmp(chan->macroexten, cmp_args->exten)) {
1745  ret = 0; /* exten match failed */
1746  }
1747  } else if (!ast_strlen_zero(cmp_args->uniqueid)) {
1748  if ((!name_len && strcasecmp(chan->uniqueid, cmp_args->uniqueid)) ||
1749  (name_len && strncasecmp(chan->uniqueid, cmp_args->uniqueid, name_len))) {
1750  ret = 0; /* uniqueid match failed */
1751  }
1752  } else {
1753  ret = 0;
1754  }
1755 
1756  ast_channel_unlock(chan);
1757 
1758  return ret;
1759 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
Main Channel structure associated with a channel.
Definition: channel.h:742
const ast_string_field uniqueid
Definition: channel.h:787
char context[AST_MAX_CONTEXT]
Definition: channel.h:868
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
const ast_string_field name
Definition: channel.h:787
#define ast_channel_unlock(chan)
Definition: channel.h:2467
char macrocontext[AST_MAX_CONTEXT]
Definition: channel.h:870
char macroexten[AST_MAX_EXTENSION]
Definition: channel.h:871
char exten[AST_MAX_EXTENSION]
Definition: channel.h:869
int ast_channel_cmpwhentohangup ( struct ast_channel chan,
time_t  offset 
)

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

Parameters
chanchannel on which to check for hang up
offsetoffset in seconds from current time
Returns
1, 0, or -1

This function compares a offset from current time with the absolute time out on a channel (when to hang up). If the absolute time out on a channel is earlier than current time plus the offset, it returns 1, if the two time values are equal, it return 0, otherwise, it return -1.

See Also
ast_channel_cmpwhentohangup_tv()
Version
1.6.1 deprecated function (only had seconds precision)

Definition at line 900 of file channel.c.

References ast_channel_cmpwhentohangup_tv().

901 {
902  struct timeval when = { offset, };
903  return ast_channel_cmpwhentohangup_tv(chan, when);
904 }
int ast_channel_cmpwhentohangup_tv(struct ast_channel *chan, struct timeval offset)
Compare a offset with the settings of when to hang a channel up.
Definition: channel.c:885
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 885 of file channel.c.

References ast_tvadd(), ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), and ast_channel::whentohangup.

Referenced by ast_channel_cmpwhentohangup().

886 {
887  struct timeval whentohangup;
888 
889  if (ast_tvzero(chan->whentohangup))
890  return ast_tvzero(offset) ? 0 : -1;
891 
892  if (ast_tvzero(offset))
893  return 1;
894 
895  whentohangup = ast_tvadd(offset, ast_tvnow());
896 
897  return ast_tvdiff_ms(whentohangup, chan->whentohangup);
898 }
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:100
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:90
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
Definition: utils.c:1587
struct timeval whentohangup
Definition: channel.h:789
int ast_channel_connected_line_macro ( struct ast_channel autoservice_chan,
struct ast_channel macro_chan,
const void *  connected_info,
int  caller,
int  frame 
)

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

Since
1.8 Whenever we want to update a channel's connected line information, we may need to run a macro so that an administrator can manipulate the information before sending it out. This function both runs the macro and sends the update to the channel.
Parameters
autoservice_chanChannel to place into autoservice while the macro is running. It is perfectly safe for this to be NULL
macro_chanThe channel to run the macro on. Also the channel from which we determine which macro we need to run.
connected_infoEither an ast_party_connected_line or ast_frame pointer of type AST_CONTROL_CONNECTED_LINE
callerIf true, then run CONNECTED_LINE_CALLER_SEND_MACRO, otherwise run CONNECTED_LINE_CALLEE_SEND_MACRO
frameIf true, then connected_info is an ast_frame pointer, otherwise it is an ast_party_connected_line pointer.
Return values
0Success
-1Either the macro does not exist, or there was an error while attempting to run the macro
Todo:

Have multiple return codes based on the MACRO_RESULT

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

Definition at line 9618 of file channel.c.

References ast_app_run_macro(), 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(), chanlist::connected, ast_channel::connected, ast_frame::data, ast_frame::datalen, pbx_builtin_getvar_helper(), ast_frame::ptr, and S_OR.

Referenced by __ast_read(), app_exec(), ast_bridge_call(), ast_do_pickup(), ast_generic_bridge(), atxfer_fail_cleanup(), builtin_atxfer(), feature_request_and_dial(), handle_frame(), local_bridge_loop(), parked_call_exec(), remote_bridge_loop(), and wait_for_answer().

9619 {
9620  const char *macro;
9621  const char *macro_args;
9622  int retval;
9623 
9624  ast_channel_lock(macro_chan);
9625  macro = pbx_builtin_getvar_helper(macro_chan, is_caller
9626  ? "CONNECTED_LINE_CALLER_SEND_MACRO" : "CONNECTED_LINE_CALLEE_SEND_MACRO");
9627  macro = ast_strdupa(S_OR(macro, ""));
9628  macro_args = pbx_builtin_getvar_helper(macro_chan, is_caller
9629  ? "CONNECTED_LINE_CALLER_SEND_MACRO_ARGS" : "CONNECTED_LINE_CALLEE_SEND_MACRO_ARGS");
9630  macro_args = ast_strdupa(S_OR(macro_args, ""));
9631 
9632  if (ast_strlen_zero(macro)) {
9633  ast_channel_unlock(macro_chan);
9634  return -1;
9635  }
9636 
9637  if (is_frame) {
9638  const struct ast_frame *frame = connected_info;
9639 
9640  ast_connected_line_parse_data(frame->data.ptr, frame->datalen, &macro_chan->connected);
9641  } else {
9642  const struct ast_party_connected_line *connected = connected_info;
9643 
9644  ast_party_connected_line_copy(&macro_chan->connected, connected);
9645  }
9646  ast_channel_unlock(macro_chan);
9647 
9648  retval = ast_app_run_macro(autoservice_chan, macro_chan, macro, macro_args);
9649  if (!retval) {
9650  struct ast_party_connected_line saved_connected;
9651 
9652  ast_party_connected_line_init(&saved_connected);
9653  ast_channel_lock(macro_chan);
9654  ast_party_connected_line_copy(&saved_connected, &macro_chan->connected);
9655  ast_channel_unlock(macro_chan);
9656  ast_channel_update_connected_line(macro_chan, &saved_connected, NULL);
9657  ast_party_connected_line_free(&saved_connected);
9658  }
9659 
9660  return retval;
9661 }
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
Definition: channel.c:2308
#define ast_channel_lock(chan)
Definition: channel.h:2466
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
void * ptr
Definition: frame.h:160
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:9085
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition: channel.c:2353
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
Definition: pbx.c:10475
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
int datalen
Definition: frame.h:148
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
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:8886
Connected Line/Party information.
Definition: channel.h:401
int ast_app_run_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char *macro_name, const char *macro_args)
Run a macro on a channel, placing an optional second channel into autoservice.
Definition: app.c:294
#define ast_channel_unlock(chan)
Definition: channel.h:2467
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:2316
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:77
Data structure associated with a single frame of data.
Definition: frame.h:142
static int connected
Definition: cdr_pgsql.c:57
union ast_frame::@172 data
int ast_channel_data_add_structure ( struct ast_data tree,
struct ast_channel chan,
int  add_bridged 
)

Insert into an astdata tree, the channel structure.

Parameters
[in]treeThe ast data tree.
[in]chanThe channel structure to add to tree.
[in]add_bridgedAdd the bridged channel to the structure.
Return values
<0on error.
0on success.

Definition at line 357 of file channel.c.

References ast_channel::_softhangup, ast_channel::_state, ast_channel::amaflags, ast_bridged_channel(), ast_cause2str(), ast_cdr_data_add_structure(), ast_cdr_flags2str(), ast_channel_data_add_structure(), ast_data_add_bool(), ast_data_add_codecs(), ast_data_add_int(), ast_data_add_node(), ast_data_add_str(), ast_data_add_structure, ast_data_add_uint(), AST_SOFTHANGUP_APPUNLOAD, AST_SOFTHANGUP_ASYNCGOTO, AST_SOFTHANGUP_DEV, AST_SOFTHANGUP_EXPLICIT, AST_SOFTHANGUP_SHUTDOWN, AST_SOFTHANGUP_TIMEOUT, AST_SOFTHANGUP_UNBRIDGE, ast_state2str(), ast_tone_zone_data_add_structure(), ast_transfercapability2str(), ast_channel::cdr, channel_data_add_flags(), ast_channel::hangupcause, ast_channel::nativeformats, ast_channel::oldwriteformat, ast_channel::rawreadformat, ast_channel::rawwriteformat, ast_channel::readformat, ast_channel::transfercapability, ast_channel::whentohangup, ast_channel::writeformat, and ast_channel::zone.

Referenced by agents_data_provider_get(), ast_channel_data_add_structure(), data_channels_provider_handler(), queues_data_provider_get_helper(), and user_add_provider_cb().

359 {
360  struct ast_channel *bc;
361  struct ast_data *data_bridged;
362  struct ast_data *data_cdr;
363  struct ast_data *data_flags;
364  struct ast_data *data_zones;
365  struct ast_data *enum_node;
366  struct ast_data *data_softhangup;
367 #if 0 /* XXX AstData: ast_callerid no longer exists. (Equivalent code not readily apparent.) */
368  struct ast_data *data_callerid;
369  char value_str[100];
370 #endif
371 
372  if (!tree) {
373  return -1;
374  }
375 
376  ast_data_add_structure(ast_channel, tree, chan);
377 
378  if (add_bridged) {
379  bc = ast_bridged_channel(chan);
380  if (bc) {
381  data_bridged = ast_data_add_node(tree, "bridged");
382  if (!data_bridged) {
383  return -1;
384  }
385  ast_channel_data_add_structure(data_bridged, bc, 0);
386  }
387  }
388 
389  ast_data_add_codecs(tree, "oldwriteformat", chan->oldwriteformat);
390  ast_data_add_codecs(tree, "nativeformats", chan->nativeformats);
391  ast_data_add_codecs(tree, "readformat", chan->readformat);
392  ast_data_add_codecs(tree, "writeformat", chan->writeformat);
393  ast_data_add_codecs(tree, "rawreadformat", chan->rawreadformat);
394  ast_data_add_codecs(tree, "rawwriteformat", chan->rawwriteformat);
395 
396  /* state */
397  enum_node = ast_data_add_node(tree, "state");
398  if (!enum_node) {
399  return -1;
400  }
401  ast_data_add_str(enum_node, "text", ast_state2str(chan->_state));
402  ast_data_add_int(enum_node, "value", chan->_state);
403 
404  /* hangupcause */
405  enum_node = ast_data_add_node(tree, "hangupcause");
406  if (!enum_node) {
407  return -1;
408  }
409  ast_data_add_str(enum_node, "text", ast_cause2str(chan->hangupcause));
410  ast_data_add_int(enum_node, "value", chan->hangupcause);
411 
412  /* amaflags */
413  enum_node = ast_data_add_node(tree, "amaflags");
414  if (!enum_node) {
415  return -1;
416  }
417  ast_data_add_str(enum_node, "text", ast_cdr_flags2str(chan->amaflags));
418  ast_data_add_int(enum_node, "value", chan->amaflags);
419 
420  /* transfercapability */
421  enum_node = ast_data_add_node(tree, "transfercapability");
422  if (!enum_node) {
423  return -1;
424  }
426  ast_data_add_int(enum_node, "value", chan->transfercapability);
427 
428  /* _softphangup */
429  data_softhangup = ast_data_add_node(tree, "softhangup");
430  if (!data_softhangup) {
431  return -1;
432  }
433  ast_data_add_bool(data_softhangup, "dev", chan->_softhangup & AST_SOFTHANGUP_DEV);
434  ast_data_add_bool(data_softhangup, "asyncgoto", chan->_softhangup & AST_SOFTHANGUP_ASYNCGOTO);
435  ast_data_add_bool(data_softhangup, "shutdown", chan->_softhangup & AST_SOFTHANGUP_SHUTDOWN);
436  ast_data_add_bool(data_softhangup, "timeout", chan->_softhangup & AST_SOFTHANGUP_TIMEOUT);
437  ast_data_add_bool(data_softhangup, "appunload", chan->_softhangup & AST_SOFTHANGUP_APPUNLOAD);
438  ast_data_add_bool(data_softhangup, "explicit", chan->_softhangup & AST_SOFTHANGUP_EXPLICIT);
439  ast_data_add_bool(data_softhangup, "unbridge", chan->_softhangup & AST_SOFTHANGUP_UNBRIDGE);
440 
441  /* channel flags */
442  data_flags = ast_data_add_node(tree, "flags");
443  if (!data_flags) {
444  return -1;
445  }
446  channel_data_add_flags(data_flags, chan);
447 
448  ast_data_add_uint(tree, "timetohangup", chan->whentohangup.tv_sec);
449 
450 #if 0 /* XXX AstData: ast_callerid no longer exists. (Equivalent code not readily apparent.) */
451  /* callerid */
452  data_callerid = ast_data_add_node(tree, "callerid");
453  if (!data_callerid) {
454  return -1;
455  }
456  ast_data_add_structure(ast_callerid, data_callerid, &(chan->cid));
457  /* insert the callerid ton */
458  enum_node = ast_data_add_node(data_callerid, "cid_ton");
459  if (!enum_node) {
460  return -1;
461  }
462  ast_data_add_int(enum_node, "value", chan->cid.cid_ton);
463  snprintf(value_str, sizeof(value_str), "TON: %s/Plan: %s",
464  party_number_ton2str(chan->cid.cid_ton),
465  party_number_plan2str(chan->cid.cid_ton));
466  ast_data_add_str(enum_node, "text", value_str);
467 #endif
468 
469  /* tone zone */
470  if (chan->zone) {
471  data_zones = ast_data_add_node(tree, "zone");
472  if (!data_zones) {
473  return -1;
474  }
475  ast_tone_zone_data_add_structure(data_zones, chan->zone);
476  }
477 
478  /* insert cdr */
479  data_cdr = ast_data_add_node(tree, "cdr");
480  if (!data_cdr) {
481  return -1;
482  }
483 
484  ast_cdr_data_add_structure(data_cdr, chan->cdr, 1);
485 
486  return 0;
487 }
Main Channel structure associated with a channel.
Definition: channel.h:742
The data tree to be returned by the callbacks and managed by functions local to this file...
Definition: data.c:85
struct ast_tone_zone * zone
Definition: channel.h:767
format_t writeformat
Definition: channel.h:854
format_t rawwriteformat
Definition: channel.h:856
struct ast_data * ast_data_add_uint(struct ast_data *root, const char *childname, unsigned int value)
Add an unsigned integer node type.
Definition: data.c:2332
struct ast_data * ast_data_add_bool(struct ast_data *root, const char *childname, unsigned int boolean)
Add a boolean node type.
Definition: data.c:2344
struct ast_cdr * cdr
Definition: channel.h:766
unsigned short transfercapability
Definition: channel.h:863
format_t nativeformats
Definition: channel.h:852
const char * ast_state2str(enum ast_channel_state)
Gives the string form of a given channel state.
Definition: channel.c:1007
char * ast_cdr_flags2str(int flags)
Definition: cdr.c:977
format_t rawreadformat
Definition: channel.h:855
int ast_cdr_data_add_structure(struct ast_data *tree, struct ast_cdr *cdr, int recur)
Definition: cdr.c:1674
format_t oldwriteformat
Definition: channel.h:837
int ast_channel_data_add_structure(struct ast_data *tree, struct ast_channel *chan, int add_bridged)
Insert into an astdata tree, the channel structure.
Definition: channel.c:357
struct ast_data * ast_data_add_node(struct ast_data *root, const char *childname)
Add a container child.
Definition: data.c:2317
int ast_data_add_codecs(struct ast_data *root, const char *node_name, format_t capability)
Add the list of codecs in the root node based on the capability parameter.
Definition: data.c:3112
#define ast_data_add_structure(structure_name, root, structure)
Definition: data.h:620
int ast_tone_zone_data_add_structure(struct ast_data *tree, struct ast_tone_zone *zone)
Add a tone_zone structure to the data tree specified.
Definition: indications.c:1127
enum ast_channel_state _state
Definition: channel.h:839
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
Definition: channel.c:7160
int _softhangup
Definition: channel.h:832
const char * ast_cause2str(int state) attribute_pure
Gives the string form of a given cause code.
Definition: channel.c:980
format_t readformat
Definition: channel.h:853
char * ast_transfercapability2str(int transfercapability) attribute_const
Gives the string form of a given transfer capability.
Definition: channel.c:1041
int hangupcause
Definition: channel.h:849
struct timeval whentohangup
Definition: channel.h:789
struct ast_data * ast_data_add_str(struct ast_data *root, const char *childname, const char *string)
Add a string node type.
Definition: data.c:2401
int amaflags
Definition: channel.h:843
struct ast_data * ast_data_add_int(struct ast_data *root, const char *childname, int value)
Add an integer node type.
Definition: data.c:2322
static void channel_data_add_flags(struct ast_data *tree, struct ast_channel *chan)
Definition: channel.c:281
int ast_channel_data_cmp_structure ( const struct ast_data_search tree,
struct ast_channel chan,
const char *  structure_name 
)

Compare to channel structures using the data api.

Parameters
[in]treeThe search tree generated by the data api.
[in]chanThe channel to compare.
[in]structure_nameThe name of the node of the channel structure.
Return values
0The structure matches.
1The structure doesn't matches.

Definition at line 489 of file channel.c.

References ast_data_search_cmp_structure.

491 {
492  return ast_data_search_cmp_structure(tree, ast_channel, chan, structure_name);
493 }
Main Channel structure associated with a channel.
Definition: channel.h:742
#define ast_data_search_cmp_structure(search, structure_name, structure, structure_name_cmp)
Definition: data.h:420
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 2590 of file channel.c.

References AST_LIST_INSERT_HEAD, and ast_channel::datastores.

Referenced by __ast_channel_masquerade(), _macro_exec(), acf_curlopt_write(), acf_iaxvar_write(), acf_odbc_read(), add_features_datastore(), add_to_agi(), apply_plc(), ast_cel_fabricate_channel_from_event(), ast_channel_cc_params_init(), ast_do_pickup(), ast_iax2_new(), ast_setup_cc_recall_datastore(), audiohook_volume_get(), authenticate_reply(), calendar_query_exec(), cc_interfaces_datastore_init(), dial_exec_full(), do_notify(), dundi_query_read(), enable_jack_hook(), enum_query_read(), find_or_create_details(), find_transaction(), frame_trace_helper(), func_channel_write_real(), get_lock(), gosub_exec(), lua_get_state(), mute_add_audiohook(), pitchshift_helper(), raise_exception(), set_chan_app_data(), setup_inheritance_datastore(), setup_mixmonitor_ds(), setup_transfer_datastore(), shared_write(), smdi_msg_retrieve_read(), socket_process(), speech_create(), speex_write(), srv_datastore_setup(), try_calling(), and volume_write().

2591 {
2592  int res = 0;
2593 
2594  AST_LIST_INSERT_HEAD(&chan->datastores, datastore, entry);
2595 
2596  return res;
2597 }
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: linkedlists.h:696
struct ast_channel::datastores datastores
struct ast_datastore* ast_channel_datastore_alloc ( const struct ast_datastore_info info,
const char *  uid 
)

Create a channel data store object.

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.
Deprecated:
You should use the ast_datastore_alloc() generic function instead.
Version
1.6.1 deprecated

Definition at line 2563 of file channel.c.

References ast_datastore_alloc().

2564 {
2565  return ast_datastore_alloc(info, uid);
2566 }
struct ast_datastore * ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
Definition: datastore.c:98
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 2604 of file channel.c.

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

Referenced by _macro_exec(), acf_curl_helper(), acf_curlopt_helper(), acf_curlopt_write(), acf_exception_read(), acf_fetch(), acf_iaxvar_read(), acf_iaxvar_write(), acf_odbc_read(), add_agi_cmd(), add_features_datastore(), add_to_agi(), apply_plc(), 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_get_cc_config_params(), ast_do_masquerade(), ast_handle_cc_control_frame(), ast_ignore_cc(), ast_odbc_retrieve_transaction_obj(), ast_set_cc_interfaces_chanvar(), attended_transfer_occurred(), audiohook_volume_callback(), audiohook_volume_get(), balance_stack(), builtin_atxfer(), calendar_event_read(), calendar_query_exec(), calendar_query_result_exec(), cc_build_payload(), clear_dialed_interfaces(), dial_exec_full(), disable_jack_hook(), dundi_result_read(), enable_jack_hook(), enum_result_read(), exec_odbcfinish(), find_details(), find_speech(), find_transaction(), frame_trace_helper(), func_channel_read(), func_channel_write_real(), func_inheritance_write(), func_mute_write(), get_agi_cmd(), get_lock(), gosub_exec(), gosub_run(), handle_gosub(), iax2_call(), jack_hook_callback(), local_read(), local_write(), lock_fixup(), lua_get_state(), manage_parked_call(), manager_mutestream(), mark_transaction_active(), mute_callback(), parked_call_exec(), pitchshift_cb(), pitchshift_helper(), pop_exec(), queue_transfer_fixup(), raise_exception(), release_transaction(), return_exec(), set_security_requirements(), shared_read(), shared_write(), smdi_msg_read(), speech_datastore_destroy(), speex_callback(), speex_read(), speex_write(), srv_query_read(), srv_result_read(), stackpeek_read(), stop_mixmonitor_exec(), try_calling(), unlock_read(), volume_callback(), and volume_write().

2605 {
2606  struct ast_datastore *datastore = NULL;
2607 
2608  if (info == NULL)
2609  return NULL;
2610 
2611  AST_LIST_TRAVERSE(&chan->datastores, datastore, entry) {
2612  if (datastore->info != info) {
2613  continue;
2614  }
2615 
2616  if (uid == NULL) {
2617  /* matched by type only */
2618  break;
2619  }
2620 
2621  if ((datastore->uid != NULL) && !strcasecmp(uid, datastore->uid)) {
2622  /* Matched by type AND uid */
2623  break;
2624  }
2625  }
2626 
2627  return datastore;
2628 }
struct ast_datastore::@163 entry
struct ast_datastore_info * info
Definition: datastore.h:57
Structure for a data store object.
Definition: datastore.h:54
const char * uid
Definition: datastore.h:55
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
struct ast_channel::datastores datastores
int ast_channel_datastore_free ( struct ast_datastore datastore)

Free a channel data store object.

Deprecated:
You should use the ast_datastore_free() generic function instead.
Version
1.6.1 deprecated

Definition at line 2568 of file channel.c.

References ast_datastore_free().

2569 {
2570  return ast_datastore_free(datastore);
2571 }
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Definition: datastore.c:65
int ast_channel_datastore_inherit ( struct ast_channel from,
struct ast_channel to 
)

Inherit datastores from a parent to a child.

Definition at line 2573 of file channel.c.

References ast_datastore_alloc(), AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_datastore::data, DATASTORE_INHERIT_FOREVER, ast_channel::datastores, ast_datastore_info::duplicate, ast_datastore::info, ast_datastore::inheritance, and ast_datastore::uid.

Referenced by __ast_request_and_dial(), begin_dial_channel(), call_forward_inherit(), dial_exec_full(), dial_transfer(), do_forward(), findmeexec(), local_call(), ring_entry(), and wait_for_answer().

2574 {
2575  struct ast_datastore *datastore = NULL, *datastore2;
2576 
2577  AST_LIST_TRAVERSE(&from->datastores, datastore, entry) {
2578  if (datastore->inheritance > 0) {
2579  datastore2 = ast_datastore_alloc(datastore->info, datastore->uid);
2580  if (datastore2) {
2581  datastore2->data = datastore->info->duplicate ? datastore->info->duplicate(datastore->data) : NULL;
2582  datastore2->inheritance = datastore->inheritance == DATASTORE_INHERIT_FOREVER ? DATASTORE_INHERIT_FOREVER : datastore->inheritance - 1;
2583  AST_LIST_INSERT_TAIL(&to->datastores, datastore2, entry);
2584  }
2585  }
2586  }
2587  return 0;
2588 }
struct ast_datastore::@163 entry
struct ast_datastore_info * info
Definition: datastore.h:57
void *(* duplicate)(void *data)
Definition: datastore.h:33
Structure for a data store object.
Definition: datastore.h:54
const char * uid
Definition: datastore.h:55
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:716
struct ast_datastore * ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
Definition: datastore.c:98
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
struct ast_channel::datastores datastores
#define DATASTORE_INHERIT_FOREVER
Definition: channel.h:156
unsigned int inheritance
Definition: datastore.h:58
void * data
Definition: datastore.h:56
int ast_channel_datastore_remove ( struct ast_channel chan,
struct ast_datastore datastore 
)

Remove a datastore from a channel.

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

Definition at line 2599 of file channel.c.

References AST_LIST_REMOVE, and ast_channel::datastores.

Referenced by acf_fetch(), acf_odbc_read(), adjust_frame_for_plc(), ast_do_masquerade(), ast_do_pickup(), clear_dialed_interfaces(), dial_exec_full(), disable_jack_hook(), exec_odbcfinish(), frame_trace_helper(), lua_get_state(), queue_transfer_fixup(), speech_datastore_destroy(), speex_write(), srv_query_read(), stop_mixmonitor_exec(), and try_calling().

2600 {
2601  return AST_LIST_REMOVE(&chan->datastores, datastore, entry) ? 0 : -1;
2602 }
struct ast_datastore::@163 entry
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
Definition: linkedlists.h:841
struct ast_channel::datastores datastores
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 1616 of file channel.c.

References AST_FLAG_DEFER_DTMF, ast_set_flag, and ast_test_flag.

Referenced by __adsi_transmit_messages(), and find_cache().

1617 {
1618  int pre = 0;
1619 
1620  if (chan) {
1621  pre = ast_test_flag(chan, AST_FLAG_DEFER_DTMF);
1623  }
1624  return pre;
1625 }
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define ast_set_flag(p, flag)
Definition: utils.h:70
static void ast_channel_destructor ( void *  obj)
static

Free a channel structure.

Definition at line 2403 of file channel.c.

References ast_channel::alertpipe, ast_app_group_discard(), ast_atomic_fetchadd_int(), ast_cdr_discard(), AST_CEL_CHANNEL_END, ast_cel_check_retire_linkedid(), ast_cel_report_event(), ast_channel_lock, AST_CHANNEL_NAME, ast_channel_unlock, ast_copy_string(), ast_datastore_free(), AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, ast_devstate_changed_literal(), AST_DEVSTATE_NOT_CACHABLE, AST_FLAG_DISABLE_DEVSTATE_CACHE, ast_free, ast_frfree, ast_jb_destroy(), AST_LIST_REMOVE_HEAD, ast_log(), AST_MAX_FDS, ast_moh_cleanup(), ast_party_caller_free(), ast_party_connected_line_free(), ast_party_dialed_free(), ast_party_redirecting_free(), ast_string_field_free_memory, ast_timer_close(), ast_tone_zone_unref(), ast_translator_free_path(), ast_var_delete(), ast_channel::caller, ast_channel::cdr, ast_channel::connected, ast_channel::datastores, ast_channel::dialed, f, ast_channel::flags, free, LOG_WARNING, ast_channel::monitor, ast_channel::music_state, ast_channel::name, ast_channel::pbx, ast_channel::readq, ast_channel::readtrans, ast_channel::redirecting, ast_channel::sched, sched_context_destroy(), ast_channel_monitor::stop, ast_channel::tech_pvt, ast_channel::timer, ast_channel::varshead, ast_channel::writetrans, and ast_channel::zone.

Referenced by __ast_channel_alloc_ap().

2404 {
2405  struct ast_channel *chan = obj;
2406  int fd;
2407 #ifdef HAVE_EPOLL
2408  int i;
2409 #endif
2410  struct ast_var_t *vardata;
2411  struct ast_frame *f;
2412  struct varshead *headp;
2413  struct ast_datastore *datastore;
2414  char device_name[AST_CHANNEL_NAME];
2415 
2416  if (chan->name) {
2417  /* The string fields were initialized. */
2418  ast_cel_report_event(chan, AST_CEL_CHANNEL_END, NULL, NULL, NULL);
2420  }
2421 
2422  /* Get rid of each of the data stores on the channel */
2423  ast_channel_lock(chan);
2424  while ((datastore = AST_LIST_REMOVE_HEAD(&chan->datastores, entry)))
2425  /* Free the data store */
2426  ast_datastore_free(datastore);
2427  ast_channel_unlock(chan);
2428 
2429  /* Lock and unlock the channel just to be sure nobody has it locked still
2430  due to a reference that was stored in a datastore. (i.e. app_chanspy) */
2431  ast_channel_lock(chan);
2432  ast_channel_unlock(chan);
2433 
2434  if (chan->tech_pvt) {
2435  ast_log(LOG_WARNING, "Channel '%s' may not have been hung up properly\n", chan->name);
2436  ast_free(chan->tech_pvt);
2437  }
2438 
2439  if (chan->sched)
2441 
2442  if (chan->name) {
2443  char *dashptr;
2444 
2445  /* The string fields were initialized. */
2446  ast_copy_string(device_name, chan->name, sizeof(device_name));
2447  if ((dashptr = strrchr(device_name, '-'))) {
2448  *dashptr = '\0';
2449  }
2450  } else {
2451  device_name[0] = '\0';
2452  }
2453 
2454  /* Stop monitoring */
2455  if (chan->monitor)
2456  chan->monitor->stop( chan, 0 );
2457 
2458  /* If there is native format music-on-hold state, free it */
2459  if (chan->music_state)
2460  ast_moh_cleanup(chan);
2461 
2462  /* Free translators */
2463  if (chan->readtrans)
2465  if (chan->writetrans)
2467  if (chan->pbx)
2468  ast_log(LOG_WARNING, "PBX may not have been terminated properly on '%s'\n", chan->name);
2469 
2470  ast_party_dialed_free(&chan->dialed);
2471  ast_party_caller_free(&chan->caller);
2474 
2475  /* Close pipes if appropriate */
2476  if ((fd = chan->alertpipe[0]) > -1)
2477  close(fd);
2478  if ((fd = chan->alertpipe[1]) > -1)
2479  close(fd);
2480  if (chan->timer) {
2481  ast_timer_close(chan->timer);
2482  chan->timer = NULL;
2483  }
2484 #ifdef HAVE_EPOLL
2485  for (i = 0; i < AST_MAX_FDS; i++) {
2486  if (chan->epfd_data[i])
2487  free(chan->epfd_data[i]);
2488  }
2489  close(chan->epfd);
2490 #endif
2491  while ((f = AST_LIST_REMOVE_HEAD(&chan->readq, frame_list)))
2492  ast_frfree(f);
2493 
2494  /* loop over the variables list, freeing all data and deleting list items */
2495  /* no need to lock the list, as the channel is already locked */
2496  headp = &chan->varshead;
2497  while ((vardata = AST_LIST_REMOVE_HEAD(headp, entries)))
2498  ast_var_delete(vardata);
2499 
2500  ast_app_group_discard(chan);
2501 
2502  /* Destroy the jitterbuffer */
2503  ast_jb_destroy(chan);
2504 
2505  if (chan->cdr) {
2506  ast_cdr_discard(chan->cdr);
2507  chan->cdr = NULL;
2508  }
2509 
2510  if (chan->zone) {
2511  chan->zone = ast_tone_zone_unref(chan->zone);
2512  }
2513 
2515 
2516  if (device_name[0]) {
2517  /*
2518  * We have a device name to notify of a new state.
2519  *
2520  * Queue an unknown state, because, while we know that this particular
2521  * instance is dead, we don't know the state of all other possible
2522  * instances.
2523  */
2525  }
2527 }
void * music_state
Definition: channel.h:745
struct ast_datastore::@163 entry
#define ast_channel_lock(chan)
Definition: channel.h:2466
Main Channel structure associated with a channel.
Definition: channel.h:742
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
struct ast_tone_zone * zone
Definition: channel.h:767
static struct ast_tone_zone * ast_tone_zone_unref(struct ast_tone_zone *tz)
Release a reference to an ast_tone_zone.
Definition: indications.h:204
void ast_cel_check_retire_linkedid(struct ast_channel *chan)
Check and potentially retire a Linked ID.
Definition: cel.c:429
void * tech_pvt
Definition: channel.h:744
#define LOG_WARNING
Definition: logger.h:144
int ast_cel_report_event(struct ast_channel *chan, enum ast_cel_event_type event_type, const char *userdefevname, const char *extra, struct ast_channel *peer2)
Report a channel event.
Definition: cel.c:645
struct ast_timer * timer
Definition: channel.h:866
int ast_app_group_discard(struct ast_channel *chan)
Discard all group counting for a channel.
Definition: app.c:1348
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Definition: channel.h:814
void ast_timer_close(struct ast_timer *handle)
Close an opened timing handle.
Definition: timing.c:150
void ast_party_caller_free(struct ast_party_caller *doomed)
Destroy the caller party contents.
Definition: channel.c:2302
int(* stop)(struct ast_channel *chan, int need_lock)
Definition: monitor.h:50
struct ast_cdr * cdr
Definition: channel.h:766
Structure for a data store object.
Definition: datastore.h:54
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition: channel.c:2353
int alertpipe[2]
Definition: channel.h:851
void ast_var_delete(struct ast_var_t *var)
Definition: chanvars.c:63
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return * the previous value of *p. This can be used to handle reference co...
Definition: lock.h:603
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Definition: datastore.c:65
unsigned int flags
Definition: channel.h:850
void ast_moh_cleanup(struct ast_channel *chan)
Definition: channel.c:8057
void ast_jb_destroy(struct ast_channel *chan)
Destroys jitterbuffer on a channel.
Definition: abstract_jb.c:536
struct sched_context * sched
Definition: channel.h:756
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:818
struct ast_party_dialed dialed
Dialed/Called information.
Definition: channel.h:797
struct ast_trans_pvt * writetrans
Definition: channel.h:762
void sched_context_destroy(struct sched_context *c)
destroys a schedule context Destroys (free&#39;s) the given sched_context structure
Definition: sched.c:267
#define free(a)
Definition: astmm.h:94
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_channel_unlock(chan)
Definition: channel.h:2467
channel end
Definition: cel.h:52
struct ast_channel::datastores datastores
#define ast_free(a)
Definition: astmm.h:97
#define AST_CHANNEL_NAME
Definition: channel.h:137
#define AST_MAX_FDS
Definition: channel.h:158
static struct ast_format f[]
Definition: format_g726.c:181
void ast_cdr_discard(struct ast_cdr *cdr)
Discard and free a CDR record.
Definition: cdr.c:488
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition: channel.c:2396
static int chancount
Definition: channel.c:102
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
Data structure associated with a single frame of data.
Definition: frame.h:142
void ast_party_dialed_free(struct ast_party_dialed *doomed)
Destroy the dialed party contents.
Definition: channel.c:2262
struct ast_trans_pvt * readtrans
Definition: channel.h:763
#define ast_frfree(fr)
Definition: frame.h:583
struct ast_channel_monitor * monitor
Definition: channel.h:769
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.
Definition: devicestate.c:472
struct ast_channel::@156 readq
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
Definition: stringfields.h:253
struct varshead varshead
Definition: channel.h:817
void ast_translator_free_path(struct ast_trans_pvt *tr)
Frees a translator path Frees the given translator path structure.
Definition: translate.c:272
struct ast_pbx * pbx
Definition: channel.h:761
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 7406 of file channel.c.

References ast_channel_tech::early_bridge, and ast_channel::tech.

Referenced by dial_exec_full(), and wait_for_answer().

7407 {
7408  /* Make sure we can early bridge, if not error out */
7409  if (!c0->tech->early_bridge || (c1 && (!c1->tech->early_bridge || c0->tech->early_bridge != c1->tech->early_bridge)))
7410  return -1;
7411 
7412  return c0->tech->early_bridge(c0, c1);
7413 }
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:573
struct ast_channel_tech * tech
Definition: channel.h:743
struct ast_channel* ast_channel_get_by_exten ( const char *  exten,
const char *  context 
)

Find a channel by extension and context.

  • exten the extension to search for
  • context the context to search for (optional)

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

References ast_channel_get_full().

1814 {
1815  return ast_channel_get_full(NULL, 0, exten, context);
1816 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:109
static struct ast_channel * ast_channel_get_full(const char *name, size_t name_len, const char *exten, const char *context)
Definition: channel.c:1761
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:107
struct ast_channel* ast_channel_get_by_name ( const char *  name)

Find a channel by name.

Channel search functions

  • name the name or uniqueid of the channel to search for

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

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

Definition at line 1803 of file channel.c.

References ast_channel_get_full().

Referenced by action_add_agi_cmd(), action_aocmessage(), action_atxfer(), action_getvar(), action_hangup(), action_redirect(), action_sendtext(), action_setvar(), action_status(), action_timeout(), ast_async_goto_by_name(), ast_bridge_call(), asyncgoto_exec(), change_monitor_action(), do_pause_or_unpause(), func_mchan_read(), func_mchan_write(), handle_channelstatus(), handle_cli_agi_add_cmd(), handle_core_set_debug_channel(), handle_getvariablefull(), handle_hangup(), handle_redirect(), handle_set_chanvar(), handle_show_chanvar(), handle_showchan(), handle_softhangup(), import_helper(), manager_mute_mixmonitor(), manager_mutestream(), manager_optimize_away(), manager_park(), manager_play_dtmf(), park_call_full(), pbx_builtin_importvar(), senddtmf_exec(), shared_read(), shared_write(), start_monitor_action(), and stop_monitor_action().

1804 {
1805  return ast_channel_get_full(name, 0, NULL, NULL);
1806 }
static struct ast_channel * ast_channel_get_full(const char *name, size_t name_len, const char *exten, const char *context)
Definition: channel.c:1761
static const char name[]
struct ast_channel* ast_channel_get_by_name_prefix ( const char *  name,
size_t  name_len 
)

Find a channel by a name prefix.

  • name The channel name or uniqueid prefix to search for
  • name_len Only search for up to this many characters from the name

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

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

Definition at line 1808 of file channel.c.

References ast_channel_get_full().

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

1809 {
1810  return ast_channel_get_full(name, name_len, NULL, NULL);
1811 }
static struct ast_channel * ast_channel_get_full(const char *name, size_t name_len, const char *exten, const char *context)
Definition: channel.c:1761
static const char name[]
int ast_channel_get_cc_agent_type ( struct ast_channel chan,
char *  agent_type,
size_t  size 
)

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

Since
1.8

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

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

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

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

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

Definition at line 9793 of file channel.c.

References ast_channel_queryoption(), ast_copy_string(), AST_OPTION_CC_AGENT_TYPE, and ast_channel::name.

Referenced by find_agent_callbacks().

9794 {
9795  int len = size;
9796  char *slash;
9797 
9798  if (!ast_channel_queryoption(chan, AST_OPTION_CC_AGENT_TYPE, agent_type, &len, 0)) {
9799  return 0;
9800  }
9801 
9802  ast_copy_string(agent_type, chan->name, size);
9803  if ((slash = strchr(agent_type, '/'))) {
9804  *slash = '\0';
9805  }
9806  return 0;
9807 }
int ast_channel_queryoption(struct ast_channel *channel, int option, void *data, int *datalen, int block)
Checks the value of an option.
Definition: channel.c:7815
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
const ast_string_field name
Definition: channel.h:787
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
#define AST_OPTION_CC_AGENT_TYPE
Definition: frame.h:520
struct ast_cc_config_params* ast_channel_get_cc_config_params ( struct ast_channel chan)

Get the CCSS parameters from a channel.

Since
1.8

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

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

Definition at line 9754 of file channel.c.

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

Referenced by acf_cc_read(), acf_cc_write(), analog_call(), ast_cc_call_failed(), ast_cc_call_init(), ast_queue_cc_frame(), cc_agent_init(), cc_core_init_instance(), find_agent_callbacks(), local_call(), local_request(), sig_pri_cc_available(), and sig_pri_cc_generic_check().

9755 {
9756  struct ast_datastore *cc_datastore;
9757 
9758  if (!(cc_datastore = ast_channel_datastore_find(chan, &cc_channel_datastore_info, NULL))) {
9759  /* If we can't find the datastore, it almost definitely means that the channel type being
9760  * used has not had its driver modified to parse CC config parameters. The best action
9761  * to take here is to create the parameters on the spot with the defaults set.
9762  */
9763  if (ast_channel_cc_params_init(chan, NULL)) {
9764  return NULL;
9765  }
9766  if (!(cc_datastore = ast_channel_datastore_find(chan, &cc_channel_datastore_info, NULL))) {
9767  /* Should be impossible */
9768  return NULL;
9769  }
9770  }
9771 
9772  ast_assert(cc_datastore->data != NULL);
9773  return cc_datastore->data;
9774 }
#define ast_assert(a)
Definition: utils.h:738
Structure for a data store object.
Definition: datastore.h:54
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:2604
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:9731
void * data
Definition: datastore.h:56
static struct ast_datastore_info cc_channel_datastore_info
Definition: channel.c:9725
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 9776 of file channel.c.

References ast_channel_queryoption(), ast_copy_string(), AST_OPTION_DEVICE_NAME, and ast_channel::name.

Referenced by ast_cc_call_failed(), ast_cc_is_recall(), ast_queue_cc_frame(), cc_core_init_instance(), cccancel_exec(), ccreq_exec(), dial_exec_full(), sig_pri_call(), sig_pri_cc_available(), sig_pri_cc_generic_check(), sip_call(), and sip_handle_cc().

9777 {
9778  int len = name_buffer_length;
9779  char *dash;
9780  if (!ast_channel_queryoption(chan, AST_OPTION_DEVICE_NAME, device_name, &len, 0)) {
9781  return 0;
9782  }
9783 
9784  /* Dang. Do it the old-fashioned way */
9785  ast_copy_string(device_name, chan->name, name_buffer_length);
9786  if ((dash = strrchr(device_name, '-'))) {
9787  *dash = '\0';
9788  }
9789 
9790  return 0;
9791 }
int ast_channel_queryoption(struct ast_channel *channel, int option, void *data, int *datalen, int block)
Checks the value of an option.
Definition: channel.c:7815
#define AST_OPTION_DEVICE_NAME
Definition: frame.h:516
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
const ast_string_field name
Definition: channel.h:787
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
static struct ast_channel* ast_channel_get_full ( const char *  name,
size_t  name_len,
const char *  exten,
const char *  context 
)
static

Definition at line 1761 of file channel.c.

References ao2_find, ast_copy_string(), ast_strlen_zero(), chanlist::chan, channels, ast_channel::context, ast_channel::exten, name, ast_channel::name, OBJ_POINTER, and ast_channel::uniqueid.

Referenced by ast_channel_get_by_exten(), ast_channel_get_by_name(), and ast_channel_get_by_name_prefix().

1763 {
1764  struct ast_channel tmp_chan = {
1765  .name = name,
1766  /* This is sort of a hack. Basically, we're using an arbitrary field
1767  * in ast_channel to pass the name_len for a prefix match. If this
1768  * gets changed, then the compare callback must be changed, too. */
1769  .rings = name_len,
1770  };
1771  struct ast_channel *chan;
1772 
1773  if (exten) {
1774  ast_copy_string(tmp_chan.exten, exten, sizeof(tmp_chan.exten));
1775  }
1776 
1777  if (context) {
1778  ast_copy_string(tmp_chan.context, context, sizeof(tmp_chan.context));
1779  }
1780 
1781  if ((chan = ao2_find(channels, &tmp_chan,
1782  (!ast_strlen_zero(name) && (name_len == 0)) ? OBJ_POINTER : 0))) {
1783  return chan;
1784  }
1785 
1786  if (!name) {
1787  return NULL;
1788  }
1789 
1790  /* If name was specified, but the result was NULL,
1791  * try a search on uniqueid, instead. */
1792 
1793  {
1794  struct ast_channel tmp_chan2 = {
1795  .uniqueid = name,
1796  .rings = name_len,
1797  };
1798 
1799  return ao2_find(channels, &tmp_chan2, 0);
1800  }
1801 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:109
Main Channel structure associated with a channel.
Definition: channel.h:742
const ast_string_field uniqueid
Definition: channel.h:787
char context[AST_MAX_CONTEXT]
Definition: channel.h:868
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:197
const ast_string_field name
Definition: channel.h:787
#define ao2_find(arg1, arg2, arg3)
Definition: astobj2.h:964
static const char name[]
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:107
char exten[AST_MAX_EXTENSION]
Definition: channel.h:869
static int ast_channel_hash_cb ( const void *  obj,
const int  flags 
)
static

Definition at line 8063 of file channel.c.

References ast_str_case_hash(), ast_strlen_zero(), and ast_channel::name.

Referenced by ast_channels_init().

8064 {
8065  const struct ast_channel *chan = obj;
8066 
8067  /* If the name isn't set, return 0 so that the ao2_find() search will
8068  * start in the first bucket. */
8069  if (ast_strlen_zero(chan->name)) {
8070  return 0;
8071  }
8072 
8073  return ast_str_case_hash(chan->name);
8074 }
Main Channel structure associated with a channel.
Definition: channel.h:742
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
const ast_string_field name
Definition: channel.h:787
static force_inline int attribute_pure ast_str_case_hash(const char *str)
Compute a hash value on a case-insensitive string.
Definition: strings.h:989
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 6241 of file channel.c.

References ast_debug, AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_var_assign(), ast_var_full_name(), ast_var_name(), ast_var_value(), ast_var_t::entries, ast_channel::name, and ast_channel::varshead.

Referenced by __ast_request_and_dial(), begin_dial_channel(), call_forward_inherit(), dial_exec_full(), dial_transfer(), do_forward(), feature_request_and_dial(), findmeexec(), ring_entry(), and wait_for_answer().

6242 {
6243  struct ast_var_t *current, *newvar;
6244  const char *varname;
6245 
6246  AST_LIST_TRAVERSE(&parent->varshead, current, entries) {
6247  int vartype = 0;
6248 
6249  varname = ast_var_full_name(current);
6250  if (!varname)
6251  continue;
6252 
6253  if (varname[0] == '_') {
6254  vartype = 1;
6255  if (varname[1] == '_')
6256  vartype = 2;
6257  }
6258 
6259  switch (vartype) {
6260  case 1:
6261  newvar = ast_var_assign(&varname[1], ast_var_value(current));
6262  if (newvar) {
6263  AST_LIST_INSERT_TAIL(&child->varshead, newvar, entries);
6264  ast_debug(1, "Inheriting variable %s from %s to %s.\n",
6265  ast_var_name(newvar), parent->name, child->name);
6266  }
6267  break;
6268  case 2:
6269  newvar = ast_var_assign(varname, ast_var_value(current));
6270  if (newvar) {
6271  AST_LIST_INSERT_TAIL(&child->varshead, newvar, entries);
6272  ast_debug(1, "Inheriting variable %s from %s to %s.\n",
6273  ast_var_name(newvar), parent->name, child->name);
6274  }
6275  break;
6276  default:
6277  break;
6278  }
6279  }
6280 }
const char * ast_var_value(const struct ast_var_t *var)
Definition: chanvars.c:89
struct ast_var_t * ast_var_assign(const char *name, const char *value)
Definition: chanvars.c:41
const char * ast_var_name(const struct ast_var_t *var)
Definition: chanvars.c:69
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:716
const ast_string_field name
Definition: channel.h:787
const char * ast_var_full_name(const struct ast_var_t *var)
Definition: chanvars.c:84
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
struct ast_var_t::@158 entries
struct varshead varshead
Definition: channel.h:817
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.

Return values
NULLon failure
anew channel iterator
Since
1.8

Definition at line 1701 of file channel.c.

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

Referenced by action_coreshowchannels(), action_status(), ast_complete_channels(), ast_var_channel_bridge(), ast_var_channel_types_table(), ast_var_channels_table(), common_exec(), data_channels_provider_handler(), func_channels_read(), handle_chanlist(), and handle_softhangup().

1702 {
1703  struct ast_channel_iterator *i;
1704 
1705  if (!(i = ast_calloc(1, sizeof(*i)))) {
1706  return NULL;
1707  }
1708 
1711 
1712  return i;
1713 }
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags)
Create an iterator for a container.
Definition: astobj2.c:818
struct ao2_iterator simple_iterator
Definition: channel.c:1642
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:197
struct ao2_iterator * active_iterator
Definition: channel.c:1646
#define ast_calloc(a, b)
Definition: astmm.h:82
struct ast_channel_iterator* ast_channel_iterator_by_exten_new ( const char *  exten,
const char *  context 
)

Create a new channel iterator based on extension.

  • exten The extension that channels must be in
  • context The context that channels must be in (optional)

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.

Return values
NULLon failure
anew channel iterator based on the specified parameters
Since
1.8

Definition at line 1691 of file channel.c.

References channel_iterator_search().

Referenced by common_exec(), and pickup_by_exten().

1692 {
1693  return channel_iterator_search(NULL, 0, exten, context);
1694 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:109
static struct ast_channel_iterator * channel_iterator_search(const char *name, size_t name_len, const char *exten, const char *context)
Definition: channel.c:1657
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:107
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.

  • name channel name or channel uniqueid to match
  • name_len number 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.

Return values
NULLon failure
anew channel iterator based on the specified parameters
Since
1.8

Definition at line 1696 of file channel.c.

References channel_iterator_search().

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

1697 {
1698  return channel_iterator_search(name, name_len, NULL, NULL);
1699 }
static const char name[]
static struct ast_channel_iterator * channel_iterator_search(const char *name, size_t name_len, const char *exten, const char *context)
Definition: channel.c:1657
struct ast_channel_iterator* ast_channel_iterator_destroy ( struct ast_channel_iterator i)

Destroy a channel iterator.

  • i the itereator to destroy

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

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

Definition at line 1649 of file channel.c.

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

Referenced by action_coreshowchannels(), action_status(), ast_complete_channels(), ast_var_channel_bridge(), ast_var_channel_types_table(), ast_var_channels_table(), common_exec(), data_channels_provider_handler(), func_channels_read(), handle_chanlist(), handle_softhangup(), pickup_by_exten(), and softhangup_exec().

1650 {
1652  ast_free(i);
1653 
1654  return NULL;
1655 }
#define ast_free(a)
Definition: astmm.h:97
struct ao2_iterator * active_iterator
Definition: channel.c:1646
void ao2_iterator_destroy(struct ao2_iterator *i)
Destroy a container iterator.
Definition: astobj2.c:833
struct ast_channel* ast_channel_iterator_next ( struct ast_channel_iterator i)

Get the next channel for a channel iterator.

  • i the channel iterator that was created using one of the channel_iterator_new() functions.

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

Return values
thenext channel that matches the parameters used when the iterator was created.
NULL,ifno more channels match the iterator parameters.
Since
1.8

Definition at line 1715 of file channel.c.

References ast_channel_iterator::active_iterator, and ao2_iterator_next.

Referenced by action_coreshowchannels(), action_status(), ast_complete_channels(), ast_var_channel_bridge(), ast_var_channel_types_table(), ast_var_channels_table(), data_channels_provider_handler(), func_channels_read(), handle_chanlist(), handle_softhangup(), next_channel(), pickup_by_exten(), and softhangup_exec().

1716 {
1718 }
#define ao2_iterator_next(arg1)
Definition: astobj2.h:1126
struct ao2_iterator * active_iterator
Definition: channel.c:1646
int ast_channel_make_compatible ( struct ast_channel c0,
struct ast_channel c1 
)

Makes two channel formats compatible.

Parameters
c0first channel to make compatible
c1other channel to make compatible

Set two channels to compatible formats – call before ast_channel_bridge in general.

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

Definition at line 5970 of file channel.c.

References ast_channel_make_compatible_helper().

Referenced by action_bridge(), app_exec(), ast_channel_bridge(), bridge_exec(), check_compat(), dial_exec_full(), do_forward(), multiplexed_bridge_join(), parked_call_exec(), simple_bridge_join(), try_calling(), and wait_for_answer().

5971 {
5972  /* Some callers do not check return code, and we must try to set all call legs correctly */
5973  int rc = 0;
5974 
5975  /* Set up translation from the chan to the peer */
5976  rc = ast_channel_make_compatible_helper(chan, peer);
5977 
5978  if (rc < 0)
5979  return rc;
5980 
5981  /* Set up translation from the peer to the chan */
5982  rc = ast_channel_make_compatible_helper(peer, chan);
5983 
5984  return rc;
5985 }
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:5920
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 5920 of file channel.c.

References ast_channel_setoption(), AST_FORMAT_AUDIO_MASK, AST_FORMAT_SLINEAR, ast_getformatname(), ast_log(), ast_opt_generic_plc, ast_opt_transcode_via_slin, AST_OPTION_MAKE_COMPATIBLE, ast_set_read_format(), ast_set_write_format(), ast_translate_path_steps(), ast_translator_best_choice(), ast_channel_tech::bridge, LOG_WARNING, ast_channel::name, ast_channel::nativeformats, ast_channel::readformat, ast_channel::tech, and ast_channel::writeformat.

Referenced by ast_channel_make_compatible().

5921 {
5922  format_t src, dst;
5923  int use_slin;
5924 
5925  /* See if the channel driver can natively make these two channels compatible */
5926  if (from->tech->bridge && from->tech->bridge == to->tech->bridge &&
5927  !ast_channel_setoption(from, AST_OPTION_MAKE_COMPATIBLE, to, sizeof(struct ast_channel *), 0)) {
5928  return 0;
5929  }
5930 
5931  if (from->readformat == to->writeformat && from->writeformat == to->readformat) {
5932  /* Already compatible! Moving on ... */
5933  return 0;
5934  }
5935 
5936  /* Set up translation from the 'from' channel to the 'to' channel */
5937  src = from->nativeformats;
5938  dst = to->nativeformats;
5939 
5940  /* If there's no audio in this call, don't bother with trying to find a translation path */
5941  if ((src & AST_FORMAT_AUDIO_MASK) == 0 || (dst & AST_FORMAT_AUDIO_MASK) == 0)
5942  return 0;
5943 
5944  if (ast_translator_best_choice(&dst, &src) < 0) {
5945  ast_log(LOG_WARNING, "No path to translate from %s to %s\n", from->name, to->name);
5946  return -1;
5947  }
5948 
5949  /* if the best path is not 'pass through', then
5950  * transcoding is needed; if desired, force transcode path
5951  * to use SLINEAR between channels, but only if there is
5952  * no direct conversion available. If generic PLC is
5953  * desired, then transcoding via SLINEAR is a requirement
5954  */
5955  use_slin = (src == AST_FORMAT_SLINEAR || dst == AST_FORMAT_SLINEAR);
5956  if ((src != dst) && (ast_opt_generic_plc || ast_opt_transcode_via_slin) &&
5957  (ast_translate_path_steps(dst, src) != 1 || use_slin))
5958  dst = AST_FORMAT_SLINEAR;
5959  if (ast_set_read_format(from, dst) < 0) {
5960  ast_log(LOG_WARNING, "Unable to set read format on channel %s to %s\n", from->name, ast_getformatname(dst));
5961  return -1;
5962  }
5963  if (ast_set_write_format(to, dst) < 0) {
5964  ast_log(LOG_WARNING, "Unable to set write format on channel %s to %s\n", to->name, ast_getformatname(dst));
5965  return -1;
5966  }
5967  return 0;
5968 }
Main Channel structure associated with a channel.
Definition: channel.h:742
format_t writeformat
Definition: channel.h:854
#define LOG_WARNING
Definition: logger.h:144
format_t nativeformats
Definition: channel.h:852
#define AST_OPTION_MAKE_COMPATIBLE
Definition: frame.h:504
int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block)
Sets an option on a channel.
Definition: channel.c:7795
int ast_set_write_format(struct ast_channel *chan, format_t format)
Sets write format on channel chan Set write format for channel to whichever component of &quot;format&quot; is ...
Definition: channel.c:5307
int ast_set_read_format(struct ast_channel *chan, format_t format)
Sets read format on channel chan Set read format for channel to whichever component of &quot;format&quot; is be...
Definition: channel.c:5301
#define ast_opt_generic_plc
Definition: options.h:132
enum ast_bridge_result(*const bridge)(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms)
Bridge two channels of the same type together.
Definition: channel.h:569
char * ast_getformatname(format_t format)
Get the name of a format.
Definition: frame.c:578
#define ast_opt_transcode_via_slin
Definition: options.h:114
int64_t format_t
Definition: frame_defs.h:32
unsigned int ast_translate_path_steps(format_t dest, format_t src)
Returns the number of steps required to convert from &#39;src&#39; to &#39;dest&#39;.
Definition: translate.c:1059
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define AST_FORMAT_AUDIO_MASK
Definition: frame.h:274
#define AST_FORMAT_SLINEAR
Definition: frame.h:254
format_t readformat
Definition: channel.h:853
struct ast_channel_tech * tech
Definition: channel.h:743
format_t ast_translator_best_choice(format_t *dsts, format_t *srcs)
Chooses the best translation path.
Definition: translate.c:984
int ast_channel_masquerade ( struct ast_channel original,
struct ast_channel clone 
)

Weird function made for call transfers.

Parameters
originalchannel to make a copy of
clonecopy of the original channel

This is a very strange and freaky function used primarily for transfer. Suppose that "original" and "clone" are two channels in random situations. This function takes the guts out of "clone" and puts them into the "original" channel, then alerts the channel driver of the change, asking it to fixup any private information (like the p->owner pointer) that is affected by the change. The physical layer of the original channel is hung up.

Note
Neither channel passed here should be locked before calling this function. This function performs deadlock avoidance involving these two channels.

Definition at line 6110 of file channel.c.

References __ast_channel_masquerade().

Referenced by ast_async_goto(), ast_do_pickup(), attempt_transfer(), builtin_atxfer(), check_availability(), check_bridge(), check_goto_on_transfer(), do_bridge_masquerade(), handle_invite_replaces(), iax_park(), masq_park_call(), sip_park(), and skinny_transfer().

6111 {
6112  return __ast_channel_masquerade(original, clone, NULL);
6113 }
static int __ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clonechan, struct ast_datastore *xfer_ds)
Definition: channel.c:5987
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 7815 of file channel.c.

References ast_channel_lock, ast_channel_unlock, ast_log(), errno, LOG_ERROR, ast_channel_tech::queryoption, and ast_channel::tech.

Referenced by ast_channel_get_cc_agent_type(), ast_channel_get_device_name(), ast_channel_get_t38_state(), local_queryoption(), rcvfax_exec(), and sndfax_exec().

7816 {
7817  int res;
7818 
7819  ast_channel_lock(chan);
7820  if (!chan->tech->queryoption) {
7821  errno = ENOSYS;
7822  ast_channel_unlock(chan);
7823  return -1;
7824  }
7825 
7826  if (block)
7827  ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n");
7828 
7829  res = chan->tech->queryoption(chan, option, data, datalen);
7830  ast_channel_unlock(chan);
7831 
7832  return res;
7833 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
int(*const queryoption)(struct ast_channel *chan, int option, void *data, int *datalen)
Query a given option. Called with chan locked.
Definition: channel.h:585
#define LOG_ERROR
Definition: logger.h:155
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int errno
struct ast_channel_tech * tech
Definition: channel.h:743
void ast_channel_queue_connected_line_update ( struct ast_channel chan,
const struct ast_party_connected_line connected,
const struct ast_set_party_connected_line update 
)

Queue a connected line update frame on a channel.

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

Definition at line 9098 of file channel.c.

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

Referenced by ast_do_pickup(), handle_request_invite(), handle_request_update(), handle_response_invite(), local_attended_transfer(), masquerade_colp_transfer(), misdn_queue_connected_line_update(), sig_pri_handle_subcmds(), and sip_call().

9099 {
9100  unsigned char data[1024]; /* This should be large enough */
9101  size_t datalen;
9102 
9103  datalen = ast_connected_line_build_data(data, sizeof(data), connected, update);
9104  if (datalen == (size_t) -1) {
9105  return;
9106  }
9107 
9108  ast_queue_control_data(chan, AST_CONTROL_CONNECTED_LINE, data, datalen);
9109 }
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:8825
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:1608
void ast_channel_queue_redirecting_update ( struct ast_channel chan,
const struct ast_party_redirecting redirecting,
const struct ast_set_party_redirecting update 
)

Queue a redirecting update frame on a channel.

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

Definition at line 9605 of file channel.c.

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

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

9606 {
9607  unsigned char data[1024]; /* This should be large enough */
9608  size_t datalen;
9609 
9610  datalen = ast_redirecting_build_data(data, sizeof(data), redirecting, update);
9611  if (datalen == (size_t) -1) {
9612  return;
9613  }
9614 
9615  ast_queue_control_data(chan, AST_CONTROL_REDIRECTING, data, datalen);
9616 }
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:1608
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:9161
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 5313 of file channel.c.

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

Referenced by attempt_thread().

5314 {
5315  switch (reason) /* the following appear to be the only ones actually returned by request_and_dial */
5316  {
5317  case 0:
5318  return "Call Failure (not BUSY, and not NO_ANSWER, maybe Circuit busy or down?)";
5319  case AST_CONTROL_HANGUP:
5320  return "Hangup";
5321  case AST_CONTROL_RING:
5322  return "Local Ring";
5323  case AST_CONTROL_RINGING:
5324  return "Remote end Ringing";
5325  case AST_CONTROL_ANSWER:
5326  return "Remote end has Answered";
5327  case AST_CONTROL_BUSY:
5328  return "Remote end is Busy";
5330  return "Congestion (circuits busy)";
5331  default:
5332  return "Unknown Reason!!";
5333  }
5334 }
int ast_channel_redirecting_macro ( struct ast_channel autoservice_chan,
struct ast_channel macro_chan,
const void *  redirecting_info,
int  is_caller,
int  is_frame 
)

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

Since
1.8

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

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

Have multiple return codes based on the MACRO_RESULT

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

Definition at line 9663 of file channel.c.

References ast_app_run_macro(), ast_channel_lock, 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(), ast_frame::data, ast_frame::datalen, pbx_builtin_getvar_helper(), ast_frame::ptr, ast_channel::redirecting, and S_OR.

Referenced by ast_bridge_call(), ast_generic_bridge(), call_forward_inherit(), do_forward(), feature_request_and_dial(), handle_frame(), local_bridge_loop(), remote_bridge_loop(), and wait_for_answer().

9664 {
9665  const char *macro;
9666  const char *macro_args;
9667  int retval;
9668 
9669  ast_channel_lock(macro_chan);
9670  macro = pbx_builtin_getvar_helper(macro_chan, is_caller
9671  ? "REDIRECTING_CALLER_SEND_MACRO" : "REDIRECTING_CALLEE_SEND_MACRO");
9672  macro = ast_strdupa(S_OR(macro, ""));
9673  macro_args = pbx_builtin_getvar_helper(macro_chan, is_caller
9674  ? "REDIRECTING_CALLER_SEND_MACRO_ARGS" : "REDIRECTING_CALLEE_SEND_MACRO_ARGS");
9675  macro_args = ast_strdupa(S_OR(macro_args, ""));
9676 
9677  if (ast_strlen_zero(macro)) {
9678  ast_channel_unlock(macro_chan);
9679  return -1;
9680  }
9681 
9682  if (is_frame) {
9683  const struct ast_frame *frame = redirecting_info;
9684 
9685  ast_redirecting_parse_data(frame->data.ptr, frame->datalen, &macro_chan->redirecting);
9686  } else {
9687  const struct ast_party_redirecting *redirecting = redirecting_info;
9688 
9689  ast_party_redirecting_copy(&macro_chan->redirecting, redirecting);
9690  }
9691  ast_channel_unlock(macro_chan);
9692 
9693  retval = ast_app_run_macro(autoservice_chan, macro_chan, macro, macro_args);
9694  if (!retval) {
9695  struct ast_party_redirecting saved_redirecting;
9696 
9697  ast_party_redirecting_init(&saved_redirecting);
9698  ast_channel_lock(macro_chan);
9699  ast_party_redirecting_copy(&saved_redirecting, &macro_chan->redirecting);
9700  ast_channel_unlock(macro_chan);
9701  ast_channel_update_redirecting(macro_chan, &saved_redirecting, NULL);
9702  ast_party_redirecting_free(&saved_redirecting);
9703  }
9704 
9705  return retval;
9706 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
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:9254
void * ptr
Definition: frame.h:160
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:9592
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Definition: channel.h:814
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
Definition: pbx.c:10475
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
int datalen
Definition: frame.h:148
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
Definition: channel.h:447
int ast_app_run_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char *macro_name, const char *macro_args)
Run a macro on a channel, placing an optional second channel into autoservice.
Definition: app.c:294
#define ast_channel_unlock(chan)
Definition: channel.h:2467
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition: channel.c:2396
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:77
void ast_party_redirecting_init(struct ast_party_redirecting *init)
Initialize the given redirecting structure.
Definition: channel.c:2359
Data structure associated with a single frame of data.
Definition: frame.h:142
union ast_frame::@172 data
void ast_party_redirecting_copy(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src)
Copy the source redirecting information to the destination redirecting.
Definition: channel.c:2367
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 907 of file channel.c.

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

Referenced by load_module(), and unload_module().

908 {
909  struct chanlist *chan;
910 
912 
914  if (!strcasecmp(tech->type, chan->tech->type)) {
915  ast_log(LOG_WARNING, "Already have a handler for type '%s'\n", tech->type);
917  return -1;
918  }
919  }
920 
921  if (!(chan = ast_calloc(1, sizeof(*chan)))) {
923  return -1;
924  }
925  chan->tech = tech;
927 
928  ast_debug(1, "Registered handler for '%s' (%s)\n", chan->tech->type, chan->tech->description);
929 
930  ast_verb(2, "Registered channel type '%s' (%s)\n", chan->tech->type, chan->tech->description);
931 
933 
934  return 0;
935 }
struct chanlist::@238 list
const char *const type
Definition: channel.h:508
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define LOG_WARNING
Definition: logger.h:144
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define ast_verb(level,...)
Definition: logger.h:243
the list of registered channel types
Definition: channel.c:143
struct ast_channel_tech * tech
Definition: channel.c:122
#define AST_RWLIST_INSERT_HEAD
Definition: linkedlists.h:703
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
struct ast_channel * chan
Definition: app_dial.c:666
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
List of channel drivers.
Definition: app_dial.c:664
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
const char *const description
Definition: channel.h:509
#define ast_calloc(a, b)
Definition: astmm.h:82
struct ast_channel* ast_channel_release ( struct ast_channel chan)

Unlink and release reference to a channel.

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

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

Definition at line 1921 of file channel.c.

References ao2_unlink, ast_channel_unref, and channels.

Referenced by agent_cleanup(), ast_iax2_new(), ast_request(), bridge_request(), do_notify(), gtalk_newcall(), local_new(), and local_request().

1922 {
1923  /* Safe, even if already unlinked. */
1924  ao2_unlink(channels, chan);
1925  return ast_channel_unref(chan);
1926 }
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2502
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:197
#define ao2_unlink(arg1, arg2)
Definition: astobj2.h:817
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 5907 of file channel.c.

References ast_channel_tech::send_html, and ast_channel::tech.

Referenced by agent_sendhtml(), ast_channel_sendurl(), and wait_for_answer().

5908 {
5909  if (chan->tech->send_html)
5910  return chan->tech->send_html(chan, subclass, data, datalen);
5911  return -1;
5912 }
int(*const send_html)(struct ast_channel *chan, int subclass, const char *data, int len)
Send HTML data.
Definition: channel.h:563
struct ast_channel_tech * tech
Definition: channel.h:743
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 5914 of file channel.c.

References ast_channel_sendhtml(), and AST_HTML_URL.

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

5915 {
5916  return ast_channel_sendhtml(chan, AST_HTML_URL, url, strlen(url) + 1);
5917 }
#define AST_HTML_URL
Definition: frame.h:222
int ast_channel_sendhtml(struct ast_channel *channel, int subclass, const char *data, int datalen)
Sends HTML on given channel Send HTML or URL on link.
Definition: channel.c:5907
static char url[512]
void ast_channel_set_caller ( struct ast_channel chan,
const struct ast_party_caller caller,
const struct ast_set_party_caller update 
)

Set the caller id information in the Asterisk channel.

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

Definition at line 7079 of file channel.c.

References ast_channel_lock, ast_channel_unlock, ast_party_caller_set(), and ast_channel::caller.

7080 {
7081  if (&chan->caller == caller) {
7082  /* Don't set to self */
7083  return;
7084  }
7085 
7086  ast_channel_lock(chan);
7087  ast_party_caller_set(&chan->caller, caller, update);
7088  ast_channel_unlock(chan);
7089 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
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:2295
#define ast_channel_unlock(chan)
Definition: channel.h:2467
void ast_channel_set_caller_event ( struct ast_channel chan,
const struct ast_party_caller caller,
const struct ast_set_party_caller update 
)

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

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

Definition at line 7091 of file channel.c.

References ast_cdr_setcid(), ast_channel_lock, ast_channel_unlock, ast_party_caller_set(), ast_channel::caller, ast_channel::cdr, ast_party_caller::id, ast_party_id::name, ast_party_id::number, report_new_callerid(), S_COR, ast_party_name::str, ast_party_number::str, ast_party_name::valid, and ast_party_number::valid.

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

7092 {
7093  const char *pre_set_number;
7094  const char *pre_set_name;
7095 
7096  if (&chan->caller == caller) {
7097  /* Don't set to self */
7098  return;
7099  }
7100 
7101  ast_channel_lock(chan);
7102  pre_set_number =
7103  S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL);
7104  pre_set_name = S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, NULL);
7105  ast_party_caller_set(&chan->caller, caller, update);
7106  if (S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL)
7107  != pre_set_number
7108  || S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, NULL)
7109  != pre_set_name) {
7110  /* The caller id name or number changed. */
7111  report_new_callerid(chan);
7112  }
7113  if (chan->cdr) {
7114  ast_cdr_setcid(chan->cdr, chan);
7115  }
7116  ast_channel_unlock(chan);
7117 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
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:2295
char * str
Subscriber name (Malloced)
Definition: channel.h:214
struct ast_cdr * cdr
Definition: channel.h:766
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
int ast_cdr_setcid(struct ast_cdr *cdr, struct ast_channel *chan)
Initialize based on a channel.
Definition: cdr.c:883
#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:83
static void report_new_callerid(struct ast_channel *chan)
Definition: channel.c:6468
#define ast_channel_unlock(chan)
Definition: channel.h:2467
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
void ast_channel_set_connected_line ( struct ast_channel chan,
const struct ast_party_connected_line connected,
const struct ast_set_party_connected_line update 
)

Set the connected line information in the Asterisk channel.

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

Definition at line 8458 of file channel.c.

References ast_channel_lock, ast_channel_unlock, ast_party_connected_line_set(), and ast_channel::connected.

Referenced by __ast_request_and_dial(), ast_indicate_data(), connectedline_write(), dial_exec_full(), and feature_request_and_dial().

8459 {
8460  if (&chan->connected == connected) {
8461  /* Don't set to self */
8462  return;
8463  }
8464 
8465  ast_channel_lock(chan);
8466  ast_party_connected_line_set(&chan->connected, connected, update);
8467  ast_channel_unlock(chan);
8468 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
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:2337
#define ast_channel_unlock(chan)
Definition: channel.h:2467
void ast_channel_set_fd ( struct ast_channel chan,
int  which,
int  fd 
)

Set the file descriptor on the channel

Definition at line 2631 of file channel.c.

References ast_calloc, ast_epoll_data::chan, chanlist::chan, ast_channel::fds, free, and ast_epoll_data::which.

Referenced by __ast_channel_alloc_ap(), __oh323_new(), __oh323_rtp_create(), __oh323_update_info(), alsa_new(), ast_do_masquerade(), dahdi_new(), deactivate_generator_nolock(), gtalk_new(), initialize_udptl(), jingle_new(), mgcp_new(), misdn_new(), my_swap_subchannels(), nbs_new(), oss_new(), phone_new(), process_sdp(), setformat(), sip_new(), sip_set_rtp_peer(), skinny_new(), start_rtp(), and swap_subs().

2632 {
2633 #ifdef HAVE_EPOLL
2634  struct epoll_event ev;
2635  struct ast_epoll_data *aed = NULL;
2636 
2637  if (chan->fds[which] > -1) {
2638  epoll_ctl(chan->epfd, EPOLL_CTL_DEL, chan->fds[which], &ev);
2639  aed = chan->epfd_data[which];
2640  }
2641 
2642  /* If this new fd is valid, add it to the epoll */
2643  if (fd > -1) {
2644  if (!aed && (!(aed = ast_calloc(1, sizeof(*aed)))))
2645  return;
2646 
2647  chan->epfd_data[which] = aed;
2648  aed->chan = chan;
2649  aed->which = which;
2650 
2651  ev.events = EPOLLIN | EPOLLPRI | EPOLLERR | EPOLLHUP;
2652  ev.data.ptr = aed;
2653  epoll_ctl(chan->epfd, EPOLL_CTL_ADD, fd, &ev);
2654  } else if (aed) {
2655  /* We don't have to keep around this epoll data structure now */
2656  free(aed);
2657  chan->epfd_data[which] = NULL;
2658  }
2659 #endif
2660  chan->fds[which] = fd;
2661  return;
2662 }
struct ast_channel * chan
Definition: channel.c:88
int fds[AST_MAX_FDS]
Definition: channel.h:829
#define free(a)
Definition: astmm.h:94
#define ast_calloc(a, b)
Definition: astmm.h:82
void ast_channel_set_linkgroup ( struct ast_channel chan,
struct ast_channel peer 
)

Propagate the oldest linkedid between associated channels.

propagate the linked id between chan and peer

Definition at line 6387 of file channel.c.

References ast_channel::_bridge, ast_bridged_channel(), ast_channel_change_linkedid(), ast_strdupa, ast_channel::linkedid, oldest_linkedid(), and ast_channel::uniqueid.

Referenced by ast_bridge_call(), and ast_do_masquerade().

6388 {
6389  const char* linkedid=NULL;
6390  struct ast_channel *bridged;
6391 
6392  linkedid = oldest_linkedid(chan->linkedid, peer->linkedid);
6393  linkedid = oldest_linkedid(linkedid, chan->uniqueid);
6394  linkedid = oldest_linkedid(linkedid, peer->uniqueid);
6395  if (chan->_bridge) {
6396  bridged = ast_bridged_channel(chan);
6397  if (bridged && bridged != peer) {
6398  linkedid = oldest_linkedid(linkedid, bridged->linkedid);
6399  linkedid = oldest_linkedid(linkedid, bridged->uniqueid);
6400  }
6401  }
6402  if (peer->_bridge) {
6403  bridged = ast_bridged_channel(peer);
6404  if (bridged && bridged != chan) {
6405  linkedid = oldest_linkedid(linkedid, bridged->linkedid);
6406  linkedid = oldest_linkedid(linkedid, bridged->uniqueid);
6407  }
6408  }
6409 
6410  /* just in case setting a stringfield to itself causes problems */
6411  linkedid = ast_strdupa(linkedid);
6412 
6413  ast_channel_change_linkedid(chan, linkedid);
6414  ast_channel_change_linkedid(peer, linkedid);
6415  if (chan->_bridge) {
6416  bridged = ast_bridged_channel(chan);
6417  if (bridged && bridged != peer) {
6418  ast_channel_change_linkedid(bridged, linkedid);
6419  }
6420  }
6421  if (peer->_bridge) {
6422  bridged = ast_bridged_channel(peer);
6423  if (bridged && bridged != chan) {
6424  ast_channel_change_linkedid(bridged, linkedid);
6425  }
6426  }
6427 }
Main Channel structure associated with a channel.
Definition: channel.h:742
const ast_string_field uniqueid
Definition: channel.h:787
const ast_string_field linkedid
Definition: channel.h:787
static const char * oldest_linkedid(const char *a, const char *b)
Definition: channel.c:6320
struct ast_channel * _bridge
Definition: channel.h:748
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
Definition: channel.c:7160
static void ast_channel_change_linkedid(struct ast_channel *chan, const char *linkedid)
Definition: channel.c:6370
void ast_channel_set_redirecting ( struct ast_channel chan,
const struct ast_party_redirecting redirecting,
const struct ast_set_party_redirecting update 
)

Set the redirecting id information in the Asterisk channel.

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

Definition at line 9111 of file channel.c.

References ast_channel_lock, ast_channel_unlock, ast_party_redirecting_set(), and ast_channel::redirecting.

Referenced by ast_indicate_data(), handle_request_invite(), handle_response(), misdn_copy_redirecting_to_ast(), redirecting_write(), and sig_pri_handle_subcmds().

9112 {
9113  if (&chan->redirecting == redirecting) {
9114  /* Don't set to self */
9115  return;
9116  }
9117 
9118  ast_channel_lock(chan);
9119  ast_party_redirecting_set(&chan->redirecting, redirecting, update);
9120  ast_channel_unlock(chan);
9121 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
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:2388
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Definition: channel.h:814
#define ast_channel_unlock(chan)
Definition: channel.h:2467
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 7795 of file channel.c.

References ast_channel_lock, ast_channel_unlock, ast_log(), errno, LOG_ERROR, ast_channel_tech::setoption, and ast_channel::tech.

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

7796 {
7797  int res;
7798 
7799  ast_channel_lock(chan);
7800  if (!chan->tech->setoption) {
7801  errno = ENOSYS;
7802  ast_channel_unlock(chan);
7803  return -1;
7804  }
7805 
7806  if (block)
7807  ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n");
7808 
7809  res = chan->tech->setoption(chan, option, data, datalen);
7810  ast_channel_unlock(chan);
7811 
7812  return res;
7813 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
const char * data
Definition: channel.h:755
int(*const setoption)(struct ast_channel *chan, int option, void *data, int datalen)
Set a given option. Called with chan locked.
Definition: channel.h:582
#define LOG_ERROR
Definition: logger.h:155
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int errno
struct ast_channel_tech * tech
Definition: channel.h:743
void ast_channel_setwhentohangup ( struct ast_channel chan,
time_t  offset 
)

Set when to hang a channel up.

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

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

Note
This function does not require that the channel is locked before calling it.
Returns
Nothing
See Also
ast_channel_setwhentohangup_tv()
Version
1.6.1 deprecated function (only had seconds precision)

Definition at line 878 of file channel.c.

References ast_channel_setwhentohangup_tv().

879 {
880  struct timeval when = { offset, };
881  ast_channel_setwhentohangup_tv(chan, when);
882 }
void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset)
Set when to hang a channel up.
Definition: channel.c:871
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 871 of file channel.c.

References ast_null_frame, ast_queue_frame(), ast_tvadd(), ast_tvnow(), ast_tvzero(), and ast_channel::whentohangup.

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

872 {
873  chan->whentohangup = ast_tvzero(offset) ? offset : ast_tvadd(offset, ast_tvnow());
875  return;
876 }
struct ast_frame ast_null_frame
Definition: frame.c:131
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:100
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
Definition: utils.c:1587
struct timeval whentohangup
Definition: channel.h:789
static int ast_channel_softhangup_cb ( void *  obj,
void *  arg,
int  flags 
)
static

Definition at line 829 of file channel.c.

References ast_softhangup(), and AST_SOFTHANGUP_SHUTDOWN.

Referenced by ast_begin_shutdown().

830 {
831  struct ast_channel *chan = obj;
832 
834 
835  return 0;
836 }
Main Channel structure associated with a channel.
Definition: channel.h:742
int ast_softhangup(struct ast_channel *chan, int reason)
Softly hangup up a channel.
Definition: channel.c:2746
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 8309 of file channel.c.

References ast_activate_generator(), ast_calloc, ast_debug, AST_FORMAT_SLINEAR, ast_free, ast_log(), ast_set_write_format(), LOG_ERROR, ast_channel::name, ast_silence_generator::old_write_format, state, and ast_channel::writeformat.

Referenced by __ast_play_and_record(), ast_bridge_call(), ast_dtmf_stream(), ast_readstring_full(), ast_safe_sleep_conditional(), channel_spy(), record_exec(), TransferCallStep1(), waitfor_exec(), and waitforring_exec().

8310 {
8311  struct ast_silence_generator *state;
8312 
8313  if (!(state = ast_calloc(1, sizeof(*state)))) {
8314  return NULL;
8315  }
8316 
8317  state->old_write_format = chan->writeformat;
8318 
8319  if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) {
8320  ast_log(LOG_ERROR, "Could not set write format to SLINEAR\n");
8321  ast_free(state);
8322  return NULL;
8323  }
8324 
8326 
8327  ast_debug(1, "Started silence generator on '%s'\n", chan->name);
8328 
8329  return state;
8330 }
enum sip_cc_notify_state state
Definition: chan_sip.c:842
format_t writeformat
Definition: channel.h:854
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
Definition: channel.c:3148
int ast_set_write_format(struct ast_channel *chan, format_t format)
Sets write format on channel chan Set write format for channel to whichever component of &quot;format&quot; is ...
Definition: channel.c:5307
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
static struct ast_generator silence_generator
Definition: channel.c:8299
#define LOG_ERROR
Definition: logger.h:155
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_free(a)
Definition: astmm.h:97
#define AST_FORMAT_SLINEAR
Definition: frame.h:254
#define ast_calloc(a, b)
Definition: astmm.h:82
void ast_channel_stop_silence_generator ( struct ast_channel chan,
struct ast_silence_generator state 
)

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

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

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

Definition at line 8355 of file channel.c.

References ast_debug, ast_free, ast_log(), ast_set_write_format(), deactivate_silence_generator(), LOG_ERROR, ast_channel::name, and ast_silence_generator::old_write_format.

Referenced by __ast_play_and_record(), ast_bridge_call(), ast_dtmf_stream(), ast_readstring_full(), ast_safe_sleep_conditional(), channel_spy(), HandleCallOutgoing(), key_dial_page(), record_exec(), unistim_hangup(), waitfor_exec(), and waitforring_exec().

8356 {
8357  if (!state) {
8358  return;
8359  }
8360 
8361  if (deactivate_silence_generator(chan)) {
8362  ast_debug(1, "Stopped silence generator on '%s'\n", chan->name);
8363 
8364  if (ast_set_write_format(chan, state->old_write_format) < 0)
8365  ast_log(LOG_ERROR, "Could not return write format to its original state\n");
8366  }
8367  ast_free(state);
8368 }
static int deactivate_silence_generator(struct ast_channel *chan)
Definition: channel.c:8332
int ast_set_write_format(struct ast_channel *chan, format_t format)
Sets write format on channel chan Set write format for channel to whichever component of &quot;format&quot; is ...
Definition: channel.c:5307
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
#define LOG_ERROR
Definition: logger.h:155
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_free(a)
Definition: astmm.h:97
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 5902 of file channel.c.

References ast_channel_tech::send_html, and ast_channel::tech.

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

5903 {
5904  return (chan->tech->send_html) ? 1 : 0;
5905 }
int(*const send_html)(struct ast_channel *chan, int subclass, const char *data, int len)
Send HTML data.
Definition: channel.h:563
struct ast_channel_tech * tech
Definition: channel.h:743
int ast_channel_transfer_masquerade ( struct ast_channel target_chan,
const struct ast_party_connected_line target_id,
int  target_held,
struct ast_channel transferee_chan,
const struct ast_party_connected_line transferee_id,
int  transferee_held 
)

Setup a masquerade to transfer a call.

Since
1.8
Parameters
target_chanTarget of the call transfer. (Masquerade original channel)
target_idNew connected line information for the target channel.
target_heldTRUE if the target call is on hold.
transferee_chanTransferee of the call transfer. (Masquerade clone channel)
transferee_idNew connected line information for the transferee channel.
transferee_heldTRUE if the transferee call is on hold.

Party A - Transferee Party B - Transferer Party C - Target of transfer

Party B transfers A to C.

Party A is connected to bridged channel B1. Party B is connected to channels C1 and C2. Party C is connected to bridged channel B2.

Party B – C1 == B1 – Party A __/ / Party B – C2 == B2 – Party C

Bridged channel B1 is masqueraded into channel C2. Where B1 is the masquerade clone channel and C2 is the masquerade original channel.

See Also
ast_channel_masquerade()
Note
Has the same locking requirements as ast_channel_masquerade().
Return values
0on success.
-1on error.

Definition at line 6184 of file channel.c.

References __ast_channel_masquerade(), ast_calloc, ast_datastore_alloc(), ast_datastore_free(), ast_datastore::data, party_connected_line_copy_transfer(), xfer_masquerade_ds::target_held, xfer_masquerade_ds::target_id, xfer_masquerade_ds::transferee_held, and xfer_masquerade_ds::transferee_id.

Referenced by analog_attempt_transfer(), misdn_attempt_transfer(), and sig_pri_attempt_transfer().

6191 {
6192  struct ast_datastore *xfer_ds;
6193  struct xfer_masquerade_ds *xfer_colp;
6194  int res;
6195 
6196  xfer_ds = ast_datastore_alloc(&xfer_ds_info, NULL);
6197  if (!xfer_ds) {
6198  return -1;
6199  }
6200 
6201  xfer_colp = ast_calloc(1, sizeof(*xfer_colp));
6202  if (!xfer_colp) {
6203  ast_datastore_free(xfer_ds);
6204  return -1;
6205  }
6206  party_connected_line_copy_transfer(&xfer_colp->target_id, target_id);
6207  xfer_colp->target_held = target_held;
6208  party_connected_line_copy_transfer(&xfer_colp->transferee_id, transferee_id);
6209  xfer_colp->transferee_held = transferee_held;
6210  xfer_ds->data = xfer_colp;
6211 
6212  res = __ast_channel_masquerade(target_chan, transferee_chan, xfer_ds);
6213  if (res) {
6214  ast_datastore_free(xfer_ds);
6215  }
6216  return res;
6217 }
Structure for a data store object.
Definition: datastore.h:54
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Definition: datastore.c:65
static void party_connected_line_copy_transfer(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src)
Definition: channel.c:6125
struct ast_party_connected_line transferee_id
Definition: channel.c:6154
struct ast_datastore * ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
Definition: datastore.c:98
static int __ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clonechan, struct ast_datastore *xfer_ds)
Definition: channel.c:5987
void * data
Definition: datastore.h:56
#define ast_calloc(a, b)
Definition: astmm.h:82
struct ast_party_connected_line target_id
Definition: channel.c:6152
static struct ast_datastore_info xfer_ds_info
Definition: channel.c:6179
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 1628 of file channel.c.

References ast_clear_flag, and AST_FLAG_DEFER_DTMF.

Referenced by __adsi_transmit_messages(), and find_cache().

1629 {
1630  if (chan)
1632 }
#define ast_clear_flag(p, flag)
Definition: utils.h:77
void ast_channel_unregister ( const struct ast_channel_tech tech)

Unregister channel driver.

Unregister a channel technology.

Definition at line 938 of file channel.c.

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

Referenced by __unload_module(), load_module(), and unload_module().

939 {
940  struct chanlist *chan;
941 
942  ast_debug(1, "Unregistering channel type '%s'\n", tech->type);
943 
945 
947  if (chan->tech == tech) {
949  ast_free(chan);
950  ast_verb(2, "Unregistered channel type '%s'\n", tech->type);
951  break;
952  }
953  }
955 
957 }
struct chanlist::@238 list
const char *const type
Definition: channel.h:508
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:600
#define ast_verb(level,...)
Definition: logger.h:243
the list of registered channel types
Definition: channel.c:143
struct ast_channel_tech * tech
Definition: channel.c:122
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
struct ast_channel * chan
Definition: app_dial.c:666
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:554
List of channel drivers.
Definition: app_dial.c:664
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
Definition: linkedlists.h:542
#define ast_free(a)
Definition: astmm.h:97
void ast_channel_update_connected_line ( struct ast_channel chan,
const struct ast_party_connected_line connected,
const struct ast_set_party_connected_line update 
)

Indicate that the connected line information has changed.

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

Definition at line 9085 of file channel.c.

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

Referenced by app_exec(), ast_channel_connected_line_macro(), ast_do_pickup(), atxfer_fail_cleanup(), builtin_atxfer(), connectedline_write(), parked_call_exec(), and wait_for_answer().

9086 {
9087  unsigned char data[1024]; /* This should be large enough */
9088  size_t datalen;
9089 
9090  datalen = ast_connected_line_build_data(data, sizeof(data), connected, update);
9091  if (datalen == (size_t) -1) {
9092  return;
9093  }
9094 
9095  ast_indicate_data(chan, AST_CONTROL_CONNECTED_LINE, data, datalen);
9096 }
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:8825
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:4447
void ast_channel_update_redirecting ( struct ast_channel chan,
const struct ast_party_redirecting redirecting,
const struct ast_set_party_redirecting update 
)

Indicate that the redirecting id has changed.

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

Definition at line 9592 of file channel.c.

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

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

9593 {
9594  unsigned char data[1024]; /* This should be large enough */
9595  size_t datalen;
9596 
9597  datalen = ast_redirecting_build_data(data, sizeof(data), redirecting, update);
9598  if (datalen == (size_t) -1) {
9599  return;
9600  }
9601 
9602  ast_indicate_data(chan, AST_CONTROL_REDIRECTING, data, datalen);
9603 }
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:4447
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:9161
void ast_channels_init ( void  )

Provided by channel.c

Definition at line 8221 of file channel.c.

References ao2_container_alloc, ARRAY_LEN, ast_channel_cmp_cb(), ast_channel_hash_cb(), ast_cli_register_multiple(), ast_data_register_multiple_core, ast_plc_reload(), ast_register_atexit(), channels, channels_shutdown(), cli_channel, and NUM_CHANNEL_BUCKETS.

Referenced by main().

8222 {
8225 
8227 
8229 
8230  ast_plc_reload();
8231 
8233 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static int ast_channel_hash_cb(const void *obj, const int flags)
Definition: channel.c:8063
#define ast_data_register_multiple_core(data_entries, entries)
Definition: data.h:379
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: asterisk.c:998
static int ast_channel_cmp_cb(void *obj, void *arg, int flags)
Definition: channel.c:1720
int ast_plc_reload(void)
Reload genericplc configuration value from codecs.conf.
Definition: channel.c:8076
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:197
static void channels_shutdown(void)
Definition: channel.c:8211
#define NUM_CHANNEL_BUCKETS
Definition: channel.c:148
#define ao2_container_alloc(arg1, arg2, arg3)
Definition: astobj2.h:734
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
Definition: cli.c:2167
static struct ast_cli_entry cli_channel[]
Definition: channel.c:624
static struct ast_data_entry channel_providers[]
Definition: channel.c:8206
struct ast_variable* ast_channeltype_list ( void  )

return an ast_variable list of channeltypes

Definition at line 261 of file channel.c.

References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_variable_new(), ast_channel_tech::description, chanlist::tech, ast_channel_tech::type, and var.

Referenced by ast_var_channel_types(), and ast_var_channel_types_table().

262 {
263  struct chanlist *cl;
264  struct ast_variable *var = NULL, *prev = NULL;
265 
267  AST_RWLIST_TRAVERSE(&backends, cl, list) {
268  if (prev) {
269  if ((prev->next = ast_variable_new(cl->tech->type, cl->tech->description, "")))
270  prev = prev->next;
271  } else {
272  var = ast_variable_new(cl->tech->type, cl->tech->description, "");
273  prev = var;
274  }
275  }
277 
278  return var;
279 }
const char *const type
Definition: channel.h:508
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
Structure for variables, used for configurations and for channel variables.
Definition: config.h:75
#define var
Definition: ast_expr2f.c:606
the list of registered channel types
Definition: channel.c:143
struct ast_channel_tech * tech
Definition: channel.c:122
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
List of channel drivers.
Definition: app_dial.c:664
const char *const description
Definition: channel.h:509
struct ast_variable * ast_variable_new(const char *name, const char *value, const char *filename)
Definition: config.c:278
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 806 of file channel.c.

References ast_channel::_softhangup, ast_debug, AST_SOFTHANGUP_TIMEOUT, ast_test_suite_event_notify, ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), ast_channel::name, and ast_channel::whentohangup.

Referenced by __ast_pbx_run(), __ast_read(), _macro_exec(), agent_indicate(), agi_exec(), agi_handle_command(), announce_thread(), ast_bridge_call(), ast_call(), ast_channel_bridge(), ast_check_hangup_locked(), ast_indicate_data(), ast_raw_answer(), ast_readstring_full(), ast_recvtext(), ast_rtp_instance_bridge(), ast_sendtext(), ast_transfer(), ast_udptl_bridge(), ast_waitfordigit_full(), ast_write(), autoservice_run(), bridge_call_thread(), bridge_exec(), builtin_atxfer(), call_forward_inherit(), channel_spy(), check_bridge(), common_exec(), conf_play(), conf_run(), dahdi_accept_r2_call_exec(), dahdi_sendtext(), dahdi_setoption(), dial_exec_full(), dundi_lookup_internal(), eagi_exec(), eivr_comm(), feature_request_and_dial(), findmeexec(), func_channel_read(), gosub_run(), handle_sendimage(), iax2_bridge(), launch_asyncagi(), local_bridge_loop(), local_fixup(), login_exec(), lua_check_hangup(), ospfinished_exec(), pbx_builtin_incomplete(), pbx_builtin_waitexten(), pbx_exec(), read_exec(), readexten_exec(), remote_bridge_loop(), run_agi(), run_ras(), try_calling(), and wait_for_answer().

807 {
808  if (chan->_softhangup) /* yes if soft hangup flag set */
809  return 1;
810  if (ast_tvzero(chan->whentohangup)) /* no if no hangup scheduled */
811  return 0;
812  if (ast_tvdiff_ms(chan->whentohangup, ast_tvnow()) > 0) /* no if hangup time has not come yet. */
813  return 0;
814  ast_debug(4, "Hangup time has come: %" PRIi64 "\n", ast_tvdiff_ms(chan->whentohangup, ast_tvnow()));
815  ast_test_suite_event_notify("HANGUP_TIME", "Channel: %s", chan->name);
816  chan->_softhangup |= AST_SOFTHANGUP_TIMEOUT; /* record event */
817  return 1;
818 }
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:100
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:90
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
#define ast_test_suite_event_notify(s, f,...)
Definition: test.h:184
const ast_string_field name
Definition: channel.h:787
int _softhangup
Definition: channel.h:832
struct timeval whentohangup
Definition: channel.h:789
int ast_check_hangup_locked ( struct ast_channel chan)

Definition at line 820 of file channel.c.

References ast_channel_lock, ast_channel_unlock, and ast_check_hangup().

Referenced by action_redirect(), and ast_channel_bridge().

821 {
822  int res;
823  ast_channel_lock(chan);
824  res = ast_check_hangup(chan);
825  ast_channel_unlock(chan);
826  return res;
827 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
#define ast_channel_unlock(chan)
Definition: channel.h:2467
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 8825 of file channel.c.

References AST_CONNECTED_LINE_ID_PRESENTATION, AST_CONNECTED_LINE_NAME, AST_CONNECTED_LINE_NAME_CHAR_SET, AST_CONNECTED_LINE_NAME_PRESENTATION, AST_CONNECTED_LINE_NAME_VALID, AST_CONNECTED_LINE_NUMBER, AST_CONNECTED_LINE_NUMBER_PLAN, AST_CONNECTED_LINE_NUMBER_PRESENTATION, AST_CONNECTED_LINE_NUMBER_VALID, AST_CONNECTED_LINE_SOURCE, AST_CONNECTED_LINE_SUBADDRESS, AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN, AST_CONNECTED_LINE_SUBADDRESS_TYPE, AST_CONNECTED_LINE_SUBADDRESS_VALID, AST_CONNECTED_LINE_TAG, AST_CONNECTED_LINE_VERSION, ast_log(), ast_party_connected_line::id, ast_set_party_connected_line::id, LOG_WARNING, ast_party_id_ies::name, party_id_build_data(), ast_party_connected_line::source, ast_party_name_ies::str, and value.

Referenced by ast_channel_queue_connected_line_update(), ast_channel_update_connected_line(), local_attended_transfer(), local_indicate(), and masquerade_colp_transfer().

8826 {
8827  int32_t value;
8828  size_t pos = 0;
8829  int res;
8830 
8831  static const struct ast_party_id_ies ies = {
8833  .name.char_set = AST_CONNECTED_LINE_NAME_CHAR_SET,
8834  .name.presentation = AST_CONNECTED_LINE_NAME_PRESENTATION,
8835  .name.valid = AST_CONNECTED_LINE_NAME_VALID,
8836 
8837  .number.str = AST_CONNECTED_LINE_NUMBER,
8838  .number.plan = AST_CONNECTED_LINE_NUMBER_PLAN,
8839  .number.presentation = AST_CONNECTED_LINE_NUMBER_PRESENTATION,
8840  .number.valid = AST_CONNECTED_LINE_NUMBER_VALID,
8841 
8842  .subaddress.str = AST_CONNECTED_LINE_SUBADDRESS,
8843  .subaddress.type = AST_CONNECTED_LINE_SUBADDRESS_TYPE,
8844  .subaddress.odd_even_indicator = AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN,
8845  .subaddress.valid = AST_CONNECTED_LINE_SUBADDRESS_VALID,
8846 
8847  .tag = AST_CONNECTED_LINE_TAG,
8848  .combined_presentation = AST_CONNECTED_LINE_ID_PRESENTATION,
8849  };
8850 
8851  /*
8852  * The size of integer values must be fixed in case the frame is
8853  * shipped to another machine.
8854  */
8855 
8856  /* Connected line frame version */
8857  if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8858  ast_log(LOG_WARNING, "No space left for connected line frame version\n");
8859  return -1;
8860  }
8861  data[pos++] = AST_CONNECTED_LINE_VERSION;
8862  data[pos++] = 1;
8863  data[pos++] = 2;/* Version 1 did not have a version ie */
8864 
8865  res = party_id_build_data(data + pos, datalen - pos, &connected->id,
8866  "connected line", &ies, update ? &update->id : NULL);
8867  if (res < 0) {
8868  return -1;
8869  }
8870  pos += res;
8871 
8872  /* Connected line source */
8873  if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) {
8874  ast_log(LOG_WARNING, "No space left for connected line source\n");
8875  return -1;
8876  }
8877  data[pos++] = AST_CONNECTED_LINE_SOURCE;
8878  data[pos++] = sizeof(value);
8879  value = htonl(connected->source);
8880  memcpy(data + pos, &value, sizeof(value));
8881  pos += sizeof(value);
8882 
8883  return pos;
8884 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
#define LOG_WARNING
Definition: logger.h:144
int value
Definition: syslog.c:39
struct ast_party_name_ies name
Subscriber name ies.
Definition: channel.c:8696
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int source
Information about the source of an update.
Definition: channel.h:424
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:8722
struct ast_set_party_id id
Definition: channel.h:433
int str
Subscriber name ie.
Definition: channel.c:8473
void ast_connected_line_copy_from_caller ( struct ast_party_connected_line dest,
const struct ast_party_caller src 
)

Copy the caller information to the connected line information.

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

Definition at line 8443 of file channel.c.

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

Referenced by app_exec(), ast_do_pickup(), begin_dial_channel(), builtin_atxfer(), dial_exec_full(), dial_transfer(), do_forward(), feature_request_and_dial(), findmeexec(), local_call(), parked_call_exec(), ring_entry(), and wait_for_answer().

8444 {
8445  ast_party_id_copy(&dest->id, &src->id);
8446  ast_party_id_copy(&dest->ani, &src->ani);
8447  dest->ani2 = src->ani2;
8448 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
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:2095
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:417
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:377
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:410
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:380
void ast_connected_line_copy_to_caller ( struct ast_party_caller dest,
const struct ast_party_connected_line src 
)

Copy the connected line information to the caller information.

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

Definition at line 8450 of file channel.c.

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

Referenced by local_call(), and local_indicate().

8451 {
8452  ast_party_id_copy(&dest->id, &src->id);
8453  ast_party_id_copy(&dest->ani, &src->ani);
8454 
8455  dest->ani2 = src->ani2;
8456 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
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:2095
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:417
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:377
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:410
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:380
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 8886 of file channel.c.

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

Referenced by __ast_read(), ast_channel_connected_line_macro(), ast_indicate_data(), feature_request_and_dial(), socket_process(), wait_for_answer(), and wait_for_winner().

8887 {
8888  size_t pos;
8889  unsigned char ie_len;
8890  unsigned char ie_id;
8891  int32_t value;
8892  int frame_version = 1;
8893  int combined_presentation = 0;
8894  int got_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
8895 
8896  for (pos = 0; pos < datalen; pos += ie_len) {
8897  if (datalen < pos + sizeof(ie_id) + sizeof(ie_len)) {
8898  ast_log(LOG_WARNING, "Invalid connected line update\n");
8899  return -1;
8900  }
8901  ie_id = data[pos++];
8902  ie_len = data[pos++];
8903  if (datalen < pos + ie_len) {
8904  ast_log(LOG_WARNING, "Invalid connected line update\n");
8905  return -1;
8906  }
8907 
8908  switch (ie_id) {
8909 /* Connected line party frame version */
8911  if (ie_len != 1) {
8912  ast_log(LOG_WARNING, "Invalid connected line frame version (%u)\n",
8913  (unsigned) ie_len);
8914  break;
8915  }
8916  frame_version = data[pos];
8917  break;
8918 /* Connected line party id name */
8920  ast_free(connected->id.name.str);
8921  connected->id.name.str = ast_malloc(ie_len + 1);
8922  if (connected->id.name.str) {
8923  memcpy(connected->id.name.str, data + pos, ie_len);
8924  connected->id.name.str[ie_len] = 0;
8925  }
8926  break;
8928  if (ie_len != 1) {
8929  ast_log(LOG_WARNING, "Invalid connected line name char set (%u)\n",
8930  (unsigned) ie_len);
8931  break;
8932  }
8933  connected->id.name.char_set = data[pos];
8934  break;
8936  if (ie_len != 1) {
8937  ast_log(LOG_WARNING, "Invalid connected line name presentation (%u)\n",
8938  (unsigned) ie_len);
8939  break;
8940  }
8941  connected->id.name.presentation = data[pos];
8942  break;
8944  if (ie_len != 1) {
8945  ast_log(LOG_WARNING, "Invalid connected line name valid (%u)\n",
8946  (unsigned) ie_len);
8947  break;
8948  }
8949  connected->id.name.valid = data[pos];
8950  break;
8951 /* Connected line party id number */
8953  ast_free(connected->id.number.str);
8954  connected->id.number.str = ast_malloc(ie_len + 1);
8955  if (connected->id.number.str) {
8956  memcpy(connected->id.number.str, data + pos, ie_len);
8957  connected->id.number.str[ie_len] = 0;
8958  }
8959  break;
8961  if (ie_len != 1) {
8962  ast_log(LOG_WARNING, "Invalid connected line numbering plan (%u)\n",
8963  (unsigned) ie_len);
8964  break;
8965  }
8966  connected->id.number.plan = data[pos];
8967  break;
8969  if (ie_len != 1) {
8970  ast_log(LOG_WARNING, "Invalid connected line number presentation (%u)\n",
8971  (unsigned) ie_len);
8972  break;
8973  }
8974  connected->id.number.presentation = data[pos];
8975  break;
8977  if (ie_len != 1) {
8978  ast_log(LOG_WARNING, "Invalid connected line number valid (%u)\n",
8979  (unsigned) ie_len);
8980  break;
8981  }
8982  connected->id.number.valid = data[pos];
8983  break;
8984 /* Connected line party id combined presentation */
8986  if (ie_len != 1) {
8987  ast_log(LOG_WARNING, "Invalid connected line combined presentation (%u)\n",
8988  (unsigned) ie_len);
8989  break;
8990  }
8991  combined_presentation = data[pos];
8992  got_combined_presentation = 1;
8993  break;
8994 /* Connected line party id subaddress */
8996  ast_free(connected->id.subaddress.str);
8997  connected->id.subaddress.str = ast_malloc(ie_len + 1);
8998  if (connected->id.subaddress.str) {
8999  memcpy(connected->id.subaddress.str, data + pos, ie_len);
9000  connected->id.subaddress.str[ie_len] = 0;
9001  }
9002  break;
9004  if (ie_len != 1) {
9005  ast_log(LOG_WARNING, "Invalid connected line type of subaddress (%u)\n",
9006  (unsigned) ie_len);
9007  break;
9008  }
9009  connected->id.subaddress.type = data[pos];
9010  break;
9012  if (ie_len != 1) {
9014  "Invalid connected line subaddress odd-even indicator (%u)\n",
9015  (unsigned) ie_len);
9016  break;
9017  }
9018  connected->id.subaddress.odd_even_indicator = data[pos];
9019  break;
9021  if (ie_len != 1) {
9022  ast_log(LOG_WARNING, "Invalid connected line subaddress valid (%u)\n",
9023  (unsigned) ie_len);
9024  break;
9025  }
9026  connected->id.subaddress.valid = data[pos];
9027  break;
9028 /* Connected line party tag */
9030  ast_free(connected->id.tag);
9031  connected->id.tag = ast_malloc(ie_len + 1);
9032  if (connected->id.tag) {
9033  memcpy(connected->id.tag, data + pos, ie_len);
9034  connected->id.tag[ie_len] = 0;
9035  }
9036  break;
9037 /* Connected line party source */
9039  if (ie_len != sizeof(value)) {
9040  ast_log(LOG_WARNING, "Invalid connected line source (%u)\n",
9041  (unsigned) ie_len);
9042  break;
9043  }
9044  memcpy(&value, data + pos, sizeof(value));
9045  connected->source = ntohl(value);
9046  break;
9047 /* Connected line party unknown element */
9048  default:
9049  ast_log(LOG_DEBUG, "Unknown connected line element: %u (%u)\n",
9050  (unsigned) ie_id, (unsigned) ie_len);
9051  break;
9052  }
9053  }
9054 
9055  switch (frame_version) {
9056  case 1:
9057  /*
9058  * The other end is an earlier version that we need to adjust
9059  * for compatibility.
9060  */
9061  connected->id.name.valid = 1;
9063  connected->id.number.valid = 1;
9064  if (got_combined_presentation) {
9067  }
9068  break;
9069  case 2:
9070  /* The other end is at the same level as we are. */
9071  break;
9072  default:
9073  /*
9074  * The other end is newer than we are.
9075  * We need to assume that they are compatible with us.
9076  */
9077  ast_log(LOG_DEBUG, "Connected line frame has newer version: %u\n",
9078  (unsigned) frame_version);
9079  break;
9080  }
9081 
9082  return 0;
9083 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:227
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:245
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
#define LOG_WARNING
Definition: logger.h:144
int char_set
Character set the name is using.
Definition: channel.h:222
char * str
Subscriber name (Malloced)
Definition: channel.h:214
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:278
char * str
Malloced subaddress string.
Definition: channel.h:263
int value
Definition: syslog.c:39
#define LOG_DEBUG
Definition: logger.h:122
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:276
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:294
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:243
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int source
Information about the source of an update.
Definition: channel.h:424
#define ast_free(a)
Definition: astmm.h:97
int combined_presentation
Combined name and number presentation ie.
Definition: channel.c:8704
char * tag
User-set &quot;tag&quot;.
Definition: channel.h:304
int type
Q.931 subaddress type.
Definition: channel.h:270
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
#define ast_malloc(a)
Definition: astmm.h:91
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
AST_DATA_STRUCTURE ( ast_channel  ,
DATA_EXPORT_CHANNEL   
)
void ast_deactivate_generator ( struct ast_channel chan)

Deactivate an active generator

Definition at line 3107 of file channel.c.

References ast_channel_lock, ast_channel_unlock, and deactivate_generator_nolock().

Referenced by __ast_read(), app_exec(), ast_openstream_full(), ast_playtones_stop(), ast_quiet_chan(), ast_read_generator_actions(), ast_tonepair_stop(), ast_write(), cb_events(), channel_spy(), dial_exec_full(), generator_force(), local_ast_moh_stop(), old_milliwatt_exec(), transmit_audio(), and wait_for_answer().

3108 {
3109  ast_channel_lock(chan);
3111  ast_channel_unlock(chan);
3112 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define ast_channel_unlock(chan)
Definition: channel.h:2467
static void deactivate_generator_nolock(struct ast_channel *chan)
Definition: channel.c:3091
int ast_do_masquerade ( struct ast_channel original)

Masquerade a channel.

Start masquerading 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.

< TRUE if the clonechan was a zombie before the masquerade.

Definition at line 6546 of file channel.c.

References __ast_change_name_nolink(), ast_channel::_bridge, ast_channel::_softhangup, ast_channel::_state, accountcode, ast_channel::accountcode, ast_channel::adsicpe, ast_channel::alertpipe, ao2_link, ao2_lock, ao2_unlink, ao2_unlock, ast_app_group_update(), ast_autochan_new_channel(), ast_bridge_end_dtmf(), ast_bridged_channel(), ast_cause2str(), AST_CEL_BRIDGE_UPDATE, ast_cel_report_event(), ast_channel_datastore_find(), ast_channel_datastore_remove(), ast_channel_lock, ast_channel_lock_both, AST_CHANNEL_NAME, ast_channel_ref, ast_channel_set_fd(), ast_channel_set_linkgroup(), ast_channel_unlock, ast_channel_unref, ast_clear_flag, AST_CONTROL_SRCCHANGE, AST_CONTROL_UNHOLD, ast_copy_string(), ast_datastore_free(), ast_debug, AST_FLAG_BLOCKING, AST_FLAG_DISABLE_DEVSTATE_CACHE, AST_FLAG_EXCEPTION, AST_FLAG_MOH, AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, AST_GENERATOR_FD, ast_getformatname(), ast_indicate(), ast_kill_tech, 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_manager_event, ast_manager_event_multichan, AST_MAX_FDS, ast_moh_start(), ast_null_frame, ast_queue_frame(), ast_set_flag, ast_set_read_format(), ast_set_write_format(), AST_SOFTHANGUP_DEV, ast_state2str(), ast_string_field_set, ast_test_flag, AST_TIMING_FD, ast_channel::blocker, ast_channel::caller, ast_channel::cdr, ast_datastore_info::chan_fixup, channels, clone_variables(), ast_channel::connected, ast_datastore::data, ast_channel::datastores, ast_channel::dialed, errno, EVENT_FLAG_CALL, ast_channel::fdno, ast_channel::fds, ast_channel_tech::fixup, free_translation(), ast_channel_tech::hangup, ast_channel::hangupcause, ast_datastore::info, language, ast_channel::language, LOG_WARNING, ast_channel::masq, ast_channel::masqr, masquerade_colp_transfer(), ast_channel::monitor, musicclass, ast_channel::musicclass, ast_channel::name, ast_channel::nativeformats, parkinglot, ast_channel::parkinglot, ast_channel::rawreadformat, ast_channel::rawwriteformat, ast_channel::readformat, ast_channel::readq, ast_channel::redirecting, report_new_callerid(), S_OR, ast_channel::sending_dtmf_digit, ast_channel::sending_dtmf_tv, ast_channel::tech, ast_channel::tech_pvt, ast_channel::timingfd, xfer_masquerade_ds::transferee_held, ast_channel_tech::type, ast_cdr::uniqueid, ast_channel::uniqueid, ast_channel::visible_indication, ast_channel::whentohangup, and ast_channel::writeformat.

Referenced by __ast_read(), ast_async_goto(), ast_do_pickup(), ast_hangup(), ast_waitfor_nandfds(), ast_write(), builtin_atxfer(), check_bridge(), check_goto_on_transfer(), do_bridge_masquerade(), handle_invite_replaces(), iax_park(), local_attended_transfer(), masq_park_call(), and sip_park().

6547 {
6548  int x;
6549  int i;
6550  int origstate;
6551  unsigned int orig_disablestatecache;
6552  unsigned int clone_disablestatecache;
6553  int visible_indication;
6554  int moh_is_playing;
6555  int clone_was_zombie = 0;/*!< TRUE if the clonechan was a zombie before the masquerade. */
6556  struct ast_frame *current;
6557  const struct ast_channel_tech *t;
6558  void *t_pvt;
6559  union {
6560  struct ast_party_dialed dialed;
6561  struct ast_party_caller caller;
6563  struct ast_party_redirecting redirecting;
6564  } exchange;
6565  struct ast_channel *clonechan, *chans[2];
6566  struct ast_channel *bridged;
6567  struct ast_cdr *cdr;
6568  struct ast_datastore *xfer_ds;
6569  struct xfer_masquerade_ds *xfer_colp;
6570  format_t rformat;
6571  format_t wformat;
6572  format_t tmp_format;
6573  char newn[AST_CHANNEL_NAME];
6574  char orig[AST_CHANNEL_NAME];
6575  char masqn[AST_CHANNEL_NAME];
6576  char zombn[AST_CHANNEL_NAME];
6577  char clone_sending_dtmf_digit;
6578  struct timeval clone_sending_dtmf_tv;
6579 
6580  /* XXX This operation is a bit odd. We're essentially putting the guts of
6581  * the clone channel into the original channel. Start by killing off the
6582  * original channel's backend. While the features are nice, which is the
6583  * reason we're keeping it, it's still awesomely weird. XXX */
6584 
6585  /*
6586  * The reasoning for the channels ao2_container lock here is
6587  * complex.
6588  *
6589  * There is a race condition that exists for this function.
6590  * Since all pvt and channel locks must be let go before calling
6591  * ast_do_masquerade, it is possible that it could be called
6592  * multiple times for the same channel. In order to prevent the
6593  * race condition with competing threads to do the masquerade
6594  * and new masquerade attempts, the channels container must be
6595  * locked for the entire masquerade. The original and clonechan
6596  * need to be unlocked earlier to avoid potential deadlocks with
6597  * the chan_local deadlock avoidance method.
6598  *
6599  * The container lock blocks competing masquerade attempts from
6600  * starting as well as being necessary for proper locking order
6601  * because the channels must to be unlinked to change their
6602  * names.
6603  *
6604  * The original and clonechan locks must be held while the
6605  * channel contents are shuffled around for the masquerade.
6606  *
6607  * The masq and masqr pointers need to be left alone until the
6608  * masquerade has restabilized the channels to prevent another
6609  * masquerade request until the AST_FLAG_ZOMBIE can be set on
6610  * the clonechan.
6611  */
6612  ao2_lock(channels);
6613 
6614  /*
6615  * Lock the original channel to determine if the masquerade is
6616  * still required.
6617  */
6618  ast_channel_lock(original);
6619 
6620  clonechan = original->masq;
6621  if (!clonechan) {
6622  /*
6623  * The masq is already completed by another thread or never
6624  * needed to be done to begin with.
6625  */
6626  ast_channel_unlock(original);
6628  return 0;
6629  }
6630 
6631  /* Bump the refs to ensure that they won't dissapear on us. */
6632  ast_channel_ref(original);
6633  ast_channel_ref(clonechan);
6634 
6635  /* unlink from channels container as name (which is the hash value) will change */
6636  ao2_unlink(channels, original);
6637  ao2_unlink(channels, clonechan);
6638 
6639  /* Get any transfer masquerade connected line exchange data. */
6640  xfer_ds = ast_channel_datastore_find(original, &xfer_ds_info, NULL);
6641  if (xfer_ds) {
6642  ast_channel_datastore_remove(original, xfer_ds);
6643  xfer_colp = xfer_ds->data;
6644  } else {
6645  xfer_colp = NULL;
6646  }
6647 
6648  moh_is_playing = ast_test_flag(original, AST_FLAG_MOH);
6649 
6650  /*
6651  * Stop any visible indication on the original channel so we can
6652  * transfer it to the clonechan taking the original's place.
6653  */
6654  visible_indication = original->visible_indication;
6655  ast_channel_unlock(original);
6656  ast_indicate(original, -1);
6657 
6658  /*
6659  * Release any hold on the transferee channel before going any
6660  * further with the masquerade.
6661  */
6662  if (xfer_colp && xfer_colp->transferee_held) {
6663  ast_indicate(clonechan, AST_CONTROL_UNHOLD);
6664  }
6665 
6666  /* Start the masquerade channel contents rearangement. */
6667  ast_channel_lock_both(original, clonechan);
6668 
6669  ast_debug(4, "Actually Masquerading %s(%u) into the structure of %s(%u)\n",
6670  clonechan->name, clonechan->_state, original->name, original->_state);
6671 
6672  chans[0] = clonechan;
6673  chans[1] = original;
6674  ast_manager_event_multichan(EVENT_FLAG_CALL, "Masquerade", 2, chans,
6675  "Clone: %s\r\n"
6676  "CloneState: %s\r\n"
6677  "Original: %s\r\n"
6678  "OriginalState: %s\r\n",
6679  clonechan->name, ast_state2str(clonechan->_state), original->name, ast_state2str(original->_state));
6680 
6681  /*
6682  * Remember the original read/write formats. We turn off any
6683  * translation on either one
6684  */
6685  rformat = original->readformat;
6686  wformat = original->writeformat;
6687  free_translation(clonechan);
6688  free_translation(original);
6689 
6690  /* Save the current DTMF digit being sent if any. */
6691  clone_sending_dtmf_digit = clonechan->sending_dtmf_digit;
6692  clone_sending_dtmf_tv = clonechan->sending_dtmf_tv;
6693 
6694  /* Save the original name */
6695  ast_copy_string(orig, original->name, sizeof(orig));
6696  /* Save the new name */
6697  ast_copy_string(newn, clonechan->name, sizeof(newn));
6698  /* Create the masq name */
6699  snprintf(masqn, sizeof(masqn), "%s<MASQ>", newn);
6700 
6701  /* Mangle the name of the clone channel */
6702  __ast_change_name_nolink(clonechan, masqn);
6703 
6704  /* Copy the name from the clone channel */
6705  __ast_change_name_nolink(original, newn);
6706 
6707  /* share linked id's */
6708  ast_channel_set_linkgroup(original, clonechan);
6709 
6710  /* Swap the technologies */
6711  t = original->tech;
6712  original->tech = clonechan->tech;
6713  clonechan->tech = t;
6714 
6715  t_pvt = original->tech_pvt;
6716  original->tech_pvt = clonechan->tech_pvt;
6717  clonechan->tech_pvt = t_pvt;
6718 
6719  /* Swap the cdrs */
6720  cdr = original->cdr;
6721  /* swap cdr uniqueid between channels, to get cdr uniqueid = channel uniqueid */
6722  ast_copy_string(clonechan->cdr->uniqueid, cdr->uniqueid, sizeof(cdr->uniqueid));
6723  original->cdr = clonechan->cdr;
6724  clonechan->cdr = cdr;
6725 
6726  /* Swap the alertpipes */
6727  for (i = 0; i < 2; i++) {
6728  x = original->alertpipe[i];
6729  original->alertpipe[i] = clonechan->alertpipe[i];
6730  clonechan->alertpipe[i] = x;
6731  }
6732 
6733  /*
6734  * Swap the readq's. The end result should be this:
6735  *
6736  * 1) All frames should be on the new (original) channel.
6737  * 2) Any frames that were already on the new channel before this
6738  * masquerade need to be at the end of the readq, after all of the
6739  * frames on the old (clone) channel.
6740  * 3) The alertpipe needs to get poked for every frame that was already
6741  * on the new channel, since we are now using the alert pipe from the
6742  * old (clone) channel.
6743  */
6744  {
6745  AST_LIST_HEAD_NOLOCK(, ast_frame) tmp_readq;
6746 
6747  AST_LIST_HEAD_INIT_NOLOCK(&tmp_readq);
6748  AST_LIST_APPEND_LIST(&tmp_readq, &original->readq, frame_list);
6749  AST_LIST_APPEND_LIST(&original->readq, &clonechan->readq, frame_list);
6750 
6751  while ((current = AST_LIST_REMOVE_HEAD(&tmp_readq, frame_list))) {
6752  AST_LIST_INSERT_TAIL(&original->readq, current, frame_list);
6753  if (original->alertpipe[1] > -1) {
6754  int poke = 0;
6755 
6756  if (write(original->alertpipe[1], &poke, sizeof(poke)) < 0) {
6757  ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
6758  }
6759  }
6760  }
6761  }
6762 
6763  /* Swap the raw formats */
6764  tmp_format = original->rawreadformat;
6765  original->rawreadformat = clonechan->rawreadformat;
6766  clonechan->rawreadformat = tmp_format;
6767 
6768  tmp_format = original->rawwriteformat;
6769  original->rawwriteformat = clonechan->rawwriteformat;
6770  clonechan->rawwriteformat = tmp_format;
6771 
6772  clonechan->_softhangup = AST_SOFTHANGUP_DEV;
6773 
6774  /* And of course, so does our current state. Note we need not
6775  call ast_setstate since the event manager doesn't really consider
6776  these separate. We do this early so that the clone has the proper
6777  state of the original channel. */
6778  origstate = original->_state;
6779  original->_state = clonechan->_state;
6780  clonechan->_state = origstate;
6781 
6782  /* And the swap the cachable state too. Otherwise we'd start caching
6783  * Local channels and ignoring real ones. */
6784  orig_disablestatecache = ast_test_flag(original, AST_FLAG_DISABLE_DEVSTATE_CACHE);
6785  clone_disablestatecache = ast_test_flag(clonechan, AST_FLAG_DISABLE_DEVSTATE_CACHE);
6786  if (orig_disablestatecache != clone_disablestatecache) {
6787  if (orig_disablestatecache) {
6790  } else {
6793  }
6794  }
6795 
6796  /* Mangle the name of the clone channel */
6797  snprintf(zombn, sizeof(zombn), "%s<ZOMBIE>", orig); /* quick, hide the brains! */
6798  __ast_change_name_nolink(clonechan, zombn);
6799 
6800  /* Update the type. */
6801  t_pvt = original->monitor;
6802  original->monitor = clonechan->monitor;
6803  clonechan->monitor = t_pvt;
6804 
6805  /* Keep the same language. */
6806  ast_string_field_set(original, language, clonechan->language);
6807 
6808  /* Keep the same parkinglot. */
6809  ast_string_field_set(original, parkinglot, clonechan->parkinglot);
6810 
6811  /* Copy the FD's other than the generator fd */
6812  for (x = 0; x < AST_MAX_FDS; x++) {
6813  if (x != AST_GENERATOR_FD)
6814  ast_channel_set_fd(original, x, clonechan->fds[x]);
6815  }
6816 
6817  ast_app_group_update(clonechan, original);
6818 
6819  /* Move data stores over */
6820  if (AST_LIST_FIRST(&clonechan->datastores)) {
6821  struct ast_datastore *ds;
6822  /* We use a safe traversal here because some fixup routines actually
6823  * remove the datastore from the list and free them.
6824  */
6825  AST_LIST_TRAVERSE_SAFE_BEGIN(&clonechan->datastores, ds, entry) {
6826  if (ds->info->chan_fixup)
6827  ds->info->chan_fixup(ds->data, clonechan, original);
6828  }
6830  AST_LIST_APPEND_LIST(&original->datastores, &clonechan->datastores, entry);
6831  }
6832 
6833  ast_autochan_new_channel(clonechan, original);
6834 
6835  clone_variables(original, clonechan);
6836  /* Presense of ADSI capable CPE follows clone */
6837  original->adsicpe = clonechan->adsicpe;
6838  /* Bridge remains the same */
6839  /* CDR fields remain the same */
6840  /* XXX What about blocking, softhangup, blocker, and lock and blockproc? XXX */
6841  /* Application and data remain the same */
6842  /* Clone exception becomes real one, as with fdno */
6844  original->fdno = clonechan->fdno;
6845  /* Schedule context remains the same */
6846  /* Stream stuff stays the same */
6847  /* Keep the original state. The fixup code will need to work with it most likely */
6848 
6849  /*
6850  * Just swap the whole structures, nevermind the allocations,
6851  * they'll work themselves out.
6852  */
6853  exchange.dialed = original->dialed;
6854  original->dialed = clonechan->dialed;
6855  clonechan->dialed = exchange.dialed;
6856 
6857  exchange.caller = original->caller;
6858  original->caller = clonechan->caller;
6859  clonechan->caller = exchange.caller;
6860 
6861  exchange.connected = original->connected;
6862  original->connected = clonechan->connected;
6863  clonechan->connected = exchange.connected;
6864 
6865  exchange.redirecting = original->redirecting;
6866  original->redirecting = clonechan->redirecting;
6867  clonechan->redirecting = exchange.redirecting;
6868 
6869  report_new_callerid(original);
6870 
6871  /* Restore original timing file descriptor */
6872  ast_channel_set_fd(original, AST_TIMING_FD, original->timingfd);
6873 
6874  /* Our native formats are different now */
6875  original->nativeformats = clonechan->nativeformats;
6876 
6877  /* Context, extension, priority, app data, jump table, remain the same */
6878  /* pvt switches. pbx stays the same, as does next */
6879 
6880  /* Set the write format */
6881  ast_set_write_format(original, wformat);
6882 
6883  /* Set the read format */
6884  ast_set_read_format(original, rformat);
6885 
6886  /* Copy the music class */
6887  ast_string_field_set(original, musicclass, clonechan->musicclass);
6888 
6889  /* Copy whentohangup time */
6890  original->whentohangup = clonechan->whentohangup;
6891 
6892  /* copy over accuntcode and set peeraccount across the bridge */
6893  ast_string_field_set(original, accountcode, S_OR(clonechan->accountcode, ""));
6894  if (original->_bridge) {
6895  /* XXX - should we try to lock original->_bridge here? */
6896  ast_string_field_set(original->_bridge, peeraccount, S_OR(clonechan->accountcode, ""));
6897  ast_cel_report_event(original, AST_CEL_BRIDGE_UPDATE, NULL, NULL, NULL);
6898  }
6899 
6900  ast_debug(1, "Putting channel %s in %s/%s formats\n", original->name,
6901  ast_getformatname(wformat), ast_getformatname(rformat));
6902 
6903  /* Fixup the original clonechan's physical side */
6904  if (original->tech->fixup && original->tech->fixup(clonechan, original)) {
6905  ast_log(LOG_WARNING, "Channel type '%s' could not fixup channel %s, strange things may happen. (clonechan)\n",
6906  original->tech->type, original->name);
6907  }
6908 
6909  /* Fixup the original original's physical side */
6910  if (clonechan->tech->fixup && clonechan->tech->fixup(original, clonechan)) {
6911  ast_log(LOG_WARNING, "Channel type '%s' could not fixup channel %s, strange things may happen. (original)\n",
6912  clonechan->tech->type, clonechan->name);
6913  }
6914 
6915  /*
6916  * Now, at this point, the "clone" channel is totally F'd up.
6917  * We mark it as a zombie so nothing tries to touch it. If it's
6918  * already been marked as a zombie, then we must free it (since
6919  * it already is considered invalid).
6920  *
6921  * This must be done before we unlock clonechan to prevent
6922  * setting up another masquerade on the clonechan.
6923  */
6924  if (ast_test_flag(clonechan, AST_FLAG_ZOMBIE)) {
6925  clone_was_zombie = 1;
6926  } else {
6927  ast_set_flag(clonechan, AST_FLAG_ZOMBIE);
6928  ast_queue_frame(clonechan, &ast_null_frame);
6929  }
6930 
6931  /* clear the masquerade channels */
6932  original->masq = NULL;
6933  clonechan->masqr = NULL;
6934 
6935  /*
6936  * When we unlock original here, it can be immediately setup to
6937  * masquerade again or hungup. The new masquerade or hangup
6938  * will not actually happen until we release the channels
6939  * container lock.
6940  */
6941  ast_channel_unlock(original);
6942 
6943  /* Disconnect the original original's physical side */
6944  if (clonechan->tech->hangup && clonechan->tech->hangup(clonechan)) {
6945  ast_log(LOG_WARNING, "Hangup failed! Strange things may happen!\n");
6946  } else {
6947  /*
6948  * We just hung up the original original's physical side of the
6949  * channel. Set the new zombie to use the kill channel driver
6950  * for safety.
6951  */
6952  clonechan->tech = &ast_kill_tech;
6953  }
6954 
6955  ast_channel_unlock(clonechan);
6956 
6957  if (clone_sending_dtmf_digit) {
6958  /*
6959  * The clonechan was sending a DTMF digit that was not completed
6960  * before the masquerade.
6961  */
6962  ast_bridge_end_dtmf(original, clone_sending_dtmf_digit, clone_sending_dtmf_tv,
6963  "masquerade");
6964  }
6965 
6966  /*
6967  * If an indication is currently playing, maintain it on the
6968  * channel that is taking the place of original.
6969  *
6970  * This is needed because the masquerade is swapping out the
6971  * internals of the channel, and the new channel private data
6972  * needs to be made aware of the current visible indication
6973  * (RINGING, CONGESTION, etc.)
6974  */
6975  if (visible_indication) {
6976  ast_indicate(original, visible_indication);
6977  }
6978 
6979  /* if moh is playing on the original channel then it needs to be
6980  maintained on the channel that is replacing it. */
6981  if (moh_is_playing) {
6982  ast_moh_start(original, NULL, NULL);
6983  }
6984 
6985  ast_channel_lock(original);
6986 
6987  /* Signal any blocker */
6988  if (ast_test_flag(original, AST_FLAG_BLOCKING)) {
6989  pthread_kill(original->blocker, SIGURG);
6990  }
6991 
6992  ast_debug(1, "Done Masquerading %s (%u)\n", original->name, original->_state);
6993 
6994  if ((bridged = ast_bridged_channel(original))) {
6995  ast_channel_ref(bridged);
6996  ast_channel_unlock(original);
6998  ast_channel_unref(bridged);
6999  } else {
7000  ast_channel_unlock(original);
7001  }
7003 
7004  if (xfer_colp) {
7005  /*
7006  * After the masquerade, the original channel pointer actually
7007  * points to the new transferee channel and the bridged channel
7008  * is still the intended transfer target party.
7009  */
7010  masquerade_colp_transfer(original, xfer_colp);
7011  }
7012 
7013  if (xfer_ds) {
7014  ast_datastore_free(xfer_ds);
7015  }
7016 
7017  if (clone_was_zombie) {
7018  ast_channel_lock(clonechan);
7019  ast_debug(1, "Destroying channel clone '%s'\n", clonechan->name);
7020  ast_manager_event(clonechan, EVENT_FLAG_CALL, "Hangup",
7021  "Channel: %s\r\n"
7022  "Uniqueid: %s\r\n"
7023  "Cause: %d\r\n"
7024  "Cause-txt: %s\r\n",
7025  clonechan->name,
7026  clonechan->uniqueid,
7027  clonechan->hangupcause,
7028  ast_cause2str(clonechan->hangupcause)
7029  );
7030  ast_channel_unlock(clonechan);
7031 
7032  /*
7033  * Drop the system reference to destroy the channel since it is
7034  * already unlinked.
7035  */
7036  ast_channel_unref(clonechan);
7037  } else {
7038  ao2_link(channels, clonechan);
7039  }
7040 
7041  ao2_link(channels, original);
7043 
7044  /* Release our held safety references. */
7045  ast_channel_unref(original);
7046  ast_channel_unref(clonechan);
7047 
7048  return 0;
7049 }
static char musicclass[MAX_MUSICCLASS]
Definition: chan_mgcp.c:155
static char accountcode[AST_MAX_ACCOUNT_CODE]
Definition: chan_iax2.c:383
struct ast_channel * masqr
Definition: channel.h:752
struct ast_datastore::@163 entry
#define ast_channel_lock(chan)
Definition: channel.h:2466
void ast_bridge_end_dtmf(struct ast_channel *chan, char digit, struct timeval start, const char *why)
Simulate a DTMF end on a broken bridge channel.
Definition: features.c:3927
Main Channel structure associated with a channel.
Definition: channel.h:742
struct ast_channel * masq
Definition: channel.h:751
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
const char *const type
Definition: channel.h:508
#define ao2_link(arg1, arg2)
Definition: astobj2.h:785
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
Definition: linkedlists.h:420
static char parkinglot[AST_MAX_CONTEXT]
Definition: chan_mgcp.c:156
struct ast_frame ast_null_frame
Definition: frame.c:131
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
int timingfd
Definition: channel.h:838
const ast_string_field uniqueid
Definition: channel.h:787
format_t writeformat
Definition: channel.h:854
int visible_indication
Definition: channel.h:861
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2502
#define ast_test_flag(p, flag)
Definition: utils.h:63
static void free_translation(struct ast_channel *clonechan)
Definition: channel.c:2757
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4393
void * tech_pvt
Definition: channel.h:744
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define LOG_WARNING
Definition: logger.h:144
int ast_cel_report_event(struct ast_channel *chan, enum ast_cel_event_type event_type, const char *userdefevname, const char *extra, struct ast_channel *peer2)
Report a channel event.
Definition: cel.c:645
struct ast_datastore_info * info
Definition: datastore.h:57
format_t rawwriteformat
Definition: channel.h:856
char uniqueid[150]
Definition: cdr.h:121
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Definition: channel.h:814
#define EVENT_FLAG_CALL
Definition: manager.h:72
static void clone_variables(struct ast_channel *original, struct ast_channel *clonechan)
Clone channel variables from &#39;clone&#39; channel into &#39;original&#39; channel.
Definition: channel.c:6291
struct ast_cdr * cdr
Definition: channel.h:766
#define ao2_unlock(a)
Definition: astobj2.h:497
format_t nativeformats
Definition: channel.h:852
Structure for a data store object.
Definition: datastore.h:54
int alertpipe[2]
Definition: channel.h:851
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:2604
const char * ast_state2str(enum ast_channel_state)
Gives the string form of a given channel state.
Definition: channel.c:1007
int(*const fixup)(struct ast_channel *oldchan, struct ast_channel *newchan)
Fix up a channel: If a channel is consumed, this is called. Basically update any -&gt;owner links...
Definition: channel.h:579
enum ast_channel_adsicpe adsicpe
Definition: channel.h:844
format_t rawreadformat
Definition: channel.h:855
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:600
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Definition: datastore.c:65
#define ast_manager_event(chan, category, event, contents,...)
Definition: manager.h:221
int ast_set_write_format(struct ast_channel *chan, format_t format)
Sets write format on channel chan Set write format for channel to whichever component of &quot;format&quot; is ...
Definition: channel.c:5307
a masquerade happened to alter the participants on a bridge
Definition: cel.h:94
int ast_set_read_format(struct ast_channel *chan, format_t format)
Sets read format on channel chan Set read format for channel to whichever component of &quot;format&quot; is be...
Definition: channel.c:5301
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
int(*const hangup)(struct ast_channel *chan)
Hangup (and possibly destroy) the channel.
Definition: channel.h:545
Caller Party information.
Definition: channel.h:368
#define ao2_lock(a)
Definition: astobj2.h:488
const ast_string_field parkinglot
Definition: channel.h:787
#define AST_GENERATOR_FD
Definition: channel.h:166
static char language[MAX_LANGUAGE]
Definition: chan_alsa.c:108
void ast_channel_set_linkgroup(struct ast_channel *chan, struct ast_channel *peer)
propagate the linked id between chan and peer
Definition: channel.c:6387
struct ast_channel * _bridge
Definition: channel.h:748
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:818
char sending_dtmf_digit
Definition: channel.h:873
Structure to describe a channel &quot;technology&quot;, ie a channel driver See for examples: ...
Definition: channel.h:507
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
static void report_new_callerid(struct ast_channel *chan)
Definition: channel.c:6468
int fds[AST_MAX_FDS]
Definition: channel.h:829
struct ast_party_dialed dialed
Dialed/Called information.
Definition: channel.h:797
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
Definition: linkedlists.h:224
Dialed/Called Party information.
Definition: channel.h:328
static void masquerade_colp_transfer(struct ast_channel *transferee, struct xfer_masquerade_ds *colp)
Definition: channel.c:6498
Responsible for call detail data.
Definition: cdr.h:82
char * ast_getformatname(format_t format)
Get the name of a format.
Definition: frame.c:578
struct ast_channel_tech ast_kill_tech
Kill the channel channel driver technology descriptor.
Definition: channel.c:668
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:716
int64_t format_t
Definition: frame_defs.h:32
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:197
struct timeval sending_dtmf_tv
Definition: channel.h:874
#define AST_TIMING_FD
Definition: channel.h:164
enum ast_channel_state _state
Definition: channel.h:839
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
Definition: channel.c:7160
Connected Line/Party information.
Definition: channel.h:401
const ast_string_field name
Definition: channel.h:787
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:8040
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int _softhangup
Definition: channel.h:832
while(yyssp!=yyss)
Definition: ast_expr2.c:2538
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
Definition: channel.h:447
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:6223
int fdno
Definition: channel.h:834
#define ast_channel_unlock(chan)
Definition: channel.h:2467
const char * ast_cause2str(int state) attribute_pure
Gives the string form of a given cause code.
Definition: channel.c:980
int errno
struct ast_channel::datastores datastores
void ast_autochan_new_channel(struct ast_channel *old_chan, struct ast_channel *new_chan)
Switch what channel autochans point to.
Definition: autochan.c:83
#define AST_CHANNEL_NAME
Definition: channel.h:137
#define AST_MAX_FDS
Definition: channel.h:158
#define ast_clear_flag(p, flag)
Definition: utils.h:77
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
Definition: channel.c:2631
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition: channel.h:2473
void * data
Definition: datastore.h:56
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
Definition: linkedlists.h:666
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: app.c:1329
#define ast_channel_ref(c)
Increase channel reference count.
Definition: channel.h:2491
format_t readformat
Definition: channel.h:853
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:77
pthread_t blocker
Definition: channel.h:790
const ast_string_field musicclass
Definition: channel.h:787
const ast_string_field accountcode
Definition: channel.h:787
Data structure associated with a single frame of data.
Definition: frame.h:142
int hangupcause
Definition: channel.h:849
#define ast_manager_event_multichan(category, event, nchans, chans, contents,...)
Definition: manager.h:226
static int connected
Definition: cdr_pgsql.c:57
struct timeval whentohangup
Definition: channel.h:789
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:528
struct ast_channel_monitor * monitor
Definition: channel.h:769
struct ast_channel_tech * tech
Definition: channel.h:743
struct ast_channel::@156 readq
void(* chan_fixup)(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan)
Fix up channel references.
Definition: datastore.h:50
#define ao2_unlink(arg1, arg2)
Definition: astobj2.h:817
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
Definition: channel.c:2599
static struct ast_datastore_info xfer_ds_info
Definition: channel.c:6179
const ast_string_field language
Definition: channel.h:787
#define AST_LIST_APPEND_LIST(head, list, field)
Appends a whole list to the tail of a list.
Definition: linkedlists.h:768
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:344
struct ast_channel* ast_dummy_channel_alloc ( void  )

Create a fake channel structure.

Return values
NULLfailure
non-NULLsuccessfully allocated channel
Note
This function should ONLY be used to create a fake channel that can then be populated with data for use in variable substitution when a real channel does not exist.
The created dummy channel should be destroyed by ast_channel_unref(). Using ast_channel_release() needlessly grabs the channel container lock and can cause a deadlock as a result. Also grabbing the channel container lock reduces system performance.

Definition at line 1391 of file channel.c.

References __ao2_alloc_debug(), ast_channel::alertpipe, ao2_alloc, ARRAY_LEN, ast_channel_unref, ast_dummy_channel_destructor(), AST_LIST_HEAD_INIT_NOLOCK, ast_string_field_init, ast_channel::fds, ast_channel::timingfd, and ast_channel::varshead.

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

1393 {
1394  struct ast_channel *tmp;
1395  struct varshead *headp;
1396  int x;
1397 
1398 #if defined(REF_DEBUG)
1399  tmp = __ao2_alloc_debug(sizeof(*tmp), ast_dummy_channel_destructor, "dummy channel",
1400  file, line, function, 1);
1401 #elif defined(__AST_DEBUG_MALLOC)
1402  tmp = __ao2_alloc_debug(sizeof(*tmp), ast_dummy_channel_destructor, "dummy channel",
1403  file, line, function, 0);
1404 #else
1405  tmp = ao2_alloc(sizeof(*tmp), ast_dummy_channel_destructor);
1406 #endif
1407  if (!tmp) {
1408  /* Dummy channel structure allocation failure. */
1409  return NULL;
1410  }
1411 
1412  if ((ast_string_field_init(tmp, 128))) {
1413  return ast_channel_unref(tmp);
1414  }
1415 
1416  /*
1417  * Init file descriptors to unopened state just in case
1418  * autoservice is called on the channel or something tries to
1419  * read a frame from it.
1420  */
1421  tmp->timingfd = -1;
1422  for (x = 0; x < ARRAY_LEN(tmp->alertpipe); ++x) {
1423  tmp->alertpipe[x] = -1;
1424  }
1425  for (x = 0; x < ARRAY_LEN(tmp->fds); ++x) {
1426  tmp->fds[x] = -1;
1427  }
1428 #ifdef HAVE_EPOLL
1429  tmp->epfd = -1;
1430 #endif
1431 
1432  headp = &tmp->varshead;
1434 
1435  return tmp;
1436 }
Main Channel structure associated with a channel.
Definition: channel.h:742
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int timingfd
Definition: channel.h:838
static void ast_dummy_channel_destructor(void *obj)
Free a dummy channel structure.
Definition: channel.c:2530
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2502
int alertpipe[2]
Definition: channel.h:851
void * __ao2_alloc_debug(const size_t data_size, ao2_destructor_fn destructor_fn, char *tag, const char *file, int line, const char *funcname, int ref_debug)
Definition: astobj2.c:335
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Definition: stringfields.h:249
int fds[AST_MAX_FDS]
Definition: channel.h:829
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:430
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
Definition: linkedlists.h:666
struct varshead varshead
Definition: channel.h:817
static void ast_dummy_channel_destructor ( void *  obj)
static

Free a dummy channel structure.

Definition at line 2530 of file channel.c.

References ast_cdr_discard(), 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_string_field_free_memory, ast_var_delete(), ast_channel::caller, ast_channel::cdr, ast_channel::connected, ast_channel::datastores, ast_channel::dialed, ast_channel::redirecting, and ast_channel::varshead.

Referenced by ast_dummy_channel_alloc().

2531 {
2532  struct ast_channel *chan = obj;
2533  struct ast_var_t *vardata;
2534  struct varshead *headp;
2535  struct ast_datastore *datastore;
2536 
2537  /* Get rid of each of the data stores on the channel */
2538  while ((datastore = AST_LIST_REMOVE_HEAD(&chan->datastores, entry))) {
2539  /* Free the data store */
2540  ast_datastore_free(datastore);
2541  }
2542 
2543  headp = &chan->varshead;
2544 
2545  ast_party_dialed_free(&chan->dialed);
2546  ast_party_caller_free(&chan->caller);
2549 
2550  /* loop over the variables list, freeing all data and deleting list items */
2551  /* no need to lock the list, as the channel is already locked */
2552  while ((vardata = AST_LIST_REMOVE_HEAD(headp, entries)))
2553  ast_var_delete(vardata);
2554 
2555  if (chan->cdr) {
2556  ast_cdr_discard(chan->cdr);
2557  chan->cdr = NULL;
2558  }
2559 
2561 }
struct ast_datastore::@163 entry
Main Channel structure associated with a channel.
Definition: channel.h:742
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Definition: channel.h:814
void ast_party_caller_free(struct ast_party_caller *doomed)
Destroy the caller party contents.
Definition: channel.c:2302
struct ast_cdr * cdr
Definition: channel.h:766
Structure for a data store object.
Definition: datastore.h:54
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition: channel.c:2353
void ast_var_delete(struct ast_var_t *var)
Definition: chanvars.c:63
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Definition: datastore.c:65
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:818
struct ast_party_dialed dialed
Dialed/Called information.
Definition: channel.h:797
struct ast_channel::datastores datastores
void ast_cdr_discard(struct ast_cdr *cdr)
Discard and free a CDR record.
Definition: cdr.c:488
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition: channel.c:2396
void ast_party_dialed_free(struct ast_party_dialed *doomed)
Destroy the dialed party contents.
Definition: channel.c:2262
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
Definition: stringfields.h:253
struct varshead varshead
Definition: channel.h:817
static enum ast_bridge_result ast_generic_bridge ( struct ast_channel c0,
struct ast_channel c1,
struct ast_bridge_config config,
struct ast_frame **  fo,
struct ast_channel **  rc 
)
static

Definition at line 7203 of file channel.c.

References ast_channel::_bridge, ast_channel::_softhangup, AST_BRIDGE_COMPLETE, AST_BRIDGE_DTMF_CHANNEL_0, AST_BRIDGE_DTMF_CHANNEL_1, AST_BRIDGE_IGNORE_SIGS, AST_BRIDGE_RETRY, ast_channel_clear_softhangup(), ast_channel_connected_line_macro(), ast_channel_lock_both, ast_channel_redirecting_macro(), ast_channel_unlock, ast_clear_flag, AST_CONTROL_AOC, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_HOLD, AST_CONTROL_REDIRECTING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_CONTROL_T38_PARAMETERS, AST_CONTROL_UNHOLD, AST_CONTROL_VIDUPDATE, ast_debug, AST_FEATURE_WARNING_ACTIVE, AST_FRAME_CONTROL, AST_FRAME_DTMF, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_HTML, AST_FRAME_IMAGE, AST_FRAME_MODEM, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_frfree, ast_indicate_data(), ast_jb_do_usecheck(), ast_jb_empty_and_reset(), ast_jb_get_and_deliver(), ast_jb_get_when_to_wakeup(), ast_jb_put(), ast_poll_channel_add(), ast_poll_channel_del(), ast_read(), ast_samp2tv(), ast_set_flag, AST_SOFTHANGUP_UNBRIDGE, ast_test_flag, ast_tvadd(), ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), ast_waitfor_n(), ast_write(), ast_frame::data, ast_frame::datalen, f, ast_bridge_config::feature_timer, ast_bridge_config::flags, ast_frame::frametype, ast_frame_subclass::integer, ast_channel::name, ast_channel::nativeformats, ast_bridge_config::nexteventts, ast_frame::ptr, ast_frame::subclass, ast_channel::tech_pvt, and ast_bridge_config::timelimit.

Referenced by ast_channel_bridge().

7206 {
7207  /* Copy voice back and forth between the two channels. */
7208  struct ast_channel *cs[3];
7209  struct ast_frame *f;
7211  format_t o0nativeformats;
7212  format_t o1nativeformats;
7213  int watch_c0_dtmf;
7214  int watch_c1_dtmf;
7215  void *pvt0, *pvt1;
7216  /* Indicates whether a frame was queued into a jitterbuffer */
7217  int frame_put_in_jb = 0;
7218  int jb_in_use;
7219  int to;
7220 
7221  cs[0] = c0;
7222  cs[1] = c1;
7223  pvt0 = c0->tech_pvt;
7224  pvt1 = c1->tech_pvt;
7225  o0nativeformats = c0->nativeformats;
7226  o1nativeformats = c1->nativeformats;
7227  watch_c0_dtmf = config->flags & AST_BRIDGE_DTMF_CHANNEL_0;
7228  watch_c1_dtmf = config->flags & AST_BRIDGE_DTMF_CHANNEL_1;
7229 
7230  /* Check the need of a jitterbuffer for each channel */
7231  jb_in_use = ast_jb_do_usecheck(c0, c1);
7232  if (jb_in_use)
7233  ast_jb_empty_and_reset(c0, c1);
7234 
7235  ast_poll_channel_add(c0, c1);
7236 
7237  if (config->feature_timer > 0 && ast_tvzero(config->nexteventts)) {
7238  /* nexteventts is not set when the bridge is not scheduled to
7239  * break, so calculate when the bridge should possibly break
7240  * if a partial feature match timed out */
7241  config->nexteventts = ast_tvadd(ast_tvnow(), ast_samp2tv(config->feature_timer, 1000));
7242  }
7243 
7244  for (;;) {
7245  struct ast_channel *who, *other;
7246 
7247  if ((c0->tech_pvt != pvt0) || (c1->tech_pvt != pvt1) ||
7248  (o0nativeformats != c0->nativeformats) ||
7249  (o1nativeformats != c1->nativeformats)) {
7250  /* Check for Masquerade, codec changes, etc */
7251  res = AST_BRIDGE_RETRY;
7252  break;
7253  }
7254  if (config->nexteventts.tv_sec) {
7255  to = ast_tvdiff_ms(config->nexteventts, ast_tvnow());
7256  if (to <= 0) {
7257  if (config->timelimit && !config->feature_timer && !ast_test_flag(config, AST_FEATURE_WARNING_ACTIVE)) {
7258  res = AST_BRIDGE_RETRY;
7259  /* generic bridge ending to play warning */
7261  } else if (config->feature_timer) {
7262  /* feature timer expired - make sure we do not play warning */
7264  res = AST_BRIDGE_RETRY;
7265  } else {
7266  res = AST_BRIDGE_COMPLETE;
7267  }
7268  break;
7269  }
7270  } else {
7271  /* If a feature has been started and the bridge is configured to
7272  * to not break, leave the channel bridge when the feature timer
7273  * time has elapsed so the DTMF will be sent to the other side.
7274  */
7275  if (!ast_tvzero(config->nexteventts)) {
7276  int diff = ast_tvdiff_ms(config->nexteventts, ast_tvnow());
7277  if (diff <= 0) {
7278  res = AST_BRIDGE_RETRY;
7279  break;
7280  }
7281  }
7282  to = -1;
7283  }
7284  /* Calculate the appropriate max sleep interval - in general, this is the time,
7285  left to the closest jb delivery moment */
7286  if (jb_in_use)
7287  to = ast_jb_get_when_to_wakeup(c0, c1, to);
7288  who = ast_waitfor_n(cs, 2, &to);
7289  if (!who) {
7290  /* No frame received within the specified timeout - check if we have to deliver now */
7291  if (jb_in_use)
7292  ast_jb_get_and_deliver(c0, c1);
7293  if ((c0->_softhangup | c1->_softhangup) & AST_SOFTHANGUP_UNBRIDGE) {/* Bit operators are intentional. */
7296  }
7299  }
7300  ast_channel_lock_both(c0, c1);
7301  c0->_bridge = c1;
7302  c1->_bridge = c0;
7303  ast_channel_unlock(c0);
7304  ast_channel_unlock(c1);
7305  }
7306  continue;
7307  }
7308  f = ast_read(who);
7309  if (!f) {
7310  *fo = NULL;
7311  *rc = who;
7312  ast_debug(1, "Didn't get a frame from channel: %s\n",who->name);
7313  break;
7314  }
7315 
7316  other = (who == c0) ? c1 : c0; /* the 'other' channel */
7317  /* Try add the frame info the who's bridged channel jitterbuff */
7318  if (jb_in_use)
7319  frame_put_in_jb = !ast_jb_put(other, f);
7320 
7321  if ((f->frametype == AST_FRAME_CONTROL) && !(config->flags & AST_BRIDGE_IGNORE_SIGS)) {
7322  int bridge_exit = 0;
7323 
7324  switch (f->subclass.integer) {
7325  case AST_CONTROL_AOC:
7326  ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
7327  break;
7329  if (ast_channel_redirecting_macro(who, other, f, other == c0, 1)) {
7330  ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
7331  }
7332  break;
7334  if (ast_channel_connected_line_macro(who, other, f, other == c0, 1)) {
7335  ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
7336  }
7337  break;
7338  case AST_CONTROL_HOLD:
7339  case AST_CONTROL_UNHOLD:
7340  case AST_CONTROL_VIDUPDATE:
7341  case AST_CONTROL_SRCUPDATE:
7342  case AST_CONTROL_SRCCHANGE:
7344  ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
7345  if (jb_in_use) {
7346  ast_jb_empty_and_reset(c0, c1);
7347  }
7348  break;
7349  default:
7350  *fo = f;
7351  *rc = who;
7352  bridge_exit = 1;
7353  ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass.integer, who->name);
7354  break;
7355  }
7356  if (bridge_exit)
7357  break;
7358  }
7359  if ((f->frametype == AST_FRAME_VOICE) ||
7360  (f->frametype == AST_FRAME_DTMF_BEGIN) ||
7361  (f->frametype == AST_FRAME_DTMF) ||
7362  (f->frametype == AST_FRAME_VIDEO) ||
7363  (f->frametype == AST_FRAME_IMAGE) ||
7364  (f->frametype == AST_FRAME_HTML) ||
7365  (f->frametype == AST_FRAME_MODEM) ||
7366  (f->frametype == AST_FRAME_TEXT)) {
7367  /* monitored dtmf causes exit from bridge */
7368  int monitored_source = (who == c0) ? watch_c0_dtmf : watch_c1_dtmf;
7369 
7370  if (monitored_source &&
7371  (f->frametype == AST_FRAME_DTMF_END ||
7373  *fo = f;
7374  *rc = who;
7375  ast_debug(1, "Got DTMF %s on channel (%s)\n",
7376  f->frametype == AST_FRAME_DTMF_END ? "end" : "begin",
7377  who->name);
7378 
7379  break;
7380  }
7381  /* Write immediately frames, not passed through jb */
7382  if (!frame_put_in_jb)
7383  ast_write(other, f);
7384 
7385  /* Check if we have to deliver now */
7386  if (jb_in_use)
7387  ast_jb_get_and_deliver(c0, c1);
7388  }
7389  /* XXX do we want to pass on also frames not matched above ? */
7390  ast_frfree(f);
7391 
7392 #ifndef HAVE_EPOLL
7393  /* Swap who gets priority */
7394  cs[2] = cs[0];
7395  cs[0] = cs[1];
7396  cs[1] = cs[2];
7397 #endif
7398  }
7399 
7400  ast_poll_channel_del(c0, c1);
7401 
7402  return res;
7403 }
struct ast_channel * ast_waitfor_n(struct ast_channel **chan, int n, int *ms)
Waits for input on a group of channels Wait for input on an array of channels for a given # of millis...
Definition: channel.c:3534
union ast_frame_subclass subclass
Definition: frame.h:146
Main Channel structure associated with a channel.
Definition: channel.h:742
long feature_timer
Definition: channel.h:980
void ast_poll_channel_add(struct ast_channel *chan0, struct ast_channel *chan1)
Definition: channel.c:2665
#define AST_BRIDGE_IGNORE_SIGS
Ignore all signal frames except NULL.
Definition: channel.h:1940
int ast_jb_put(struct ast_channel *chan, struct ast_frame *f)
Puts a frame into a channel jitterbuffer.
Definition: abstract_jb.c:306
#define ast_test_flag(p, flag)
Definition: utils.h:63
void ast_jb_empty_and_reset(struct ast_channel *c0, struct ast_channel *c1)
drops all frames from a jitterbuffer and resets it
Definition: abstract_jb.c:627
void * ptr
Definition: frame.h:160
void * tech_pvt
Definition: channel.h:744
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define AST_FRAME_DTMF
Definition: frame.h:128
int ast_jb_get_when_to_wakeup(struct ast_channel *c0, struct ast_channel *c1, int time_left)
Calculates the time, left to the closest delivery moment in a bridge.
Definition: abstract_jb.c:266
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:100
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4383
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:4447
struct timeval nexteventts
Definition: channel.h:978
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
format_t nativeformats
Definition: channel.h:852
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:90
int ast_channel_connected_line_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *connected_info, int caller, int frame)
Run a connected line interception macro and update a channel&#39;s connected line information.
Definition: channel.c:9618
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
unsigned int flags
Definition: channel.h:987
void ast_channel_clear_softhangup(struct ast_channel *chan, int flag)
Clear a set of softhangup flags from a channel.
Definition: channel.c:2707
int datalen
Definition: frame.h:148
struct timeval ast_samp2tv(unsigned int _nsamp, unsigned int _rate)
Returns a timeval corresponding to the duration of n samples at rate r. Useful to convert samples to ...
Definition: time.h:191
#define AST_BRIDGE_DTMF_CHANNEL_1
Report DTMF on channel 1.
Definition: channel.h:1934
struct ast_channel * _bridge
Definition: channel.h:748
int64_t format_t
Definition: frame_defs.h:32
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
Definition: utils.c:1587
const ast_string_field name
Definition: channel.h:787
int _softhangup
Definition: channel.h:832
#define ast_channel_unlock(chan)
Definition: channel.h:2467
static struct ast_format f[]
Definition: format_g726.c:181
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
Definition: channel.c:4916
#define ast_clear_flag(p, flag)
Definition: utils.h:77
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition: channel.h:2473
void ast_poll_channel_del(struct ast_channel *chan0, struct ast_channel *chan1)
Definition: channel.c:2688
void ast_jb_get_and_deliver(struct ast_channel *c0, struct ast_channel *c1)
Deliver the queued frames that should be delivered now for both channels.
Definition: abstract_jb.c:371
Data structure associated with a single frame of data.
Definition: frame.h:142
enum ast_frame_type frametype
Definition: frame.h:144
#define ast_frfree(fr)
Definition: frame.h:583
int ast_jb_do_usecheck(struct ast_channel *c0, struct ast_channel *c1)
Checks the need of a jb use in a generic bridge.
Definition: abstract_jb.c:205
union ast_frame::@172 data
#define AST_BRIDGE_DTMF_CHANNEL_0
Report DTMF on channel 0.
Definition: channel.h:1932
int ast_channel_redirecting_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *redirecting_info, int is_caller, int is_frame)
Run a redirecting interception macro and update a channel&#39;s redirecting information.
Definition: channel.c:9663
ast_bridge_result
Definition: channel.h:168
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 960 of file channel.c.

References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, chanlist::tech, and ast_channel_tech::type.

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

961 {
962  struct chanlist *chanls;
963  const struct ast_channel_tech *ret = NULL;
964 
966 
967  AST_RWLIST_TRAVERSE(&backends, chanls, list) {
968  if (!strcasecmp(name, chanls->tech->type)) {
969  ret = chanls->tech;
970  break;
971  }
972  }
973 
975 
976  return ret;
977 }
const char *const type
Definition: channel.h:508
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
the list of registered channel types
Definition: channel.c:143
struct ast_channel_tech * tech
Definition: channel.c:122
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
List of channel drivers.
Definition: app_dial.c:664
Structure to describe a channel &quot;technology&quot;, ie a channel driver See for examples: ...
Definition: channel.h:507
static const char name[]
ast_group_t ast_get_group ( const char *  s)

Definition at line 7987 of file channel.c.

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

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

7988 {
7989  char *piece;
7990  char *c;
7991  int start=0, finish=0, x;
7992  ast_group_t group = 0;
7993 
7994  if (ast_strlen_zero(s))
7995  return 0;
7996 
7997  c = ast_strdupa(s);
7998 
7999  while ((piece = strsep(&c, ","))) {
8000  if (sscanf(piece, "%30d-%30d", &start, &finish) == 2) {
8001  /* Range */
8002  } else if (sscanf(piece, "%30d", &start)) {
8003  /* Just one */
8004  finish = start;
8005  } else {
8006  ast_log(LOG_ERROR, "Syntax error parsing group configuration '%s' at '%s'. Ignoring.\n", s, piece);
8007  continue;
8008  }
8009  for (x = start; x <= finish; x++) {
8010  if ((x > 63) || (x < 0)) {
8011  ast_log(LOG_WARNING, "Ignoring invalid group %d (maximum group is 63)\n", x);
8012  } else
8013  group |= ((ast_group_t) 1 << x);
8014  }
8015  }
8016  return group;
8017 }
unsigned long long ast_group_t
Definition: channel.h:175
char * strsep(char **str, const char *delims)
#define LOG_WARNING
Definition: logger.h:144
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
#define LOG_ERROR
Definition: logger.h:155
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static ast_group_t group
Definition: chan_agent.c:221
int ast_hangup ( struct ast_channel chan)

Hangup a channel.

Hang up a channel.

Definition at line 2804 of file channel.c.

References ao2_unlink, ast_assert, ast_autoservice_stop(), ast_cause2str(), ast_cc_offer(), ast_cdr_detach(), ast_cdr_end(), AST_CDR_FLAG_BRIDGED, AST_CDR_FLAG_DIALED, AST_CDR_FLAG_POST_DISABLED, AST_CDR_NULL, AST_CEL_HANGUP, ast_cel_report_event(), ast_channel_lock, ast_channel_unlock, ast_channel_unref, ast_closestream(), ast_debug, ast_do_masquerade(), AST_FLAG_BLOCKING, AST_FLAG_ZOMBIE, ast_log(), ast_manager_event, ast_set_flag, ast_test_flag, ast_channel::blocker, ast_channel::blockproc, ast_channel::caller, ast_channel::cdr, channels, ast_channel::connected, destroy_hooks(), ast_cdr::disposition, EVENT_FLAG_CALL, free_translation(), ast_channel::generator, ast_channel::generatordata, ast_channel_tech::hangup, ast_channel::hangupcause, ast_channel::hangupsource, ast_party_caller::id, ast_party_connected_line::id, LOG_WARNING, ast_channel::masq, ast_channel::masqr, ast_party_id::name, ast_channel::name, ast_party_id::number, pbx_builtin_getvar_helper(), ast_generator::release, S_COR, S_OR, ast_channel::sched, sched_context_destroy(), ast_party_name::str, ast_party_number::str, ast_channel::stream, ast_channel::tech, ast_channel::uniqueid, ast_party_name::valid, ast_party_number::valid, and ast_channel::vstream.

Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_pbx_run(), __ast_request_and_dial(), __oh323_new(), action_bridge(), agent_request(), alsa_new(), analog_handle_init_event(), analog_ss_thread(), answer_exec_run(), app_exec(), ast_async_goto(), ast_call_forward(), ast_dial_destroy(), ast_dial_hangup(), ast_iax2_new(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_pbx_run_app(), async_wait(), begin_dial_channel(), bridge_call_thread(), bridge_call_thread_launch(), bridge_channel_thread(), bridge_exec(), build_conf(), builtin_atxfer(), chanavail_exec(), check_availability(), check_compat(), check_goto_on_transfer(), clear_caller(), conf_free(), conf_run(), console_new(), dahdi_handle_event(), dahdi_new(), destroy_conference_bridge(), dial_exec_full(), dial_transfer(), do_forward(), do_hang(), do_idle_thread(), do_monitor(), feature_attended_transfer(), feature_request_and_dial(), findmeexec(), generic_recall(), gtalk_new(), handle_call_forward(), handle_callforward_button(), handle_enbloc_call_message(), handle_frame(), handle_frame_ownerless(), handle_hd_hf(), handle_init_event(), handle_invite_replaces(), handle_offhook_message(), handle_request_invite(), handle_soft_key_event_message(), handle_stimulus_message(), handle_timeout_trip(), handle_transfer_button(), HandleCallOutgoing(), hangup_chan(), hangupcalls(), hanguptree(), iax2_request(), iax_park(), iax_park_thread(), jingle_new(), local_hangup(), manage_parked_call(), masq_park_call(), meetme_menu_admin_extended(), mgcp_new(), mgcp_ss(), monitor_dial(), mwi_thread(), my_distinctive_ring(), my_handle_notify_message(), nbs_new(), oss_new(), parkandannounce_exec(), parked_call_exec(), phone_new(), play_sound_file(), pri_dchannel(), pri_ss_thread(), sip_park(), sip_park_thread(), sip_pickup_thread(), skinny_new(), skinny_ss(), try_calling(), unistim_new(), wait_for_answer(), and wait_for_winner().

2805 {
2806  char extra_str[64]; /* used for cel logging below */
2807  int was_zombie;
2808 
2809  ast_autoservice_stop(chan);
2810 
2811  ast_channel_lock(chan);
2812 
2813  /*
2814  * Do the masquerade if someone is setup to masquerade into us.
2815  *
2816  * NOTE: We must hold the channel lock after testing for a
2817  * pending masquerade and setting the channel as a zombie to
2818  * prevent __ast_channel_masquerade() from setting up a
2819  * masquerade with a dead channel.
2820  */
2821  while (chan->masq) {
2822  ast_channel_unlock(chan);
2823  ast_do_masquerade(chan);
2824  ast_channel_lock(chan);
2825  }
2826 
2827  if (chan->masqr) {
2828  /*
2829  * This channel is one which will be masqueraded into something.
2830  * Mark it as a zombie already so ast_do_masquerade() will know
2831  * to free it later.
2832  */
2834  destroy_hooks(chan);
2835  ast_channel_unlock(chan);
2836  return 0;
2837  }
2838 
2839  /* Mark as a zombie so a masquerade cannot be setup on this channel. */
2840  if (!(was_zombie = ast_test_flag(chan, AST_FLAG_ZOMBIE))) {
2842  }
2843 
2844  ast_channel_unlock(chan);
2845  ao2_unlink(channels, chan);
2846  ast_channel_lock(chan);
2847 
2848  destroy_hooks(chan);
2849 
2850  free_translation(chan);
2851  /* Close audio stream */
2852  if (chan->stream) {
2853  ast_closestream(chan->stream);
2854  chan->stream = NULL;
2855  }
2856  /* Close video stream */
2857  if (chan->vstream) {
2858  ast_closestream(chan->vstream);
2859  chan->vstream = NULL;
2860  }
2861  if (chan->sched) {
2863  chan->sched = NULL;
2864  }
2865 
2866  if (chan->generatordata) { /* Clear any tone stuff remaining */
2867  if (chan->generator && chan->generator->release) {
2868  chan->generator->release(chan, chan->generatordata);
2869  }
2870  }
2871  chan->generatordata = NULL;
2872  chan->generator = NULL;
2873 
2874  snprintf(extra_str, sizeof(extra_str), "%d,%s,%s", chan->hangupcause, chan->hangupsource, S_OR(pbx_builtin_getvar_helper(chan, "DIALSTATUS"), ""));
2875  ast_cel_report_event(chan, AST_CEL_HANGUP, NULL, extra_str, NULL);
2876 
2877  if (ast_test_flag(chan, AST_FLAG_BLOCKING)) {
2878  ast_log(LOG_WARNING, "Hard hangup called by thread %ld on %s, while fd "
2879  "is blocked by thread %ld in procedure %s! Expect a failure\n",
2880  (long) pthread_self(), chan->name, (long)chan->blocker, chan->blockproc);
2882  }
2883  if (!was_zombie) {
2884  ast_debug(1, "Hanging up channel '%s'\n", chan->name);
2885 
2886  if (chan->tech->hangup) {
2887  chan->tech->hangup(chan);
2888  }
2889  } else {
2890  ast_debug(1, "Hanging up zombie '%s'\n", chan->name);
2891  }
2892 
2893  ast_channel_unlock(chan);
2894 
2895  ast_cc_offer(chan);
2896  ast_manager_event(chan, EVENT_FLAG_CALL, "Hangup",
2897  "Channel: %s\r\n"
2898  "Uniqueid: %s\r\n"
2899  "CallerIDNum: %s\r\n"
2900  "CallerIDName: %s\r\n"
2901  "ConnectedLineNum: %s\r\n"
2902  "ConnectedLineName: %s\r\n"
2903  "Cause: %d\r\n"
2904  "Cause-txt: %s\r\n",
2905  chan->name,
2906  chan->uniqueid,
2907  S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, "<unknown>"),
2908  S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, "<unknown>"),
2909  S_COR(chan->connected.id.number.valid, chan->connected.id.number.str, "<unknown>"),
2910  S_COR(chan->connected.id.name.valid, chan->connected.id.name.str, "<unknown>"),
2911  chan->hangupcause,
2912  ast_cause2str(chan->hangupcause)
2913  );
2914 
2915  if (chan->cdr && !ast_test_flag(chan->cdr, AST_CDR_FLAG_BRIDGED) &&
2918  ast_channel_lock(chan);
2919  ast_cdr_end(chan->cdr);
2920  ast_cdr_detach(chan->cdr);
2921  chan->cdr = NULL;
2922  ast_channel_unlock(chan);
2923  }
2924 
2925  ast_channel_unref(chan);
2926 
2927  return 0;
2928 }
struct ast_channel * masqr
Definition: channel.h:752
#define ast_channel_lock(chan)
Definition: channel.h:2466
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
struct ast_channel * masq
Definition: channel.h:751
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
const ast_string_field uniqueid
Definition: channel.h:787
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2502
#define ast_test_flag(p, flag)
Definition: utils.h:63
static void free_translation(struct ast_channel *clonechan)
Definition: channel.c:2757
void ast_cdr_end(struct ast_cdr *cdr)
End a call.
Definition: cdr.c:933
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define LOG_WARNING
Definition: logger.h:144
int ast_cel_report_event(struct ast_channel *chan, enum ast_cel_event_type event_type, const char *userdefevname, const char *extra, struct ast_channel *peer2)
Report a channel event.
Definition: cel.c:645
const char * blockproc
Definition: channel.h:753
static void destroy_hooks(struct ast_channel *chan)
Definition: channel.c:2793
struct ast_generator * generator
Definition: channel.h:747
#define EVENT_FLAG_CALL
Definition: manager.h:72
char * str
Subscriber name (Malloced)
Definition: channel.h:214
#define ast_assert(a)
Definition: utils.h:738
struct ast_cdr * cdr
Definition: channel.h:766
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
Definition: pbx.c:10475
#define ast_manager_event(chan, category, event, contents,...)
Definition: manager.h:221
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
int(*const hangup)(struct ast_channel *chan)
Hangup (and possibly destroy) the channel.
Definition: channel.h:545
#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:83
struct sched_context * sched
Definition: channel.h:756
hangup terminates connection
Definition: cel.h:54
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:238
void sched_context_destroy(struct sched_context *c)
destroys a schedule context Destroys (free&#39;s) the given sched_context structure
Definition: sched.c:267
int ast_cc_offer(struct ast_channel *caller_chan)
Offer CC to a caller.
Definition: ccss.c:3485
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:197
void ast_cdr_detach(struct ast_cdr *cdr)
Detaches the detail record for posting (and freeing) either now or at a later time in bulk with other...
Definition: cdr.c:1328
void(* release)(struct ast_channel *chan, void *data)
Definition: channel.h:181
const ast_string_field name
Definition: channel.h:787
const ast_string_field hangupsource
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_channel_unlock(chan)
Definition: channel.h:2467
const char * ast_cause2str(int state) attribute_pure
Gives the string form of a given cause code.
Definition: channel.c:980
struct ast_filestream * vstream
Definition: channel.h:758
int ast_closestream(struct ast_filestream *f)
Closes a stream.
Definition: file.c:904
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:77
pthread_t blocker
Definition: channel.h:790
int hangupcause
Definition: channel.h:849
long int disposition
Definition: cdr.h:110
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
struct ast_filestream * stream
Definition: channel.h:757
struct ast_channel_tech * tech
Definition: channel.h:743
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
#define ao2_unlink(arg1, arg2)
Definition: astobj2.h:817
void * generatordata
Definition: channel.h:746
int ast_do_masquerade(struct ast_channel *chan)
Start masquerading a channel.
Definition: channel.c:6546
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
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 4393 of file channel.c.

References ast_indicate_data().

Referenced by __ast_play_and_record(), agent_request(), alsa_call(), answer_trunk_chan(), ast_bridge_call(), ast_channel_bridge(), ast_do_masquerade(), ast_dtmf_stream(), ast_raw_answer(), attempt_transfer(), builtin_atxfer(), builtin_blindtransfer(), cli_console_answer(), conf_run(), console_call(), dial_exec_full(), dial_trunk(), disa_exec(), do_forward(), feature_request_and_dial(), finishup(), handle_callforward_button(), handle_frame(), handle_recordfile(), handle_request_refer(), local_attended_transfer(), manage_parked_call(), mgcp_ss(), monitor_dial(), oss_call(), park_call_full(), parked_call_exec(), pbx_builtin_busy(), pbx_builtin_congestion(), pbx_builtin_incomplete(), pbx_builtin_proceeding(), pbx_builtin_progress(), pbx_builtin_ringing(), pbx_builtin_waitexten(), queue_exec(), record_exec(), rna(), say_periodic_announcement(), say_position(), send_waveform_to_channel(), skinny_ss(), sla_handle_hold_event(), sla_station_exec(), sla_trunk_exec(), try_calling(), and wait_for_answer().

4394 {
4395  return ast_indicate_data(chan, condition, NULL, 0);
4396 }
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:4447
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
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 4447 of file channel.c.

References ast_channel::_state, _XXX_AST_CONTROL_T38, ast_channel_lock, ast_channel_set_connected_line(), ast_channel_set_redirecting(), ast_channel_unlock, ast_check_hangup(), ast_connected_line_parse_data(), 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_OFFHOOK, AST_CONTROL_OPTION, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_RADIO_KEY, AST_CONTROL_RADIO_UNKEY, AST_CONTROL_READ_ACTION, AST_CONTROL_REDIRECTING, AST_CONTROL_RING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, 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_FLAG_ZOMBIE, AST_FRAME_CONTROL, ast_framehook_list_is_empty(), ast_framehook_list_write_event(), ast_frdup(), ast_frfree, ast_get_indication_tone(), ast_log(), ast_party_connected_line_free(), ast_party_connected_line_set_init(), ast_party_redirecting_free(), ast_party_redirecting_set_init(), ast_playtones_start(), ast_playtones_stop(), ast_redirecting_parse_data(), AST_STATE_UP, ast_test_flag, ast_tone_zone_sound_unref(), ast_channel::connected, ast_tone_zone_sound::data, ast_frame::data, ast_frame::datalen, ast_channel::framehooks, ast_frame::frametype, ast_channel_tech::indicate, ast_frame_subclass::integer, is_visible_indication(), LOG_WARNING, ast_channel::name, ast_frame::ptr, ast_channel::redirecting, ast_frame::subclass, ast_channel::tech, ast_channel::visible_indication, and ast_channel::zone.

Referenced by __ast_read(), action_aocmessage(), agent_hangup(), ast_bridge_call(), ast_channel_update_connected_line(), ast_channel_update_redirecting(), ast_generic_bridge(), ast_handle_cc_control_frame(), ast_indicate(), disable_t38(), feature_request_and_dial(), generic_fax_exec(), handle_frame(), local_bridge_loop(), login_exec(), manage_parked_call(), park_call_full(), pbx_builtin_waitexten(), receivefax_t38_init(), remote_bridge_loop(), sendfax_t38_init(), set_fax_t38_caps(), transmit_audio(), transmit_t38(), and wait_for_answer().

4449 {
4450  /* By using an enum, we'll get compiler warnings for values not handled
4451  * in switch statements. */
4452  enum ast_control_frame_type condition = _condition;
4453  struct ast_tone_zone_sound *ts = NULL;
4454  int res;
4455  /* this frame is used by framehooks. if it is set, we must free it at the end of this function */
4456  struct ast_frame *awesome_frame = NULL;
4457 
4458  ast_channel_lock(chan);
4459 
4460  /* Don't bother if the channel is about to go away, anyway. */
4461  if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
4462  res = -1;
4463  goto indicate_cleanup;
4464  }
4465 
4467  /* Do framehooks now, do it, go, go now */
4468  struct ast_frame frame = {
4470  .subclass.integer = condition,
4471  .data.ptr = (void *) data, /* this cast from const is only okay because we do the ast_frdup below */
4472  .datalen = datalen
4473  };
4474 
4475  /* we have now committed to freeing this frame */
4476  awesome_frame = ast_frdup(&frame);
4477 
4478  /* who knows what we will get back! the anticipation is killing me. */
4479  if (!(awesome_frame = ast_framehook_list_write_event(chan->framehooks, awesome_frame))
4480  || awesome_frame->frametype != AST_FRAME_CONTROL) {
4481 
4482  res = 0;
4483  goto indicate_cleanup;
4484  }
4485 
4486  condition = awesome_frame->subclass.integer;
4487  data = awesome_frame->data.ptr;
4488  datalen = awesome_frame->datalen;
4489  }
4490 
4491  switch (condition) {
4493  {
4495 
4497  res = ast_connected_line_parse_data(data, datalen, &connected);
4498  if (!res) {
4500  }
4502  }
4503  break;
4504 
4506  {
4507  struct ast_party_redirecting redirecting;
4508 
4509  ast_party_redirecting_set_init(&redirecting, &chan->redirecting);
4510  res = ast_redirecting_parse_data(data, datalen, &redirecting);
4511  if (!res) {
4512  ast_channel_set_redirecting(chan, &redirecting, NULL);
4513  }
4514  ast_party_redirecting_free(&redirecting);
4515  }
4516  break;
4517 
4518  default:
4519  break;
4520  }
4521 
4522  if (is_visible_indication(condition)) {
4523  /* A new visible indication is requested. */
4524  chan->visible_indication = condition;
4525  } else if (condition == AST_CONTROL_UNHOLD || _condition < 0) {
4526  /* Visible indication is cleared/stopped. */
4527  chan->visible_indication = 0;
4528  }
4529 
4530  if (chan->tech->indicate) {
4531  /* See if the channel driver can handle this condition. */
4532  res = chan->tech->indicate(chan, condition, data, datalen);
4533  } else {
4534  res = -1;
4535  }
4536 
4537  if (!res) {
4538  /* The channel driver successfully handled this indication */
4539  res = 0;
4540  goto indicate_cleanup;
4541  }
4542 
4543  /* The channel driver does not support this indication, let's fake
4544  * it by doing our own tone generation if applicable. */
4545 
4546  /*!\note If we compare the enumeration type, which does not have any
4547  * negative constants, the compiler may optimize this code away.
4548  * Therefore, we must perform an integer comparison here. */
4549  if (_condition < 0) {
4550  /* Stop any tones that are playing */
4551  ast_playtones_stop(chan);
4552  res = 0;
4553  goto indicate_cleanup;
4554  }
4555 
4556  /* Handle conditions that we have tones for. */
4557  switch (condition) {
4558  case _XXX_AST_CONTROL_T38:
4559  /* deprecated T.38 control frame */
4560  res = -1;
4561  goto indicate_cleanup;
4563  /* there is no way to provide 'default' behavior for these
4564  * control frames, so we need to return failure, but there
4565  * is also no value in the log message below being emitted
4566  * since failure to handle these frames is not an 'error'
4567  * so just return right now. in addition, we want to return
4568  * whatever value the channel driver returned, in case it
4569  * has some meaning.*/
4570  goto indicate_cleanup;
4571  case AST_CONTROL_RINGING:
4572  ts = ast_get_indication_tone(chan->zone, "ring");
4573  /* It is common practice for channel drivers to return -1 if trying
4574  * to indicate ringing on a channel which is up. The idea is to let the
4575  * core generate the ringing inband. However, we don't want the
4576  * warning message about not being able to handle the specific indication
4577  * to print nor do we want ast_indicate_data to return an "error" for this
4578  * condition
4579  */
4580  if (chan->_state == AST_STATE_UP) {
4581  res = 0;
4582  }
4583  break;
4584  case AST_CONTROL_BUSY:
4585  ts = ast_get_indication_tone(chan->zone, "busy");
4586  break;
4589  ts = ast_get_indication_tone(chan->zone, "congestion");
4590  break;
4591  case AST_CONTROL_PROGRESS:
4593  case AST_CONTROL_VIDUPDATE:
4594  case AST_CONTROL_SRCUPDATE:
4595  case AST_CONTROL_SRCCHANGE:
4596  case AST_CONTROL_RADIO_KEY:
4598  case AST_CONTROL_OPTION:
4599  case AST_CONTROL_WINK:
4600  case AST_CONTROL_FLASH:
4601  case AST_CONTROL_OFFHOOK:
4603  case AST_CONTROL_ANSWER:
4604  case AST_CONTROL_HANGUP:
4605  case AST_CONTROL_RING:
4606  case AST_CONTROL_HOLD:
4607  case AST_CONTROL_UNHOLD:
4608  case AST_CONTROL_TRANSFER:
4611  case AST_CONTROL_CC:
4613  case AST_CONTROL_AOC:
4614  case AST_CONTROL_END_OF_Q:
4616  /* Nothing left to do for these. */
4617  res = 0;
4618  break;
4619  }
4620 
4621  if (ts) {
4622  /* We have a tone to play, yay. */
4623  ast_debug(1, "Driver for channel '%s' does not support indication %u, emulating it\n", chan->name, condition);
4624  res = ast_playtones_start(chan, 0, ts->data, 1);
4625  ts = ast_tone_zone_sound_unref(ts);
4626  }
4627 
4628  if (res) {
4629  /* not handled */
4630  ast_log(LOG_WARNING, "Unable to handle indication %u for '%s'\n", condition, chan->name);
4631  }
4632 
4633 indicate_cleanup:
4634  ast_channel_unlock(chan);
4635  if (awesome_frame) {
4636  ast_frfree(awesome_frame);
4637  }
4638 
4639  return res;
4640 }
union ast_frame_subclass subclass
Definition: frame.h:146
#define ast_channel_lock(chan)
Definition: channel.h:2466
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
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:9254
struct ast_tone_zone * zone
Definition: channel.h:767
static int attribute_const is_visible_indication(enum ast_control_frame_type condition)
Definition: channel.c:4398
int visible_indication
Definition: channel.h:861
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:2329
#define ast_test_flag(p, flag)
Definition: utils.h:63
void * ptr
Definition: frame.h:160
int ast_framehook_list_is_empty(struct ast_framehook_list *framehooks)
Determine if an framehook list is empty or not.
Definition: framehook.c:172
#define LOG_WARNING
Definition: logger.h:144
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Definition: channel.h:814
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition: channel.c:2353
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
Definition: indications.c:411
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
int datalen
Definition: frame.h:148
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.
Definition: indications.h:226
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:9111
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
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:8886
ast_control_frame_type
Internal control frame subtype field values.
Definition: frame.h:319
struct ast_framehook_list * framehooks
Definition: channel.h:765
enum ast_channel_state _state
Definition: channel.h:839
Description of a tone.
Definition: indications.h:36
struct ast_tone_zone_sound * ast_get_indication_tone(const struct ast_tone_zone *zone, const char *indication)
Locate a tone zone sound.
Definition: indications.c:473
Connected Line/Party information.
Definition: channel.h:401
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
Definition: channel.h:447
struct ast_frame * ast_framehook_list_write_event(struct ast_framehook_list *framehooks, struct ast_frame *frame)
This is used by the channel API push a frame write event to a channel&#39;s framehook list...
Definition: framehook.c:180
#define ast_channel_unlock(chan)
Definition: channel.h:2467
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition: channel.c:2396
Data structure associated with a single frame of data.
Definition: frame.h:142
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:2380
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
Definition: indications.c:319
static int connected
Definition: cdr_pgsql.c:57
const char * data
Description of a tone.
Definition: indications.h:53
enum ast_frame_type frametype
Definition: frame.h:144
#define ast_frfree(fr)
Definition: frame.h:583
union ast_frame::@172 data
struct ast_channel_tech * tech
Definition: channel.h:743
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:576
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:8458
struct ast_frame * ast_frdup(const struct ast_frame *fr)
Copies a frame.
Definition: frame.c:474
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 8023 of file channel.c.

References ast_moh_cleanup_ptr, ast_moh_start_ptr, and ast_moh_stop_ptr.

Referenced by load_module(), and reload().

8026 {
8027  ast_moh_start_ptr = start_ptr;
8028  ast_moh_stop_ptr = stop_ptr;
8029  ast_moh_cleanup_ptr = cleanup_ptr;
8030 }
static int(* ast_moh_start_ptr)(struct ast_channel *, const char *, const char *)
Definition: channel.c:8019
static void(* ast_moh_cleanup_ptr)(struct ast_channel *)
Definition: channel.c:8021
static void(* ast_moh_stop_ptr)(struct ast_channel *)
Definition: channel.c:8020
int ast_internal_timing_enabled ( struct ast_channel chan)

Check if the channel can run in internal timing mode.

Parameters
chanThe channel to check
Returns
boolean

This function will return 1 if internal timing is enabled and the timing device is available.

Definition at line 4378 of file channel.c.

References ast_channel::timingfd.

4379 {
4380  return chan->timingfd > -1;
4381 }
int timingfd
Definition: channel.h:838
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 1818 of file channel.c.

References 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_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, and ast_frame::frametype.

Referenced by ast_safe_sleep_conditional(), autoservice_run(), and feature_request_and_dial().

1819 {
1820  /* Do not add a default entry in this switch statement. Each new
1821  * frame type should be addressed directly as to whether it should
1822  * be queued up or not.
1823  */
1824  switch (frame->frametype) {
1825  case AST_FRAME_CONTROL:
1826  case AST_FRAME_TEXT:
1827  case AST_FRAME_IMAGE:
1828  case AST_FRAME_HTML:
1829  return 1;
1830 
1831  case AST_FRAME_DTMF_END:
1832  case AST_FRAME_DTMF_BEGIN:
1833  case AST_FRAME_VOICE:
1834  case AST_FRAME_VIDEO:
1835  case AST_FRAME_NULL:
1836  case AST_FRAME_IAX:
1837  case AST_FRAME_CNG:
1838  case AST_FRAME_MODEM:
1839  return 0;
1840  }
1841  return 0;
1842 }
enum ast_frame_type frametype
Definition: frame.h:144
void ast_moh_cleanup ( struct ast_channel chan)

Definition at line 8057 of file channel.c.

References ast_moh_cleanup_ptr.

Referenced by ast_channel_destructor().

8058 {
8059  if (ast_moh_cleanup_ptr)
8060  ast_moh_cleanup_ptr(chan);
8061 }
static void(* ast_moh_cleanup_ptr)(struct ast_channel *)
Definition: channel.c:8021
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.
interpclassThe class to use if the musicclass is not currently set on the channel structure or in the mclass argument.
Return values
Zeroon success
non-zeroon failure

Definition at line 8040 of file channel.c.

References ast_moh_start_ptr, and ast_verb.

Referenced by alsa_indicate(), app_exec(), ast_do_masquerade(), conf_start_moh(), console_indicate(), dahdi_indicate(), dial_exec_full(), feature_exec_app(), gtalk_indicate(), handle_setmusic(), iax2_indicate(), jingle_indicate(), key_call(), leave_conference_bridge(), local_indicate(), menu_callback(), mgcp_indicate(), misdn_indication(), moh_handle_digit(), monitor_dial(), oh323_indicate(), oss_indicate(), phone_indicate(), play_moh_exec(), post_join_marked(), post_join_unmarked(), queue_exec(), retrydial_exec(), rna(), say_periodic_announcement(), say_position(), sig_pri_indicate(), sip_indicate(), skinny_indicate(), start_moh_exec(), TransferCallStep1(), unistim_indicate(), and wait_moh_exec().

8041 {
8042  if (ast_moh_start_ptr)
8043  return ast_moh_start_ptr(chan, mclass, interpclass);
8044 
8045  ast_verb(3, "Music class %s requested but no musiconhold loaded.\n", mclass ? mclass : (interpclass ? interpclass : "default"));
8046 
8047  return 0;
8048 }
static int(* ast_moh_start_ptr)(struct ast_channel *, const char *, const char *)
Definition: channel.c:8019
#define ast_verb(level,...)
Definition: logger.h:243
void ast_party_caller_copy ( struct ast_party_caller dest,
const struct ast_party_caller src 
)

Copy the source caller information to the destination caller.

Since
1.8
Parameters
destDestination caller
srcSource caller
Returns
Nothing

Definition at line 2276 of file channel.c.

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

2277 {
2278  if (dest == src) {
2279  /* Don't copy to self */
2280  return;
2281  }
2282 
2283  ast_party_id_copy(&dest->id, &src->id);
2284  ast_party_id_copy(&dest->ani, &src->ani);
2285  dest->ani2 = src->ani2;
2286 }
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:2095
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:377
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:380
void ast_party_caller_free ( struct ast_party_caller doomed)

Destroy the caller party contents.

Since
1.8
Parameters
doomedThe caller party to destroy.
Returns
Nothing

Definition at line 2302 of file channel.c.

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

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

2303 {
2304  ast_party_id_free(&doomed->id);
2305  ast_party_id_free(&doomed->ani);
2306 }
void ast_party_id_free(struct ast_party_id *doomed)
Destroy the party id contents.
Definition: channel.c:2141
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:377
void ast_party_caller_init ( struct ast_party_caller init)

Initialize the given caller structure.

Since
1.8
Parameters
initCaller structure to initialize.
Returns
Nothing

Definition at line 2269 of file channel.c.

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

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

2270 {
2271  ast_party_id_init(&init->id);
2272  ast_party_id_init(&init->ani);
2273  init->ani2 = 0;
2274 }
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:377
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:380
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition: channel.c:2087
void ast_party_caller_set ( struct ast_party_caller dest,
const struct ast_party_caller src,
const struct ast_set_party_caller update 
)

Set the caller information based on another caller source.

Since
1.8

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

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

Definition at line 2295 of file channel.c.

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

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

2296 {
2297  ast_party_id_set(&dest->id, &src->id, update ? &update->id : NULL);
2298  ast_party_id_set(&dest->ani, &src->ani, update ? &update->ani : NULL);
2299  dest->ani2 = src->ani2;
2300 }
struct ast_set_party_id ani
Definition: channel.h:391
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:2118
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:377
struct ast_set_party_id id
Definition: channel.h:389
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:380
void ast_party_caller_set_init ( struct ast_party_caller init,
const struct ast_party_caller guide 
)

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

Since
1.8

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

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

Definition at line 2288 of file channel.c.

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

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

2289 {
2290  ast_party_id_set_init(&init->id, &guide->id);
2291  ast_party_id_set_init(&init->ani, &guide->ani);
2292  init->ani2 = guide->ani2;
2293 }
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:377
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:380
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:2110
void ast_party_connected_line_collect_caller ( struct ast_party_connected_line connected,
struct ast_party_caller caller 
)

Collect the caller party information into a connected line structure.

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

Definition at line 2345 of file channel.c.

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

2346 {
2347  connected->id = caller->id;
2348  connected->ani = caller->ani;
2349  connected->ani2 = caller->ani2;
2351 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:417
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:377
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:410
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:380
int source
Information about the source of an update.
Definition: channel.h:424
void ast_party_connected_line_copy ( struct ast_party_connected_line dest,
const struct ast_party_connected_line src 
)

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

Since
1.8
Parameters
destDestination connected line
srcSource connected line
Returns
Nothing

Definition at line 2316 of file channel.c.

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

Referenced by __ast_read(), ast_call_forward(), ast_channel_connected_line_macro(), ast_do_pickup(), builtin_atxfer(), dial_exec_full(), do_forward(), local_attended_transfer(), misdn_attempt_transfer(), party_connected_line_copy_transfer(), try_calling(), and wait_for_answer().

2317 {
2318  if (dest == src) {
2319  /* Don't copy to self */
2320  return;
2321  }
2322 
2323  ast_party_id_copy(&dest->id, &src->id);
2324  ast_party_id_copy(&dest->ani, &src->ani);
2325  dest->ani2 = src->ani2;
2326  dest->source = src->source;
2327 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
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:2095
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:417
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:410
int source
Information about the source of an update.
Definition: channel.h:424
void ast_party_connected_line_free ( struct ast_party_connected_line doomed)

Destroy the connected line information contents.

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

Definition at line 2353 of file channel.c.

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

Referenced by __ast_read(), app_exec(), ast_channel_connected_line_macro(), ast_channel_destructor(), ast_do_pickup(), ast_dummy_channel_destructor(), ast_indicate_data(), atxfer_fail_cleanup(), builtin_atxfer(), callattempt_free(), chanlist_free(), connectedline_write(), destroy_calling_tree(), feature_request_and_dial(), findmeexec(), local_attended_transfer(), misdn_attempt_transfer(), parked_call_exec(), sig_pri_handle_subcmds(), socket_process(), wait_for_answer(), wait_for_winner(), and xfer_ds_destroy().

2354 {
2355  ast_party_id_free(&doomed->id);
2356  ast_party_id_free(&doomed->ani);
2357 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
void ast_party_id_free(struct ast_party_id *doomed)
Destroy the party id contents.
Definition: channel.c:2141
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:410
void ast_party_connected_line_init ( struct ast_party_connected_line init)

Initialize the given connected line structure.

Since
1.8
Parameters
initConnected line structure to initialize.
Returns
Nothing

Definition at line 2308 of file channel.c.

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

Referenced by __ast_channel_alloc_ap(), __ast_read(), ast_channel_connected_line_macro(), ast_do_pickup(), builtin_atxfer(), do_forward(), handle_request_invite(), handle_request_update(), handle_response_invite(), local_attended_transfer(), misdn_attempt_transfer(), misdn_queue_connected_line_update(), parked_call_exec(), sig_pri_handle_subcmds(), sip_call(), socket_process(), and wait_for_answer().

2309 {
2310  ast_party_id_init(&init->id);
2311  ast_party_id_init(&init->ani);
2312  init->ani2 = 0;
2314 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:417
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:410
int source
Information about the source of an update.
Definition: channel.h:424
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition: channel.c:2087
void ast_party_connected_line_set ( struct ast_party_connected_line dest,
const struct ast_party_connected_line src,
const struct ast_set_party_connected_line update 
)

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

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

Definition at line 2337 of file channel.c.

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

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

2338 {
2339  ast_party_id_set(&dest->id, &src->id, update ? &update->id : NULL);
2340  ast_party_id_set(&dest->ani, &src->ani, update ? &update->ani : NULL);
2341  dest->ani2 = src->ani2;
2342  dest->source = src->source;
2343 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:417
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:2118
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:410
int source
Information about the source of an update.
Definition: channel.h:424
struct ast_set_party_id id
Definition: channel.h:433
struct ast_set_party_id ani
Definition: channel.h:435
void ast_party_connected_line_set_init ( struct ast_party_connected_line init,
const struct ast_party_connected_line guide 
)

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

Since
1.8

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

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

Definition at line 2329 of file channel.c.

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

Referenced by __ast_request_and_dial(), ast_indicate_data(), connectedline_write(), dial_exec_full(), feature_request_and_dial(), wait_for_answer(), and wait_for_winner().

2330 {
2331  ast_party_id_set_init(&init->id, &guide->id);
2332  ast_party_id_set_init(&init->ani, &guide->ani);
2333  init->ani2 = guide->ani2;
2334  init->source = guide->source;
2335 }
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:417
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:410
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:2110
int source
Information about the source of an update.
Definition: channel.h:424
void ast_party_dialed_copy ( struct ast_party_dialed dest,
const struct ast_party_dialed src 
)

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

Since
1.8
Parameters
destDestination dialed party
srcSource dialed party
Returns
Nothing

Definition at line 2227 of file channel.c.

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

Referenced by local_call().

2228 {
2229  if (dest == src) {
2230  /* Don't copy to self */
2231  return;
2232  }
2233 
2234  ast_free(dest->number.str);
2235  dest->number.str = ast_strdup(src->number.str);
2236  dest->number.plan = src->number.plan;
2239 }
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:338
char * str
Subscriber phone number (Malloced)
Definition: channel.h:336
#define ast_strdup(a)
Definition: astmm.h:109
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:2042
struct ast_party_dialed::@155 number
Dialed/Called number.
#define ast_free(a)
Definition: astmm.h:97
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition: channel.h:341
int transit_network_select
Transit Network Select.
Definition: channel.h:347
void ast_party_dialed_free ( struct ast_party_dialed doomed)

Destroy the dialed party contents.

Since
1.8
Parameters
doomedThe dialed party to destroy.
Returns
Nothing

Definition at line 2262 of file channel.c.

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

2263 {
2264  ast_free(doomed->number.str);
2265  doomed->number.str = NULL;
2267 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:336
struct ast_party_dialed::@155 number
Dialed/Called number.
void ast_party_subaddress_free(struct ast_party_subaddress *doomed)
Destroy the party subaddress contents.
Definition: channel.c:2081
#define ast_free(a)
Definition: astmm.h:97
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition: channel.h:341
void ast_party_dialed_init ( struct ast_party_dialed init)

Initialize the given dialed structure.

Since
1.8
Parameters
initDialed structure to initialize.
Returns
Nothing

Definition at line 2219 of file channel.c.

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

Referenced by __ast_channel_alloc_ap().

2220 {
2221  init->number.str = NULL;
2222  init->number.plan = 0;/* Unknown */
2224  init->transit_network_select = 0;
2225 }
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:338
char * str
Subscriber phone number (Malloced)
Definition: channel.h:336
struct ast_party_dialed::@155 number
Dialed/Called number.
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition: channel.h:341
int transit_network_select
Transit Network Select.
Definition: channel.h:347
void ast_party_subaddress_init(struct ast_party_subaddress *init)
Initialize the given subaddress structure.
Definition: channel.c:2034
void ast_party_dialed_set ( struct ast_party_dialed dest,
const struct ast_party_dialed src 
)

Set the dialed information based on another dialed source.

Since
1.8

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

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

Definition at line 2249 of file channel.c.

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

Referenced by callerid_write().

2250 {
2251  if (src->number.str && src->number.str != dest->number.str) {
2252  ast_free(dest->number.str);
2253  dest->number.str = ast_strdup(src->number.str);
2254  }
2255  dest->number.plan = src->number.plan;
2256 
2258 
2260 }
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:338
char * str
Subscriber phone number (Malloced)
Definition: channel.h:336
#define ast_strdup(a)
Definition: astmm.h:109
struct ast_party_dialed::@155 number
Dialed/Called number.
#define ast_free(a)
Definition: astmm.h:97
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition: channel.h:341
int transit_network_select
Transit Network Select.
Definition: channel.h:347
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:2064
void ast_party_dialed_set_init ( struct ast_party_dialed init,
const struct ast_party_dialed guide 
)

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

Since
1.8

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

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

Definition at line 2241 of file channel.c.

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

Referenced by callerid_write().

2242 {
2243  init->number.str = NULL;
2244  init->number.plan = guide->number.plan;
2247 }
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:338
char * str
Subscriber phone number (Malloced)
Definition: channel.h:336
struct ast_party_dialed::@155 number
Dialed/Called number.
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:2056
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition: channel.h:341
int transit_network_select
Transit Network Select.
Definition: channel.h:347
void ast_party_id_copy ( struct ast_party_id dest,
const struct ast_party_id src 
)

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

Since
1.8
Parameters
destDestination party id
srcSource party id
Returns
Nothing

Definition at line 2095 of file channel.c.

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

Referenced by ast_connected_line_copy_from_caller(), ast_connected_line_copy_to_caller(), ast_party_caller_copy(), ast_party_connected_line_copy(), ast_party_redirecting_copy(), and parkandannounce_exec().

2096 {
2097  if (dest == src) {
2098  /* Don't copy to self */
2099  return;
2100  }
2101 
2102  ast_party_name_copy(&dest->name, &src->name);
2103  ast_party_number_copy(&dest->number, &src->number);
2105 
2106  ast_free(dest->tag);
2107  dest->tag = ast_strdup(src->tag);
2108 }
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:1936
#define ast_strdup(a)
Definition: astmm.h:109
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:2042
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:294
#define ast_free(a)
Definition: astmm.h:97
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:1989
char * tag
User-set &quot;tag&quot;.
Definition: channel.h:304
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
void ast_party_id_free ( struct ast_party_id doomed)

Destroy the party id contents.

Since
1.8
Parameters
doomedThe party id to destroy.
Returns
Nothing

Definition at line 2141 of file channel.c.

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

Referenced by ast_party_caller_free(), ast_party_connected_line_free(), ast_party_redirecting_free(), parkandannounce_exec(), and sig_pri_mcid_event().

2142 {
2143  ast_party_name_free(&doomed->name);
2144  ast_party_number_free(&doomed->number);
2146 
2147  ast_free(doomed->tag);
2148  doomed->tag = NULL;
2149 }
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
void ast_party_subaddress_free(struct ast_party_subaddress *doomed)
Destroy the party subaddress contents.
Definition: channel.c:2081
void ast_party_number_free(struct ast_party_number *doomed)
Destroy the party number contents.
Definition: channel.c:2028
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:294
void ast_party_name_free(struct ast_party_name *doomed)
Destroy the party name contents.
Definition: channel.c:1975
#define ast_free(a)
Definition: astmm.h:97
char * tag
User-set &quot;tag&quot;.
Definition: channel.h:304
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
void ast_party_id_init ( struct ast_party_id init)

Initialize the given party id structure.

Since
1.8
Parameters
initParty id structure to initialize.
Returns
Nothing

Definition at line 2087 of file channel.c.

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

Referenced by ast_party_caller_init(), ast_party_connected_line_init(), ast_party_redirecting_init(), dial_exec_full(), parkandannounce_exec(), and sig_pri_mcid_event().

2088 {
2089  ast_party_name_init(&init->name);
2090  ast_party_number_init(&init->number);
2092  init->tag = NULL;
2093 }
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
void ast_party_number_init(struct ast_party_number *init)
Initialize the given number structure.
Definition: channel.c:1981
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:294
void ast_party_name_init(struct ast_party_name *init)
Initialize the given name structure.
Definition: channel.c:1928
char * tag
User-set &quot;tag&quot;.
Definition: channel.h:304
void ast_party_subaddress_init(struct ast_party_subaddress *init)
Initialize the given subaddress structure.
Definition: channel.c:2034
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
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 2151 of file channel.c.

References AST_PRES_ALLOWED, AST_PRES_NUMBER_NOT_AVAILABLE, AST_PRES_NUMBER_TYPE, AST_PRES_RESTRICTED, AST_PRES_RESTRICTION, AST_PRES_UNAVAILABLE, AST_PRES_USER_NUMBER_UNSCREENED, ast_party_id::name, ast_party_id::number, ast_party_name::valid, and ast_party_number::valid.

Referenced by add_rpid(), ast_str_retrieve_variable(), ast_var_channels_table(), callerpres_read(), iax2_call(), initreqprep(), my_set_callerid(), oh323_call(), party_id_build_data(), party_id_read(), redirecting_read(), report_new_callerid(), setup_env(), sig_pri_event_party_id(), sig_pri_handle_subcmds(), sip_call(), and socket_process().

2152 {
2153  int number_priority;
2154  int number_value;
2155  int number_screening;
2156  int name_priority;
2157  int name_value;
2158 
2159  /* Determine name presentation priority. */
2160  if (!id->name.valid) {
2161  name_value = AST_PRES_UNAVAILABLE;
2162  name_priority = 3;
2163  } else {
2164  name_value = id->name.presentation & AST_PRES_RESTRICTION;
2165  switch (name_value) {
2166  case AST_PRES_RESTRICTED:
2167  name_priority = 0;
2168  break;
2169  case AST_PRES_ALLOWED:
2170  name_priority = 1;
2171  break;
2172  case AST_PRES_UNAVAILABLE:
2173  name_priority = 2;
2174  break;
2175  default:
2176  name_value = AST_PRES_UNAVAILABLE;
2177  name_priority = 3;
2178  break;
2179  }
2180  }
2181 
2182  /* Determine number presentation priority. */
2183  if (!id->number.valid) {
2184  number_screening = AST_PRES_USER_NUMBER_UNSCREENED;
2185  number_value = AST_PRES_UNAVAILABLE;
2186  number_priority = 3;
2187  } else {
2188  number_screening = id->number.presentation & AST_PRES_NUMBER_TYPE;
2189  number_value = id->number.presentation & AST_PRES_RESTRICTION;
2190  switch (number_value) {
2191  case AST_PRES_RESTRICTED:
2192  number_priority = 0;
2193  break;
2194  case AST_PRES_ALLOWED:
2195  number_priority = 1;
2196  break;
2197  case AST_PRES_UNAVAILABLE:
2198  number_priority = 2;
2199  break;
2200  default:
2201  number_screening = AST_PRES_USER_NUMBER_UNSCREENED;
2202  number_value = AST_PRES_UNAVAILABLE;
2203  number_priority = 3;
2204  break;
2205  }
2206  }
2207 
2208  /* Select the wining presentation value. */
2209  if (name_priority < number_priority) {
2210  number_value = name_value;
2211  }
2212  if (number_value == AST_PRES_UNAVAILABLE) {
2214  }
2215 
2216  return number_value | number_screening;
2217 }
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
#define AST_PRES_RESTRICTED
Definition: callerid.h:325
#define AST_PRES_USER_NUMBER_UNSCREENED
Definition: callerid.h:318
#define AST_PRES_NUMBER_TYPE
Definition: callerid.h:317
#define AST_PRES_NUMBER_NOT_AVAILABLE
Definition: callerid.h:353
#define AST_PRES_RESTRICTION
Definition: callerid.h:323
#define AST_PRES_ALLOWED
Definition: callerid.h:324
#define AST_PRES_UNAVAILABLE
Definition: callerid.h:326
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
void ast_party_id_set ( struct ast_party_id dest,
const struct ast_party_id src,
const struct ast_set_party_id update 
)

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

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

Definition at line 2118 of file channel.c.

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

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

2119 {
2120  if (dest == src) {
2121  /* Don't set to self */
2122  return;
2123  }
2124 
2125  if (!update || update->name) {
2126  ast_party_name_set(&dest->name, &src->name);
2127  }
2128  if (!update || update->number) {
2129  ast_party_number_set(&dest->number, &src->number);
2130  }
2131  if (!update || update->subaddress) {
2133  }
2134 
2135  if (src->tag && src->tag != dest->tag) {
2136  ast_free(dest->tag);
2137  dest->tag = ast_strdup(src->tag);
2138  }
2139 }
#define ast_strdup(a)
Definition: astmm.h:109
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
unsigned char subaddress
Definition: channel.h:317
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:294
unsigned char number
Definition: channel.h:315
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:1958
#define ast_free(a)
Definition: astmm.h:97
char * tag
User-set &quot;tag&quot;.
Definition: channel.h:304
unsigned char name
Definition: channel.h:313
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:2011
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:2064
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
void ast_party_id_set_init ( struct ast_party_id init,
const struct ast_party_id guide 
)

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

Since
1.8

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

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

Definition at line 2110 of file channel.c.

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

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

2111 {
2112  ast_party_name_set_init(&init->name, &guide->name);
2113  ast_party_number_set_init(&init->number, &guide->number);
2115  init->tag = NULL;
2116 }
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:2003
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
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:2056
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:294
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:1950
char * tag
User-set &quot;tag&quot;.
Definition: channel.h:304
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
void ast_party_name_copy ( struct ast_party_name dest,
const struct ast_party_name src 
)

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

Since
1.8
Parameters
destDestination party name
srcSource party name
Returns
Nothing

Definition at line 1936 of file channel.c.

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

Referenced by ast_party_id_copy().

1937 {
1938  if (dest == src) {
1939  /* Don't copy to self */
1940  return;
1941  }
1942 
1943  ast_free(dest->str);
1944  dest->str = ast_strdup(src->str);
1945  dest->char_set = src->char_set;
1946  dest->presentation = src->presentation;
1947  dest->valid = src->valid;
1948 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:227
#define ast_strdup(a)
Definition: astmm.h:109
int char_set
Character set the name is using.
Definition: channel.h:222
char * str
Subscriber name (Malloced)
Definition: channel.h:214
#define ast_free(a)
Definition: astmm.h:97
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
void ast_party_name_free ( struct ast_party_name doomed)

Destroy the party name contents.

Since
1.8
Parameters
doomedThe party name to destroy.
Returns
Nothing

Definition at line 1975 of file channel.c.

References ast_free, and ast_party_name::str.

Referenced by __analog_ss_thread(), analog_ss_thread(), ast_party_id_free(), and skinny_newcall().

1976 {
1977  ast_free(doomed->str);
1978  doomed->str = NULL;
1979 }
char * str
Subscriber name (Malloced)
Definition: channel.h:214
#define ast_free(a)
Definition: astmm.h:97
void ast_party_name_init ( struct ast_party_name init)

Initialize the given name structure.

Since
1.8
Parameters
initName structure to initialize.
Returns
Nothing

Definition at line 1928 of file channel.c.

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

Referenced by __analog_ss_thread(), analog_ss_thread(), ast_party_id_init(), and skinny_newcall().

1929 {
1930  init->str = NULL;
1933  init->valid = 0;
1934 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:227
int char_set
Character set the name is using.
Definition: channel.h:222
char * str
Subscriber name (Malloced)
Definition: channel.h:214
#define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED
Definition: callerid.h:329
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
void ast_party_name_set ( struct ast_party_name dest,
const struct ast_party_name src 
)

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

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

Definition at line 1958 of file channel.c.

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

Referenced by ast_party_id_set().

1959 {
1960  if (dest == src) {
1961  /* Don't set to self */
1962  return;
1963  }
1964 
1965  if (src->str && src->str != dest->str) {
1966  ast_free(dest->str);
1967  dest->str = ast_strdup(src->str);
1968  }
1969 
1970  dest->char_set = src->char_set;
1971  dest->presentation = src->presentation;
1972  dest->valid = src->valid;
1973 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:227
#define ast_strdup(a)
Definition: astmm.h:109
int char_set
Character set the name is using.
Definition: channel.h:222
char * str
Subscriber name (Malloced)
Definition: channel.h:214
#define ast_free(a)
Definition: astmm.h:97
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
void ast_party_name_set_init ( struct ast_party_name init,
const struct ast_party_name guide 
)

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

Since
1.8

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

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

Definition at line 1950 of file channel.c.

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

Referenced by ast_party_id_set_init().

1951 {
1952  init->str = NULL;
1953  init->char_set = guide->char_set;
1954  init->presentation = guide->presentation;
1955  init->valid = guide->valid;
1956 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:227
int char_set
Character set the name is using.
Definition: channel.h:222
char * str
Subscriber name (Malloced)
Definition: channel.h:214
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
void ast_party_number_copy ( struct ast_party_number dest,
const struct ast_party_number src 
)

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

Since
1.8
Parameters
destDestination party number
srcSource party number
Returns
Nothing

Definition at line 1989 of file channel.c.

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

Referenced by ast_party_id_copy().

1990 {
1991  if (dest == src) {
1992  /* Don't copy to self */
1993  return;
1994  }
1995 
1996  ast_free(dest->str);
1997  dest->str = ast_strdup(src->str);
1998  dest->plan = src->plan;
1999  dest->presentation = src->presentation;
2000  dest->valid = src->valid;
2001 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:245
#define ast_strdup(a)
Definition: astmm.h:109
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:243
#define ast_free(a)
Definition: astmm.h:97
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
void ast_party_number_free ( struct ast_party_number doomed)

Destroy the party number contents.

Since
1.8
Parameters
doomedThe party number to destroy.
Returns
Nothing

Definition at line 2028 of file channel.c.

References ast_free, and ast_party_number::str.

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

2029 {
2030  ast_free(doomed->str);
2031  doomed->str = NULL;
2032 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
#define ast_free(a)
Definition: astmm.h:97
void ast_party_number_init ( struct ast_party_number init)

Initialize the given number structure.

Since
1.8
Parameters
initNumber structure to initialize.
Returns
Nothing

Definition at line 1981 of file channel.c.

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

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

1982 {
1983  init->str = NULL;
1984  init->plan = 0;/* Unknown */
1986  init->valid = 0;
1987 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:245
#define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED
Definition: callerid.h:329
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:243
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
void ast_party_number_set ( struct ast_party_number dest,
const struct ast_party_number src 
)

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

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

Definition at line 2011 of file channel.c.

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

Referenced by ast_party_id_set().

2012 {
2013  if (dest == src) {
2014  /* Don't set to self */
2015  return;
2016  }
2017 
2018  if (src->str && src->str != dest->str) {
2019  ast_free(dest->str);
2020  dest->str = ast_strdup(src->str);
2021  }
2022 
2023  dest->plan = src->plan;
2024  dest->presentation = src->presentation;
2025  dest->valid = src->valid;
2026 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:245
#define ast_strdup(a)
Definition: astmm.h:109
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:243
#define ast_free(a)
Definition: astmm.h:97
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
void ast_party_number_set_init ( struct ast_party_number init,
const struct ast_party_number guide 
)

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

Since
1.8

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

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

Definition at line 2003 of file channel.c.

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

Referenced by ast_party_id_set_init().

2004 {
2005  init->str = NULL;
2006  init->plan = guide->plan;
2007  init->presentation = guide->presentation;
2008  init->valid = guide->valid;
2009 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:245
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:243
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
void ast_party_redirecting_copy ( struct ast_party_redirecting dest,
const struct ast_party_redirecting src 
)

Copy the source redirecting information to the destination redirecting.

Since
1.8
Parameters
destDestination redirecting
srcSource redirecting
Returns
Nothing

Definition at line 2367 of file channel.c.

References ast_party_id_copy(), ast_party_redirecting::count, ast_party_redirecting::from, ast_party_redirecting::reason, and ast_party_redirecting::to.

Referenced by ast_call_forward(), ast_channel_redirecting_macro(), begin_dial_channel(), call_forward_inherit(), dial_exec_full(), do_forward(), local_call(), ring_entry(), and wait_for_answer().

2368 {
2369  if (dest == src) {
2370  /* Don't copy to self */
2371  return;
2372  }
2373 
2374  ast_party_id_copy(&dest->from, &src->from);
2375  ast_party_id_copy(&dest->to, &src->to);
2376  dest->count = src->count;
2377  dest->reason = src->reason;
2378 }
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:449
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:2095
int count
Number of times the call was redirected.
Definition: channel.h:455
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:452
int reason
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:458
void ast_party_redirecting_free ( struct ast_party_redirecting doomed)

Destroy the redirecting information contents.

Since
1.8
Parameters
doomedThe redirecting information to destroy.
Returns
Nothing

Definition at line 2396 of file channel.c.

References ast_party_id_free(), ast_party_redirecting::from, and ast_party_redirecting::to.

Referenced by ast_channel_destructor(), ast_channel_redirecting_macro(), ast_dummy_channel_destructor(), ast_indicate_data(), call_forward_inherit(), do_forward(), handle_request_invite(), handle_response(), handle_response_invite(), redirecting_write(), sig_pri_handle_subcmds(), and wait_for_answer().

2397 {
2398  ast_party_id_free(&doomed->from);
2399  ast_party_id_free(&doomed->to);
2400 }
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:449
void ast_party_id_free(struct ast_party_id *doomed)
Destroy the party id contents.
Definition: channel.c:2141
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:452
void ast_party_redirecting_init ( struct ast_party_redirecting init)

Initialize the given redirecting structure.

Since
1.8
Parameters
initRedirecting structure to initialize.
Returns
Nothing

Definition at line 2359 of file channel.c.

References ast_party_id_init(), AST_REDIRECTING_REASON_UNKNOWN, ast_party_redirecting::count, ast_party_redirecting::from, ast_party_redirecting::reason, and ast_party_redirecting::to.

Referenced by __ast_channel_alloc_ap(), ast_channel_redirecting_macro(), call_forward_inherit(), do_forward(), handle_request_invite(), handle_response(), handle_response_invite(), and wait_for_answer().

2360 {
2361  ast_party_id_init(&init->from);
2362  ast_party_id_init(&init->to);
2363  init->count = 0;
2365 }
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:449
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition: channel.c:2087
int count
Number of times the call was redirected.
Definition: channel.h:455
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:452
int reason
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:458
void ast_party_redirecting_set ( struct ast_party_redirecting dest,
const struct ast_party_redirecting src,
const struct ast_set_party_redirecting update 
)

Set the redirecting information based on another redirecting source.

Since
1.8

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

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

Definition at line 2388 of file channel.c.

References ast_party_id_set(), ast_party_redirecting::count, ast_party_redirecting::from, ast_set_party_redirecting::from, ast_party_redirecting::reason, ast_party_redirecting::to, and ast_set_party_redirecting::to.

Referenced by ast_channel_set_redirecting().

2389 {
2390  ast_party_id_set(&dest->from, &src->from, update ? &update->from : NULL);
2391  ast_party_id_set(&dest->to, &src->to, update ? &update->to : NULL);
2392  dest->reason = src->reason;
2393  dest->count = src->count;
2394 }
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:449
struct ast_set_party_id from
Definition: channel.h:467
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:2118
struct ast_set_party_id to
Definition: channel.h:469
int count
Number of times the call was redirected.
Definition: channel.h:455
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:452
int reason
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:458
void ast_party_redirecting_set_init ( struct ast_party_redirecting init,
const struct ast_party_redirecting guide 
)

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

Since
1.8

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

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

Definition at line 2380 of file channel.c.

References ast_party_id_set_init(), ast_party_redirecting::count, ast_party_redirecting::from, ast_party_redirecting::reason, and ast_party_redirecting::to.

Referenced by ast_indicate_data(), misdn_copy_redirecting_to_ast(), redirecting_write(), and sig_pri_redirecting_convert().

2381 {
2382  ast_party_id_set_init(&init->from, &guide->from);
2383  ast_party_id_set_init(&init->to, &guide->to);
2384  init->count = guide->count;
2385  init->reason = guide->reason;
2386 }
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:449
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:2110
int count
Number of times the call was redirected.
Definition: channel.h:455
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:452
int reason
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:458
void ast_party_subaddress_copy ( struct ast_party_subaddress dest,
const struct ast_party_subaddress src 
)

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

Since
1.8
Parameters
destDestination party subaddress
srcSource party subaddress
Returns
Nothing

Definition at line 2042 of file channel.c.

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

Referenced by ast_party_dialed_copy(), and ast_party_id_copy().

2043 {
2044  if (dest == src) {
2045  /* Don't copy to self */
2046  return;
2047  }
2048 
2049  ast_free(dest->str);
2050  dest->str = ast_strdup(src->str);
2051  dest->type = src->type;
2053  dest->valid = src->valid;
2054 }
#define ast_strdup(a)
Definition: astmm.h:109
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:278
char * str
Malloced subaddress string.
Definition: channel.h:263
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:276
#define ast_free(a)
Definition: astmm.h:97
int type
Q.931 subaddress type.
Definition: channel.h:270
void ast_party_subaddress_free ( struct ast_party_subaddress doomed)

Destroy the party subaddress contents.

Since
1.8
Parameters
doomedThe party subaddress to destroy.
Returns
Nothing

Definition at line 2081 of file channel.c.

References ast_free, and ast_party_subaddress::str.

Referenced by ast_party_dialed_free(), ast_party_id_free(), and pri_dchannel().

2082 {
2083  ast_free(doomed->str);
2084  doomed->str = NULL;
2085 }
char * str
Malloced subaddress string.
Definition: channel.h:263
#define ast_free(a)
Definition: astmm.h:97
void ast_party_subaddress_init ( struct ast_party_subaddress init)

Initialize the given subaddress structure.

Since
1.8
Parameters
initSubaddress structure to initialize.
Returns
Nothing

Definition at line 2034 of file channel.c.

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

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

2035 {
2036  init->str = NULL;
2037  init->type = 0;
2038  init->odd_even_indicator = 0;
2039  init->valid = 0;
2040 }
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:278
char * str
Malloced subaddress string.
Definition: channel.h:263
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:276
int type
Q.931 subaddress type.
Definition: channel.h:270
void ast_party_subaddress_set ( struct ast_party_subaddress dest,
const struct ast_party_subaddress src 
)

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

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

Definition at line 2064 of file channel.c.

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

Referenced by ast_party_dialed_set(), and ast_party_id_set().

2065 {
2066  if (dest == src) {
2067  /* Don't set to self */
2068  return;
2069  }
2070 
2071  if (src->str && src->str != dest->str) {
2072  ast_free(dest->str);
2073  dest->str = ast_strdup(src->str);
2074  }
2075 
2076  dest->type = src->type;
2078  dest->valid = src->valid;
2079 }
#define ast_strdup(a)
Definition: astmm.h:109
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:278
char * str
Malloced subaddress string.
Definition: channel.h:263
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:276
#define ast_free(a)
Definition: astmm.h:97
int type
Q.931 subaddress type.
Definition: channel.h:270
void ast_party_subaddress_set_init ( struct ast_party_subaddress init,
const struct ast_party_subaddress guide 
)

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

Since
1.8

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

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

Definition at line 2056 of file channel.c.

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

Referenced by ast_party_dialed_set_init(), and ast_party_id_set_init().

2057 {
2058  init->str = NULL;
2059  init->type = guide->type;
2060  init->odd_even_indicator = guide->odd_even_indicator;
2061  init->valid = guide->valid;
2062 }
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:278
char * str
Malloced subaddress string.
Definition: channel.h:263
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:276
int type
Q.931 subaddress type.
Definition: channel.h:270
int ast_plc_reload ( void  )

Reload genericplc configuration value from codecs.conf.

Implementation is in main/channel.c

Definition at line 8076 of file channel.c.

References ast_config_destroy(), ast_config_load, AST_OPT_FLAG_GENERIC_PLC, ast_options, ast_set2_flag, ast_true(), ast_variable_browse(), CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, CONFIG_STATUS_FILEUNCHANGED, ast_variable::name, ast_variable::next, ast_variable::value, and var.

Referenced by ast_channels_init().

8077 {
8078  struct ast_variable *var;
8079  struct ast_flags config_flags = { 0 };
8080  struct ast_config *cfg = ast_config_load("codecs.conf", config_flags);
8082  return 0;
8083  for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
8084  if (!strcasecmp(var->name, "genericplc")) {
8086  }
8087  }
8088  ast_config_destroy(cfg);
8089  return 0;
8090 }
#define ast_set2_flag(p, value, flag)
Definition: utils.h:94
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Goes through variables.
Definition: config.c:597
Structure for variables, used for configurations and for channel variables.
Definition: config.h:75
#define var
Definition: ast_expr2f.c:606
void ast_config_destroy(struct ast_config *config)
Destroys a config.
Definition: config.c:1037
#define CONFIG_STATUS_FILEMISSING
Definition: config.h:50
const char * value
Definition: config.h:79
#define ast_config_load(filename, flags)
Load a config file.
Definition: config.h:170
const char * name
Definition: config.h:77
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is &quot;true&quot;. This function checks to see whether a string passed to it is an indication of an &quot;true&quot; value. It checks to see if the string is &quot;yes&quot;, &quot;true&quot;, &quot;y&quot;, &quot;t&quot;, &quot;on&quot; or &quot;1&quot;.
Definition: utils.c:1533
Structure used to handle boolean flags.
Definition: utils.h:200
struct ast_flags ast_options
Definition: asterisk.c:178
struct ast_variable * next
Definition: config.h:82
#define CONFIG_STATUS_FILEINVALID
Definition: config.h:52
#define CONFIG_STATUS_FILEUNCHANGED
Definition: config.h:51
void ast_poll_channel_add ( struct ast_channel chan0,
struct ast_channel chan1 
)

Add a channel to an optimized waitfor

Definition at line 2665 of file channel.c.

References AST_MAX_FDS, and ast_channel::fds.

Referenced by ast_generic_bridge(), begin_dial_channel(), feature_request_and_dial(), local_bridge_loop(), remote_bridge_loop(), and wait_for_answer().

2666 {
2667 #ifdef HAVE_EPOLL
2668  struct epoll_event ev;
2669  int i = 0;
2670 
2671  if (chan0->epfd == -1)
2672  return;
2673 
2674  /* Iterate through the file descriptors on chan1, adding them to chan0 */
2675  for (i = 0; i < AST_MAX_FDS; i++) {
2676  if (chan1->fds[i] == -1)
2677  continue;
2678  ev.events = EPOLLIN | EPOLLPRI | EPOLLERR | EPOLLHUP;
2679  ev.data.ptr = chan1->epfd_data[i];
2680  epoll_ctl(chan0->epfd, EPOLL_CTL_ADD, chan1->fds[i], &ev);
2681  }
2682 
2683 #endif
2684  return;
2685 }
int fds[AST_MAX_FDS]
Definition: channel.h:829
#define AST_MAX_FDS
Definition: channel.h:158
void ast_poll_channel_del ( struct ast_channel chan0,
struct ast_channel chan1 
)

Delete a channel from an optimized waitfor

Definition at line 2688 of file channel.c.

References AST_MAX_FDS, and ast_channel::fds.

Referenced by ast_generic_bridge(), feature_request_and_dial(), local_bridge_loop(), monitor_dial(), remote_bridge_loop(), and wait_for_answer().

2689 {
2690 #ifdef HAVE_EPOLL
2691  struct epoll_event ev;
2692  int i = 0;
2693 
2694  if (chan0->epfd == -1)
2695  return;
2696 
2697  for (i = 0; i < AST_MAX_FDS; i++) {
2698  if (chan1->fds[i] == -1)
2699  continue;
2700  epoll_ctl(chan0->epfd, EPOLL_CTL_DEL, chan1->fds[i], &ev);
2701  }
2702 
2703 #endif
2704  return;
2705 }
int fds[AST_MAX_FDS]
Definition: channel.h:829
#define AST_MAX_FDS
Definition: channel.h:158
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 8236 of file channel.c.

References first.

Referenced by _sip_show_peer(), _skinny_show_line(), func_channel_read(), function_sippeer(), misdn_cfg_get_config_string(), print_group(), read_config(), and serialize_showchan().

8237 {
8238  unsigned int i;
8239  int first = 1;
8240  char num[3];
8241 
8242  buf[0] = '\0';
8243 
8244  if (!group) /* Return empty string if no group */
8245  return buf;
8246 
8247  for (i = 0; i <= 63; i++) { /* Max group is 63 */
8248  if (group & ((ast_group_t) 1 << i)) {
8249  if (!first) {
8250  strncat(buf, ", ", buflen - strlen(buf) - 1);
8251  } else {
8252  first = 0;
8253  }
8254  snprintf(num, sizeof(num), "%u", i);
8255  strncat(buf, num, buflen - strlen(buf) - 1);
8256  }
8257  }
8258  return buf;
8259 }
unsigned long long ast_group_t
Definition: channel.h:175
struct sla_ringing_trunk * first
Definition: app_meetme.c:965
int ast_prod ( struct ast_channel chan)

Send empty audio to prime a channel driver.

Definition at line 4784 of file channel.c.

References ast_channel::_state, ast_debug, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log(), AST_STATE_UP, ast_write(), ast_frame_subclass::codec, ast_frame::data, LOG_WARNING, ast_channel::name, ast_frame::ptr, ast_channel::rawwriteformat, ast_frame::src, and ast_frame::subclass.

Referenced by ast_activate_generator().

4785 {
4786  struct ast_frame a = { AST_FRAME_VOICE };
4787  char nothing[128];
4788 
4789  /* Send an empty audio frame to get things moving */
4790  if (chan->_state != AST_STATE_UP) {
4791  ast_debug(1, "Prodding channel '%s'\n", chan->name);
4792  a.subclass.codec = chan->rawwriteformat;
4793  a.data.ptr = nothing + AST_FRIENDLY_OFFSET;
4794  a.src = "ast_prod"; /* this better match check in ast_write */
4795  if (ast_write(chan, &a))
4796  ast_log(LOG_WARNING, "Prodding channel '%s' failed\n", chan->name);
4797  }
4798  return 0;
4799 }
union ast_frame_subclass subclass
Definition: frame.h:146
void * ptr
Definition: frame.h:160
#define LOG_WARNING
Definition: logger.h:144
format_t rawwriteformat
Definition: channel.h:856
format_t codec
Definition: frame.h:137
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
#define AST_FRIENDLY_OFFSET
Offset into a frame&#39;s data buffer.
Definition: frame.h:204
const char * src
Definition: frame.h:158
enum ast_channel_state _state
Definition: channel.h:839
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
Definition: channel.c:4916
Data structure associated with a single frame of data.
Definition: frame.h:142
union ast_frame::@172 data
int ast_queue_control ( struct ast_channel chan,
enum ast_control_frame_type  control 
)

Queue a control frame.

Queue a control frame with payload.

Definition at line 1601 of file channel.c.

References AST_FRAME_CONTROL, and ast_queue_frame().

Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_read(), __dahdi_exception(), __oh323_update_info(), analog_call(), analog_exception(), analog_hangup(), analog_ss_thread(), ast_do_pickup(), attempt_transfer(), auto_congest(), cb_events(), cli_console_answer(), cli_console_flash(), console_answer(), console_call(), console_sendtext(), dahdi_handle_event(), dahdi_hangup(), gtalk_is_answered(), gtalk_ringing_ack(), handle_hd_hf(), handle_incoming(), handle_offhook_message(), handle_request(), handle_request_bye(), handle_request_info(), handle_request_invite(), handle_request_refer(), handle_response(), handle_response_invite(), handle_response_refer(), handle_soft_key_event_message(), handle_stimulus_message(), HandleCallIncoming(), jingle_is_answered(), jingle_ringing_ack(), masquerade_colp_transfer(), misdn_facility_ie_handler(), multicast_rtp_call(), nbs_call(), phone_call(), process_sdp(), receive_digit(), remote_hold(), send_cause2ast(), setup_rtp_connection(), skinny_call(), skinny_transfer(), skinny_unhold(), unistim_call(), and update_state().

1602 {
1603  struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = control };
1604  return ast_queue_frame(chan, &f);
1605 }
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
static struct ast_format f[]
Definition: format_g726.c:181
Data structure associated with a single frame of data.
Definition: frame.h:142
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 1608 of file channel.c.

References AST_FRAME_CONTROL, and ast_queue_frame().

Referenced by __analog_handle_event(), analog_hangup(), ast_channel_queue_connected_line_update(), ast_channel_queue_redirecting_update(), change_t38_state(), dahdi_handle_event(), dahdi_hangup(), handle_request_notify(), handle_response_refer(), iax2_queue_control_data(), iax2_transfer(), interpret_t38_parameters(), local_attended_transfer(), masquerade_colp_transfer(), process_sdp(), sig_pri_aoc_d_from_pri(), sig_pri_aoc_e_from_pri(), sig_pri_aoc_s_from_pri(), sig_pri_send_aoce_termination_request(), sip_sipredirect(), and skinny_hold().

1610 {
1611  struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = control, .data.ptr = (void *) data, .datalen = datalen };
1612  return ast_queue_frame(chan, &f);
1613 }
int datalen
Definition: frame.h:148
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
static struct ast_format f[]
Definition: format_g726.c:181
Data structure associated with a single frame of data.
Definition: frame.h:142
union ast_frame::@172 data
int ast_queue_frame ( struct ast_channel chan,
struct ast_frame f 
)

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

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

Definition at line 1558 of file channel.c.

References __ast_queue_frame().

Referenced by __ast_channel_masquerade(), __ast_read(), __oh323_rtp_create(), __oh323_update_info(), action_atxfer(), agent_request(), alsa_call(), ast_channel_setwhentohangup_tv(), ast_do_masquerade(), ast_dsp_process(), ast_queue_cc_frame(), ast_queue_control(), ast_queue_control_data(), ast_queue_hangup(), ast_queue_hangup_with_cause(), ast_softhangup_nolock(), bridge_write(), cb_events(), cli_console_dial(), cli_console_sendtext(), console_dial(), console_do_answer(), console_flash(), console_sendtext(), dahdi_queue_frame(), dahdi_read(), dictate_exec(), do_immediate_setup(), gtalk_handle_dtmf(), handle_keypad_button_message(), handle_request_info(), handle_request_invite(), handle_response_invite(), iax2_queue_frame(), jingle_handle_dtmf(), keypad_digit(), local_queue_frame(), mgcp_queue_frame(), oh323_simulate_dtmf_end(), oss_call(), pri_queue_frame(), process_sdp(), queue_dtmf_readq(), receive_digit(), receive_message(), sig_pri_dial_complete(), sig_pri_handle_hold(), sig_pri_handle_subcmds(), stream_monitor(), unistim_do_senddigit(), unistim_senddigit_end(), and wakeup_sub().

1559 {
1560  return __ast_queue_frame(chan, fin, 0, NULL);
1561 }
static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, int head, struct ast_frame *after)
Definition: channel.c:1438
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 1563 of file channel.c.

References __ast_queue_frame().

Referenced by __ast_answer(), __ast_read(), ast_autoservice_stop(), ast_safe_sleep_conditional(), and feature_request_and_dial().

1564 {
1565  return __ast_queue_frame(chan, fin, 1, NULL);
1566 }
static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, int head, struct ast_frame *after)
Definition: channel.c:1438
int ast_queue_hangup ( struct ast_channel chan)

Queue a hangup frame for channel.

Queue a hangup frame.

Definition at line 1569 of file channel.c.

References ast_channel::_softhangup, ast_channel_trylock, ast_channel_unlock, AST_CONTROL_HANGUP, AST_FRAME_CONTROL, ast_queue_frame(), and AST_SOFTHANGUP_DEV.

Referenced by bridge_queue_hangup(), cleanup_connection(), cli_console_hangup(), close_call(), gtalk_hangup_farend(), gtalk_is_answered(), handle_onhook_message(), handle_request_bye(), handle_soft_key_event_message(), iax2_destroy(), iax2_queue_hangup(), jingle_hangup_farend(), local_fixup(), local_hangup(), mgcp_queue_hangup(), and sip_queue_hangup_cause().

1570 {
1571  struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HANGUP };
1572  /* Yeah, let's not change a lock-critical value without locking */
1573  if (!ast_channel_trylock(chan)) {
1575  ast_channel_unlock(chan);
1576  }
1577  return ast_queue_frame(chan, &f);
1578 }
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
int _softhangup
Definition: channel.h:832
#define ast_channel_unlock(chan)
Definition: channel.h:2467
static struct ast_format f[]
Definition: format_g726.c:181
Data structure associated with a single frame of data.
Definition: frame.h:142
#define ast_channel_trylock(chan)
Definition: channel.h:2468
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 1581 of file channel.c.

References ast_channel::_softhangup, ast_channel_trylock, ast_channel_unlock, AST_CONTROL_HANGUP, AST_FRAME_CONTROL, ast_queue_frame(), AST_SOFTHANGUP_DEV, ast_frame::data, ast_channel::hangupcause, and ast_frame::uint32.

Referenced by __analog_handle_event(), __oh323_update_info(), __sip_autodestruct(), close_call(), close_client(), console_hangup(), dahdi_handle_event(), dahdi_r2_on_call_disconnect(), handle_request_bye(), handle_response(), handle_response_invite(), HandleCallOutgoing(), hangup_chan(), hangup_connection(), local_hangup(), misdn_answer(), retrans_pkt(), sip_queue_hangup_cause(), and TransferCallStep1().

1582 {
1583  struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HANGUP };
1584 
1585  if (cause >= 0)
1586  f.data.uint32 = cause;
1587 
1588  /* Yeah, let's not change a lock-critical value without locking */
1589  if (!ast_channel_trylock(chan)) {
1591  if (cause < 0)
1592  f.data.uint32 = chan->hangupcause;
1593 
1594  ast_channel_unlock(chan);
1595  }
1596 
1597  return ast_queue_frame(chan, &f);
1598 }
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
int _softhangup
Definition: channel.h:832
#define ast_channel_unlock(chan)
Definition: channel.h:2467
static struct ast_format f[]
Definition: format_g726.c:181
Data structure associated with a single frame of data.
Definition: frame.h:142
int hangupcause
Definition: channel.h:849
uint32_t uint32
Definition: frame.h:160
#define ast_channel_trylock(chan)
Definition: channel.h:2468
union ast_frame::@172 data
int ast_raw_answer ( struct ast_channel chan,
int  cdr_answer 
)

Answer a channel.

Parameters
chanchannel to answer
cdr_answerflag to control whether any associated CDR should be marked as 'answered'

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

References ast_channel::_state, ast_channel_tech::answer, ast_cdr_answer(), AST_CEL_ANSWER, ast_cel_report_event(), ast_channel_lock, ast_channel_unlock, ast_check_hangup(), AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, ast_indicate(), ast_setstate(), AST_STATE_RING, AST_STATE_RINGING, AST_STATE_UP, ast_test_flag, ast_channel::cdr, and ast_channel::tech.

Referenced by __ast_answer(), and ast_bridge_call().

2931 {
2932  int res = 0;
2933 
2934  ast_channel_lock(chan);
2935 
2936  /* You can't answer an outbound call */
2937  if (ast_test_flag(chan, AST_FLAG_OUTGOING)) {
2938  ast_channel_unlock(chan);
2939  return 0;
2940  }
2941 
2942  /* Stop if we're a zombie or need a soft hangup */
2943  if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
2944  ast_channel_unlock(chan);
2945  return -1;
2946  }
2947 
2948  ast_channel_unlock(chan);
2949 
2950  switch (chan->_state) {
2951  case AST_STATE_RINGING:
2952  case AST_STATE_RING:
2953  ast_channel_lock(chan);
2954  if (chan->tech->answer) {
2955  res = chan->tech->answer(chan);
2956  }
2957  ast_setstate(chan, AST_STATE_UP);
2958  if (cdr_answer) {
2959  ast_cdr_answer(chan->cdr);
2960  }
2961  ast_cel_report_event(chan, AST_CEL_ANSWER, NULL, NULL, NULL);
2962  ast_channel_unlock(chan);
2963  break;
2964  case AST_STATE_UP:
2965  ast_cel_report_event(chan, AST_CEL_ANSWER, NULL, NULL, NULL);
2966  /* Calling ast_cdr_answer when it it has previously been called
2967  * is essentially a no-op, so it is safe.
2968  */
2969  if (cdr_answer) {
2970  ast_cdr_answer(chan->cdr);
2971  }
2972  break;
2973  default:
2974  break;
2975  }
2976 
2977  ast_indicate(chan, -1);
2978 
2979  return res;
2980 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define ast_test_flag(p, flag)
Definition: utils.h:63
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4393
int ast_cel_report_event(struct ast_channel *chan, enum ast_cel_event_type event_type, const char *userdefevname, const char *extra, struct ast_channel *peer2)
Report a channel event.
Definition: cel.c:645
struct ast_cdr * cdr
Definition: channel.h:766
int(*const answer)(struct ast_channel *chan)
Answer the channel.
Definition: channel.h:548
void ast_cdr_answer(struct ast_cdr *cdr)
Answer a call.
Definition: cdr.c:737
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
enum ast_channel_state _state
Definition: channel.h:839
#define ast_channel_unlock(chan)
Definition: channel.h:2467
A ringing phone is answered.
Definition: cel.h:56
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Definition: channel.c:7119
struct ast_channel_tech * tech
Definition: channel.h:743
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.

Definition at line 4383 of file channel.c.

References __ast_read().

Referenced by __adsi_transmit_messages(), __analog_ss_thread(), __ast_answer(), __ast_play_and_record(), __ast_request_and_dial(), adsi_careful_send(), agent_ack_sleep(), agent_read(), analog_ss_thread(), ast_bridge_handle_trip(), ast_generic_bridge(), ast_recvtext(), ast_safe_sleep_conditional(), ast_tonepair(), ast_transfer(), ast_udptl_bridge(), ast_waitfordigit_full(), async_agi_read_frame(), async_wait(), autoservice_run(), background_detect_exec(), channel_spy(), conf_flush(), conf_run(), dahdi_accept_r2_call_exec(), dahdi_bridge(), dial_exec_full(), dictate_exec(), disa_exec(), disable_t38(), do_idle_thread(), do_waiting(), echo_exec(), eivr_comm(), feature_request_and_dial(), find_cache(), generic_fax_exec(), handle_recordfile(), handle_speechrecognize(), iax2_bridge(), ices_exec(), isAnsweringMachine(), jack_exec(), local_bridge_loop(), manage_parked_call(), measurenoise(), misdn_bridge(), monitor_dial(), mp3_exec(), NBScat_exec(), receive_dtmf_digits(), receivefax_t38_init(), record_exec(), recordthread(), remote_bridge_loop(), run_agi(), send_tone_burst(), send_waveform_to_channel(), sendfax_t38_init(), sendurl_exec(), speech_background(), transmit_audio(), transmit_t38(), wait_for_answer(), wait_for_hangup(), wait_for_winner(), waitforring_exec(), and waitstream_core().

4384 {
4385  return __ast_read(chan, 0);
4386 }
static struct ast_frame * __ast_read(struct ast_channel *chan, int dropaudio)
Definition: channel.c:3836
static void ast_read_generator_actions ( struct ast_channel chan,
struct ast_frame f 
)
static

Definition at line 3722 of file channel.c.

References ast_channel_lock, ast_channel_unlock, ast_deactivate_generator(), ast_debug, ast_format_rate(), AST_FRAME_VOICE, ast_frame_subclass::codec, ast_frame::datalen, ast_frame::frametype, ast_generator::generate, generator, ast_channel::generator, ast_channel::generatordata, ast_frame::samples, ast_frame::subclass, ast_channel::timingfunc, and ast_channel::writeformat.

Referenced by __ast_read().

3723 {
3724  struct ast_generator *generator;
3725  void *gendata;
3726  int res;
3727  int samples;
3728 
3729  generator = chan->generator;
3730  if (!generator
3731  || !generator->generate
3732  || f->frametype != AST_FRAME_VOICE
3733  || !chan->generatordata
3734  || chan->timingfunc) {
3735  return;
3736  }
3737 
3738  /*
3739  * We must generate frames in phase locked mode since
3740  * we have no internal timer available.
3741  */
3742 
3743  if (f->subclass.codec != chan->writeformat) {
3744  float factor;
3745 
3746  factor = ((float) ast_format_rate(chan->writeformat)) / ((float) ast_format_rate(f->subclass.codec));
3747  samples = (int) (((float) f->samples) * factor);
3748  } else {
3749  samples = f->samples;
3750  }
3751 
3752  gendata = chan->generatordata;
3753  chan->generatordata = NULL; /* reset, to let writes go through */
3754 
3755  /*
3756  * This unlock is here based on two assumptions that hold true at
3757  * this point in the code. 1) this function is only called from
3758  * within __ast_read() and 2) all generators call ast_write() in
3759  * their generate callback.
3760  *
3761  * The reason this is added is so that when ast_write is called,
3762  * the lock that occurs there will not recursively lock the
3763  * channel. Doing this will allow deadlock avoidance to work in
3764  * deeper functions.
3765  */
3766  ast_channel_unlock(chan);
3767  res = generator->generate(chan, gendata, f->datalen, samples);
3768  ast_channel_lock(chan);
3769  if (generator == chan->generator) {
3770  chan->generatordata = gendata;
3771  if (res) {
3772  ast_debug(1, "Auto-deactivating generator\n");
3774  }
3775  }
3776 }
union ast_frame_subclass subclass
Definition: frame.h:146
#define ast_channel_lock(chan)
Definition: channel.h:2466
format_t writeformat
Definition: channel.h:854
struct ast_generator * generator
Definition: channel.h:747
static force_inline int ast_format_rate(format_t format)
Get the sample rate for a given format.
Definition: frame.h:809
format_t codec
Definition: frame.h:137
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
int datalen
Definition: frame.h:148
int(* timingfunc)(const void *data)
Definition: channel.h:759
static struct ast_generator generator
Definition: app_fax.c:361
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int(* generate)(struct ast_channel *chan, void *data, int len, int samples)
Definition: channel.h:186
void ast_deactivate_generator(struct ast_channel *chan)
Definition: channel.c:3107
enum ast_frame_type frametype
Definition: frame.h:144
void * generatordata
Definition: channel.h:746
int samples
Definition: frame.h:150
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 4388 of file channel.c.

References __ast_read().

Referenced by ast_bridge_handle_trip(), and conf_run().

4389 {
4390  return __ast_read(chan, 1);
4391 }
static struct ast_frame * __ast_read(struct ast_channel *chan, int dropaudio)
Definition: channel.c:3836
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 5837 of file channel.c.

References ast_readstring_full().

Referenced by __adsi_transmit_messages(), adsi_begin_download(), adsi_get_cpeinfo(), adsi_load_session(), ast_app_getdata(), dialout(), do_directory(), forward_message(), privacy_exec(), vm_authenticate(), vm_newuser(), and vm_options().

5838 {
5839  return ast_readstring_full(c, s, len, timeout, ftimeout, enders, -1, -1);
5840 }
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders, int audiofd, int ctrlfd)
Definition: channel.c:5842
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 5842 of file channel.c.

References ast_channel_start_silence_generator(), ast_channel_stop_silence_generator(), 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(), and ast_channel::stream.

Referenced by ast_app_getdata_full(), and ast_readstring().

5843 {
5844  int pos = 0; /* index in the buffer where we accumulate digits */
5845  int to = ftimeout;
5846 
5847  struct ast_silence_generator *silgen = NULL;
5848 
5849  /* Stop if we're a zombie or need a soft hangup */
5851  return -1;
5852  if (!len)
5853  return -1;
5854  for (;;) {
5855  int d;
5856  if (c->stream) {
5857  d = ast_waitstream_full(c, AST_DIGIT_ANY, audiofd, ctrlfd);
5858  ast_stopstream(c);
5859  if (!silgen && ast_opt_transmit_silence)
5861  usleep(1000);
5862  if (!d)
5863  d = ast_waitfordigit_full(c, to, audiofd, ctrlfd);
5864  } else {
5865  if (!silgen && ast_opt_transmit_silence)
5867  d = ast_waitfordigit_full(c, to, audiofd, ctrlfd);
5868  }
5869  if (d < 0) {
5871  return AST_GETDATA_FAILED;
5872  }
5873  if (d == 0) {
5874  s[pos] = '\0';
5876  return AST_GETDATA_TIMEOUT;
5877  }
5878  if (d == 1) {
5879  s[pos] = '\0';
5881  return AST_GETDATA_INTERRUPTED;
5882  }
5883  if (strchr(enders, d) && (pos == 0)) {
5884  s[pos] = '\0';
5887  }
5888  if (!strchr(enders, d)) {
5889  s[pos++] = d;
5890  }
5891  if (strchr(enders, d) || (pos >= len)) {
5892  s[pos] = '\0';
5894  return AST_GETDATA_COMPLETE;
5895  }
5896  to = timeout;
5897  }
5898  /* Never reached */
5899  return 0;
5900 }
#define AST_DIGIT_ANY
Definition: file.h:47
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define ast_opt_transmit_silence
Definition: options.h:120
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
Definition: channel.c:8309
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
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:8355
int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int ctrlfd)
Wait for a digit Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to mon...
Definition: channel.c:3616
int ast_waitstream_full(struct ast_channel *c, const char *breakon, int audiofd, int monfd)
Definition: file.c:1348
struct ast_filestream * stream
Definition: channel.h:757
int ast_stopstream(struct ast_channel *c)
Stops a stream.
Definition: file.c:128
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 4642 of file channel.c.

References ast_free, and ast_recvtext().

Referenced by handle_recvchar().

4643 {
4644  int c;
4645  char *buf = ast_recvtext(chan, timeout);
4646  if (buf == NULL)
4647  return -1; /* error or timeout */
4648  c = *(unsigned char *)buf;
4649  ast_free(buf);
4650  return c;
4651 }
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:4653
#define ast_free(a)
Definition: astmm.h:97
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 4653 of file channel.c.

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

Referenced by ast_recvchar(), and handle_recvtext().

4654 {
4655  int res;
4656  char *buf = NULL;
4657  struct timeval start = ast_tvnow();
4658  int ms;
4659 
4660  while ((ms = ast_remaining_ms(start, timeout))) {
4661  struct ast_frame *f;
4662 
4663  if (ast_check_hangup(chan)) {
4664  break;
4665  }
4666  res = ast_waitfor(chan, ms);
4667  if (res <= 0) {/* timeout or error */
4668  break;
4669  }
4670  f = ast_read(chan);
4671  if (f == NULL) {
4672  break; /* no frame */
4673  }
4675  ast_frfree(f);
4676  break;
4677  } else if (f->frametype == AST_FRAME_TEXT) { /* what we want */
4678  buf = ast_strndup((char *) f->data.ptr, f->datalen); /* dup and break */
4679  ast_frfree(f);
4680  break;
4681  }
4682  ast_frfree(f);
4683  }
4684  return buf;
4685 }
union ast_frame_subclass subclass
Definition: frame.h:146
void * ptr
Definition: frame.h:160
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4383
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
int datalen
Definition: frame.h:148
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
Definition: utils.c:1615
static struct ast_format f[]
Definition: format_g726.c:181
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3539
Data structure associated with a single frame of data.
Definition: frame.h:142
enum ast_frame_type frametype
Definition: frame.h:144
#define ast_frfree(fr)
Definition: frame.h:583
union ast_frame::@172 data
#define ast_strndup(a, b)
Definition: astmm.h:115
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 9161 of file channel.c.

References ast_log(), AST_REDIRECTING_COUNT, AST_REDIRECTING_FROM_ID_PRESENTATION, AST_REDIRECTING_FROM_NAME, AST_REDIRECTING_FROM_NAME_CHAR_SET, AST_REDIRECTING_FROM_NAME_PRESENTATION, AST_REDIRECTING_FROM_NAME_VALID, AST_REDIRECTING_FROM_NUMBER, AST_REDIRECTING_FROM_NUMBER_PLAN, AST_REDIRECTING_FROM_NUMBER_PRESENTATION, AST_REDIRECTING_FROM_NUMBER_VALID, AST_REDIRECTING_FROM_SUBADDRESS, AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_FROM_SUBADDRESS_TYPE, AST_REDIRECTING_FROM_SUBADDRESS_VALID, AST_REDIRECTING_FROM_TAG, AST_REDIRECTING_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::count, ast_party_redirecting::from, ast_set_party_redirecting::from, LOG_WARNING, ast_party_id_ies::name, party_id_build_data(), ast_party_redirecting::reason, ast_party_name_ies::str, ast_party_redirecting::to, ast_set_party_redirecting::to, and value.

Referenced by ast_channel_queue_redirecting_update(), ast_channel_update_redirecting(), and local_indicate().

9162 {
9163  int32_t value;
9164  size_t pos = 0;
9165  int res;
9166 
9167  static const struct ast_party_id_ies from_ies = {
9169  .name.char_set = AST_REDIRECTING_FROM_NAME_CHAR_SET,
9170  .name.presentation = AST_REDIRECTING_FROM_NAME_PRESENTATION,
9171  .name.valid = AST_REDIRECTING_FROM_NAME_VALID,
9172 
9173  .number.str = AST_REDIRECTING_FROM_NUMBER,
9174  .number.plan = AST_REDIRECTING_FROM_NUMBER_PLAN,
9175  .number.presentation = AST_REDIRECTING_FROM_NUMBER_PRESENTATION,
9176  .number.valid = AST_REDIRECTING_FROM_NUMBER_VALID,
9177 
9178  .subaddress.str = AST_REDIRECTING_FROM_SUBADDRESS,
9179  .subaddress.type = AST_REDIRECTING_FROM_SUBADDRESS_TYPE,
9180  .subaddress.odd_even_indicator = AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN,
9181  .subaddress.valid = AST_REDIRECTING_FROM_SUBADDRESS_VALID,
9182 
9183  .tag = AST_REDIRECTING_FROM_TAG,
9184  .combined_presentation = AST_REDIRECTING_FROM_ID_PRESENTATION,
9185  };
9186  static const struct ast_party_id_ies to_ies = {
9188  .name.char_set = AST_REDIRECTING_TO_NAME_CHAR_SET,
9189  .name.presentation = AST_REDIRECTING_TO_NAME_PRESENTATION,
9190  .name.valid = AST_REDIRECTING_TO_NAME_VALID,
9191 
9192  .number.str = AST_REDIRECTING_TO_NUMBER,
9193  .number.plan = AST_REDIRECTING_TO_NUMBER_PLAN,
9194  .number.presentation = AST_REDIRECTING_TO_NUMBER_PRESENTATION,
9195  .number.valid = AST_REDIRECTING_TO_NUMBER_VALID,
9196 
9197  .subaddress.str = AST_REDIRECTING_TO_SUBADDRESS,
9198  .subaddress.type = AST_REDIRECTING_TO_SUBADDRESS_TYPE,
9199  .subaddress.odd_even_indicator = AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN,
9200  .subaddress.valid = AST_REDIRECTING_TO_SUBADDRESS_VALID,
9201 
9202  .tag = AST_REDIRECTING_TO_TAG,
9203  .combined_presentation = AST_REDIRECTING_TO_ID_PRESENTATION,
9204  };
9205 
9206  /* Redirecting frame version */
9207  if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
9208  ast_log(LOG_WARNING, "No space left for redirecting frame version\n");
9209  return -1;
9210  }
9211  data[pos++] = AST_REDIRECTING_VERSION;
9212  data[pos++] = 1;
9213  data[pos++] = 2;/* Version 1 did not have a version ie */
9214 
9215  res = party_id_build_data(data + pos, datalen - pos, &redirecting->from,
9216  "redirecting-from", &from_ies, update ? &update->from : NULL);
9217  if (res < 0) {
9218  return -1;
9219  }
9220  pos += res;
9221 
9222  res = party_id_build_data(data + pos, datalen - pos, &redirecting->to,
9223  "redirecting-to", &to_ies, update ? &update->to : NULL);
9224  if (res < 0) {
9225  return -1;
9226  }
9227  pos += res;
9228 
9229  /* Redirecting reason */
9230  if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) {
9231  ast_log(LOG_WARNING, "No space left for redirecting reason\n");
9232  return -1;
9233  }
9234  data[pos++] = AST_REDIRECTING_REASON;
9235  data[pos++] = sizeof(value);
9236  value = htonl(redirecting->reason);
9237  memcpy(data + pos, &value, sizeof(value));
9238  pos += sizeof(value);
9239 
9240  /* Redirecting count */
9241  if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) {
9242  ast_log(LOG_WARNING, "No space left for redirecting count\n");
9243  return -1;
9244  }
9245  data[pos++] = AST_REDIRECTING_COUNT;
9246  data[pos++] = sizeof(value);
9247  value = htonl(redirecting->count);
9248  memcpy(data + pos, &value, sizeof(value));
9249  pos += sizeof(value);
9250 
9251  return pos;
9252 }
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:449
#define LOG_WARNING
Definition: logger.h:144
int value
Definition: syslog.c:39
struct ast_party_name_ies name
Subscriber name ies.
Definition: channel.c:8696
struct ast_set_party_id from
Definition: channel.h:467
AST_REDIRECTING_REASON
redirecting reason codes.
Definition: callerid.h:390
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
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:8722
struct ast_set_party_id to
Definition: channel.h:469
int count
Number of times the call was redirected.
Definition: channel.h:455
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:452
int reason
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:458
int str
Subscriber name ie.
Definition: channel.c:8473
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 9254 of file channel.c.

References 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_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::count, ast_party_redirecting::from, LOG_DEBUG, LOG_WARNING, ast_party_id::name, ast_party_id::number, ast_party_subaddress::odd_even_indicator, ast_party_number::plan, ast_party_name::presentation, ast_party_number::presentation, ast_party_redirecting::reason, ast_party_name::str, ast_party_number::str, ast_party_subaddress::str, ast_party_id::subaddress, ast_party_id::tag, ast_party_redirecting::to, ast_party_subaddress::type, ast_party_name::valid, ast_party_number::valid, ast_party_subaddress::valid, and value.

Referenced by ast_channel_redirecting_macro(), and ast_indicate_data().

9255 {
9256  size_t pos;
9257  unsigned char ie_len;
9258  unsigned char ie_id;
9259  int32_t value;
9260  int frame_version = 1;
9261  int from_combined_presentation = 0;
9262  int got_from_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
9263  int to_combined_presentation = 0;
9264  int got_to_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */
9265 
9266  for (pos = 0; pos < datalen; pos += ie_len) {
9267  if (datalen < pos + sizeof(ie_id) + sizeof(ie_len)) {
9268  ast_log(LOG_WARNING, "Invalid redirecting update\n");
9269  return -1;
9270  }
9271  ie_id = data[pos++];
9272  ie_len = data[pos++];
9273  if (datalen < pos + ie_len) {
9274  ast_log(LOG_WARNING, "Invalid redirecting update\n");
9275  return -1;
9276  }
9277 
9278  switch (ie_id) {
9279 /* Redirecting frame version */
9281  if (ie_len != 1) {
9282  ast_log(LOG_WARNING, "Invalid redirecting frame version (%u)\n",
9283  (unsigned) ie_len);
9284  break;
9285  }
9286  frame_version = data[pos];
9287  break;
9288 /* Redirecting-from party id name */
9290  ast_free(redirecting->from.name.str);
9291  redirecting->from.name.str = ast_malloc(ie_len + 1);
9292  if (redirecting->from.name.str) {
9293  memcpy(redirecting->from.name.str, data + pos, ie_len);
9294  redirecting->from.name.str[ie_len] = 0;
9295  }
9296  break;
9298  if (ie_len != 1) {
9299  ast_log(LOG_WARNING, "Invalid redirecting-from name char set (%u)\n",
9300  (unsigned) ie_len);
9301  break;
9302  }
9303  redirecting->from.name.char_set = data[pos];
9304  break;
9306  if (ie_len != 1) {
9307  ast_log(LOG_WARNING, "Invalid redirecting-from name presentation (%u)\n",
9308  (unsigned) ie_len);
9309  break;
9310  }
9311  redirecting->from.name.presentation = data[pos];
9312  break;
9314  if (ie_len != 1) {
9315  ast_log(LOG_WARNING, "Invalid redirecting-from name valid (%u)\n",
9316  (unsigned) ie_len);
9317  break;
9318  }
9319  redirecting->from.name.valid = data[pos];
9320  break;
9321 /* Redirecting-from party id number */
9323  ast_free(redirecting->from.number.str);
9324  redirecting->from.number.str = ast_malloc(ie_len + 1);
9325  if (redirecting->from.number.str) {
9326  memcpy(redirecting->from.number.str, data + pos, ie_len);
9327  redirecting->from.number.str[ie_len] = 0;
9328  }
9329  break;
9331  if (ie_len != 1) {
9332  ast_log(LOG_WARNING, "Invalid redirecting-from numbering plan (%u)\n",
9333  (unsigned) ie_len);
9334  break;
9335  }
9336  redirecting->from.number.plan = data[pos];
9337  break;
9339  if (ie_len != 1) {
9340  ast_log(LOG_WARNING, "Invalid redirecting-from number presentation (%u)\n",
9341  (unsigned) ie_len);
9342  break;
9343  }
9344  redirecting->from.number.presentation = data[pos];
9345  break;
9347  if (ie_len != 1) {
9348  ast_log(LOG_WARNING, "Invalid redirecting-from number valid (%u)\n",
9349  (unsigned) ie_len);
9350  break;
9351  }
9352  redirecting->from.number.valid = data[pos];
9353  break;
9354 /* Redirecting-from party id combined presentation */
9356  if (ie_len != 1) {
9357  ast_log(LOG_WARNING, "Invalid redirecting-from combined presentation (%u)\n",
9358  (unsigned) ie_len);
9359  break;
9360  }
9361  from_combined_presentation = data[pos];
9362  got_from_combined_presentation = 1;
9363  break;
9364 /* Redirecting-from party id subaddress */
9366  ast_free(redirecting->from.subaddress.str);
9367  redirecting->from.subaddress.str = ast_malloc(ie_len + 1);
9368  if (redirecting->from.subaddress.str) {
9369  memcpy(redirecting->from.subaddress.str, data + pos, ie_len);
9370  redirecting->from.subaddress.str[ie_len] = 0;
9371  }
9372  break;
9374  if (ie_len != 1) {
9375  ast_log(LOG_WARNING, "Invalid redirecting-from type of subaddress (%u)\n",
9376  (unsigned) ie_len);
9377  break;
9378  }
9379  redirecting->from.subaddress.type = data[pos];
9380  break;
9382  if (ie_len != 1) {
9384  "Invalid redirecting-from subaddress odd-even indicator (%u)\n",
9385  (unsigned) ie_len);
9386  break;
9387  }
9388  redirecting->from.subaddress.odd_even_indicator = data[pos];
9389  break;
9391  if (ie_len != 1) {
9392  ast_log(LOG_WARNING, "Invalid redirecting-from subaddress valid (%u)\n",
9393  (unsigned) ie_len);
9394  break;
9395  }
9396  redirecting->from.subaddress.valid = data[pos];
9397  break;
9398 /* Redirecting-from party id tag */
9400  ast_free(redirecting->from.tag);
9401  redirecting->from.tag = ast_malloc(ie_len + 1);
9402  if (redirecting->from.tag) {
9403  memcpy(redirecting->from.tag, data + pos, ie_len);
9404  redirecting->from.tag[ie_len] = 0;
9405  }
9406  break;
9407 /* Redirecting-to party id name */
9409  ast_free(redirecting->to.name.str);
9410  redirecting->to.name.str = ast_malloc(ie_len + 1);
9411  if (redirecting->to.name.str) {
9412  memcpy(redirecting->to.name.str, data + pos, ie_len);
9413  redirecting->to.name.str[ie_len] = 0;
9414  }
9415  break;
9417  if (ie_len != 1) {
9418  ast_log(LOG_WARNING, "Invalid redirecting-to name char set (%u)\n",
9419  (unsigned) ie_len);
9420  break;
9421  }
9422  redirecting->to.name.char_set = data[pos];
9423  break;
9425  if (ie_len != 1) {
9426  ast_log(LOG_WARNING, "Invalid redirecting-to name presentation (%u)\n",
9427  (unsigned) ie_len);
9428  break;
9429  }
9430  redirecting->to.name.presentation = data[pos];
9431  break;
9433  if (ie_len != 1) {
9434  ast_log(LOG_WARNING, "Invalid redirecting-to name valid (%u)\n",
9435  (unsigned) ie_len);
9436  break;
9437  }
9438  redirecting->to.name.valid = data[pos];
9439  break;
9440 /* Redirecting-to party id number */
9442  ast_free(redirecting->to.number.str);
9443  redirecting->to.number.str = ast_malloc(ie_len + 1);
9444  if (redirecting->to.number.str) {
9445  memcpy(redirecting->to.number.str, data + pos, ie_len);
9446  redirecting->to.number.str[ie_len] = 0;
9447  }
9448  break;
9450  if (ie_len != 1) {
9451  ast_log(LOG_WARNING, "Invalid redirecting-to numbering plan (%u)\n",
9452  (unsigned) ie_len);
9453  break;
9454  }
9455  redirecting->to.number.plan = data[pos];
9456  break;
9458  if (ie_len != 1) {
9459  ast_log(LOG_WARNING, "Invalid redirecting-to number presentation (%u)\n",
9460  (unsigned) ie_len);
9461  break;
9462  }
9463  redirecting->to.number.presentation = data[pos];
9464  break;
9466  if (ie_len != 1) {
9467  ast_log(LOG_WARNING, "Invalid redirecting-to number valid (%u)\n",
9468  (unsigned) ie_len);
9469  break;
9470  }
9471  redirecting->to.number.valid = data[pos];
9472  break;
9473 /* Redirecting-to party id combined presentation */
9475  if (ie_len != 1) {
9476  ast_log(LOG_WARNING, "Invalid redirecting-to combined presentation (%u)\n",
9477  (unsigned) ie_len);
9478  break;
9479  }
9480  to_combined_presentation = data[pos];
9481  got_to_combined_presentation = 1;
9482  break;
9483 /* Redirecting-to party id subaddress */
9485  ast_free(redirecting->to.subaddress.str);
9486  redirecting->to.subaddress.str = ast_malloc(ie_len + 1);
9487  if (redirecting->to.subaddress.str) {
9488  memcpy(redirecting->to.subaddress.str, data + pos, ie_len);
9489  redirecting->to.subaddress.str[ie_len] = 0;
9490  }
9491  break;
9493  if (ie_len != 1) {
9494  ast_log(LOG_WARNING, "Invalid redirecting-to type of subaddress (%u)\n",
9495  (unsigned) ie_len);
9496  break;
9497  }
9498  redirecting->to.subaddress.type = data[pos];
9499  break;
9501  if (ie_len != 1) {
9503  "Invalid redirecting-to subaddress odd-even indicator (%u)\n",
9504  (unsigned) ie_len);
9505  break;
9506  }
9507  redirecting->to.subaddress.odd_even_indicator = data[pos];
9508  break;
9510  if (ie_len != 1) {
9511  ast_log(LOG_WARNING, "Invalid redirecting-to subaddress valid (%u)\n",
9512  (unsigned) ie_len);
9513  break;
9514  }
9515  redirecting->to.subaddress.valid = data[pos];
9516  break;
9517 /* Redirecting-to party id tag */
9519  ast_free(redirecting->to.tag);
9520  redirecting->to.tag = ast_malloc(ie_len + 1);
9521  if (redirecting->to.tag) {
9522  memcpy(redirecting->to.tag, data + pos, ie_len);
9523  redirecting->to.tag[ie_len] = 0;
9524  }
9525  break;
9526 /* Redirecting reason */
9528  if (ie_len != sizeof(value)) {
9529  ast_log(LOG_WARNING, "Invalid redirecting reason (%u)\n",
9530  (unsigned) ie_len);
9531  break;
9532  }
9533  memcpy(&value, data + pos, sizeof(value));
9534  redirecting->reason = ntohl(value);
9535  break;
9536 /* Redirecting count */
9537  case AST_REDIRECTING_COUNT:
9538  if (ie_len != sizeof(value)) {
9539  ast_log(LOG_WARNING, "Invalid redirecting count (%u)\n",
9540  (unsigned) ie_len);
9541  break;
9542  }
9543  memcpy(&value, data + pos, sizeof(value));
9544  redirecting->count = ntohl(value);
9545  break;
9546 /* Redirecting unknown element */
9547  default:
9548  ast_log(LOG_DEBUG, "Unknown redirecting element: %u (%u)\n",
9549  (unsigned) ie_id, (unsigned) ie_len);
9550  break;
9551  }
9552  }
9553 
9554  switch (frame_version) {
9555  case 1:
9556  /*
9557  * The other end is an earlier version that we need to adjust
9558  * for compatibility.
9559  */
9560  redirecting->from.name.valid = 1;
9562  redirecting->from.number.valid = 1;
9563  if (got_from_combined_presentation) {
9564  redirecting->from.name.presentation = from_combined_presentation;
9565  redirecting->from.number.presentation = from_combined_presentation;
9566  }
9567 
9568  redirecting->to.name.valid = 1;
9570  redirecting->to.number.valid = 1;
9571  if (got_to_combined_presentation) {
9572  redirecting->to.name.presentation = to_combined_presentation;
9573  redirecting->to.number.presentation = to_combined_presentation;
9574  }
9575  break;
9576  case 2:
9577  /* The other end is at the same level as we are. */
9578  break;
9579  default:
9580  /*
9581  * The other end is newer than we are.
9582  * We need to assume that they are compatible with us.
9583  */
9584  ast_log(LOG_DEBUG, "Redirecting frame has newer version: %u\n",
9585  (unsigned) frame_version);
9586  break;
9587  }
9588 
9589  return 0;
9590 }
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:227
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:245
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:449
#define LOG_WARNING
Definition: logger.h:144
int char_set
Character set the name is using.
Definition: channel.h:222
char * str
Subscriber name (Malloced)
Definition: channel.h:214
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:278
char * str
Malloced subaddress string.
Definition: channel.h:263
int value
Definition: syslog.c:39
#define LOG_DEBUG
Definition: logger.h:122
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:276
AST_REDIRECTING_REASON
redirecting reason codes.
Definition: callerid.h:390
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:294
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:243
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_free(a)
Definition: astmm.h:97
char * tag
User-set &quot;tag&quot;.
Definition: channel.h:304
int type
Q.931 subaddress type.
Definition: channel.h:270
int count
Number of times the call was redirected.
Definition: channel.h:455
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:452
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
int reason
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:458
#define ast_malloc(a)
Definition: astmm.h:91
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
struct ast_channel* ast_request ( const char *  type,
format_t  format,
const struct ast_channel requestor,
void *  data,
int *  status 
)

Requests a channel.

Parameters
typetype of channel to request
formatrequested channel format (codec)
requestorchannel asking for data
datadata to pass to the channel requester (Should be treated as const char *)
statusstatus

Request a channel of a given type, with data as optional information used by the low level module

Return values
NULLfailure
non-NULLchannel on success

Definition at line 5695 of file channel.c.

References AST_CAUSE_BEARERCAPABILITY_NOTAVAIL, AST_CAUSE_NOSUCHDRIVER, AST_CAUSE_NOTDEFINED, ast_channel_release(), AST_FORMAT_AUDIO_MASK, AST_FORMAT_TEXT_MASK, AST_FORMAT_VIDEO_MASK, ast_getformatname_multiple(), ast_log(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_translator_best_choice(), capabilities, ast_channel_tech::capabilities, chanlist::chan, LOG_WARNING, ast_channel_tech::requester, set_security_requirements(), chanlist::tech, and ast_channel_tech::type.

Referenced by __ast_request_and_dial(), ast_call_forward(), begin_dial_channel(), build_conf(), chanavail_exec(), conf_run(), dial_exec_full(), dial_transfer(), do_forward(), feature_request_and_dial(), findmeexec(), meetme_menu_admin_extended(), play_sound_file(), ring_entry(), and wait_for_answer().

5696 {
5697  struct chanlist *chan;
5698  struct ast_channel *c;
5700  format_t fmt;
5701  int res;
5702  int foo;
5703  format_t videoformat = format & AST_FORMAT_VIDEO_MASK;
5704  format_t textformat = format & AST_FORMAT_TEXT_MASK;
5705 
5706  if (!cause)
5707  cause = &foo;
5708  *cause = AST_CAUSE_NOTDEFINED;
5709 
5710  if (AST_RWLIST_RDLOCK(&backends)) {
5711  ast_log(LOG_WARNING, "Unable to lock technology backend list\n");
5712  return NULL;
5713  }
5714 
5715  AST_RWLIST_TRAVERSE(&backends, chan, list) {
5716  if (strcasecmp(type, chan->tech->type))
5717  continue;
5718 
5719  capabilities = chan->tech->capabilities;
5720  fmt = format & AST_FORMAT_AUDIO_MASK;
5721  if (fmt) {
5722  /* We have audio - is it possible to connect the various calls to each other?
5723  (Avoid this check for calls without audio, like text+video calls)
5724  */
5725  res = ast_translator_best_choice(&fmt, &capabilities);
5726  if (res < 0) {
5727  char tmp1[256], tmp2[256];
5728  ast_log(LOG_WARNING, "No translator path exists for channel type %s (native %s) to %s\n", type,
5729  ast_getformatname_multiple(tmp1, sizeof(tmp1), chan->tech->capabilities),
5730  ast_getformatname_multiple(tmp2, sizeof(tmp2), format));
5733  return NULL;
5734  }
5735  }
5737  if (!chan->tech->requester)
5738  return NULL;
5739 
5740  if (!(c = chan->tech->requester(type, capabilities | videoformat | textformat, requestor, data, cause)))
5741  return NULL;
5742 
5743  if (set_security_requirements(requestor, c)) {
5744  ast_log(LOG_WARNING, "Setting security requirements failed\n");
5745  c = ast_channel_release(c);
5747  return NULL;
5748  }
5749 
5750  /* no need to generate a Newchannel event here; it is done in the channel_alloc call */
5751  return c;
5752  }
5753 
5754  ast_log(LOG_WARNING, "No channel type registered for '%s'\n", type);
5755  *cause = AST_CAUSE_NOSUCHDRIVER;
5757 
5758  return NULL;
5759 }
Main Channel structure associated with a channel.
Definition: channel.h:742
const char *const type
Definition: channel.h:508
struct ast_channel *(*const requester)(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
Requester - to set up call data structures (pvt&#39;s)
Definition: channel.h:519
format_t capabilities
Definition: channel.h:511
#define AST_CAUSE_NOSUCHDRIVER
Definition: causes.h:155
struct ast_channel * ast_channel_release(struct ast_channel *chan)
Unlink and release reference to a channel.
Definition: channel.c:1921
#define LOG_WARNING
Definition: logger.h:144
static struct aji_capabilities * capabilities
Definition: res_jabber.c:393
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
const char * data
Definition: channel.h:755
the list of registered channel types
Definition: channel.c:143
static int set_security_requirements(const struct ast_channel *requestor, struct ast_channel *out)
Definition: channel.c:5655
struct ast_channel_tech * tech
Definition: channel.c:122
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
struct ast_channel * chan
Definition: app_dial.c:666
#define AST_FORMAT_TEXT_MASK
Definition: frame.h:297
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
List of channel drivers.
Definition: app_dial.c:664
#define AST_CAUSE_NOTDEFINED
Definition: causes.h:154
int64_t format_t
Definition: frame_defs.h:32
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define AST_FORMAT_VIDEO_MASK
Definition: frame.h:290
#define AST_FORMAT_AUDIO_MASK
Definition: frame.h:274
static const char type[]
Definition: chan_nbs.c:57
char * ast_getformatname_multiple(char *buf, size_t size, format_t format)
Get the names of a set of formats.
Definition: frame.c:591
#define AST_CAUSE_BEARERCAPABILITY_NOTAVAIL
Definition: causes.h:129
static snd_pcm_format_t format
Definition: chan_alsa.c:93
format_t ast_translator_best_choice(format_t *dsts, format_t *srcs)
Chooses the best translation path.
Definition: translate.c:984
struct ast_channel* ast_request_and_dial ( const char *  type,
format_t  format,
const struct ast_channel requestor,
void *  data,
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
formatrequested channel format
requestorchannel asking for data
datadata to pass to the channel requester
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 5650 of file channel.c.

References __ast_request_and_dial().

Referenced by ast_pbx_outgoing_exten(), and generic_recall().

5651 {
5652  return __ast_request_and_dial(type, format, requestor, data, timeout, outstate, cidnum, cidname, NULL);
5653 }
struct ast_channel * __ast_request_and_dial(const char *type, format_t format, const struct ast_channel *requestor, void *data, int timeout, int *reason, const char *cid_num, const char *cid_name, struct outgoing_helper *oh)
Request a channel of a given type, with data as optional information used by the low level module and...
Definition: channel.c:5456
const char * data
Definition: channel.h:755
static const char type[]
Definition: chan_nbs.c:57
static snd_pcm_format_t format
Definition: chan_alsa.c:93
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 1916 of file channel.c.

References ast_safe_sleep_conditional().

Referenced by __analog_ss_thread(), adsi_transmit_message_full(), alarmreceiver_exec(), analog_ss_thread(), ast_dtmf_stream(), ast_senddigit(), builtin_atxfer(), builtin_parkcall(), conf_run(), dahdi_send_callrerouting_facility_exec(), dial_trunk(), dictate_exec(), disa_exec(), flash_exec(), handle_callforward_button(), login_exec(), mgcp_ss(), milliwatt_exec(), misdn_check_l2l1(), old_milliwatt_exec(), park_call_exec(), pbx_builtin_wait(), play_moh_exec(), playtone(), privacy_exec(), receive_ademco_contact_id(), skinny_ss(), testclient_exec(), testserver_exec(), try_calling(), wait_for_hangup(), wait_moh_exec(), waituntil_exec(), and zapateller_exec().

1917 {
1918  return ast_safe_sleep_conditional(chan, ms, NULL, NULL);
1919 }
int ast_safe_sleep_conditional(struct ast_channel *chan, int ms, int(*cond)(void *), void *data)
Wait for a specified amount of time, looking for hangups and a condition argument.
Definition: channel.c:1845
int ast_safe_sleep_conditional ( struct ast_channel chan,
int  timeout_ms,
int(*)(void *)  cond,
void *  data 
)

Wait, look for hangups and condition arg.

Wait for a specified amount of time, looking for hangups and a condition argument.

Definition at line 1845 of file channel.c.

References 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, f, and ast_channel::generatordata.

Referenced by ast_safe_sleep(), and login_exec().

1846 {
1847  struct ast_frame *f;
1848  struct ast_silence_generator *silgen = NULL;
1849  int res = 0;
1850  struct timeval start;
1851  int ms;
1852  AST_LIST_HEAD_NOLOCK(, ast_frame) deferred_frames;
1853 
1854  AST_LIST_HEAD_INIT_NOLOCK(&deferred_frames);
1855 
1856  /* If no other generator is present, start silencegen while waiting */
1857  if (ast_opt_transmit_silence && !chan->generatordata) {
1858  silgen = ast_channel_start_silence_generator(chan);
1859  }
1860 
1861  start = ast_tvnow();
1862  while ((ms = ast_remaining_ms(start, timeout_ms))) {
1863  struct ast_frame *dup_f = NULL;
1864 
1865  if (cond && ((*cond)(data) == 0)) {
1866  break;
1867  }
1868  ms = ast_waitfor(chan, ms);
1869  if (ms < 0) {
1870  res = -1;
1871  break;
1872  }
1873  if (ms > 0) {
1874  f = ast_read(chan);
1875  if (!f) {
1876  res = -1;
1877  break;
1878  }
1879 
1880  if (!ast_is_deferrable_frame(f)) {
1881  ast_frfree(f);
1882  continue;
1883  }
1884 
1885  if ((dup_f = ast_frisolate(f))) {
1886  if (dup_f != f) {
1887  ast_frfree(f);
1888  }
1889  AST_LIST_INSERT_HEAD(&deferred_frames, dup_f, frame_list);
1890  }
1891  }
1892  }
1893 
1894  /* stop silgen if present */
1895  if (silgen) {
1896  ast_channel_stop_silence_generator(chan, silgen);
1897  }
1898 
1899  /* We need to free all the deferred frames, but we only need to
1900  * queue the deferred frames if there was no error and no
1901  * hangup was received
1902  */
1903  ast_channel_lock(chan);
1904  while ((f = AST_LIST_REMOVE_HEAD(&deferred_frames, frame_list))) {
1905  if (!res) {
1906  ast_queue_frame_head(chan, f);
1907  }
1908  ast_frfree(f);
1909  }
1910  ast_channel_unlock(chan);
1911 
1912  return res;
1913 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4383
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
#define ast_opt_transmit_silence
Definition: options.h:120
struct ast_frame * ast_frisolate(struct ast_frame *fr)
Makes a frame independent of any static storage.
Definition: frame.c:391
ast_cond_t cond
Definition: app_meetme.c:963
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:818
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
Definition: channel.c:8309
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
Definition: linkedlists.h:224
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
Definition: utils.c:1615
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: linkedlists.h:696
#define ast_channel_unlock(chan)
Definition: channel.h:2467
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:8355
static struct ast_format f[]
Definition: format_g726.c:181
if(yyss+yystacksize-1<=yyssp)
Definition: ast_expr2.c:1874
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
Definition: linkedlists.h:666
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3539
int ast_is_deferrable_frame(const struct ast_frame *frame)
Should we keep this frame for later?
Definition: channel.c:1818
Data structure associated with a single frame of data.
Definition: frame.h:142
#define ast_frfree(fr)
Definition: frame.h:583
int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to the head of a channel&#39;s frame queue.
Definition: channel.c:1563
union ast_frame::@172 data
int ast_say_character_str ( struct ast_channel chan,
const char *  str,
const char *  ints,
const char *  lang 
)

Definition at line 8421 of file channel.c.

References ast_say_character_str_full.

Referenced by common_exec(), pbx_builtin_saycharacters(), play_mailbox_owner(), and vmsayname_exec().

8423 {
8424  return ast_say_character_str_full(chan, str, ints, lang, -1, -1);
8425 }
const char * str
Definition: app_jack.c:144
SAY_EXTERN int(* ast_say_character_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd) SAY_INIT(ast_say_character_str_full)
Definition: say.h:154
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 8415 of file channel.c.

References ast_say_digit_str_full.

Referenced by __analog_ss_thread(), forward_message(), invent_message(), mgcp_ss(), pbx_builtin_saydigits(), and play_message_callerid().

8417 {
8418  return ast_say_digit_str_full(chan, str, ints, lang, -1, -1);
8419 }
const char * str
Definition: app_jack.c:144
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)
Definition: say.h:140
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 8409 of file channel.c.

References ast_say_digits_full().

Referenced by common_exec(), conf_exec(), conf_run(), park_call_full(), and parkandannounce_exec().

8411 {
8412  return ast_say_digits_full(chan, num, ints, lang, -1, -1);
8413 }
int ast_say_digits_full(struct ast_channel *chan, int num, const char *ints, const char *lang, int audiofd, int ctrlfd)
Definition: channel.c:8433
int ast_say_digits_full ( struct ast_channel chan,
int  num,
const char *  ints,
const char *  lang,
int  audiofd,
int  ctrlfd 
)

Definition at line 8433 of file channel.c.

References ast_say_digit_str_full.

Referenced by ast_say_digits(), ast_say_enumeration_full_da(), ast_say_enumeration_full_de(), ast_say_number_full_cs(), ast_say_number_full_da(), ast_say_number_full_de(), ast_say_number_full_en(), ast_say_number_full_en_GB(), ast_say_number_full_es(), ast_say_number_full_fr(), ast_say_number_full_he(), ast_say_number_full_hu(), ast_say_number_full_it(), ast_say_number_full_ka(), ast_say_number_full_nl(), ast_say_number_full_no(), ast_say_number_full_pt(), ast_say_number_full_ru(), ast_say_number_full_se(), ast_say_number_full_th(), ast_say_number_full_ur(), ast_say_number_full_vi(), ast_say_number_full_zh(), and say_init_mode().

8435 {
8436  char buf[256];
8437 
8438  snprintf(buf, sizeof(buf), "%d", num);
8439 
8440  return ast_say_digit_str_full(chan, buf, ints, lang, audiofd, ctrlfd);
8441 }
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)
Definition: say.h:140
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, 'p' for plural

Vocally says an enumeration on a given channel (first, sencond, 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 8403 of file channel.c.

References ast_say_enumeration_full.

Referenced by ast_say_date_da(), ast_say_date_de(), ast_say_date_with_format_da(), ast_say_date_with_format_de(), ast_say_date_with_format_en(), ast_say_date_with_format_pl(), and ast_say_date_with_format_vi().

8405 {
8406  return ast_say_enumeration_full(chan, num, ints, language, options, -1, -1);
8407 }
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)
Definition: say.h:105
static char language[MAX_LANGUAGE]
Definition: chan_alsa.c:108
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, 'p' for plural

Vocally says a number on a given channel

Return values
0on success
DTMFdigit on interrupt
-1on failure

Definition at line 8397 of file channel.c.

References ast_say_number_full.

Referenced by announce_user_count(), ast_say_date_da(), ast_say_date_de(), ast_say_date_en(), ast_say_date_es(), ast_say_date_fr(), ast_say_date_gr(), ast_say_date_he(), ast_say_date_hu(), 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_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_pt(), ast_say_datetime_th(), ast_say_datetime_zh(), ast_say_time_de(), ast_say_time_en(), ast_say_time_es(), ast_say_time_fr(), ast_say_time_gr(), ast_say_time_hu(), 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(), bridge_playfile(), conf_run(), count_exec(), dictate_exec(), get_folder(), gr_say_number_female(), meetme_menu_admin_extended(), pbx_builtin_saynumber(), play_message(), play_message_duration(), say_and_wait(), say_position(), try_calling(), vm_intro_gr(), vm_intro_he(), vm_intro_multilang(), vm_intro_pt(), and vm_intro_pt_BR().

8399 {
8400  return ast_say_number_full(chan, num, ints, language, options, -1, -1);
8401 }
static char language[MAX_LANGUAGE]
Definition: chan_alsa.c:108
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)
Definition: say.h:86
int ast_say_phonetic_str ( struct ast_channel chan,
const char *  str,
const char *  ints,
const char *  lang 
)

Definition at line 8427 of file channel.c.

References ast_say_phonetic_str_full.

Referenced by pbx_builtin_sayphonetic().

8429 {
8430  return ast_say_phonetic_str_full(chan, str, ints, lang, -1, -1);
8431 }
const char * str
Definition: app_jack.c:144
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:159
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
Returns
0 on success, -1 on failure

Definition at line 4774 of file channel.c.

References AST_DEFAULT_EMULATE_DTMF_DURATION, ast_safe_sleep(), ast_senddigit_begin(), ast_senddigit_end(), ast_channel_tech::send_digit_begin, and ast_channel::tech.

Referenced by ast_dtmf_stream(), dial_exec_full(), and manager_play_dtmf().

4775 {
4776  if (chan->tech->send_digit_begin) {
4777  ast_senddigit_begin(chan, digit);
4779  }
4780 
4781  return ast_senddigit_end(chan, digit, (duration >= AST_DEFAULT_EMULATE_DTMF_DURATION ? duration : AST_DEFAULT_EMULATE_DTMF_DURATION));
4782 }
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
Definition: channel.c:1916
#define AST_DEFAULT_EMULATE_DTMF_DURATION
Definition: channel.c:111
int(*const send_digit_begin)(struct ast_channel *chan, char digit)
Start sending a literal DTMF digit.
Definition: channel.h:528
int ast_senddigit_begin(struct ast_channel *chan, char digit)
Send a DTMF digit to a channel.
Definition: channel.c:4705
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition: channel.c:4755
struct ast_channel_tech * tech
Definition: channel.h:743
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 4705 of file channel.c.

References ast_channel_lock, ast_channel_unlock, ast_debug, ast_playtones_start(), ast_tvnow(), ast_channel::name, ast_channel_tech::send_digit_begin, ast_channel::sending_dtmf_digit, ast_channel::sending_dtmf_tv, and ast_channel::tech.

Referenced by agent_digit_begin(), ast_senddigit(), and ast_write().

4706 {
4707  /* Device does not support DTMF tones, lets fake
4708  * it by doing our own generation. */
4709  static const char * const dtmf_tones[] = {
4710  "941+1336", /* 0 */
4711  "697+1209", /* 1 */
4712  "697+1336", /* 2 */
4713  "697+1477", /* 3 */
4714  "770+1209", /* 4 */
4715  "770+1336", /* 5 */
4716  "770+1477", /* 6 */
4717  "852+1209", /* 7 */
4718  "852+1336", /* 8 */
4719  "852+1477", /* 9 */
4720  "697+1633", /* A */
4721  "770+1633", /* B */
4722  "852+1633", /* C */
4723  "941+1633", /* D */
4724  "941+1209", /* * */
4725  "941+1477" /* # */
4726  };
4727 
4728  if (!chan->tech->send_digit_begin)
4729  return 0;
4730 
4731  ast_channel_lock(chan);
4732  chan->sending_dtmf_digit = digit;
4733  chan->sending_dtmf_tv = ast_tvnow();
4734  ast_channel_unlock(chan);
4735 
4736  if (!chan->tech->send_digit_begin(chan, digit))
4737  return 0;
4738 
4739  if (digit >= '0' && digit <='9')
4740  ast_playtones_start(chan, 0, dtmf_tones[digit-'0'], 0);
4741  else if (digit >= 'A' && digit <= 'D')
4742  ast_playtones_start(chan, 0, dtmf_tones[digit-'A'+10], 0);
4743  else if (digit == '*')
4744  ast_playtones_start(chan, 0, dtmf_tones[14], 0);
4745  else if (digit == '#')
4746  ast_playtones_start(chan, 0, dtmf_tones[15], 0);
4747  else {
4748  /* not handled */
4749  ast_debug(1, "Unable to generate DTMF tone '%c' for '%s'\n", digit, chan->name);
4750  }
4751 
4752  return 0;
4753 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
int(*const send_digit_begin)(struct ast_channel *chan, char digit)
Start sending a literal DTMF digit.
Definition: channel.h:528
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
char sending_dtmf_digit
Definition: channel.h:873
struct timeval sending_dtmf_tv
Definition: channel.h:874
const ast_string_field name
Definition: channel.h:787
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
Definition: indications.c:319
struct ast_channel_tech * tech
Definition: channel.h:743
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 4755 of file channel.c.

References ast_channel_lock, ast_channel_unlock, ast_playtones_stop(), ast_channel::generator, ast_channel_tech::send_digit_end, ast_channel::sending_dtmf_digit, and ast_channel::tech.

Referenced by agent_digit_end(), ast_bridge_end_dtmf(), ast_senddigit(), and ast_write().

4756 {
4757  int res = -1;
4758 
4759  ast_channel_lock(chan);
4760  if (chan->sending_dtmf_digit == digit) {
4761  chan->sending_dtmf_digit = 0;
4762  }
4763  ast_channel_unlock(chan);
4764 
4765  if (chan->tech->send_digit_end)
4766  res = chan->tech->send_digit_end(chan, digit, duration);
4767 
4768  if (res && chan->generator)
4769  ast_playtones_stop(chan);
4770 
4771  return 0;
4772 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
struct ast_generator * generator
Definition: channel.h:747
int(*const send_digit_end)(struct ast_channel *chan, char digit, unsigned int duration)
Stop sending a literal DTMF digit.
Definition: channel.h:535
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
Definition: indications.c:411
char sending_dtmf_digit
Definition: channel.h:873
#define ast_channel_unlock(chan)
Definition: channel.h:2467
struct ast_channel_tech * tech
Definition: channel.h:743
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 4687 of file channel.c.

References ast_channel_lock, ast_channel_unlock, ast_check_hangup(), ast_clear_flag, AST_FLAG_BLOCKING, AST_FLAG_ZOMBIE, ast_test_flag, CHECK_BLOCKING, ast_channel_tech::send_text, and ast_channel::tech.

Referenced by action_sendtext(), agent_sendtext(), handle_sendtext(), and sendtext_exec().

4688 {
4689  int res = 0;
4690 
4691  ast_channel_lock(chan);
4692  /* Stop if we're a zombie or need a soft hangup */
4693  if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
4694  ast_channel_unlock(chan);
4695  return -1;
4696  }
4697  CHECK_BLOCKING(chan);
4698  if (chan->tech->send_text)
4699  res = chan->tech->send_text(chan, text);
4701  ast_channel_unlock(chan);
4702  return res;
4703 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define ast_test_flag(p, flag)
Definition: utils.h:63
char * text
Definition: app_queue.c:1091
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int(*const send_text)(struct ast_channel *chan, const char *text)
Display or transmit text.
Definition: channel.h:557
#define ast_clear_flag(p, flag)
Definition: utils.h:77
#define CHECK_BLOCKING(c)
Definition: channel.h:2427
struct ast_channel_tech * tech
Definition: channel.h:743
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 7051 of file channel.c.

References ast_party_caller::ani, ast_cdr_setcid(), ast_channel_lock, ast_channel_unlock, ast_free, ast_strdup, ast_channel::caller, ast_channel::cdr, ast_party_caller::id, ast_party_id::name, ast_party_id::number, report_new_callerid(), 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(), cb_events(), disa_exec(), get_pai(), get_rpid(), handle_setcallerid(), mgcp_ss(), privacy_exec(), ring_entry(), skinny_newcall(), and socket_process().

7052 {
7053  ast_channel_lock(chan);
7054 
7055  if (cid_num) {
7056  chan->caller.id.number.valid = 1;
7057  ast_free(chan->caller.id.number.str);
7058  chan->caller.id.number.str = ast_strdup(cid_num);
7059  }
7060  if (cid_name) {
7061  chan->caller.id.name.valid = 1;
7062  ast_free(chan->caller.id.name.str);
7063  chan->caller.id.name.str = ast_strdup(cid_name);
7064  }
7065  if (cid_ani) {
7066  chan->caller.ani.number.valid = 1;
7067  ast_free(chan->caller.ani.number.str);
7068  chan->caller.ani.number.str = ast_strdup(cid_ani);
7069  }
7070  if (chan->cdr) {
7071  ast_cdr_setcid(chan->cdr, chan);
7072  }
7073 
7074  report_new_callerid(chan);
7075 
7076  ast_channel_unlock(chan);
7077 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
#define ast_strdup(a)
Definition: astmm.h:109
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
char * str
Subscriber name (Malloced)
Definition: channel.h:214
struct ast_cdr * cdr
Definition: channel.h:766
static char cid_num[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:157
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
int ast_cdr_setcid(struct ast_cdr *cdr, struct ast_channel *chan)
Initialize based on a channel.
Definition: cdr.c:883
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:377
static void report_new_callerid(struct ast_channel *chan)
Definition: channel.c:6468
#define ast_channel_unlock(chan)
Definition: channel.h:2467
#define ast_free(a)
Definition: astmm.h:97
static char cid_name[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:158
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
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 2769 of file channel.c.

References ast_bridged_channel(), ast_channel_lock, ast_channel_ref, ast_channel_unlock, ast_channel_unref, ast_string_field_set, ast_strlen_zero(), ast_channel::bridge, and ast_channel::hangupsource.

Referenced by __dahdi_exception(), analog_exception(), func_channel_write_real(), handle_hangup(), pbx_builtin_hangup(), set_hangup_source_and_cause(), and sip_queue_hangup_cause().

2770 {
2771  struct ast_channel *bridge;
2772 
2773  ast_channel_lock(chan);
2774  if (force || ast_strlen_zero(chan->hangupsource)) {
2775  ast_string_field_set(chan, hangupsource, source);
2776  }
2777  bridge = ast_bridged_channel(chan);
2778  if (bridge) {
2779  ast_channel_ref(bridge);
2780  }
2781  ast_channel_unlock(chan);
2782 
2783  if (bridge) {
2784  ast_channel_lock(bridge);
2785  if (force || ast_strlen_zero(bridge->hangupsource)) {
2786  ast_string_field_set(bridge, hangupsource, source);
2787  }
2788  ast_channel_unlock(bridge);
2789  ast_channel_unref(bridge);
2790  }
2791 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
Main Channel structure associated with a channel.
Definition: channel.h:742
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2502
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
Definition: channel.c:7160
const ast_string_field hangupsource
Definition: channel.h:787
struct ast_bridge * bridge
Definition: channel.h:865
#define ast_channel_unlock(chan)
Definition: channel.h:2467
#define ast_channel_ref(c)
Increase channel reference count.
Definition: channel.h:2491
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:344
static void ast_set_owners_and_peers ( struct ast_channel chan1,
struct ast_channel chan2 
)
static

Definition at line 6430 of file channel.c.

References accountcode, ast_channel::accountcode, ast_log(), ast_string_field_set, ast_strlen_zero(), LOG_DEBUG, ast_channel::name, and ast_channel::peeraccount.

Referenced by ast_channel_bridge().

6432 {
6433  if (!ast_strlen_zero(chan1->accountcode) && ast_strlen_zero(chan2->peeraccount)) {
6434  ast_log(LOG_DEBUG, "setting peeraccount to %s for %s from data on channel %s\n",
6435  chan1->accountcode, chan2->name, chan1->name);
6437  }
6438  if (!ast_strlen_zero(chan2->accountcode) && ast_strlen_zero(chan1->peeraccount)) {
6439  ast_log(LOG_DEBUG, "setting peeraccount to %s for %s from data on channel %s\n",
6440  chan2->accountcode, chan1->name, chan2->name);
6442  }
6443  if (!ast_strlen_zero(chan1->peeraccount) && ast_strlen_zero(chan2->accountcode)) {
6444  ast_log(LOG_DEBUG, "setting accountcode to %s for %s from data on channel %s\n",
6445  chan1->peeraccount, chan2->name, chan1->name);
6447  }
6448  if (!ast_strlen_zero(chan2->peeraccount) && ast_strlen_zero(chan1->accountcode)) {
6449  ast_log(LOG_DEBUG, "setting accountcode to %s for %s from data on channel %s\n",
6450  chan2->peeraccount, chan1->name, chan2->name);
6452  }
6453  if (0 != strcmp(chan1->accountcode, chan2->peeraccount)) {
6454  ast_log(LOG_DEBUG, "changing peeraccount from %s to %s on %s to match channel %s\n",
6455  chan2->peeraccount, chan1->peeraccount, chan2->name, chan1->name);
6457  }
6458  if (0 != strcmp(chan2->accountcode, chan1->peeraccount)) {
6459  ast_log(LOG_DEBUG, "changing peeraccount from %s to %s on %s to match channel %s\n",
6460  chan1->peeraccount, chan2->peeraccount, chan1->name, chan2->name);
6462  }
6463 }
const ast_string_field peeraccount
Definition: channel.h:787
static char accountcode[AST_MAX_ACCOUNT_CODE]
Definition: chan_iax2.c:383
#define LOG_DEBUG
Definition: logger.h:122
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
const ast_string_field accountcode
Definition: channel.h:787
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:344
int ast_set_read_format ( struct ast_channel chan,
format_t  format 
)

Sets read format on channel chan Set read format for channel to whichever component of "format" is best.

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

Definition at line 5301 of file channel.c.

References ast_channel::rawreadformat, ast_channel::readformat, ast_channel::readtrans, and set_format().

Referenced by __ast_play_and_record(), __oh323_update_info(), adsi_transmit_message_full(), agent_call(), alarmreceiver_exec(), ast_channel_make_compatible_helper(), ast_do_masquerade(), background_detect_exec(), bridge_channel_join(), bridge_make_compatible(), build_conf(), conf_run(), dictate_exec(), do_waiting(), eagi_exec(), echo_exec(), generic_fax_exec(), gtalk_rtp_read(), handle_recordfile(), handle_speechrecognize(), ices_exec(), isAnsweringMachine(), jack_exec(), jingle_rtp_read(), login_exec(), measurenoise(), meetme_menu_admin_extended(), mgcp_rtp_read(), oh323_rtp_read(), old_milliwatt_exec(), process_sdp(), record_exec(), setup_rtp_connection(), sip_rtp_read(), skinny_rtp_read(), socket_process(), speech_background(), transmit_audio(), and unistim_rtp_read().

5302 {
5303  return set_format(chan, fmt, &chan->rawreadformat, &chan->readformat,
5304  &chan->readtrans, 0);
5305 }
static int set_format(struct ast_channel *chan, format_t fmt, format_t *rawformat, format_t *format, struct ast_trans_pvt **trans, const int direction)
Definition: channel.c:5218
format_t rawreadformat
Definition: channel.h:855
format_t readformat
Definition: channel.h:853
struct ast_trans_pvt * readtrans
Definition: channel.h:763
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

Variable names can be for a regular channel variable or a dialplan function that has the ability to be written to.

Definition at line 8261 of file channel.c.

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

Referenced by __ast_request_and_dial(), ast_call_forward(), ast_pbx_outgoing_app(), and ast_pbx_outgoing_exten().

8262 {
8263  struct ast_variable *cur;
8264 
8265  for (cur = vars; cur; cur = cur->next)
8266  pbx_builtin_setvar_helper(chan, cur->name, cur->value);
8267 }
Structure for variables, used for configurations and for channel variables.
Definition: config.h:75
const char * value
Definition: config.h:79
const char * name
Definition: config.h:77
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...
Definition: pbx.c:10546
struct ast_variable * next
Definition: config.h:82
int ast_set_write_format ( struct ast_channel chan,
format_t  format 
)

Sets write format on channel chan Set write format for channel to whichever component of "format" is best.

Parameters
chanchannel to change
formatnew format for writing
Returns
Returns 0 on success, -1 on failure

Definition at line 5307 of file channel.c.

References ast_channel::rawwriteformat, set_format(), ast_channel::writeformat, and ast_channel::writetrans.

Referenced by __oh323_update_info(), adsi_transmit_message_full(), agent_call(), alarmreceiver_exec(), ast_channel_make_compatible_helper(), ast_channel_start_silence_generator(), ast_channel_stop_silence_generator(), ast_do_masquerade(), ast_openstream_full(), ast_stopstream(), ast_write(), bridge_channel_join(), bridge_make_compatible(), build_conf(), chanspy_exec(), conf_run(), dahdiscan_exec(), echo_exec(), extenspy_exec(), generic_fax_exec(), gtalk_rtp_read(), jack_exec(), jingle_rtp_read(), linear_alloc(), linear_release(), login_exec(), meetme_menu_admin_extended(), mgcp_rtp_read(), moh_alloc(), moh_files_release(), moh_release(), mp3_exec(), NBScat_exec(), oh323_rtp_read(), old_milliwatt_exec(), playtones_alloc(), playtones_release(), process_sdp(), send_waveform_to_channel(), setup_rtp_connection(), sip_rtp_read(), skinny_rtp_read(), socket_process(), tonepair_alloc(), tonepair_release(), transmit_audio(), and unistim_rtp_read().

5308 {
5309  return set_format(chan, fmt, &chan->rawwriteformat, &chan->writeformat,
5310  &chan->writetrans, 1);
5311 }
format_t writeformat
Definition: channel.h:854
static int set_format(struct ast_channel *chan, format_t fmt, format_t *rawformat, format_t *format, struct ast_trans_pvt **trans, const int direction)
Definition: channel.c:5218
format_t rawwriteformat
Definition: channel.h:856
struct ast_trans_pvt * writetrans
Definition: channel.h:762
int ast_setstate ( struct ast_channel chan,
enum ast_channel_state  state 
)

Change the state of a channel.

Definition at line 7119 of file channel.c.

References ast_channel::_state, AST_CHANNEL_NAME, ast_copy_string(), AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, ast_devstate_changed_literal(), AST_DEVSTATE_NOT_CACHABLE, AST_FLAG_DISABLE_DEVSTATE_CACHE, ast_manager_event, ast_state2str(), ast_channel::caller, ast_channel::connected, EVENT_FLAG_CALL, ast_channel::flags, ast_party_caller::id, ast_party_connected_line::id, name, ast_party_id::name, ast_channel::name, ast_party_id::number, S_COR, state, ast_party_name::str, ast_party_number::str, ast_channel::uniqueid, ast_party_name::valid, and ast_party_number::valid.

Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_read(), __dahdi_exception(), __oh323_update_info(), agent_call(), alsa_answer(), analog_answer(), analog_call(), analog_exception(), analog_ss_thread(), ast_raw_answer(), cb_events(), check_availability(), console_answer(), dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_indicate(), dahdi_read(), do_bridge_masquerade(), gtalk_call(), gtalk_newcall(), handle_invite_replaces(), handle_offhook_message(), handle_request_invite(), handle_response_invite(), handle_soft_key_event_message(), handle_stimulus_message(), iax2_call(), jingle_call(), jingle_newcall(), local_queue_frame(), mgcp_answer(), mgcp_call(), mgcp_ss(), misdn_call(), misdn_indication(), my_set_waitingfordt(), nbs_call(), nbs_hangup(), oh323_answer(), oss_answer(), pbx_builtin_busy(), pbx_builtin_congestion(), phone_answer(), phone_call(), phone_exception(), phone_hangup(), phone_write(), pri_dchannel(), pri_ss_thread(), release_chan(), release_chan_early(), sig_pri_answer(), sig_pri_call(), sig_pri_indicate(), sip_answer(), skinny_answer(), skinny_call(), skinny_newcall(), unistim_answer(), unistim_call(), unistim_new(), unistim_ss(), and update_state().

7120 {
7121  int oldstate = chan->_state;
7122  char name[AST_CHANNEL_NAME], *dashptr;
7123 
7124  if (oldstate == state)
7125  return 0;
7126 
7127  ast_copy_string(name, chan->name, sizeof(name));
7128  if ((dashptr = strrchr(name, '-'))) {
7129  *dashptr = '\0';
7130  }
7131 
7132  chan->_state = state;
7133 
7134  /* We have to pass AST_DEVICE_UNKNOWN here because it is entirely possible that the channel driver
7135  * for this channel is using the callback method for device state. If we pass in an actual state here
7136  * we override what they are saying the state is and things go amuck. */
7138 
7139  /* setstate used to conditionally report Newchannel; this is no more */
7140  ast_manager_event(chan, EVENT_FLAG_CALL, "Newstate",
7141  "Channel: %s\r\n"
7142  "ChannelState: %u\r\n"
7143  "ChannelStateDesc: %s\r\n"
7144  "CallerIDNum: %s\r\n"
7145  "CallerIDName: %s\r\n"
7146  "ConnectedLineNum: %s\r\n"
7147  "ConnectedLineName: %s\r\n"
7148  "Uniqueid: %s\r\n",
7149  chan->name, chan->_state, ast_state2str(chan->_state),
7150  S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""),
7151  S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, ""),
7152  S_COR(chan->connected.id.number.valid, chan->connected.id.number.str, ""),
7153  S_COR(chan->connected.id.name.valid, chan->connected.id.name.str, ""),
7154  chan->uniqueid);
7155 
7156  return 0;
7157 }
enum sip_cc_notify_state state
Definition: chan_sip.c:842
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
const ast_string_field uniqueid
Definition: channel.h:787
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
#define EVENT_FLAG_CALL
Definition: manager.h:72
char * str
Subscriber name (Malloced)
Definition: channel.h:214
const char * ast_state2str(enum ast_channel_state)
Gives the string form of a given channel state.
Definition: channel.c:1007
#define ast_manager_event(chan, category, event, contents,...)
Definition: manager.h:221
unsigned int flags
Definition: channel.h:850
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
#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:83
enum ast_channel_state _state
Definition: channel.h:839
const ast_string_field name
Definition: channel.h:787
static const char name[]
#define AST_CHANNEL_NAME
Definition: channel.h:137
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
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.
Definition: devicestate.c:472
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
int ast_settimeout ( struct ast_channel c,
unsigned int  rate,
int(*)(const void *data)  func,
void *  data 
)

Enable or disable timer ticks for a channel.

Parameters
cchannel
ratenumber of timer ticks per second
funccallback function
data

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

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

Definition at line 3557 of file channel.c.

References ast_settimeout_full().

Referenced by ast_activate_generator(), ast_readaudio_callback(), deactivate_generator_nolock(), and filestream_close().

3558 {
3559  return ast_settimeout_full(c, rate, func, data, 0);
3560 }
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:3562
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 3562 of file channel.c.

References ao2_ref, ast_channel_lock, 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, ast_channel::data, ast_channel::fdno, ast_channel::timer, ast_channel::timingdata, ast_channel::timingfd, and ast_channel::timingfunc.

Referenced by ast_readaudio_callback(), and ast_settimeout().

3563 {
3564  int res;
3565  unsigned int real_rate = rate, max_rate;
3566 
3567  ast_channel_lock(c);
3568 
3569  if (c->timingfd == -1) {
3570  ast_channel_unlock(c);
3571  return -1;
3572  }
3573 
3574  if (!func) {
3575  rate = 0;
3576  data = NULL;
3577  }
3578 
3579  if (rate && rate > (max_rate = ast_timer_get_max_rate(c->timer))) {
3580  real_rate = max_rate;
3581  }
3582 
3583  ast_debug(1, "Scheduling timer at (%u requested / %u actual) timer ticks per second\n", rate, real_rate);
3584 
3585  res = ast_timer_set_rate(c->timer, real_rate);
3586 
3588  ao2_ref(c->timingdata, -1);
3589  }
3590 
3591  c->timingfunc = func;
3592  c->timingdata = data;
3593 
3594  if (data && is_ao2_obj) {
3595  ao2_ref(data, 1);
3597  } else {
3599  }
3600 
3601  if (func == NULL && rate == 0 && c->fdno == AST_TIMING_FD) {
3602  /* Clearing the timing func and setting the rate to 0
3603  * means that we don't want to be reading from the timingfd
3604  * any more. Setting c->fdno to -1 means we won't have any
3605  * errant reads from the timingfd, meaning we won't potentially
3606  * miss any important frames.
3607  */
3608  c->fdno = -1;
3609  }
3610 
3611  ast_channel_unlock(c);
3612 
3613  return res;
3614 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
unsigned int ast_timer_get_max_rate(const struct ast_timer *handle)
Get maximum rate supported for a timer.
Definition: timing.c:208
int timingfd
Definition: channel.h:838
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define ast_set_flag(p, flag)
Definition: utils.h:70
struct ast_timer * timer
Definition: channel.h:866
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
#define ao2_ref(o, delta)
Definition: astobj2.h:472
int(* timingfunc)(const void *data)
Definition: channel.h:759
#define AST_TIMING_FD
Definition: channel.h:164
void * timingdata
Definition: channel.h:760
int fdno
Definition: channel.h:834
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int ast_timer_set_rate(const struct ast_timer *handle, unsigned int rate)
Set the timing tick rate.
Definition: timing.c:163
#define ast_clear_flag(p, flag)
Definition: utils.h:77
int ast_shutting_down ( void  )

Returns non-zero if Asterisk is being shut down.

Returns
non-zero if Asterisk is being shut down

Definition at line 865 of file channel.c.

References shutting_down.

Referenced by handle_request_options().

866 {
867  return shutting_down;
868 }
static int shutting_down
Prevent new channel allocation if shutting down.
Definition: channel.c:99
int ast_softhangup ( struct ast_channel chan,
int  cause 
)

Softly hangup a channel, lock.

Softly hangup up a channel.

Definition at line 2746 of file channel.c.

References ast_channel_lock, ast_channel_unlock, and ast_softhangup_nolock().

Referenced by __analog_handle_event(), __ast_module_user_hangup_all(), __ast_pbx_run(), __unload_module(), agent_hangup(), agent_logoff(), agent_read(), ast_bridge_call(), ast_channel_softhangup_cb(), ast_dial_join(), cc_generic_agent_stop_ringing(), conf_free(), dahdi_handle_event(), handle_hangup(), handle_softhangup(), login_exec(), manager_park(), mgcp_pktcgate_remove(), read_agent_config(), sla_handle_hold_event(), softhangup_exec(), start_spying(), startmon(), and unload_module().

2747 {
2748  int res;
2749 
2750  ast_channel_lock(chan);
2751  res = ast_softhangup_nolock(chan, cause);
2752  ast_channel_unlock(chan);
2753 
2754  return res;
2755 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
int ast_softhangup_nolock(struct ast_channel *chan, int reason)
Softly hangup up a channel (no channel lock)
Definition: channel.c:2733
#define ast_channel_unlock(chan)
Definition: channel.h:2467
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 2733 of file channel.c.

References ast_channel::_softhangup, ast_debug, AST_FLAG_BLOCKING, ast_null_frame, ast_queue_frame(), ast_test_flag, ast_channel::blocker, and ast_channel::name.

Referenced by __analog_handle_event(), action_hangup(), analog_attempt_transfer(), ast_async_goto(), ast_softhangup(), attempt_transfer(), check_pendings(), check_rtp_timeout(), dahdi_softhangup_all(), gosub_run(), oh323_indicate(), pri_dchannel(), proc_session_timer(), sig_pri_indicate(), sig_pri_send_aoce_termination_request(), sip_indicate(), and skinny_indicate().

2734 {
2735  ast_debug(1, "Soft-Hanging up channel '%s'\n", chan->name);
2736  /* Inform channel driver that we need to be hung up, if it cares */
2737  chan->_softhangup |= cause;
2739  /* Interrupt any poll call or such */
2740  if (ast_test_flag(chan, AST_FLAG_BLOCKING))
2741  pthread_kill(chan->blocker, SIGURG);
2742  return 0;
2743 }
struct ast_frame ast_null_frame
Definition: frame.c:131
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
const ast_string_field name
Definition: channel.h:787
int _softhangup
Definition: channel.h:832
pthread_t blocker
Definition: channel.h:790
const char* ast_state2str ( enum ast_channel_state  state)

Gives the string form of a given channel state.

Note
This function is not reentrant.

Definition at line 1007 of file channel.c.

References AST_STATE_BUSY, AST_STATE_DIALING, AST_STATE_DIALING_OFFHOOK, AST_STATE_DOWN, AST_STATE_OFFHOOK, AST_STATE_PRERING, AST_STATE_RESERVED, AST_STATE_RING, AST_STATE_RINGING, AST_STATE_UP, ast_threadstorage_get(), STATE2STR_BUFSIZE, and state2str_threadbuf.

Referenced by __ast_channel_alloc_ap(), action_coreshowchannels(), action_status(), agent_hangup(), ast_channel_data_add_structure(), ast_do_masquerade(), ast_setstate(), attempt_transfer(), func_channel_read(), handle_chanlist(), handle_showchan(), local_attended_transfer(), mgcp_new(), serialize_showchan(), sip_hangup(), and update_connectedline().

1008 {
1009  char *buf;
1010 
1011  switch (state) {
1012  case AST_STATE_DOWN:
1013  return "Down";
1014  case AST_STATE_RESERVED:
1015  return "Rsrvd";
1016  case AST_STATE_OFFHOOK:
1017  return "OffHook";
1018  case AST_STATE_DIALING:
1019  return "Dialing";
1020  case AST_STATE_RING:
1021  return "Ring";
1022  case AST_STATE_RINGING:
1023  return "Ringing";
1024  case AST_STATE_UP:
1025  return "Up";
1026  case AST_STATE_BUSY:
1027  return "Busy";
1029  return "Dialing Offhook";
1030  case AST_STATE_PRERING:
1031  return "Pre-ring";
1032  default:
1034  return "Unknown";
1035  snprintf(buf, STATE2STR_BUFSIZE, "Unknown (%u)", state);
1036  return buf;
1037  }
1038 }
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
#define STATE2STR_BUFSIZE
Definition: channel.c:107
static struct ast_threadstorage state2str_threadbuf
Definition: channel.c:106
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 993 of file channel.c.

References ARRAY_LEN, and causes.

Referenced by pbx_builtin_hangup().

994 {
995  int x;
996 
997  for (x = 0; x < ARRAY_LEN(causes); x++)
998  if (!strncasecmp(causes[x].name, name, strlen(causes[x].name)))
999  return causes[x].cause;
1000 
1001  return -1;
1002 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static struct causes_map causes[]
Definition: channel.c:209
static const char name[]
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 7969 of file channel.c.

References ast_frfree, ast_read(), ast_tonepair_start(), ast_waitfor(), and ast_channel::generatordata.

Referenced by zapateller_exec().

7970 {
7971  int res;
7972 
7973  if ((res = ast_tonepair_start(chan, freq1, freq2, duration, vol)))
7974  return res;
7975 
7976  /* Give us some wiggle room */
7977  while (chan->generatordata && ast_waitfor(chan, 100) >= 0) {
7978  struct ast_frame *f = ast_read(chan);
7979  if (f)
7980  ast_frfree(f);
7981  else
7982  return -1;
7983  }
7984  return 0;
7985 }
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4383
static struct ast_format f[]
Definition: format_g726.c:181
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3539
Data structure associated with a single frame of data.
Definition: frame.h:142
int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
Definition: channel.c:7951
#define ast_frfree(fr)
Definition: frame.h:583
void * generatordata
Definition: channel.h:746
int ast_tonepair_start ( struct ast_channel chan,
int  freq1,
int  freq2,
int  duration,
int  vol 
)

Start a tone going

Definition at line 7951 of file channel.c.

References ast_activate_generator(), tonepair_def::duration, tonepair_def::freq1, tonepair_def::freq2, and tonepair_def::vol.

Referenced by ast_tonepair(), pbx_builtin_waitexten(), play_dialtone(), and sendnoise().

7952 {
7953  struct tonepair_def d = { 0, };
7954 
7955  d.freq1 = freq1;
7956  d.freq2 = freq2;
7957  d.duration = duration;
7958  d.vol = (vol < 1) ? 8192 : vol; /* force invalid to 8192 */
7959  if (ast_activate_generator(chan, &tonepair, &d))
7960  return -1;
7961  return 0;
7962 }
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
Definition: channel.c:3148
int duration
Definition: channel.c:7838
static struct ast_generator tonepair
Definition: channel.c:7945
void ast_tonepair_stop ( struct ast_channel chan)

Stop a tone from playing

Definition at line 7964 of file channel.c.

References ast_deactivate_generator().

Referenced by sendnoise().

7965 {
7967 }
void ast_deactivate_generator(struct ast_channel *chan)
Definition: channel.c:3107
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 5788 of file channel.c.

References 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, ast_channel::tech, and ast_channel_tech::transfer.

Referenced by transfer_exec().

5789 {
5790  int res = -1;
5791 
5792  /* Stop if we're a zombie or need a soft hangup */
5793  ast_channel_lock(chan);
5794  if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) {
5795  if (chan->tech->transfer) {
5796  res = chan->tech->transfer(chan, dest);
5797  if (!res)
5798  res = 1;
5799  } else
5800  res = 0;
5801  }
5802  ast_channel_unlock(chan);
5803 
5804  if (res <= 0) {
5805  return res;
5806  }
5807 
5808  for (;;) {
5809  struct ast_frame *fr;
5810 
5811  res = ast_waitfor(chan, -1);
5812 
5813  if (res < 0 || !(fr = ast_read(chan))) {
5814  res = -1;
5815  break;
5816  }
5817 
5819  enum ast_control_transfer *message = fr->data.ptr;
5820 
5821  if (*message == AST_TRANSFER_SUCCESS) {
5822  res = 1;
5823  } else {
5824  res = -1;
5825  }
5826 
5827  ast_frfree(fr);
5828  break;
5829  }
5830 
5831  ast_frfree(fr);
5832  }
5833 
5834  return res;
5835 }
union ast_frame_subclass subclass
Definition: frame.h:146
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define ast_test_flag(p, flag)
Definition: utils.h:63
void * ptr
Definition: frame.h:160
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4383
ast_control_transfer
Definition: frame.h:422
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int(*const transfer)(struct ast_channel *chan, const char *newdest)
Blind transfer other side (see app_transfer.c and ast_transfer()
Definition: channel.h:588
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3539
Data structure associated with a single frame of data.
Definition: frame.h:142
enum ast_frame_type frametype
Definition: frame.h:144
#define ast_frfree(fr)
Definition: frame.h:583
union ast_frame::@172 data
struct ast_channel_tech * tech
Definition: channel.h:743
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 1041 of file channel.c.

References AST_TRANS_CAP_3_1K_AUDIO, AST_TRANS_CAP_DIGITAL, AST_TRANS_CAP_DIGITAL_W_TONES, AST_TRANS_CAP_RESTRICTED_DIGITAL, AST_TRANS_CAP_SPEECH, and AST_TRANS_CAP_VIDEO.

Referenced by ast_channel_data_add_structure(), cb_events(), misdn_call(), oh323_call(), sig_pri_call(), and sig_pri_new_ast_channel().

1042 {
1043  switch (transfercapability) {
1044  case AST_TRANS_CAP_SPEECH:
1045  return "SPEECH";
1046  case AST_TRANS_CAP_DIGITAL:
1047  return "DIGITAL";
1049  return "RESTRICTED_DIGITAL";
1051  return "3K1AUDIO";
1053  return "DIGITAL_W_TONES";
1054  case AST_TRANS_CAP_VIDEO:
1055  return "VIDEO";
1056  default:
1057  return "UNKNOWN";
1058  }
1059 }
#define AST_TRANS_CAP_DIGITAL_W_TONES
Definition: transcap.h:39
#define AST_TRANS_CAP_3_1K_AUDIO
Definition: transcap.h:37
#define AST_TRANS_CAP_VIDEO
Definition: transcap.h:40
#define AST_TRANS_CAP_RESTRICTED_DIGITAL
Definition: transcap.h:36
#define AST_TRANS_CAP_SPEECH
Definition: transcap.h:34
#define AST_TRANS_CAP_DIGITAL
Definition: transcap.h:35
int ast_undestroyed_channels ( void  )
Returns
the number of channels not yet destroyed

Definition at line 853 of file channel.c.

References ast_atomic_fetchadd_int().

Referenced by can_safely_quit().

854 {
856 }
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return * the previous value of *p. This can be used to handle reference co...
Definition: lock.h:603
static int chancount
Definition: channel.c:102
void ast_uninstall_music_functions ( void  )

Definition at line 8032 of file channel.c.

References ast_moh_cleanup_ptr, ast_moh_start_ptr, and ast_moh_stop_ptr.

Referenced by unload_module().

8033 {
8034  ast_moh_start_ptr = NULL;
8035  ast_moh_stop_ptr = NULL;
8036  ast_moh_cleanup_ptr = NULL;
8037 }
static int(* ast_moh_start_ptr)(struct ast_channel *, const char *, const char *)
Definition: channel.c:8019
static void(* ast_moh_cleanup_ptr)(struct ast_channel *)
Definition: channel.c:8021
static void(* ast_moh_stop_ptr)(struct ast_channel *)
Definition: channel.c:8020
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 3539 of file channel.c.

References ast_waitfor_nandfds().

Referenced by __adsi_transmit_messages(), __analog_ss_thread(), __ast_answer(), __ast_play_and_record(), __ast_request_and_dial(), adsi_careful_send(), agent_ack_sleep(), analog_ss_thread(), ast_dtmf_stream(), ast_recvtext(), ast_safe_sleep_conditional(), ast_tonepair(), ast_transfer(), async_wait(), background_detect_exec(), channel_spy(), conf_flush(), dahdi_accept_r2_call_exec(), dictate_exec(), disa_exec(), disable_t38(), do_idle_thread(), do_waiting(), echo_exec(), handle_recordfile(), handle_speechrecognize(), ices_exec(), isAnsweringMachine(), jack_exec(), launch_asyncagi(), measurenoise(), mp3_exec(), NBScat_exec(), receive_dtmf_digits(), receivefax_t38_init(), record_exec(), recordthread(), send_tone_burst(), send_waveform_to_channel(), sendfax_t38_init(), sendurl_exec(), speech_background(), transmit_audio(), transmit_t38(), wait_for_hangup(), waitforring_exec(), and waitstream_core().

3540 {
3541  if (ms < 0) {
3542  do {
3543  ms = 100000;
3544  ast_waitfor_nandfds(&c, 1, NULL, 0, NULL, NULL, &ms);
3545  } while (!ms);
3546  } else {
3547  ast_waitfor_nandfds(&c, 1, NULL, 0, NULL, NULL, &ms);
3548  }
3549  return ms;
3550 }
struct ast_channel * ast_waitfor_nandfds(struct ast_channel **chan, int n, int *fds, int nfds, int *exception, int *outfd, int *ms)
Waits for activity on a group of channels.
Definition: channel.c:3188
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 3534 of file channel.c.

References ast_waitfor_nandfds().

Referenced by ast_generic_bridge(), ast_udptl_bridge(), autoservice_run(), dahdi_bridge(), dial_exec_full(), feature_request_and_dial(), generic_thread_loop(), iax2_bridge(), local_bridge_loop(), misdn_bridge(), monitor_dial(), remote_bridge_loop(), wait_for_answer(), and wait_for_winner().

3535 {
3536  return ast_waitfor_nandfds(c, n, NULL, 0, NULL, NULL, ms);
3537 }
struct ast_channel * ast_waitfor_nandfds(struct ast_channel **chan, int n, int *fds, int nfds, int *exception, int *outfd, int *ms)
Waits for activity on a group of channels.
Definition: channel.c:3188
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 3176 of file channel.c.

References ast_waitfor_nandfds().

Referenced by dundi_lookup_internal(), dundi_precache_internal(), and softmix_bridge_thread().

3177 {
3178  int winner = -1;
3179  ast_waitfor_nandfds(NULL, 0, fds, n, exception, &winner, ms);
3180  return winner;
3181 }
struct ast_channel * ast_waitfor_nandfds(struct ast_channel **chan, int n, int *fds, int nfds, int *exception, int *outfd, int *ms)
Waits for activity on a group of channels.
Definition: channel.c:3188
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 3188 of file channel.c.

References ast_channel::_softhangup, ast_add_fd(), ast_alloca, ast_channel_lock, ast_channel_unlock, ast_clear_flag, ast_do_masquerade(), AST_FLAG_BLOCKING, AST_FLAG_EXCEPTION, AST_MAX_FDS, ast_poll, ast_set_flag, AST_SOFTHANGUP_TIMEOUT, ast_test_suite_event_notify, ast_tvcmp(), ast_tvdiff_ms(), ast_tvnow(), ast_tvsub(), ast_tvzero(), chanlist::chan, CHECK_BLOCKING, errno, ast_channel::fdno, and name.

Referenced by ast_waitfor(), ast_waitfor_n(), ast_waitfor_n_fd(), ast_waitfordigit_full(), bridge_channel_join_multithreaded(), conf_run(), eivr_comm(), find_cache(), generic_fax_exec(), multiplexed_thread_function(), run_agi(), and waitstream_core().

3191 {
3192  struct timeval start = { 0 , 0 };
3193  struct pollfd *pfds = NULL;
3194  int res;
3195  long rms;
3196  int x, y, max;
3197  int sz;
3198  struct timeval now = { 0, 0 };
3199  struct timeval whentohangup = { 0, 0 }, diff;
3200  struct ast_channel *winner = NULL;
3201  struct fdmap {
3202  int chan;
3203  int fdno;
3204  } *fdmap = NULL;
3205 
3206  if (outfd)
3207  *outfd = -99999;
3208  if (exception)
3209  *exception = 0;
3210 
3211  if ((sz = n * AST_MAX_FDS + nfds)) {
3212  pfds = ast_alloca(sizeof(*pfds) * sz);
3213  fdmap = ast_alloca(sizeof(*fdmap) * sz);
3214  } else {
3215  /* nothing to allocate and no FDs to check */
3216  return NULL;
3217  }
3218 
3219  /* Perform any pending masquerades */
3220  for (x = 0; x < n; x++) {
3221  while (c[x]->masq) {
3222  ast_do_masquerade(c[x]);
3223  }
3224 
3225  ast_channel_lock(c[x]);
3226  if (!ast_tvzero(c[x]->whentohangup)) {
3227  if (ast_tvzero(whentohangup))
3228  now = ast_tvnow();
3229  diff = ast_tvsub(c[x]->whentohangup, now);
3230  if (diff.tv_sec < 0 || ast_tvzero(diff)) {
3231  ast_test_suite_event_notify("HANGUP_TIME", "Channel: %s", c[x]->name);
3232  /* Should already be hungup */
3234  ast_channel_unlock(c[x]);
3235  return c[x];
3236  }
3237  if (ast_tvzero(whentohangup) || ast_tvcmp(diff, whentohangup) < 0)
3238  whentohangup = diff;
3239  }
3240  ast_channel_unlock(c[x]);
3241  }
3242  /* Wait full interval */
3243  rms = *ms;
3244  /* INT_MAX, not LONG_MAX, because it matters on 64-bit */
3245  if (!ast_tvzero(whentohangup) && whentohangup.tv_sec < INT_MAX / 1000) {
3246  rms = whentohangup.tv_sec * 1000 + whentohangup.tv_usec / 1000; /* timeout in milliseconds */
3247  if (*ms >= 0 && *ms < rms) { /* original *ms still smaller */
3248  rms = *ms;
3249  }
3250  } else if (!ast_tvzero(whentohangup) && rms < 0) {
3251  /* Tiny corner case... call would need to last >24 days */
3252  rms = INT_MAX;
3253  }
3254  /*
3255  * Build the pollfd array, putting the channels' fds first,
3256  * followed by individual fds. Order is important because
3257  * individual fd's must have priority over channel fds.
3258  */
3259  max = 0;
3260  for (x = 0; x < n; x++) {
3261  for (y = 0; y < AST_MAX_FDS; y++) {
3262  fdmap[max].fdno = y; /* fd y is linked to this pfds */
3263  fdmap[max].chan = x; /* channel x is linked to this pfds */
3264  max += ast_add_fd(&pfds[max], c[x]->fds[y]);
3265  }
3266  CHECK_BLOCKING(c[x]);
3267  }
3268  /* Add the individual fds */
3269  for (x = 0; x < nfds; x++) {
3270  fdmap[max].chan = -1;
3271  max += ast_add_fd(&pfds[max], fds[x]);
3272  }
3273 
3274  if (*ms > 0)
3275  start = ast_tvnow();
3276 
3277  if (sizeof(int) == 4) { /* XXX fix timeout > 600000 on linux x86-32 */
3278  do {
3279  int kbrms = rms;
3280  if (kbrms > 600000)
3281  kbrms = 600000;
3282  res = ast_poll(pfds, max, kbrms);
3283  if (!res)
3284  rms -= kbrms;
3285  } while (!res && (rms > 0));
3286  } else {
3287  res = ast_poll(pfds, max, rms);
3288  }
3289  for (x = 0; x < n; x++)
3291  if (res < 0) { /* Simulate a timeout if we were interrupted */
3292  if (errno != EINTR)
3293  *ms = -1;
3294  return NULL;
3295  }
3296  if (!ast_tvzero(whentohangup)) { /* if we have a timeout, check who expired */
3297  now = ast_tvnow();
3298  for (x = 0; x < n; x++) {
3299  if (!ast_tvzero(c[x]->whentohangup) && ast_tvcmp(c[x]->whentohangup, now) <= 0) {
3300  ast_test_suite_event_notify("HANGUP_TIME", "Channel: %s", c[x]->name);
3302  if (winner == NULL)
3303  winner = c[x];
3304  }
3305  }
3306  }
3307  if (res == 0) { /* no fd ready, reset timeout and done */
3308  *ms = 0; /* XXX use 0 since we may not have an exact timeout. */
3309  return winner;
3310  }
3311  /*
3312  * Then check if any channel or fd has a pending event.
3313  * Remember to check channels first and fds last, as they
3314  * must have priority on setting 'winner'
3315  */
3316  for (x = 0; x < max; x++) {
3317  res = pfds[x].revents;
3318  if (res == 0)
3319  continue;
3320  if (fdmap[x].chan >= 0) { /* this is a channel */
3321  winner = c[fdmap[x].chan]; /* override previous winners */
3322  if (res & POLLPRI)
3324  else
3326  winner->fdno = fdmap[x].fdno;
3327  } else { /* this is an fd */
3328  if (outfd)
3329  *outfd = pfds[x].fd;
3330  if (exception)
3331  *exception = (res & POLLPRI) ? -1 : 0;
3332  winner = NULL;
3333  }
3334  }
3335  if (*ms > 0) {
3336  *ms -= ast_tvdiff_ms(ast_tvnow(), start);
3337  if (*ms < 0)
3338  *ms = 0;
3339  }
3340  return winner;
3341 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
Main Channel structure associated with a channel.
Definition: channel.h:742
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: utils.h:653
#define ast_set_flag(p, flag)
Definition: utils.h:70
static int ast_add_fd(struct pollfd *pfd, int fd)
if fd is a valid descriptor, set *pfd with the descriptor
Definition: channel.h:2390
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:100
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:90
#define ast_poll(a, b, c)
Definition: poll-compat.h:88
#define ast_test_suite_event_notify(s, f,...)
Definition: test.h:184
int ast_tvcmp(struct timeval _a, struct timeval _b)
Compres two struct timeval instances returning -1, 0, 1 if the first arg is smaller, equal or greater to the second.
Definition: time.h:120
int _softhangup
Definition: channel.h:832
int fdno
Definition: channel.h:834
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int errno
static const char name[]
#define AST_MAX_FDS
Definition: channel.h:158
#define ast_clear_flag(p, flag)
Definition: utils.h:77
#define CHECK_BLOCKING(c)
Definition: channel.h:2427
struct timeval ast_tvsub(struct timeval a, struct timeval b)
Returns the difference of two timevals a - b.
Definition: utils.c:1601
int ast_do_masquerade(struct ast_channel *chan)
Start masquerading a channel.
Definition: channel.c:6546
int ast_waitfordigit ( struct ast_channel c,
int  ms 
)

Waits for a digit.

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

Definition at line 3552 of file channel.c.

References ast_waitfordigit_full().

Referenced by __analog_ss_thread(), _while_exec(), adsi_get_cpeid(), adsi_get_cpeinfo(), adsi_print(), adsi_read_encoded_dtmf(), adsi_transmit_message_full(), advanced_options(), analog_my_getsigstr(), analog_ss_thread(), ast_app_dtget(), ast_control_streamfile(), ast_record_review(), bridge_channel_feature(), builtin_atxfer(), collect_digits(), common_exec(), cpeid_exec(), dialout(), directory_exec(), forward_message(), get_folder(), ivr_dispatch(), mgcp_ss(), my_getsigstr(), pbx_builtin_waitexten(), play_record_review(), pri_ss_thread(), read_exec(), read_newoption(), readexten_exec(), retrydial_exec(), select_item_menu(), select_item_pause(), select_item_seq(), sendnoise(), testclient_exec(), testserver_exec(), vm_execmain(), vm_forwardoptions(), vm_instructions_en(), vm_options(), vm_tempgreeting(), wait_a_bit(), and wait_our_turn().

3553 {
3554  return ast_waitfordigit_full(c, ms, -1, -1);
3555 }
int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int ctrlfd)
Wait for a digit Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to mon...
Definition: channel.c:3616
int ast_waitfordigit_full ( struct ast_channel c,
int  ms,
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).
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 3616 of file channel.c.

References ast_check_hangup(), ast_clear_flag, AST_CONTROL_ANSWER, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_REDIRECTING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, 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_set_flag, ast_test_flag, ast_tvnow(), ast_waitfor_nandfds(), ast_frame::data, ast_frame::datalen, errno, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, ast_frame::ptr, and ast_frame::subclass.

Referenced by ast_readstring_full(), ast_waitfordigit(), handle_getoption(), and handle_waitfordigit().

3617 {
3618  struct timeval start = ast_tvnow();
3619  int ms;
3620 
3621  /* Stop if we're a zombie or need a soft hangup */
3623  return -1;
3624 
3625  /* Only look for the end of DTMF, don't bother with the beginning and don't emulate things */
3627 
3628  /* Wait for a digit, no more than timeout_ms milliseconds total.
3629  * Or, wait indefinitely if timeout_ms is <0.
3630  */
3631  while ((ms = ast_remaining_ms(start, timeout_ms))) {
3632  struct ast_channel *rchan;
3633  int outfd = -1;
3634 
3635  errno = 0;
3636  /* While ast_waitfor_nandfds tries to help by reducing the timeout by how much was waited,
3637  * it is unhelpful if it waited less than a millisecond.
3638  */
3639  rchan = ast_waitfor_nandfds(&c, 1, &cmdfd, (cmdfd > -1) ? 1 : 0, NULL, &outfd, &ms);
3640 
3641  if (!rchan && outfd < 0 && ms) {
3642  if (errno == 0 || errno == EINTR)
3643  continue;
3644  ast_log(LOG_WARNING, "Wait failed (%s)\n", strerror(errno));
3646  return -1;
3647  } else if (outfd > -1) {
3648  /* The FD we were watching has something waiting */
3649  ast_log(LOG_WARNING, "The FD we were waiting for has something waiting. Waitfordigit returning numeric 1\n");
3651  return 1;
3652  } else if (rchan) {
3653  int res;
3654  struct ast_frame *f = ast_read(c);
3655  if (!f)
3656  return -1;
3657 
3658  switch (f->frametype) {
3659  case AST_FRAME_DTMF_BEGIN:
3660  break;
3661  case AST_FRAME_DTMF_END:
3662  res = f->subclass.integer;
3663  ast_frfree(f);
3665  return res;
3666  case AST_FRAME_CONTROL:
3667  switch (f->subclass.integer) {
3668  case AST_CONTROL_HANGUP:
3669  ast_frfree(f);
3671  return -1;
3672  case AST_CONTROL_RINGING:
3673  case AST_CONTROL_ANSWER:
3674  case AST_CONTROL_SRCUPDATE:
3675  case AST_CONTROL_SRCCHANGE:
3679  case AST_CONTROL_HOLD:
3680  case AST_CONTROL_UNHOLD:
3681  case -1:
3682  /* Unimportant */
3683  break;
3684  default:
3685  ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", f->subclass.integer);
3686  break;
3687  }
3688  break;
3689  case AST_FRAME_VOICE:
3690  /* Write audio if appropriate */
3691  if (audiofd > -1) {
3692  if (write(audiofd, f->data.ptr, f->datalen) < 0) {
3693  ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
3694  }
3695  }
3696  default:
3697  /* Ignore */
3698  break;
3699  }
3700  ast_frfree(f);
3701  }
3702  }
3703 
3705 
3706  return 0; /* Time is up */
3707 }
union ast_frame_subclass subclass
Definition: frame.h:146
Main Channel structure associated with a channel.
Definition: channel.h:742
#define ast_test_flag(p, flag)
Definition: utils.h:63
void * ptr
Definition: frame.h:160
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define LOG_WARNING
Definition: logger.h:144
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4383
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
struct ast_channel * ast_waitfor_nandfds(struct ast_channel **chan, int n, int *fds, int nfds, int *exception, int *outfd, int *ms)
Waits for activity on a group of channels.
Definition: channel.c:3188
int datalen
Definition: frame.h:148
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
Definition: utils.c:1615
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int errno
static struct ast_format f[]
Definition: format_g726.c:181
#define ast_clear_flag(p, flag)
Definition: utils.h:77
Data structure associated with a single frame of data.
Definition: frame.h:142
enum ast_frame_type frametype
Definition: frame.h:144
#define ast_frfree(fr)
Definition: frame.h:583
union ast_frame::@172 data
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.
Todo:
XXX should return 0 maybe ?

Definition at line 4916 of file channel.c.

References ast_channel::_softhangup, apply_plc(), ast_audiohook_detach_list(), AST_AUDIOHOOK_DIRECTION_WRITE, ast_audiohook_write_list(), ast_audiohook_write_list_empty(), ast_channel_lock, ast_channel_trylock, ast_channel_unlock, ast_check_hangup(), ast_clear_flag, AST_CONTROL_UNHOLD, ast_deactivate_generator(), ast_debug, ast_do_masquerade(), AST_FLAG_BLOCKING, AST_FLAG_WRITE_INT, AST_FLAG_ZOMBIE, AST_FORMAT_AUDIO_MASK, ast_format_rate(), AST_FORMAT_SLINEAR, 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_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_framehook_list_write_event(), ast_frfree, ast_frisolate(), ast_getformatname(), ast_getformatname_multiple(), AST_LIST_NEXT, ast_log(), AST_MONITOR_RUNNING, ast_opt_generic_plc, ast_seekstream(), ast_senddigit_begin(), ast_senddigit_end(), ast_set_write_format(), AST_SOFTHANGUP_DEV, ast_test_flag, ast_translate(), ast_writestream(), ast_channel::audiohooks, calc_monitor_jump(), CHECK_BLOCKING, ast_frame_subclass::codec, ast_frame::data, ast_frame::datalen, DEBUGCHAN_FLAG, ast_filestream::fmt, ast_format::format, ast_channel::fout, FRAMECOUNT_INC, ast_channel::framehooks, ast_frame::frametype, ast_channel::generatordata, ast_channel_tech::indicate, ast_channel::insmpl, ast_frame_subclass::integer, ast_frame::len, LOG_WARNING, ast_channel::masq, ast_channel::masqr, ast_channel::monitor, ast_channel::name, ast_channel::nativeformats, chanlist::next, ast_channel::outsmpl, ast_frame::ptr, ast_channel::rawwriteformat, ast_channel_monitor::read_stream, ast_frame::samples, SEEK_FORCECUR, send_dtmf_event(), ast_channel_tech::send_html, ast_channel_tech::send_text, ast_frame::src, ast_channel_monitor::state, ast_frame::subclass, ast_channel::tech, ast_channel_tech::write, ast_channel_monitor::write_stream, ast_channel_tech::write_text, ast_channel_tech::write_video, ast_channel::writeformat, and ast_channel::writetrans.

Referenced by adsi_careful_send(), agent_write(), ast_bridge_call(), ast_generic_bridge(), ast_prod(), ast_readaudio_callback(), ast_readvideo_callback(), ast_udptl_bridge(), ast_write_video(), conf_queue_dtmf(), conf_run(), dahdi_bridge(), dictate_exec(), echo_exec(), fax_generator_generate(), feature_request_and_dial(), gen_generate(), generic_fax_exec(), handle_jack_audio(), iax2_bridge(), jb_get_and_deliver(), linear_generator(), local_bridge_loop(), milliwatt_generate(), misdn_bridge(), moh_files_generator(), moh_generate(), mp3_exec(), multiplexed_bridge_write(), NBScat_exec(), playtones_generator(), remote_bridge_loop(), send_tone_burst(), send_waveform_to_channel(), silence_generator_generate(), simple_bridge_write(), sms_generate(), softmix_bridge_poke(), softmix_bridge_write(), spy_generate(), t38_tx_packet_handler(), tonepair_generator(), and wait_for_answer().

4917 {
4918  int res = -1;
4919  struct ast_frame *f = NULL;
4920  int count = 0;
4921 
4922  /*Deadlock avoidance*/
4923  while(ast_channel_trylock(chan)) {
4924  /*cannot goto done since the channel is not locked*/
4925  if(count++ > 10) {
4926  ast_debug(1, "Deadlock avoided for write to channel '%s'\n", chan->name);
4927  return 0;
4928  }
4929  usleep(1);
4930  }
4931  /* Stop if we're a zombie or need a soft hangup */
4932  if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan))
4933  goto done;
4934 
4935  /* Handle any pending masquerades */
4936  while (chan->masq) {
4937  ast_channel_unlock(chan);
4938  ast_do_masquerade(chan);
4939  ast_channel_lock(chan);
4940  }
4941  if (chan->masqr) {
4942  res = 0; /* XXX explain, why 0 ? */
4943  goto done;
4944  }
4945 
4946  /* Perform the framehook write event here. After the frame enters the framehook list
4947  * there is no telling what will happen, how awesome is that!!! */
4948  if (!(fr = ast_framehook_list_write_event(chan->framehooks, fr))) {
4949  res = 0;
4950  goto done;
4951  }
4952 
4953  if (chan->generatordata && (!fr->src || strcasecmp(fr->src, "ast_prod"))) {
4954  if (ast_test_flag(chan, AST_FLAG_WRITE_INT)) {
4956  } else {
4957  if (fr->frametype == AST_FRAME_DTMF_END) {
4958  /* There is a generator running while we're in the middle of a digit.
4959  * It's probably inband DTMF, so go ahead and pass it so it can
4960  * stop the generator */
4962  ast_channel_unlock(chan);
4963  res = ast_senddigit_end(chan, fr->subclass.integer, fr->len);
4964  ast_channel_lock(chan);
4965  CHECK_BLOCKING(chan);
4966  } else if (fr->frametype == AST_FRAME_CONTROL && fr->subclass.integer == AST_CONTROL_UNHOLD) {
4967  /* This is a side case where Echo is basically being called and the person put themselves on hold and took themselves off hold */
4968  res = (chan->tech->indicate == NULL) ? 0 :
4969  chan->tech->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
4970  }
4971  res = 0; /* XXX explain, why 0 ? */
4972  goto done;
4973  }
4974  }
4975  /* High bit prints debugging */
4976  if (chan->fout & DEBUGCHAN_FLAG)
4977  ast_frame_dump(chan->name, fr, ">>");
4978  CHECK_BLOCKING(chan);
4979  switch (fr->frametype) {
4980  case AST_FRAME_CONTROL:
4981  res = (chan->tech->indicate == NULL) ? 0 :
4982  chan->tech->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
4983  break;
4984  case AST_FRAME_DTMF_BEGIN:
4985  if (chan->audiohooks) {
4986  struct ast_frame *old_frame = fr;
4988  if (old_frame != fr)
4989  f = fr;
4990  }
4991  send_dtmf_event(chan, "Sent", fr->subclass.integer, "Yes", "No");
4993  ast_channel_unlock(chan);
4994  res = ast_senddigit_begin(chan, fr->subclass.integer);
4995  ast_channel_lock(chan);
4996  CHECK_BLOCKING(chan);
4997  break;
4998  case AST_FRAME_DTMF_END:
4999  if (chan->audiohooks) {
5000  struct ast_frame *new_frame = fr;
5001 
5003  if (new_frame != fr) {
5004  ast_frfree(new_frame);
5005  }
5006  }
5007  send_dtmf_event(chan, "Sent", fr->subclass.integer, "No", "Yes");
5009  ast_channel_unlock(chan);
5010  res = ast_senddigit_end(chan, fr->subclass.integer, fr->len);
5011  ast_channel_lock(chan);
5012  CHECK_BLOCKING(chan);
5013  break;
5014  case AST_FRAME_TEXT:
5015  if (fr->subclass.integer == AST_FORMAT_T140) {
5016  res = (chan->tech->write_text == NULL) ? 0 :
5017  chan->tech->write_text(chan, fr);
5018  } else {
5019  res = (chan->tech->send_text == NULL) ? 0 :
5020  chan->tech->send_text(chan, (char *) fr->data.ptr);
5021  }
5022  break;
5023  case AST_FRAME_HTML:
5024  res = (chan->tech->send_html == NULL) ? 0 :
5025  chan->tech->send_html(chan, fr->subclass.integer, (char *) fr->data.ptr, fr->datalen);
5026  break;
5027  case AST_FRAME_VIDEO:
5028  /* XXX Handle translation of video codecs one day XXX */
5029  res = (chan->tech->write_video == NULL) ? 0 :
5030  chan->tech->write_video(chan, fr);
5031  break;
5032  case AST_FRAME_MODEM:
5033  res = (chan->tech->write == NULL) ? 0 :
5034  chan->tech->write(chan, fr);
5035  break;
5036  case AST_FRAME_VOICE:
5037  if (chan->tech->write == NULL)
5038  break; /*! \todo XXX should return 0 maybe ? */
5039 
5041  apply_plc(chan, fr);
5042  }
5043 
5044  /* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */
5045  if (fr->subclass.codec == chan->rawwriteformat) {
5046  f = fr;
5047  } else {
5048  if ((!(fr->subclass.codec & chan->nativeformats)) && (chan->writeformat != fr->subclass.codec)) {
5049  char nf[512];
5050 
5051  /*
5052  * XXX Something is not right. We are not compatible with this
5053  * frame. Bad things can happen. Problems range from no audio,
5054  * one-way audio, to unexplained line hangups. As a last resort
5055  * try to adjust the format. Ideally, we do not want to do this
5056  * because it indicates a deeper problem. For now, we log these
5057  * events to reduce user impact and help identify the problem
5058  * areas.
5059  */
5060  ast_log(LOG_WARNING, "Codec mismatch on channel %s setting write format to %s from %s native formats %s\n",
5063  ast_set_write_format(chan, fr->subclass.codec);
5064  }
5065 
5066  f = (chan->writetrans) ? ast_translate(chan->writetrans, fr, 0) : fr;
5067  }
5068 
5069  if (!f) {
5070  res = 0;
5071  break;
5072  }
5073 
5074  if (chan->audiohooks) {
5075  struct ast_frame *prev = NULL, *new_frame, *cur, *dup;
5076  int freeoldlist = 0;
5077 
5078  if (f != fr) {
5079  freeoldlist = 1;
5080  }
5081 
5082  /* Since ast_audiohook_write may return a new frame, and the cur frame is
5083  * an item in a list of frames, create a new list adding each cur frame back to it
5084  * regardless if the cur frame changes or not. */
5085  for (cur = f; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
5086  new_frame = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, cur);
5087 
5088  /* if this frame is different than cur, preserve the end of the list,
5089  * free the old frames, and set cur to be the new frame */
5090  if (new_frame != cur) {
5091 
5092  /* doing an ast_frisolate here seems silly, but we are not guaranteed the new_frame
5093  * isn't part of local storage, meaning if ast_audiohook_write is called multiple
5094  * times it may override the previous frame we got from it unless we dup it */
5095  if ((dup = ast_frisolate(new_frame))) {
5097  if (freeoldlist) {
5098  AST_LIST_NEXT(cur, frame_list) = NULL;
5099  ast_frfree(cur);
5100  }
5101  if (new_frame != dup) {
5102  ast_frfree(new_frame);
5103  }
5104  cur = dup;
5105  }
5106  }
5107 
5108  /* now, regardless if cur is new or not, add it to the new list,
5109  * if the new list has not started, cur will become the first item. */
5110  if (prev) {
5111  AST_LIST_NEXT(prev, frame_list) = cur;
5112  } else {
5113  f = cur; /* set f to be the beginning of our new list */
5114  }
5115  prev = cur;
5116  }
5117  }
5118 
5119  /* If Monitor is running on this channel, then we have to write frames out there too */
5120  /* the translator on chan->writetrans may have returned multiple frames
5121  from the single frame we passed in; if so, feed each one of them to the
5122  monitor */
5123  if (chan->monitor && chan->monitor->write_stream) {
5124  struct ast_frame *cur;
5125 
5126  for (cur = f; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
5127  /* XXX must explain this code */
5128 #ifndef MONITOR_CONSTANT_DELAY
5129  int jump = chan->insmpl - chan->outsmpl - 4 * cur->samples;
5130  if (jump >= 0) {
5132  if (ast_seekstream(chan->monitor->write_stream, jump, SEEK_FORCECUR) == -1)
5133  ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n");
5134  chan->outsmpl += (chan->insmpl - chan->outsmpl) + cur->samples;
5135  } else {
5136  chan->outsmpl += cur->samples;
5137  }
5138 #else
5140  if (jump - MONITOR_DELAY >= 0) {
5141  if (ast_seekstream(chan->monitor->write_stream, jump - cur->samples, SEEK_FORCECUR) == -1)
5142  ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n");
5143  chan->outsmpl += chan->insmpl - chan->outsmpl;
5144  } else {
5145  chan->outsmpl += cur->samples;
5146  }
5147 #endif
5148  if (chan->monitor->state == AST_MONITOR_RUNNING) {
5149  if (ast_writestream(chan->monitor->write_stream, cur) < 0)
5150  ast_log(LOG_WARNING, "Failed to write data to channel monitor write stream\n");
5151  }
5152  }
5153  }
5154 
5155  /* the translator on chan->writetrans may have returned multiple frames
5156  from the single frame we passed in; if so, feed each one of them to the
5157  channel, freeing each one after it has been written */
5158  if ((f != fr) && AST_LIST_NEXT(f, frame_list)) {
5159  struct ast_frame *cur, *next;
5160  unsigned int skip = 0;
5161 
5162  for (cur = f, next = AST_LIST_NEXT(cur, frame_list);
5163  cur;
5164  cur = next, next = cur ? AST_LIST_NEXT(cur, frame_list) : NULL) {
5165  if (!skip) {
5166  if ((res = chan->tech->write(chan, cur)) < 0) {
5168  skip = 1;
5169  } else if (next) {
5170  /* don't do this for the last frame in the list,
5171  as the code outside the loop will do it once
5172  */
5173  chan->fout = FRAMECOUNT_INC(chan->fout);
5174  }
5175  }
5176  ast_frfree(cur);
5177  }
5178 
5179  /* reset f so the code below doesn't attempt to free it */
5180  f = NULL;
5181  } else {
5182  res = chan->tech->write(chan, f);
5183  }
5184  break;
5185  case AST_FRAME_NULL:
5186  case AST_FRAME_IAX:
5187  /* Ignore these */
5188  res = 0;
5189  break;
5190  default:
5191  /* At this point, fr is the incoming frame and f is NULL. Channels do
5192  * not expect to get NULL as a frame pointer and will segfault. Hence,
5193  * we output the original frame passed in. */
5194  res = chan->tech->write(chan, fr);
5195  break;
5196  }
5197 
5198  if (f && f != fr)
5199  ast_frfree(f);
5201 
5202  /* Consider a write failure to force a soft hangup */
5203  if (res < 0) {
5205  } else {
5206  chan->fout = FRAMECOUNT_INC(chan->fout);
5207  }
5208 done:
5210  /* The list gets recreated if audiohooks are added again later */
5212  chan->audiohooks = NULL;
5213  }
5214  ast_channel_unlock(chan);
5215  return res;
5216 }
union ast_frame_subclass subclass
Definition: frame.h:146
struct ast_channel * masqr
Definition: channel.h:752
#define ast_channel_lock(chan)
Definition: channel.h:2466
struct ast_channel * masq
Definition: channel.h:751
int(*const write_video)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format.
Definition: channel.h:591
void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
Definition: frame.c:778
#define DEBUGCHAN_FLAG
Definition: channel.h:648
format_t writeformat
Definition: channel.h:854
static int calc_monitor_jump(int samples, int sample_rate, int seek_rate)
calculates the number of samples to jump forward with in a monitor stream.
Definition: channel.c:3823
#define ast_test_flag(p, flag)
Definition: utils.h:63
void * ptr
Definition: frame.h:160
int ast_audiohook_write_list_empty(struct ast_audiohook_list *audiohook_list)
determines if a audiohook_list is empty or not.
Definition: audiohook.c:744
#define LOG_WARNING
Definition: logger.h:144
unsigned int fout
Definition: channel.h:847
format_t rawwriteformat
Definition: channel.h:856
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
Definition: linkedlists.h:438
unsigned long outsmpl
Definition: channel.h:827
static force_inline int ast_format_rate(format_t format)
Get the sample rate for a given format.
Definition: frame.h:809
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:328
format_t nativeformats
Definition: channel.h:852
struct ast_frame * ast_frisolate(struct ast_frame *fr)
Makes a frame independent of any static storage.
Definition: frame.c:391
static void send_dtmf_event(struct ast_channel *chan, const char *direction, const char digit, const char *begin, const char *end)
Definition: channel.c:3709
format_t codec
Definition: frame.h:137
int ast_senddigit_begin(struct ast_channel *chan, char digit)
Send a DTMF digit to a channel.
Definition: channel.c:4705
format_t format
Definition: mod_format.h:47
int ast_set_write_format(struct ast_channel *chan, format_t format)
Sets write format on channel chan Set write format for channel to whichever component of &quot;format&quot; is ...
Definition: channel.c:5307
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
const char * src
Definition: frame.h:158
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition: channel.c:4755
struct ast_audiohook_list * audiohooks
Definition: channel.h:764
int datalen
Definition: frame.h:148
int(*const write_text)(struct ast_channel *chan, struct ast_frame *frame)
Write a text frame, in standard format.
Definition: channel.h:594
struct ast_format * fmt
Definition: mod_format.h:102
#define ast_opt_generic_plc
Definition: options.h:132
static void apply_plc(struct ast_channel *chan, struct ast_frame *frame)
Definition: channel.c:4890
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
struct ast_trans_pvt * writetrans
Definition: channel.h:762
char * ast_getformatname(format_t format)
Get the name of a format.
Definition: frame.c:578
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:762
unsigned long insmpl
Definition: channel.h:826
struct ast_framehook_list * framehooks
Definition: channel.h:765
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int _softhangup
Definition: channel.h:832
struct ast_frame * ast_framehook_list_write_event(struct ast_framehook_list *framehooks, struct ast_frame *frame)
This is used by the channel API push a frame write event to a channel&#39;s framehook list...
Definition: framehook.c:180
int ast_seekstream(struct ast_filestream *fs, off_t sample_offset, int whence)
Seeks into stream.
Definition: file.c:879
struct ast_filestream * read_stream
Definition: monitor.h:41
int(*const send_html)(struct ast_channel *chan, int subclass, const char *data, int len)
Send HTML data.
Definition: channel.h:563
#define ast_channel_unlock(chan)
Definition: channel.h:2467
int(*const send_text)(struct ast_channel *chan, const char *text)
Display or transmit text.
Definition: channel.h:557
#define SEEK_FORCECUR
Definition: file.h:50
#define AST_FORMAT_AUDIO_MASK
Definition: frame.h:274
struct ast_filestream * write_stream
Definition: monitor.h:42
static struct ast_format f[]
Definition: format_g726.c:181
#define FRAMECOUNT_INC(x)
Definition: channel.h:651
#define ast_clear_flag(p, flag)
Definition: utils.h:77
#define CHECK_BLOCKING(c)
Definition: channel.h:2427
int(*const write)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format (see frame.h)
Definition: channel.h:554
void ast_deactivate_generator(struct ast_channel *chan)
Definition: channel.c:3107
#define AST_FORMAT_T140
Definition: frame.h:294
#define AST_FORMAT_SLINEAR
Definition: frame.h:254
int ast_writestream(struct ast_filestream *fs, struct ast_frame *f)
Writes a frame to a stream.
Definition: file.c:150
struct ast_frame * next
Definition: frame.h:164
char * ast_getformatname_multiple(char *buf, size_t size, format_t format)
Get the names of a set of formats.
Definition: frame.c:591
Data structure associated with a single frame of data.
Definition: frame.h:142
enum ast_frame_type frametype
Definition: frame.h:144
#define ast_channel_trylock(chan)
Definition: channel.h:2468
#define ast_frfree(fr)
Definition: frame.h:583
struct ast_channel_monitor * monitor
Definition: channel.h:769
enum AST_MONITORING_STATE state
Definition: monitor.h:49
union ast_frame::@172 data
struct ast_channel_tech * tech
Definition: channel.h:743
int ast_audiohook_detach_list(struct ast_audiohook_list *audiohook_list)
Detach audiohooks from list and destroy said list.
Definition: audiohook.c:418
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:576
long len
Definition: frame.h:170
void * generatordata
Definition: channel.h:746
int ast_do_masquerade(struct ast_channel *chan)
Start masquerading a channel.
Definition: channel.c:6546
int samples
Definition: frame.h:150
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 4801 of file channel.c.

References ast_write(), ast_channel::tech, and ast_channel_tech::write_video.

4802 {
4803  int res;
4804  if (!chan->tech->write_video)
4805  return 0;
4806  res = ast_write(chan, fr);
4807  if (!res)
4808  res = 1;
4809  return res;
4810 }
int(*const write_video)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format.
Definition: channel.h:591
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
Definition: channel.c:4916
struct ast_channel_tech * tech
Definition: channel.h:743
static void bridge_play_sounds ( struct ast_channel c0,
struct ast_channel c1 
)
static

Definition at line 7478 of file channel.c.

References ast_channel_lock, ast_channel_unlock, ast_strdupa, bridge_playfile(), pbx_builtin_getvar_helper(), and pbx_builtin_setvar_helper().

Referenced by ast_channel_bridge().

7479 {
7480  const char *s, *sound;
7481 
7482  /* See if we need to play an audio file to any side of the bridge */
7483 
7484  ast_channel_lock(c0);
7485  if ((s = pbx_builtin_getvar_helper(c0, "BRIDGE_PLAY_SOUND"))) {
7486  sound = ast_strdupa(s);
7487  ast_channel_unlock(c0);
7488  bridge_playfile(c0, c1, sound, 0);
7489  pbx_builtin_setvar_helper(c0, "BRIDGE_PLAY_SOUND", NULL);
7490  } else {
7491  ast_channel_unlock(c0);
7492  }
7493 
7494  ast_channel_lock(c1);
7495  if ((s = pbx_builtin_getvar_helper(c1, "BRIDGE_PLAY_SOUND"))) {
7496  sound = ast_strdupa(s);
7497  ast_channel_unlock(c1);
7498  bridge_playfile(c1, c0, sound, 0);
7499  pbx_builtin_setvar_helper(c1, "BRIDGE_PLAY_SOUND", NULL);
7500  } else {
7501  ast_channel_unlock(c1);
7502  }
7503 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
Definition: pbx.c:10475
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
static void bridge_playfile(struct ast_channel *chan, struct ast_channel *peer, const char *sound, int remain)
Definition: channel.c:7169
#define ast_channel_unlock(chan)
Definition: channel.h:2467
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...
Definition: pbx.c:10546
static void bridge_playfile ( struct ast_channel chan,
struct ast_channel peer,
const char *  sound,
int  remain 
)
static

Definition at line 7169 of file channel.c.

References ast_autoservice_start(), ast_autoservice_stop(), AST_DIGIT_ANY, ast_say_number(), ast_stream_and_wait(), and ast_channel::language.

Referenced by ast_channel_bridge(), and bridge_play_sounds().

7170 {
7171  int min = 0, sec = 0, check;
7172 
7173  check = ast_autoservice_start(peer);
7174  if (check)
7175  return;
7176 
7177  if (remain > 0) {
7178  if (remain / 60 > 1) {
7179  min = remain / 60;
7180  sec = remain % 60;
7181  } else {
7182  sec = remain;
7183  }
7184  }
7185 
7186  if (!strcmp(sound,"timeleft")) { /* Queue support */
7187  ast_stream_and_wait(chan, "vm-youhave", "");
7188  if (min) {
7189  ast_say_number(chan, min, AST_DIGIT_ANY, chan->language, NULL);
7190  ast_stream_and_wait(chan, "queue-minutes", "");
7191  }
7192  if (sec) {
7193  ast_say_number(chan, sec, AST_DIGIT_ANY, chan->language, NULL);
7194  ast_stream_and_wait(chan, "queue-seconds", "");
7195  }
7196  } else {
7197  ast_stream_and_wait(chan, sound, "");
7198  }
7199 
7200  ast_autoservice_stop(peer);
7201 }
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
Definition: autoservice.c:179
#define AST_DIGIT_ANY
Definition: file.h:47
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:238
int ast_stream_and_wait(struct ast_channel *chan, const char *file, const char *digits)
stream file until digit If the file name is non-empty, try to play it.
Definition: file.c:1370
int ast_say_number(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options)
says a number
Definition: channel.c:8397
const ast_string_field language
Definition: channel.h:787
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 3823 of file channel.c.

References ast_frame::samples.

Referenced by __ast_read(), and ast_write().

3824 {
3825  int diff = sample_rate - seek_rate;
3826 
3827  if (diff > 0) {
3828  samples = samples / (float) (sample_rate / seek_rate);
3829  } else if (diff < 0) {
3830  samples = samples * (float) (seek_rate / sample_rate);
3831  }
3832 
3833  return samples;
3834 }
int samples
Definition: frame.h:150
static void call_forward_inherit ( struct ast_channel new_chan,
struct ast_channel parent,
struct ast_channel orig 
)
static

Definition at line 5359 of file channel.c.

References ast_channel_datastore_inherit(), ast_channel_inherit_variables(), ast_channel_lock, ast_channel_lock_both, ast_channel_redirecting_macro(), ast_channel_unlock, ast_channel_update_redirecting(), ast_check_hangup(), AST_FLAG_ZOMBIE, ast_party_redirecting_copy(), ast_party_redirecting_free(), ast_party_redirecting_init(), ast_test_flag, and ast_channel::redirecting.

Referenced by ast_call_forward().

5360 {
5361  if (!ast_test_flag(parent, AST_FLAG_ZOMBIE) && !ast_check_hangup(parent)) {
5362  struct ast_party_redirecting redirecting;
5363 
5364  /*
5365  * The parent is not a ZOMBIE or hungup so update it with the
5366  * original channel's redirecting information.
5367  */
5368  ast_party_redirecting_init(&redirecting);
5369  ast_channel_lock(orig);
5370  ast_party_redirecting_copy(&redirecting, &orig->redirecting);
5371  ast_channel_unlock(orig);
5372  if (ast_channel_redirecting_macro(orig, parent, &redirecting, 1, 0)) {
5373  ast_channel_update_redirecting(parent, &redirecting, NULL);
5374  }
5375  ast_party_redirecting_free(&redirecting);
5376  }
5377 
5378  /* Safely inherit variables and datastores from the parent channel. */
5379  ast_channel_lock_both(parent, new_chan);
5380  ast_channel_inherit_variables(parent, new_chan);
5381  ast_channel_datastore_inherit(parent, new_chan);
5382  ast_channel_unlock(new_chan);
5383  ast_channel_unlock(parent);
5384 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define ast_test_flag(p, flag)
Definition: utils.h:63
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:9592
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Definition: channel.h:814
int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to)
Inherit datastores from a parent to a child.
Definition: channel.c:2573
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
Definition: channel.h:447
#define ast_channel_unlock(chan)
Definition: channel.h:2467
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:6241
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition: channel.h:2473
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition: channel.c:2396
void ast_party_redirecting_init(struct ast_party_redirecting *init)
Initialize the given redirecting structure.
Definition: channel.c:2359
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:2367
int ast_channel_redirecting_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *redirecting_info, int is_caller, int is_frame)
Run a redirecting interception macro and update a channel&#39;s redirecting information.
Definition: channel.c:9663
static void* channel_cc_params_copy ( void *  data)
static

Definition at line 9708 of file channel.c.

References ast_cc_config_params_init, and ast_cc_copy_config_params().

9709 {
9710  const struct ast_cc_config_params *src = data;
9712  if (!dest) {
9713  return NULL;
9714  }
9715  ast_cc_copy_config_params(dest, src);
9716  return dest;
9717 }
#define ast_cc_config_params_init()
Allocate and initialize an ast_cc_config_params structure.
Definition: ccss.h:135
void ast_cc_copy_config_params(struct ast_cc_config_params *dest, const struct ast_cc_config_params *src)
copy CCSS configuration parameters from one structure to another
Definition: ccss.c:741
static void channel_cc_params_destroy ( void *  data)
static

Definition at line 9719 of file channel.c.

References ast_cc_config_params_destroy().

9720 {
9721  struct ast_cc_config_params *cc_params = data;
9722  ast_cc_config_params_destroy(cc_params);
9723 }
void ast_cc_config_params_destroy(struct ast_cc_config_params *params)
Free memory from CCSS configuration params.
Definition: ccss.c:579
static void channel_data_add_flags ( struct ast_data tree,
struct ast_channel chan 
)
static

Definition at line 281 of file channel.c.

References ast_data_add_bool(), AST_FLAG_ANSWERED_ELSEWHERE, AST_FLAG_BLOCKING, AST_FLAG_BRIDGE_HANGUP_DONT, AST_FLAG_BRIDGE_HANGUP_RUN, AST_FLAG_DEFER_DTMF, AST_FLAG_DISABLE_DEVSTATE_CACHE, AST_FLAG_DISABLE_WORKAROUNDS, AST_FLAG_EMULATE_DTMF, AST_FLAG_END_DTMF_ONLY, AST_FLAG_EXCEPTION, AST_FLAG_IN_AUTOLOOP, AST_FLAG_IN_DTMF, AST_FLAG_MASQ_NOSTREAM, AST_FLAG_MOH, AST_FLAG_NBRIDGE, AST_FLAG_OUTGOING, AST_FLAG_SPYING, AST_FLAG_WRITE_INT, AST_FLAG_ZOMBIE, and ast_test_flag.

Referenced by ast_channel_data_add_structure().

283 {
284  ast_data_add_bool(tree, "DEFER_DTMF", ast_test_flag(chan, AST_FLAG_DEFER_DTMF));
285  ast_data_add_bool(tree, "WRITE_INT", ast_test_flag(chan, AST_FLAG_WRITE_INT));
286  ast_data_add_bool(tree, "BLOCKING", ast_test_flag(chan, AST_FLAG_BLOCKING));
287  ast_data_add_bool(tree, "ZOMBIE", ast_test_flag(chan, AST_FLAG_ZOMBIE));
288  ast_data_add_bool(tree, "EXCEPTION", ast_test_flag(chan, AST_FLAG_EXCEPTION));
289  ast_data_add_bool(tree, "MOH", ast_test_flag(chan, AST_FLAG_MOH));
290  ast_data_add_bool(tree, "SPYING", ast_test_flag(chan, AST_FLAG_SPYING));
291  ast_data_add_bool(tree, "NBRIDGE", ast_test_flag(chan, AST_FLAG_NBRIDGE));
292  ast_data_add_bool(tree, "IN_AUTOLOOP", ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP));
293  ast_data_add_bool(tree, "OUTGOING", ast_test_flag(chan, AST_FLAG_OUTGOING));
294  ast_data_add_bool(tree, "IN_DTMF", ast_test_flag(chan, AST_FLAG_IN_DTMF));
295  ast_data_add_bool(tree, "EMULATE_DTMF", ast_test_flag(chan, AST_FLAG_EMULATE_DTMF));
296  ast_data_add_bool(tree, "END_DTMF_ONLY", ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY));
297  ast_data_add_bool(tree, "ANSWERED_ELSEWHERE", ast_test_flag(chan, AST_FLAG_ANSWERED_ELSEWHERE));
298  ast_data_add_bool(tree, "MASQ_NOSTREAM", ast_test_flag(chan, AST_FLAG_MASQ_NOSTREAM));
299  ast_data_add_bool(tree, "BRIDGE_HANGUP_RUN", ast_test_flag(chan, AST_FLAG_BRIDGE_HANGUP_RUN));
300  ast_data_add_bool(tree, "BRIDGE_HANGUP_DONT", ast_test_flag(chan, AST_FLAG_BRIDGE_HANGUP_DONT));
301  ast_data_add_bool(tree, "DISABLE_WORKAROUNDS", ast_test_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS));
302  ast_data_add_bool(tree, "DISABLE_DEVSTATE_CACHE", ast_test_flag(chan, AST_FLAG_DISABLE_DEVSTATE_CACHE));
303 }
#define ast_test_flag(p, flag)
Definition: utils.h:63
struct ast_data * ast_data_add_bool(struct ast_data *root, const char *childname, unsigned int boolean)
Add a boolean node type.
Definition: data.c:2344
static struct ast_channel_iterator* channel_iterator_search ( const char *  name,
size_t  name_len,
const char *  exten,
const char *  context 
)
static

Definition at line 1657 of file channel.c.

References ast_channel_iterator::active_iterator, ao2_find, ast_calloc, ast_copy_string(), ast_free, ast_strlen_zero(), channels, ast_channel::context, ast_channel::exten, name, ast_channel::name, OBJ_MULTIPLE, and OBJ_POINTER.

Referenced by ast_channel_iterator_by_exten_new(), and ast_channel_iterator_by_name_new().

1660 {
1661  struct ast_channel_iterator *i;
1662  struct ast_channel tmp_chan = {
1663  .name = name,
1664  /* This is sort of a hack. Basically, we're using an arbitrary field
1665  * in ast_channel to pass the name_len for a prefix match. If this
1666  * gets changed, then the compare callback must be changed, too. */
1667  .rings = name_len,
1668  };
1669 
1670  if (!(i = ast_calloc(1, sizeof(*i)))) {
1671  return NULL;
1672  }
1673 
1674  if (exten) {
1675  ast_copy_string(tmp_chan.exten, exten, sizeof(tmp_chan.exten));
1676  }
1677 
1678  if (context) {
1679  ast_copy_string(tmp_chan.context, context, sizeof(tmp_chan.context));
1680  }
1681 
1682  if (!(i->active_iterator = ao2_find(channels, &tmp_chan,
1683  OBJ_MULTIPLE | ((!ast_strlen_zero(name) && (name_len == 0)) ? OBJ_POINTER : 0)))) {
1684  ast_free(i);
1685  return NULL;
1686  }
1687 
1688  return i;
1689 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:109
Main Channel structure associated with a channel.
Definition: channel.h:742
char context[AST_MAX_CONTEXT]
Definition: channel.h:868
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:197
const ast_string_field name
Definition: channel.h:787
#define ao2_find(arg1, arg2, arg3)
Definition: astobj2.h:964
static const char name[]
#define ast_free(a)
Definition: astmm.h:97
struct ao2_iterator * active_iterator
Definition: channel.c:1646
#define ast_calloc(a, b)
Definition: astmm.h:82
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:107
char exten[AST_MAX_EXTENSION]
Definition: channel.h:869
const char* channelreloadreason2txt ( enum channelreloadreason  reason)

Convert enum channelreloadreason to text string for manager event.

\ brief Convert channel reloadreason (ENUM) to text string for manager event

Definition at line 8372 of file channel.c.

References CHANNEL_CLI_RELOAD, CHANNEL_MODULE_LOAD, and CHANNEL_MODULE_RELOAD.

Referenced by reload_config().

8373 {
8374  switch (reason) {
8375  case CHANNEL_MODULE_LOAD:
8376  return "LOAD (Channel module load)";
8377 
8378  case CHANNEL_MODULE_RELOAD:
8379  return "RELOAD (Channel module reload)";
8380 
8381  case CHANNEL_CLI_RELOAD:
8382  return "CLIRELOAD (Channel module reload by CLI command)";
8383 
8384  default:
8385  return "MANAGERRELOAD (Channel module reload by manager)";
8386  }
8387 };
static void channels_shutdown ( void  )
static

Definition at line 8211 of file channel.c.

References ao2_ref, ARRAY_LEN, ast_cli_unregister_multiple(), ast_data_unregister, channels, and cli_channel.

Referenced by ast_channels_init().

8212 {
8213  ast_data_unregister(NULL);
8215  if (channels) {
8216  ao2_ref(channels, -1);
8217  channels = NULL;
8218  }
8219 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: cli.c:2177
#define ast_data_unregister(path)
Definition: data.h:394
#define ao2_ref(o, delta)
Definition: astobj2.h:472
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:197
static struct ast_cli_entry cli_channel[]
Definition: channel.c:624
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 6291 of file channel.c.

References AST_LIST_APPEND_LIST, AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_var_assign(), ast_var_t::entries, ast_var_t::name, ast_var_t::value, and ast_channel::varshead.

Referenced by ast_do_masquerade().

6292 {
6293  struct ast_var_t *current, *newvar;
6294  /* Append variables from clone channel into original channel */
6295  /* XXX Is this always correct? We have to in order to keep MACROS working XXX */
6296  AST_LIST_APPEND_LIST(&original->varshead, &clonechan->varshead, entries);
6297 
6298  /* then, dup the varshead list into the clone */
6299 
6300  AST_LIST_TRAVERSE(&original->varshead, current, entries) {
6301  newvar = ast_var_assign(current->name, current->value);
6302  if (newvar)
6303  AST_LIST_INSERT_TAIL(&clonechan->varshead, newvar, entries);
6304  }
6305 }
struct ast_var_t * ast_var_assign(const char *name, const char *value)
Definition: chanvars.c:41
char * value
Definition: chanvars.h:30
char name[0]
Definition: chanvars.h:31
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:716
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
struct ast_var_t::@158 entries
struct varshead varshead
Definition: channel.h:817
#define AST_LIST_APPEND_LIST(head, list, field)
Appends a whole list to the tail of a list.
Definition: linkedlists.h:768
static char* complete_channeltypes ( struct ast_cli_args a)
static

Definition at line 537 of file channel.c.

References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_strdup, ast_cli_args::n, ast_cli_args::pos, chanlist::tech, ast_channel_tech::type, and ast_cli_args::word.

Referenced by handle_cli_core_show_channeltype().

538 {
539  struct chanlist *cl;
540  int which = 0;
541  int wordlen;
542  char *ret = NULL;
543 
544  if (a->pos != 3)
545  return NULL;
546 
547  wordlen = strlen(a->word);
548 
551  if (!strncasecmp(a->word, cl->tech->type, wordlen) && ++which > a->n) {
552  ret = ast_strdup(cl->tech->type);
553  break;
554  }
555  }
557 
558  return ret;
559 }
struct chanlist::@238 list
const char *const type
Definition: channel.h:508
#define ast_strdup(a)
Definition: astmm.h:109
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
the list of registered channel types
Definition: channel.c:143
struct ast_channel_tech * tech
Definition: channel.c:122
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
const int n
Definition: cli.h:159
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
List of channel drivers.
Definition: app_dial.c:664
const char * word
Definition: cli.h:157
const int pos
Definition: cli.h:158
static int data_channels_provider_handler ( const struct ast_data_search search,
struct ast_data root 
)
static

Definition at line 8096 of file channel.c.

References ast_channel_data_add_structure(), ast_channel_iterator_all_new(), ast_channel_iterator_destroy(), ast_channel_iterator_next(), ast_channel_lock, ast_channel_unlock, ast_channel_unref, ast_data_add_node(), ast_data_remove_node(), ast_data_search_match(), ast_log(), and LOG_ERROR.

8098 {
8099  struct ast_channel *c;
8100  struct ast_channel_iterator *iter = NULL;
8101  struct ast_data *data_channel;
8102 
8103  for (iter = ast_channel_iterator_all_new();
8104  iter && (c = ast_channel_iterator_next(iter)); ast_channel_unref(c)) {
8105  ast_channel_lock(c);
8106 
8107  data_channel = ast_data_add_node(root, "channel");
8108  if (!data_channel) {
8109  ast_channel_unlock(c);
8110  continue;
8111  }
8112 
8113  if (ast_channel_data_add_structure(data_channel, c, 1) < 0) {
8114  ast_log(LOG_ERROR, "Unable to add channel structure for channel: %s\n", c->name);
8115  }
8116 
8117  ast_channel_unlock(c);
8118 
8119  if (!ast_data_search_match(search, data_channel)) {
8120  ast_data_remove_node(root, data_channel);
8121  }
8122  }
8123  if (iter) {
8125  }
8126 
8127  return 0;
8128 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
Main Channel structure associated with a channel.
Definition: channel.h:742
struct ast_channel * ast_channel_iterator_next(struct ast_channel_iterator *i)
Get the next channel for a channel iterator.
Definition: channel.c:1715
The data tree to be returned by the callbacks and managed by functions local to this file...
Definition: data.c:85
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2502
int ast_channel_data_add_structure(struct ast_data *tree, struct ast_channel *chan, int add_bridged)
Insert into an astdata tree, the channel structure.
Definition: channel.c:357
struct ast_data * ast_data_add_node(struct ast_data *root, const char *childname)
Add a container child.
Definition: data.c:2317
#define LOG_ERROR
Definition: logger.h:155
void ast_data_remove_node(struct ast_data *root, struct ast_data *child)
Remove a node that was added using ast_data_add_.
Definition: data.c:2486
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_channel_unlock(chan)
Definition: channel.h:2467
struct ast_channel_iterator * ast_channel_iterator_destroy(struct ast_channel_iterator *i)
Destroy a channel iterator.
Definition: channel.c:1649
struct ast_channel_iterator * ast_channel_iterator_all_new(void)
Create a new channel iterator.
Definition: channel.c:1701
int ast_data_search_match(const struct ast_data_search *search, struct ast_data *data)
Check the current generated node to know if it matches the search condition.
Definition: data.c:1458
static int data_channeltypes_provider_handler ( const struct ast_data_search search,
struct ast_data data_root 
)
static

Definition at line 8134 of file channel.c.

References ast_channel_tech::answer, ast_data_add_bool(), ast_data_add_codecs(), ast_data_add_node(), ast_data_add_str(), ast_data_remove_node(), ast_data_search_match(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_channel_tech::bridge, ast_channel_tech::bridged_channel, ast_channel_tech::call, ast_channel_tech::capabilities, ast_channel_tech::cc_callback, ast_channel_tech::description, ast_channel_tech::devicestate, ast_channel_tech::early_bridge, ast_channel_tech::exception, ast_channel_tech::fixup, ast_channel_tech::func_channel_read, ast_channel_tech::func_channel_write, ast_channel_tech::get_base_channel, ast_channel_tech::get_pvt_uniqueid, ast_channel_tech::hangup, ast_channel_tech::indicate, ast_channel_tech::queryoption, ast_channel_tech::read, ast_channel_tech::send_digit_begin, ast_channel_tech::send_digit_end, ast_channel_tech::send_html, ast_channel_tech::send_image, ast_channel_tech::send_text, ast_channel_tech::set_base_channel, ast_channel_tech::setoption, chanlist::tech, ast_channel_tech::transfer, ast_channel_tech::type, ast_channel_tech::write, ast_channel_tech::write_text, and ast_channel_tech::write_video.

8136 {
8137  struct chanlist *cl;
8138  struct ast_data *data_type;
8139 
8141  AST_RWLIST_TRAVERSE(&backends, cl, list) {
8142  data_type = ast_data_add_node(data_root, "type");
8143  if (!data_type) {
8144  continue;
8145  }
8146  ast_data_add_str(data_type, "name", cl->tech->type);
8147  ast_data_add_str(data_type, "description", cl->tech->description);
8148  ast_data_add_bool(data_type, "devicestate", cl->tech->devicestate ? 1 : 0);
8149  ast_data_add_bool(data_type, "indications", cl->tech->indicate ? 1 : 0);
8150  ast_data_add_bool(data_type, "transfer", cl->tech->transfer ? 1 : 0);
8151  ast_data_add_bool(data_type, "send_digit_begin", cl->tech->send_digit_begin ? 1 : 0);
8152  ast_data_add_bool(data_type, "send_digit_end", cl->tech->send_digit_end ? 1 : 0);
8153  ast_data_add_bool(data_type, "call", cl->tech->call ? 1 : 0);
8154  ast_data_add_bool(data_type, "hangup", cl->tech->hangup ? 1 : 0);
8155  ast_data_add_bool(data_type, "answer", cl->tech->answer ? 1 : 0);
8156  ast_data_add_bool(data_type, "read", cl->tech->read ? 1 : 0);
8157  ast_data_add_bool(data_type, "write", cl->tech->write ? 1 : 0);
8158  ast_data_add_bool(data_type, "send_text", cl->tech->send_text ? 1 : 0);
8159  ast_data_add_bool(data_type, "send_image", cl->tech->send_image ? 1 : 0);
8160  ast_data_add_bool(data_type, "send_html", cl->tech->send_html ? 1 : 0);
8161  ast_data_add_bool(data_type, "exception", cl->tech->exception ? 1 : 0);
8162  ast_data_add_bool(data_type, "bridge", cl->tech->bridge ? 1 : 0);
8163  ast_data_add_bool(data_type, "early_bridge", cl->tech->early_bridge ? 1 : 0);
8164  ast_data_add_bool(data_type, "fixup", cl->tech->fixup ? 1 : 0);
8165  ast_data_add_bool(data_type, "setoption", cl->tech->setoption ? 1 : 0);
8166  ast_data_add_bool(data_type, "queryoption", cl->tech->queryoption ? 1 : 0);
8167  ast_data_add_bool(data_type, "write_video", cl->tech->write_video ? 1 : 0);
8168  ast_data_add_bool(data_type, "write_text", cl->tech->write_text ? 1 : 0);
8169  ast_data_add_bool(data_type, "bridged_channel", cl->tech->bridged_channel ? 1 : 0);
8170  ast_data_add_bool(data_type, "func_channel_read", cl->tech->func_channel_read ? 1 : 0);
8171  ast_data_add_bool(data_type, "func_channel_write", cl->tech->func_channel_write ? 1 : 0);
8172  ast_data_add_bool(data_type, "get_base_channel", cl->tech->get_base_channel ? 1 : 0);
8173  ast_data_add_bool(data_type, "set_base_channel", cl->tech->set_base_channel ? 1 : 0);
8174  ast_data_add_bool(data_type, "get_pvt_uniqueid", cl->tech->get_pvt_uniqueid ? 1 : 0);
8175  ast_data_add_bool(data_type, "cc_callback", cl->tech->cc_callback ? 1 : 0);
8176 
8177  ast_data_add_codecs(data_type, "capabilities", cl->tech->capabilities);
8178 
8179  if (!ast_data_search_match(search, data_type)) {
8180  ast_data_remove_node(data_root, data_type);
8181  }
8182  }
8184 
8185  return 0;
8186 }
int(* func_channel_read)(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len)
Provide additional read items for CHANNEL() dialplan function.
Definition: channel.h:600
const char *const type
Definition: channel.h:508
int(*const send_image)(struct ast_channel *chan, struct ast_frame *frame)
Display or send an image.
Definition: channel.h:560
The data tree to be returned by the callbacks and managed by functions local to this file...
Definition: data.c:85
int(*const write_video)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format.
Definition: channel.h:591
format_t capabilities
Definition: channel.h:511
int(*const send_digit_begin)(struct ast_channel *chan, char digit)
Start sending a literal DTMF digit.
Definition: channel.h:528
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
int(* cc_callback)(struct ast_channel *inbound, const char *dest, ast_cc_callback_fn callback)
Call a function with cc parameters as a function parameter.
Definition: channel.h:635
struct ast_frame *(*const read)(struct ast_channel *chan)
Read a frame, in standard format (see frame.h)
Definition: channel.h:551
int(*const send_digit_end)(struct ast_channel *chan, char digit, unsigned int duration)
Stop sending a literal DTMF digit.
Definition: channel.h:535
struct ast_data * ast_data_add_bool(struct ast_data *root, const char *childname, unsigned int boolean)
Add a boolean node type.
Definition: data.c:2344
int(*const queryoption)(struct ast_channel *chan, int option, void *data, int *datalen)
Query a given option. Called with chan locked.
Definition: channel.h:585
int(*const fixup)(struct ast_channel *oldchan, struct ast_channel *newchan)
Fix up a channel: If a channel is consumed, this is called. Basically update any -&gt;owner links...
Definition: channel.h:579
the list of registered channel types
Definition: channel.c:143
int(*const answer)(struct ast_channel *chan)
Answer the channel.
Definition: channel.h:548
struct ast_channel_tech * tech
Definition: channel.c:122
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
int(*const setoption)(struct ast_channel *chan, int option, void *data, int datalen)
Set a given option. Called with chan locked.
Definition: channel.h:582
int(* set_base_channel)(struct ast_channel *chan, struct ast_channel *base)
Set base channel (agent and local)
Definition: channel.h:609
int(*const hangup)(struct ast_channel *chan)
Hangup (and possibly destroy) the channel.
Definition: channel.h:545
struct ast_data * ast_data_add_node(struct ast_data *root, const char *childname)
Add a container child.
Definition: data.c:2317
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
int(*const write_text)(struct ast_channel *chan, struct ast_frame *frame)
Write a text frame, in standard format.
Definition: channel.h:594
List of channel drivers.
Definition: app_dial.c:664
struct ast_frame *(*const exception)(struct ast_channel *chan)
Handle an exception, reading a frame.
Definition: channel.h:566
const char *(* get_pvt_uniqueid)(struct ast_channel *chan)
Get the unique identifier for the PVT, i.e. SIP call-ID for SIP.
Definition: channel.h:612
int ast_data_add_codecs(struct ast_data *root, const char *node_name, format_t capability)
Add the list of codecs in the root node based on the capability parameter.
Definition: data.c:3112
enum ast_bridge_result(*const bridge)(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms)
Bridge two channels of the same type together.
Definition: channel.h:569
void ast_data_remove_node(struct ast_data *root, struct ast_data *child)
Remove a node that was added using ast_data_add_.
Definition: data.c:2486
struct ast_channel *(* get_base_channel)(struct ast_channel *chan)
Retrieve base channel (agent and local)
Definition: channel.h:606
int(*const send_html)(struct ast_channel *chan, int subclass, const char *data, int len)
Send HTML data.
Definition: channel.h:563
int(*const transfer)(struct ast_channel *chan, const char *newdest)
Blind transfer other side (see app_transfer.c and ast_transfer()
Definition: channel.h:588
int(*const send_text)(struct ast_channel *chan, const char *text)
Display or transmit text.
Definition: channel.h:557
struct ast_channel *(*const bridged_channel)(struct ast_channel *chan, struct ast_channel *bridge)
Find bridged channel.
Definition: channel.h:597
const char *const description
Definition: channel.h:509
int(*const write)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format (see frame.h)
Definition: channel.h:554
int(*const call)(struct ast_channel *chan, char *addr, int timeout)
Call a given phone number (address, etc), but don&#39;t take longer than timeout seconds to do so...
Definition: channel.h:542
int(*const devicestate)(void *data)
Definition: channel.h:521
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:573
int(* func_channel_write)(struct ast_channel *chan, const char *function, char *data, const char *value)
Provide additional write items for CHANNEL() dialplan function.
Definition: channel.h:603
struct ast_data * ast_data_add_str(struct ast_data *root, const char *childname, const char *string)
Add a string node type.
Definition: data.c:2401
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:576
int ast_data_search_match(const struct ast_data_search *search, struct ast_data *data)
Check the current generated node to know if it matches the search condition.
Definition: data.c:1458
static void deactivate_generator_nolock ( struct ast_channel chan)
static

Definition at line 3091 of file channel.c.

References ast_channel_set_fd(), ast_clear_flag, AST_FLAG_WRITE_INT, AST_GENERATOR_FD, ast_settimeout(), generator, ast_channel::generator, ast_channel::generatordata, and ast_generator::release.

Referenced by ast_deactivate_generator(), and deactivate_silence_generator().

3092 {
3093  if (chan->generatordata) {
3094  struct ast_generator *generator = chan->generator;
3095 
3096  if (generator && generator->release) {
3097  generator->release(chan, chan->generatordata);
3098  }
3099  chan->generatordata = NULL;
3100  chan->generator = NULL;
3103  ast_settimeout(chan, 0, NULL, NULL);
3104  }
3105 }
struct ast_generator * generator
Definition: channel.h:747
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:3557
#define AST_GENERATOR_FD
Definition: channel.h:166
static struct ast_generator generator
Definition: app_fax.c:361
void(* release)(struct ast_channel *chan, void *data)
Definition: channel.h:181
#define ast_clear_flag(p, flag)
Definition: utils.h:77
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
Definition: channel.c:2631
void * generatordata
Definition: channel.h:746
static int deactivate_silence_generator ( struct ast_channel chan)
static

Definition at line 8332 of file channel.c.

References ast_channel_lock, ast_channel_unlock, ast_debug, deactivate_generator_nolock(), ast_channel::generator, ast_channel::generatordata, and ast_channel::name.

Referenced by ast_channel_stop_silence_generator().

8333 {
8334  ast_channel_lock(chan);
8335 
8336  if (!chan->generatordata) {
8337  ast_debug(1, "Trying to stop silence generator when there is no generator on '%s'\n",
8338  chan->name);
8339  ast_channel_unlock(chan);
8340  return 0;
8341  }
8342  if (chan->generator != &silence_generator) {
8343  ast_debug(1, "Trying to stop silence generator when it is not the current generator on '%s'\n",
8344  chan->name);
8345  ast_channel_unlock(chan);
8346  return 0;
8347  }
8349 
8350  ast_channel_unlock(chan);
8351 
8352  return 1;
8353 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
struct ast_generator * generator
Definition: channel.h:747
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
static struct ast_generator silence_generator
Definition: channel.c:8299
const ast_string_field name
Definition: channel.h:787
#define ast_channel_unlock(chan)
Definition: channel.h:2467
void * generatordata
Definition: channel.h:746
static void deactivate_generator_nolock(struct ast_channel *chan)
Definition: channel.c:3091
static void destroy_hooks ( struct ast_channel chan)
static

Definition at line 2793 of file channel.c.

References ast_audiohook_detach_list(), ast_framehook_list_destroy(), and ast_channel::audiohooks.

Referenced by ast_hangup().

2794 {
2795  if (chan->audiohooks) {
2797  chan->audiohooks = NULL;
2798  }
2799 
2801 }
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:155
struct ast_audiohook_list * audiohooks
Definition: channel.h:764
int ast_audiohook_detach_list(struct ast_audiohook_list *audiohook_list)
Detach audiohooks from list and destroy said list.
Definition: audiohook.c:418
static void free_translation ( struct ast_channel clonechan)
static

Definition at line 2757 of file channel.c.

References ast_translator_free_path(), ast_channel::nativeformats, ast_channel::rawreadformat, ast_channel::rawwriteformat, ast_channel::readtrans, and ast_channel::writetrans.

Referenced by ast_do_masquerade(), and ast_hangup().

2758 {
2759  if (clonechan->writetrans)
2761  if (clonechan->readtrans)
2762  ast_translator_free_path(clonechan->readtrans);
2763  clonechan->writetrans = NULL;
2764  clonechan->readtrans = NULL;
2765  clonechan->rawwriteformat = clonechan->nativeformats;
2766  clonechan->rawreadformat = clonechan->nativeformats;
2767 }
format_t rawwriteformat
Definition: channel.h:856
format_t nativeformats
Definition: channel.h:852
format_t rawreadformat
Definition: channel.h:855
struct ast_trans_pvt * writetrans
Definition: channel.h:762
struct ast_trans_pvt * readtrans
Definition: channel.h:763
void ast_translator_free_path(struct ast_trans_pvt *tr)
Frees a translator path Frees the given translator path structure.
Definition: translate.c:272
static int generator_force ( const void *  data)
static

Definition at line 3114 of file channel.c.

References ast_channel_lock, ast_channel_unlock, ast_deactivate_generator(), ast_debug, AST_FORMAT_AUDIO_MASK, ast_format_rate(), chanlist::chan, ast_generator::generate, ast_channel::generator, ast_channel::generatordata, and ast_channel::writeformat.

Referenced by ast_activate_generator().

3115 {
3116  /* Called if generator doesn't have data */
3117  void *tmp;
3118  int res;
3119  int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples) = NULL;
3120  struct ast_channel *chan = (struct ast_channel *)data;
3121 
3122  ast_channel_lock(chan);
3123  tmp = chan->generatordata;
3124  chan->generatordata = NULL;
3125  if (chan->generator)
3126  generate = chan->generator->generate;
3127  ast_channel_unlock(chan);
3128 
3129  if (!tmp || !generate)
3130  return 0;
3131 
3132  res = generate(chan, tmp, 0, ast_format_rate(chan->writeformat & AST_FORMAT_AUDIO_MASK) / 50);
3133 
3134  ast_channel_lock(chan);
3135  if (chan->generator && generate == chan->generator->generate) {
3136  chan->generatordata = tmp;
3137  }
3138  ast_channel_unlock(chan);
3139 
3140  if (res) {
3141  ast_debug(1, "Auto-deactivating generator\n");
3143  }
3144 
3145  return 0;
3146 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
Main Channel structure associated with a channel.
Definition: channel.h:742
format_t writeformat
Definition: channel.h:854
struct ast_generator * generator
Definition: channel.h:747
static force_inline int ast_format_rate(format_t format)
Get the sample rate for a given format.
Definition: frame.h:809
const char * data
Definition: channel.h:755
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
#define ast_channel_unlock(chan)
Definition: channel.h:2467
#define AST_FORMAT_AUDIO_MASK
Definition: frame.h:274
int(* generate)(struct ast_channel *chan, void *data, int len, int samples)
Definition: channel.h:186
void ast_deactivate_generator(struct ast_channel *chan)
Definition: channel.c:3107
void * generatordata
Definition: channel.h:746
static void handle_cause ( int  cause,
int *  outstate 
)
static

Definition at line 5336 of file channel.c.

References AST_CAUSE_BUSY, AST_CAUSE_CONGESTION, AST_CONTROL_BUSY, and AST_CONTROL_CONGESTION.

Referenced by __ast_request_and_dial(), and ast_call_forward().

5337 {
5338  if (outstate) {
5339  /* compute error and return */
5340  if (cause == AST_CAUSE_BUSY)
5341  *outstate = AST_CONTROL_BUSY;
5342  else if (cause == AST_CAUSE_CONGESTION)
5343  *outstate = AST_CONTROL_CONGESTION;
5344  else
5345  *outstate = 0;
5346  }
5347 }
#define AST_CAUSE_BUSY
Definition: causes.h:148
#define AST_CAUSE_CONGESTION
Definition: causes.h:152
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 562 of file channel.c.

References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_getformatname_multiple(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_channel_tech::capabilities, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_channeltypes(), ast_channel_tech::devicestate, ast_cli_args::fd, ast_channel_tech::indicate, ast_channel_tech::send_digit_begin, ast_channel_tech::send_digit_end, ast_channel_tech::send_html, ast_channel_tech::send_image, ast_channel_tech::send_text, chanlist::tech, ast_channel_tech::transfer, ast_channel_tech::type, and ast_cli_entry::usage.

563 {
564  struct chanlist *cl = NULL;
565  char buf[512];
566 
567  switch (cmd) {
568  case CLI_INIT:
569  e->command = "core show channeltype";
570  e->usage =
571  "Usage: core show channeltype <name>\n"
572  " Show details about the specified channel type, <name>.\n";
573  return NULL;
574  case CLI_GENERATE:
575  return complete_channeltypes(a);
576  }
577 
578  if (a->argc != 4)
579  return CLI_SHOWUSAGE;
580 
582 
584  if (!strncasecmp(cl->tech->type, a->argv[3], strlen(cl->tech->type)))
585  break;
586  }
587 
588 
589  if (!cl) {
590  ast_cli(a->fd, "\n%s is not a registered channel driver.\n", a->argv[3]);
592  return CLI_FAILURE;
593  }
594 
595  ast_cli(a->fd,
596  "-- Info about channel driver: %s --\n"
597  " Device State: %s\n"
598  " Indication: %s\n"
599  " Transfer : %s\n"
600  " Capabilities: %s\n"
601  " Digit Begin: %s\n"
602  " Digit End: %s\n"
603  " Send HTML : %s\n"
604  " Image Support: %s\n"
605  " Text Support: %s\n",
606  cl->tech->type,
607  (cl->tech->devicestate) ? "yes" : "no",
608  (cl->tech->indicate) ? "yes" : "no",
609  (cl->tech->transfer) ? "yes" : "no",
610  ast_getformatname_multiple(buf, sizeof(buf), (cl->tech->capabilities) ? cl->tech->capabilities : -1),
611  (cl->tech->send_digit_begin) ? "yes" : "no",
612  (cl->tech->send_digit_end) ? "yes" : "no",
613  (cl->tech->send_html) ? "yes" : "no",
614  (cl->tech->send_image) ? "yes" : "no",
615  (cl->tech->send_text) ? "yes" : "no"
616 
617  );
618 
620 
621  return CLI_SUCCESS;
622 }
struct chanlist::@238 list
const char *const type
Definition: channel.h:508
int(*const send_image)(struct ast_channel *chan, struct ast_frame *frame)
Display or send an image.
Definition: channel.h:560
format_t capabilities
Definition: channel.h:511
int(*const send_digit_begin)(struct ast_channel *chan, char digit)
Start sending a literal DTMF digit.
Definition: channel.h:528
const int argc
Definition: cli.h:154
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
Definition: cli.h:146
int(*const send_digit_end)(struct ast_channel *chan, char digit, unsigned int duration)
Stop sending a literal DTMF digit.
Definition: channel.h:535
void ast_cli(int fd, const char *fmt,...)
Definition: cli.c:105
the list of registered channel types
Definition: channel.c:143
struct ast_channel_tech * tech
Definition: channel.c:122
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
const int fd
Definition: cli.h:153
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
List of channel drivers.
Definition: app_dial.c:664
const char *const * argv
Definition: cli.h:155
#define CLI_SHOWUSAGE
Definition: cli.h:44
int(*const send_html)(struct ast_channel *chan, int subclass, const char *data, int len)
Send HTML data.
Definition: channel.h:563
int(*const transfer)(struct ast_channel *chan, const char *newdest)
Blind transfer other side (see app_transfer.c and ast_transfer()
Definition: channel.h:588
#define CLI_FAILURE
Definition: cli.h:45
int(*const send_text)(struct ast_channel *chan, const char *text)
Display or transmit text.
Definition: channel.h:557
char * command
Definition: cli.h:180
static char * complete_channeltypes(struct ast_cli_args *a)
Definition: channel.c:537
const char * usage
Definition: cli.h:171
#define CLI_SUCCESS
Definition: cli.h:43
int(*const devicestate)(void *data)
Definition: channel.h:521
char * ast_getformatname_multiple(char *buf, size_t size, format_t format)
Get the names of a set of formats.
Definition: frame.c:591
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:576
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 496 of file channel.c.

References ast_cli_args::argc, ast_cli(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_channel_tech::description, ast_channel_tech::devicestate, ast_cli_args::fd, FORMAT, ast_channel_tech::indicate, chanlist::tech, ast_channel_tech::transfer, ast_channel_tech::type, and ast_cli_entry::usage.

497 {
498 #define FORMAT "%-10.10s %-40.40s %-12.12s %-12.12s %-12.12s\n"
499  struct chanlist *cl;
500  int count_chan = 0;
501 
502  switch (cmd) {
503  case CLI_INIT:
504  e->command = "core show channeltypes";
505  e->usage =
506  "Usage: core show channeltypes\n"
507  " Lists available channel types registered in your\n"
508  " Asterisk server.\n";
509  return NULL;
510  case CLI_GENERATE:
511  return NULL;
512  }
513 
514  if (a->argc != 3)
515  return CLI_SHOWUSAGE;
516 
517  ast_cli(a->fd, FORMAT, "Type", "Description", "Devicestate", "Indications", "Transfer");
518  ast_cli(a->fd, FORMAT, "----------", "-----------", "-----------", "-----------", "--------");
519 
522  ast_cli(a->fd, FORMAT, cl->tech->type, cl->tech->description,
523  (cl->tech->devicestate) ? "yes" : "no",
524  (cl->tech->indicate) ? "yes" : "no",
525  (cl->tech->transfer) ? "yes" : "no");
526  count_chan++;
527  }
529 
530  ast_cli(a->fd, "----------\n%d channel drivers registered.\n", count_chan);
531 
532  return CLI_SUCCESS;
533 
534 #undef FORMAT
535 }
struct chanlist::@238 list
const char *const type
Definition: channel.h:508
const int argc
Definition: cli.h:154
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
Definition: cli.h:146
void ast_cli(int fd, const char *fmt,...)
Definition: cli.c:105
the list of registered channel types
Definition: channel.c:143
struct ast_channel_tech * tech
Definition: channel.c:122
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
const int fd
Definition: cli.h:153
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
List of channel drivers.
Definition: app_dial.c:664
#define CLI_SHOWUSAGE
Definition: cli.h:44
#define FORMAT
int(*const transfer)(struct ast_channel *chan, const char *newdest)
Blind transfer other side (see app_transfer.c and ast_transfer()
Definition: channel.h:588
char * command
Definition: cli.h:180
const char *const description
Definition: channel.h:509
const char * usage
Definition: cli.h:171
#define CLI_SUCCESS
Definition: cli.h:43
int(*const devicestate)(void *data)
Definition: channel.h:521
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:576
static int attribute_const is_visible_indication ( enum ast_control_frame_type  condition)
static

Definition at line 4398 of file channel.c.

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_OFFHOOK, AST_CONTROL_OPTION, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_RADIO_KEY, AST_CONTROL_RADIO_UNKEY, AST_CONTROL_READ_ACTION, AST_CONTROL_REDIRECTING, AST_CONTROL_RING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, 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 ast_indicate_data().

4399 {
4400  /* Don't include a default case here so that we get compiler warnings
4401  * when a new type is added. */
4402 
4403  switch (condition) {
4404  case AST_CONTROL_PROGRESS:
4406  case AST_CONTROL_VIDUPDATE:
4407  case AST_CONTROL_SRCUPDATE:
4408  case AST_CONTROL_SRCCHANGE:
4409  case AST_CONTROL_RADIO_KEY:
4411  case AST_CONTROL_OPTION:
4412  case AST_CONTROL_WINK:
4413  case AST_CONTROL_FLASH:
4414  case AST_CONTROL_OFFHOOK:
4416  case AST_CONTROL_ANSWER:
4417  case AST_CONTROL_HANGUP:
4420  case AST_CONTROL_TRANSFER:
4422  case _XXX_AST_CONTROL_T38:
4423  case AST_CONTROL_CC:
4425  case AST_CONTROL_AOC:
4426  case AST_CONTROL_END_OF_Q:
4428  break;
4429 
4432  case AST_CONTROL_BUSY:
4433  case AST_CONTROL_RINGING:
4434  case AST_CONTROL_RING:
4435  case AST_CONTROL_HOLD:
4436  /* You can hear these */
4437  return 1;
4438 
4439  case AST_CONTROL_UNHOLD:
4440  /* This is a special case. You stop hearing this. */
4441  break;
4442  }
4443 
4444  return 0;
4445 }
static struct ast_frame* kill_exception ( struct ast_channel chan)
static

Definition at line 635 of file channel.c.

636 {
637  /* Hangup channel. */
638  return NULL;
639 }
static int kill_fixup ( struct ast_channel oldchan,
struct ast_channel newchan 
)
static

Definition at line 647 of file channel.c.

648 {
649  /* No problem fixing up the channel. */
650  return 0;
651 }
static int kill_hangup ( struct ast_channel chan)
static

Definition at line 653 of file channel.c.

References ast_channel::tech_pvt.

654 {
655  chan->tech_pvt = NULL;
656  return 0;
657 }
void * tech_pvt
Definition: channel.h:744
static struct ast_frame* kill_read ( struct ast_channel chan)
static

Definition at line 629 of file channel.c.

630 {
631  /* Hangup channel. */
632  return NULL;
633 }
static int kill_write ( struct ast_channel chan,
struct ast_frame frame 
)
static

Definition at line 641 of file channel.c.

642 {
643  /* Hangup channel. */
644  return -1;
645 }
static void manager_bridge_event ( int  onoff,
int  type,
struct ast_channel c0,
struct ast_channel c1 
)
static

Send manager event for bridge link and unlink events.

Parameters
onoffLink/Unlinked
type1 for core, 2 for native
c0first channel in bridge
c1second channel in bridge

Definition at line 7421 of file channel.c.

References ast_manager_event_multichan, ast_channel::caller, EVENT_FLAG_CALL, ast_party_caller::id, ast_channel::name, ast_party_id::number, S_COR, ast_party_number::str, ast_channel::uniqueid, and ast_party_number::valid.

Referenced by ast_channel_bridge().

7422 {
7423  struct ast_channel *chans[2] = { c0, c1 };
7424  ast_manager_event_multichan(EVENT_FLAG_CALL, "Bridge", 2, chans,
7425  "Bridgestate: %s\r\n"
7426  "Bridgetype: %s\r\n"
7427  "Channel1: %s\r\n"
7428  "Channel2: %s\r\n"
7429  "Uniqueid1: %s\r\n"
7430  "Uniqueid2: %s\r\n"
7431  "CallerID1: %s\r\n"
7432  "CallerID2: %s\r\n",
7433  onoff ? "Link" : "Unlink",
7434  type == 1 ? "core" : "native",
7435  c0->name, c1->name,
7436  c0->uniqueid, c1->uniqueid,
7437  S_COR(c0->caller.id.number.valid, c0->caller.id.number.str, ""),
7438  S_COR(c1->caller.id.number.valid, c1->caller.id.number.str, ""));
7439 }
Main Channel structure associated with a channel.
Definition: channel.h:742
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
const ast_string_field uniqueid
Definition: channel.h:787
#define EVENT_FLAG_CALL
Definition: manager.h:72
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
#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:83
const ast_string_field name
Definition: channel.h:787
static const char type[]
Definition: chan_nbs.c:57
#define ast_manager_event_multichan(category, event, nchans, chans, contents,...)
Definition: manager.h:226
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
static void masquerade_colp_transfer ( struct ast_channel transferee,
struct xfer_masquerade_ds colp 
)
static

Definition at line 6498 of file channel.c.

References ast_alloca, ast_channel_queue_connected_line_update(), ast_connected_line_build_data(), AST_CONTROL_READ_ACTION, AST_CONTROL_UNHOLD, AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO, ast_queue_control(), ast_queue_control_data(), frame_size, ast_control_read_action_payload::payload_size, xfer_masquerade_ds::target_held, xfer_masquerade_ds::target_id, and xfer_masquerade_ds::transferee_id.

Referenced by ast_do_masquerade().

6499 {
6500  struct ast_control_read_action_payload *frame_payload;
6501  int payload_size;
6502  int frame_size;
6503  unsigned char connected_line_data[1024];
6504 
6505  /* Release any hold on the target. */
6506  if (colp->target_held) {
6508  }
6509 
6510  /*
6511  * Since transferee may not actually be bridged to another channel,
6512  * there is no way for us to queue a frame so that its connected
6513  * line status will be updated. Instead, we use the somewhat
6514  * hackish approach of using a special control frame type that
6515  * instructs ast_read() to perform a specific action. In this
6516  * case, the frame we queue tells ast_read() to call the
6517  * connected line interception macro configured for transferee.
6518  */
6519  payload_size = ast_connected_line_build_data(connected_line_data,
6520  sizeof(connected_line_data), &colp->target_id, NULL);
6521  if (payload_size != -1) {
6522  frame_size = payload_size + sizeof(*frame_payload);
6523  frame_payload = ast_alloca(frame_size);
6524  frame_payload->action = AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO;
6525  frame_payload->payload_size = payload_size;
6526  memcpy(frame_payload->payload, connected_line_data, payload_size);
6527  ast_queue_control_data(transferee, AST_CONTROL_READ_ACTION, frame_payload,
6528  frame_size);
6529  }
6530  /*
6531  * In addition to queueing the read action frame so that the
6532  * connected line info on transferee will be updated, we also are
6533  * going to queue a plain old connected line update on transferee to
6534  * update the target.
6535  */
6536  ast_channel_queue_connected_line_update(transferee, &colp->transferee_id, NULL);
6537 }
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:8825
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame with payload.
Definition: channel.c:1601
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: utils.h:653
void ast_channel_queue_connected_line_update(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Queue a connected line update frame on a channel.
Definition: channel.c:9098
struct ast_party_connected_line transferee_id
Definition: channel.c:6154
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:1608
struct ast_party_connected_line target_id
Definition: channel.c:6152
static int frame_size[4]
Definition: format_g726.c:53
static const char* oldest_linkedid ( const char *  a,
const char *  b 
)
static

Definition at line 6320 of file channel.c.

References ast_strlen_zero().

Referenced by ast_channel_set_linkgroup().

6321 {
6322  const char *satime, *saseq;
6323  const char *sbtime, *sbseq;
6324  const char *dash;
6325 
6326  unsigned int atime, aseq, btime, bseq;
6327 
6328  if (ast_strlen_zero(a))
6329  return b;
6330 
6331  if (ast_strlen_zero(b))
6332  return a;
6333 
6334  satime = a;
6335  sbtime = b;
6336 
6337  /* jump over the system name */
6338  if ((dash = strrchr(satime, '-'))) {
6339  satime = dash+1;
6340  }
6341  if ((dash = strrchr(sbtime, '-'))) {
6342  sbtime = dash+1;
6343  }
6344 
6345  /* the sequence comes after the '.' */
6346  saseq = strchr(satime, '.');
6347  sbseq = strchr(sbtime, '.');
6348  if (!saseq || !sbseq)
6349  return NULL;
6350  saseq++;
6351  sbseq++;
6352 
6353  /* convert it all to integers */
6354  atime = atoi(satime); /* note that atoi is ignoring the '.' after the time string */
6355  btime = atoi(sbtime); /* note that atoi is ignoring the '.' after the time string */
6356  aseq = atoi(saseq);
6357  bseq = atoi(sbseq);
6358 
6359  /* and finally compare */
6360  if (atime == btime) {
6361  return (aseq < bseq) ? a : b;
6362  }
6363  else {
6364  return (atime < btime) ? a : b;
6365  }
6366 }
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
static void party_connected_line_copy_transfer ( struct ast_party_connected_line dest,
const struct ast_party_connected_line src 
)
static

Definition at line 6125 of file channel.c.

References AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER, ast_party_connected_line_copy(), and ast_party_connected_line::source.

Referenced by ast_channel_transfer_masquerade().

6126 {
6128 
6129  connected = *((struct ast_party_connected_line *) src);
6130  connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER;
6131 
6132  /* Make sure empty strings will be erased. */
6133  if (!connected.id.name.str) {
6134  connected.id.name.str = "";
6135  }
6136  if (!connected.id.number.str) {
6137  connected.id.number.str = "";
6138  }
6139  if (!connected.id.subaddress.str) {
6140  connected.id.subaddress.str = "";
6141  }
6142  if (!connected.id.tag) {
6143  connected.id.tag = "";
6144  }
6145 
6146  ast_party_connected_line_copy(dest, &connected);
6147 }
Connected Line/Party information.
Definition: channel.h:401
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:2316
static int connected
Definition: cdr_pgsql.c:57
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 8722 of file channel.c.

References ast_log(), ast_party_id_presentation(), ast_party_id_ies::combined_presentation, LOG_WARNING, ast_party_id::name, ast_set_party_id::name, ast_party_id_ies::name, ast_party_id::number, ast_set_party_id::number, ast_party_id_ies::number, party_name_build_data(), party_number_build_data(), party_subaddress_build_data(), ast_party_id::subaddress, ast_set_party_id::subaddress, ast_party_id_ies::subaddress, ast_party_id::tag, and ast_party_id_ies::tag.

Referenced by ast_connected_line_build_data(), and ast_redirecting_build_data().

8725 {
8726  size_t length;
8727  size_t pos = 0;
8728  int res;
8729 
8730  /*
8731  * The size of integer values must be fixed in case the frame is
8732  * shipped to another machine.
8733  */
8734 
8735  if (!update || update->name) {
8736  res = party_name_build_data(data + pos, datalen - pos, &id->name, label,
8737  &ies->name);
8738  if (res < 0) {
8739  return -1;
8740  }
8741  pos += res;
8742  }
8743 
8744  if (!update || update->number) {
8745  res = party_number_build_data(data + pos, datalen - pos, &id->number, label,
8746  &ies->number);
8747  if (res < 0) {
8748  return -1;
8749  }
8750  pos += res;
8751  }
8752 
8753  if (!update || update->subaddress) {
8754  res = party_subaddress_build_data(data + pos, datalen - pos, &id->subaddress,
8755  label, &ies->subaddress);
8756  if (res < 0) {
8757  return -1;
8758  }
8759  pos += res;
8760  }
8761 
8762  /* *************** Party id user tag **************************** */
8763  if (id->tag) {
8764  length = strlen(id->tag);
8765  if (datalen < pos + (sizeof(data[0]) * 2) + length) {
8766  ast_log(LOG_WARNING, "No space left for %s tag\n", label);
8767  return -1;
8768  }
8769  data[pos++] = ies->tag;
8770  data[pos++] = length;
8771  memcpy(data + pos, id->tag, length);
8772  pos += length;
8773  }
8774 
8775  /* *************** Party id combined presentation *************** */
8776  if (!update || update->number) {
8777  int presentation;
8778 
8779  if (!update || update->name) {
8780  presentation = ast_party_id_presentation(id);
8781  } else {
8782  /*
8783  * We must compromise because not all the information is available
8784  * to determine a combined presentation value.
8785  * We will only send the number presentation instead.
8786  */
8787  presentation = id->number.presentation;
8788  }
8789 
8790  if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8791  ast_log(LOG_WARNING, "No space left for %s combined presentation\n", label);
8792  return -1;
8793  }
8794  data[pos++] = ies->combined_presentation;
8795  data[pos++] = 1;
8796  data[pos++] = presentation;
8797  }
8798 
8799  return pos;
8800 }
struct ast_party_subaddress_ies subaddress
Subscriber subaddress ies.
Definition: channel.c:8700
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
struct ast_party_number_ies number
Subscriber phone number ies.
Definition: channel.c:8698
#define LOG_WARNING
Definition: logger.h:144
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
Definition: channel.c:2151
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:8570
struct ast_party_name_ies name
Subscriber name ies.
Definition: channel.c:8696
unsigned char subaddress
Definition: channel.h:317
int tag
User party id tag ie.
Definition: channel.c:8702
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:294
unsigned char number
Definition: channel.h:315
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:8496
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
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:8644
int combined_presentation
Combined name and number presentation ie.
Definition: channel.c:8704
char * tag
User-set &quot;tag&quot;.
Definition: channel.h:304
unsigned char name
Definition: channel.h:313
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
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 8496 of file channel.c.

References ast_log(), ast_party_name::char_set, ast_party_name_ies::char_set, LOG_WARNING, ast_party_name::presentation, ast_party_name_ies::presentation, ast_party_name::str, ast_party_name_ies::str, ast_party_name::valid, and ast_party_name_ies::valid.

Referenced by party_id_build_data().

8497 {
8498  size_t length;
8499  size_t pos = 0;
8500 
8501  /*
8502  * The size of integer values must be fixed in case the frame is
8503  * shipped to another machine.
8504  */
8505  if (name->str) {
8506  length = strlen(name->str);
8507  if (datalen < pos + (sizeof(data[0]) * 2) + length) {
8508  ast_log(LOG_WARNING, "No space left for %s name\n", label);
8509  return -1;
8510  }
8511  data[pos++] = ies->str;
8512  data[pos++] = length;
8513  memcpy(data + pos, name->str, length);
8514  pos += length;
8515  }
8516 
8517  if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8518  ast_log(LOG_WARNING, "No space left for %s name char set\n", label);
8519  return -1;
8520  }
8521  data[pos++] = ies->char_set;
8522  data[pos++] = 1;
8523  data[pos++] = name->char_set;
8524 
8525  if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8526  ast_log(LOG_WARNING, "No space left for %s name presentation\n", label);
8527  return -1;
8528  }
8529  data[pos++] = ies->presentation;
8530  data[pos++] = 1;
8531  data[pos++] = name->presentation;
8532 
8533  if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8534  ast_log(LOG_WARNING, "No space left for %s name valid\n", label);
8535  return -1;
8536  }
8537  data[pos++] = ies->valid;
8538  data[pos++] = 1;
8539  data[pos++] = name->valid;
8540 
8541  return pos;
8542 }
int valid
valid/present ie
Definition: channel.c:8479
int char_set
Character set ie.
Definition: channel.c:8475
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:227
int presentation
presentation-indicator ie
Definition: channel.c:8477
#define LOG_WARNING
Definition: logger.h:144
int char_set
Character set the name is using.
Definition: channel.h:222
char * str
Subscriber name (Malloced)
Definition: channel.h:214
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
int str
Subscriber name ie.
Definition: channel.c:8473
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 8570 of file channel.c.

References ast_log(), LOG_WARNING, ast_party_number::plan, ast_party_number_ies::plan, ast_party_number::presentation, ast_party_number_ies::presentation, ast_party_number::str, ast_party_number_ies::str, ast_party_number::valid, and ast_party_number_ies::valid.

Referenced by party_id_build_data().

8571 {
8572  size_t length;
8573  size_t pos = 0;
8574 
8575  /*
8576  * The size of integer values must be fixed in case the frame is
8577  * shipped to another machine.
8578  */
8579  if (number->str) {
8580  length = strlen(number->str);
8581  if (datalen < pos + (sizeof(data[0]) * 2) + length) {
8582  ast_log(LOG_WARNING, "No space left for %s number\n", label);
8583  return -1;
8584  }
8585  data[pos++] = ies->str;
8586  data[pos++] = length;
8587  memcpy(data + pos, number->str, length);
8588  pos += length;
8589  }
8590 
8591  if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8592  ast_log(LOG_WARNING, "No space left for %s numbering plan\n", label);
8593  return -1;
8594  }
8595  data[pos++] = ies->plan;
8596  data[pos++] = 1;
8597  data[pos++] = number->plan;
8598 
8599  if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8600  ast_log(LOG_WARNING, "No space left for %s number presentation\n", label);
8601  return -1;
8602  }
8603  data[pos++] = ies->presentation;
8604  data[pos++] = 1;
8605  data[pos++] = number->presentation;
8606 
8607  if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8608  ast_log(LOG_WARNING, "No space left for %s number valid\n", label);
8609  return -1;
8610  }
8611  data[pos++] = ies->valid;
8612  data[pos++] = 1;
8613  data[pos++] = number->valid;
8614 
8615  return pos;
8616 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
int str
Subscriber phone number ie.
Definition: channel.c:8547
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:245
#define LOG_WARNING
Definition: logger.h:144
int plan
Type-Of-Number and Numbering-Plan ie.
Definition: channel.c:8549
int presentation
presentation-indicator ie
Definition: channel.c:8551
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:243
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int valid
valid/present ie
Definition: channel.c:8553
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
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 8644 of file channel.c.

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

8645 {
8646  size_t length;
8647  size_t pos = 0;
8648 
8649  /*
8650  * The size of integer values must be fixed in case the frame is
8651  * shipped to another machine.
8652  */
8653  if (subaddress->str) {
8654  length = strlen(subaddress->str);
8655  if (datalen < pos + (sizeof(data[0]) * 2) + length) {
8656  ast_log(LOG_WARNING, "No space left for %s subaddress\n", label);
8657  return -1;
8658  }
8659  data[pos++] = ies->str;
8660  data[pos++] = length;
8661  memcpy(data + pos, subaddress->str, length);
8662  pos += length;
8663  }
8664 
8665  if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8666  ast_log(LOG_WARNING, "No space left for %s type of subaddress\n", label);
8667  return -1;
8668  }
8669  data[pos++] = ies->type;
8670  data[pos++] = 1;
8671  data[pos++] = subaddress->type;
8672 
8673  if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8675  "No space left for %s subaddress odd-even indicator\n", label);
8676  return -1;
8677  }
8678  data[pos++] = ies->odd_even_indicator;
8679  data[pos++] = 1;
8680  data[pos++] = subaddress->odd_even_indicator;
8681 
8682  if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
8683  ast_log(LOG_WARNING, "No space left for %s subaddress valid\n", label);
8684  return -1;
8685  }
8686  data[pos++] = ies->valid;
8687  data[pos++] = 1;
8688  data[pos++] = subaddress->valid;
8689 
8690  return pos;
8691 }
#define LOG_WARNING
Definition: logger.h:144
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:278
char * str
Malloced subaddress string.
Definition: channel.h:263
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:276
int odd_even_indicator
odd/even indicator ie
Definition: channel.c:8625
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int valid
valid/present ie
Definition: channel.c:8627
int str
subaddress ie.
Definition: channel.c:8621
int type
Q.931 subaddress type.
Definition: channel.h:270
int type
subaddress type ie
Definition: channel.c:8623
static void plc_ds_destroy ( void *  data)
static

Definition at line 4825 of file channel.c.

References ast_free, and plc_ds::samples_buf.

4826 {
4827  struct plc_ds *plc = data;
4828  ast_free(plc->samples_buf);
4829  ast_free(plc);
4830 }
int16_t * samples_buf
Definition: channel.c:4817
#define ast_free(a)
Definition: astmm.h:97
static void queue_dtmf_readq ( struct ast_channel chan,
struct ast_frame f 
)
inlinestatic

Definition at line 3778 of file channel.c.

References AST_FRAME_DTMF_END, ast_queue_frame(), ast_channel::dtmff, ast_frame::frametype, ast_frame_subclass::integer, ast_frame::len, and ast_frame::subclass.

Referenced by __ast_read().

3779 {
3780  struct ast_frame *fr = &chan->dtmff;
3781 
3783  fr->subclass.integer = f->subclass.integer;
3784  fr->len = f->len;
3785 
3786  /* The only time this function will be called is for a frame that just came
3787  * out of the channel driver. So, we want to stick it on the tail of the
3788  * readq. */
3789 
3790  ast_queue_frame(chan, fr);
3791 }
union ast_frame_subclass subclass
Definition: frame.h:146
struct ast_frame dtmff
Definition: channel.h:816
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
Data structure associated with a single frame of data.
Definition: frame.h:142
enum ast_frame_type frametype
Definition: frame.h:144
long len
Definition: frame.h:170
static void report_new_callerid ( struct ast_channel chan)
static
Precondition
chan is locked

Definition at line 6468 of file channel.c.

References ast_describe_caller_presentation(), ast_manager_event, ast_party_id_presentation(), ast_channel::caller, EVENT_FLAG_CALL, ast_party_caller::id, ast_party_id::name, ast_channel::name, ast_party_id::number, S_COR, ast_party_name::str, ast_party_number::str, ast_channel::uniqueid, ast_party_name::valid, and ast_party_number::valid.

Referenced by ast_channel_set_caller_event(), ast_do_masquerade(), and ast_set_callerid().

6469 {
6470  int pres;
6471 
6472  pres = ast_party_id_presentation(&chan->caller.id);
6473  ast_manager_event(chan, EVENT_FLAG_CALL, "NewCallerid",
6474  "Channel: %s\r\n"
6475  "CallerIDNum: %s\r\n"
6476  "CallerIDName: %s\r\n"
6477  "Uniqueid: %s\r\n"
6478  "CID-CallingPres: %d (%s)\r\n",
6479  chan->name,
6480  S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""),
6481  S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, ""),
6482  chan->uniqueid,
6483  pres,
6485  );
6486 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
const ast_string_field uniqueid
Definition: channel.h:787
const char * ast_describe_caller_presentation(int data)
Convert caller ID pres value to explanatory string.
Definition: callerid.c:1165
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
Definition: channel.c:2151
#define EVENT_FLAG_CALL
Definition: manager.h:72
char * str
Subscriber name (Malloced)
Definition: channel.h:214
#define ast_manager_event(chan, category, event, contents,...)
Definition: manager.h:221
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
#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:83
const ast_string_field name
Definition: channel.h:787
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
static void send_dtmf_event ( struct ast_channel chan,
const char *  direction,
const char  digit,
const char *  begin,
const char *  end 
)
static

Definition at line 3709 of file channel.c.

References ast_manager_event, EVENT_FLAG_DTMF, ast_channel::name, and ast_channel::uniqueid.

Referenced by __ast_read(), and ast_write().

3710 {
3712  "DTMF",
3713  "Channel: %s\r\n"
3714  "Uniqueid: %s\r\n"
3715  "Digit: %c\r\n"
3716  "Direction: %s\r\n"
3717  "Begin: %s\r\n"
3718  "End: %s\r\n",
3719  chan->name, chan->uniqueid, digit, direction, begin, end);
3720 }
const ast_string_field uniqueid
Definition: channel.h:787
#define EVENT_FLAG_DTMF
Definition: manager.h:79
#define ast_manager_event(chan, category, event, contents,...)
Definition: manager.h:221
const ast_string_field name
Definition: channel.h:787
static int set_format ( struct ast_channel chan,
format_t  fmt,
format_t rawformat,
format_t format,
struct ast_trans_pvt **  trans,
const int  direction 
)
static

Definition at line 5218 of file channel.c.

References ast_best_codec(), ast_channel_lock, ast_channel_setoption(), ast_channel_unlock, ast_debug, AST_FORMAT_AUDIO_MASK, ast_getformatname(), ast_getformatname_multiple(), ast_log(), AST_OPTION_FORMAT_READ, AST_OPTION_FORMAT_WRITE, ast_translator_best_choice(), ast_translator_build_path(), ast_translator_free_path(), LOG_WARNING, ast_channel::name, and ast_channel::nativeformats.

Referenced by ast_set_read_format(), and ast_set_write_format().

5220 {
5221  format_t native, native_fmt = ast_best_codec(fmt);
5222  int res;
5223  char from[200], to[200];
5224 
5225  /* Make sure we only consider audio */
5226  fmt &= AST_FORMAT_AUDIO_MASK;
5227 
5228  native = chan->nativeformats;
5229 
5230  if (!fmt || !native) /* No audio requested */
5231  return 0; /* Let's try a call without any sounds (video, text) */
5232 
5233  /* See if the underlying channel driver is capable of performing transcoding for us */
5234  if (!ast_channel_setoption(chan, direction ? AST_OPTION_FORMAT_WRITE : AST_OPTION_FORMAT_READ, &native_fmt, sizeof(int*), 0)) {
5235  ast_debug(1, "Channel driver natively set channel %s to %s format %s\n", chan->name,
5236  direction ? "write" : "read", ast_getformatname(native_fmt));
5237  chan->nativeformats = *rawformat = *format = native_fmt;
5238  if (*trans) {
5239  ast_translator_free_path(*trans);
5240  }
5241  *trans = NULL;
5242  return 0;
5243  }
5244 
5245  /* Find a translation path from the native format to one of the desired formats */
5246  if (!direction)
5247  /* reading */
5248  res = ast_translator_best_choice(&fmt, &native);
5249  else
5250  /* writing */
5251  res = ast_translator_best_choice(&native, &fmt);
5252 
5253  if (res < 0) {
5254  ast_log(LOG_WARNING, "Unable to find a codec translation path from %s to %s\n",
5255  ast_getformatname_multiple(from, sizeof(from), native),
5256  ast_getformatname_multiple(to, sizeof(to), fmt));
5257  return -1;
5258  }
5259 
5260  /* Now we have a good choice for both. */
5261  ast_channel_lock(chan);
5262 
5263  if ((*rawformat == native) && (*format == fmt) && ((*rawformat == *format) || (*trans))) {
5264  /* the channel is already in these formats, so nothing to do */
5265  ast_channel_unlock(chan);
5266  return 0;
5267  }
5268 
5269  *rawformat = native;
5270  /* User perspective is fmt */
5271  *format = fmt;
5272  /* Free any read translation we have right now */
5273  if (*trans) {
5274  ast_translator_free_path(*trans);
5275  *trans = NULL;
5276  }
5277  /* Build a translation path from the raw format to the desired format */
5278  if (*format == *rawformat) {
5279  /*
5280  * If we were able to swap the native format to the format that
5281  * has been requested, then there is no need to try to build
5282  * a translation path.
5283  */
5284  res = 0;
5285  } else {
5286  if (!direction) {
5287  /* reading */
5288  *trans = ast_translator_build_path(*format, *rawformat);
5289  } else {
5290  /* writing */
5291  *trans = ast_translator_build_path(*rawformat, *format);
5292  }
5293  res = *trans ? 0 : -1;
5294  }
5295  ast_channel_unlock(chan);
5296  ast_debug(1, "Set channel %s to %s format %s\n", chan->name,
5297  direction ? "write" : "read", ast_getformatname(fmt));
5298  return res;
5299 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define AST_OPTION_FORMAT_WRITE
Definition: frame.h:498
#define LOG_WARNING
Definition: logger.h:144
format_t ast_best_codec(format_t fmts)
Pick the best audio codec.
Definition: channel.c:1062
format_t nativeformats
Definition: channel.h:852
int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block)
Sets an option on a channel.
Definition: channel.c:7795
struct ast_trans_pvt * ast_translator_build_path(format_t dest, format_t source)
Builds a translator path Build a path (possibly NULL) from source to dest.
Definition: translate.c:282
#define AST_OPTION_FORMAT_READ
Definition: frame.h:494
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
char * ast_getformatname(format_t format)
Get the name of a format.
Definition: frame.c:578
int64_t format_t
Definition: frame_defs.h:32
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_channel_unlock(chan)
Definition: channel.h:2467
#define AST_FORMAT_AUDIO_MASK
Definition: frame.h:274
char * ast_getformatname_multiple(char *buf, size_t size, format_t format)
Get the names of a set of formats.
Definition: frame.c:591
static snd_pcm_format_t format
Definition: chan_alsa.c:93
format_t ast_translator_best_choice(format_t *dsts, format_t *srcs)
Chooses the best translation path.
Definition: translate.c:984
void ast_translator_free_path(struct ast_trans_pvt *tr)
Frees a translator path Frees the given translator path structure.
Definition: translate.c:272
static int set_security_requirements ( const struct ast_channel requestor,
struct ast_channel out 
)
static

Definition at line 5655 of file channel.c.

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, secure_call_info, and ast_secure_call_store::signaling.

Referenced by ast_request().

5656 {
5657  int ops[2][2] = {
5660  };
5661  int i;
5662  struct ast_channel *r = (struct ast_channel *) requestor; /* UGLY */
5663  struct ast_datastore *ds;
5664 
5665  if (!requestor || !out) {
5666  return 0;
5667  }
5668 
5669  ast_channel_lock(r);
5670  if ((ds = ast_channel_datastore_find(r, &secure_call_info, NULL))) {
5671  struct ast_secure_call_store *encrypt = ds->data;
5672  ops[0][1] = encrypt->signaling;
5673  ops[1][1] = encrypt->media;
5674  } else {
5675  ast_channel_unlock(r);
5676  return 0;
5677  }
5678  ast_channel_unlock(r);
5679 
5680  for (i = 0; i < 2; i++) {
5681  if (ops[i][1]) {
5682  if (ast_channel_setoption(out, ops[i][0], &ops[i][1], sizeof(ops[i][1]), 0)) {
5683  /* We require a security feature, but the channel won't provide it */
5684  return -1;
5685  }
5686  } else {
5687  /* We don't care if we can't clear the option on a channel that doesn't support it */
5688  ast_channel_setoption(out, ops[i][0], &ops[i][1], sizeof(ops[i][1]), 0);
5689  }
5690  }
5691 
5692  return 0;
5693 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
Main Channel structure associated with a channel.
Definition: channel.h:742
Structure for a data store object.
Definition: datastore.h:54
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:2604
int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block)
Sets an option on a channel.
Definition: channel.c:7795
#define AST_OPTION_SECURE_MEDIA
Definition: frame.h:525
struct ast_datastore_info secure_call_info
#define AST_OPTION_SECURE_SIGNALING
Definition: frame.h:524
#define ast_channel_unlock(chan)
Definition: channel.h:2467
void * data
Definition: datastore.h:56
static int should_skip_dtmf ( struct ast_channel chan)
inlinestatic

Determine whether or not we should ignore DTMF in the readq.

Definition at line 3796 of file channel.c.

References AST_FLAG_DEFER_DTMF, AST_FLAG_EMULATE_DTMF, AST_MIN_DTMF_GAP, ast_test_flag, ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), and ast_channel::dtmf_tv.

Referenced by __ast_read().

3797 {
3799  /* We're in the middle of emulating a digit, or DTMF has been
3800  * explicitly deferred. Skip this digit, then. */
3801  return 1;
3802  }
3803 
3804  if (!ast_tvzero(chan->dtmf_tv) &&
3806  /* We're not in the middle of a digit, but it hasn't been long enough
3807  * since the last digit, so we'll have to skip DTMF for now. */
3808  return 1;
3809  }
3810 
3811  return 0;
3812 }
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define AST_MIN_DTMF_GAP
Definition: channel.c:118
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:100
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:90
struct timeval dtmf_tv
Definition: channel.h:822
static void* silence_generator_alloc ( struct ast_channel chan,
void *  data 
)
static

Definition at line 8269 of file channel.c.

8270 {
8271  /* just store the data pointer in the channel structure */
8272  return data;
8273 }
static int silence_generator_generate ( struct ast_channel chan,
void *  data,
int  len,
int  samples 
)
static

Definition at line 8280 of file channel.c.

References AST_FORMAT_SLINEAR, AST_FRAME_VOICE, ast_write(), ast_frame::frametype, and ast_frame::samples.

8281 {
8282  short buf[samples];
8283  struct ast_frame frame = {
8285  .subclass.codec = AST_FORMAT_SLINEAR,
8286  .data.ptr = buf,
8287  .samples = samples,
8288  .datalen = sizeof(buf),
8289  };
8290 
8291  memset(buf, 0, sizeof(buf));
8292 
8293  if (ast_write(chan, &frame))
8294  return -1;
8295 
8296  return 0;
8297 }
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
Definition: channel.c:4916
#define AST_FORMAT_SLINEAR
Definition: frame.h:254
Data structure associated with a single frame of data.
Definition: frame.h:142
enum ast_frame_type frametype
Definition: frame.h:144
int samples
Definition: frame.h:150
static void silence_generator_release ( struct ast_channel chan,
void *  data 
)
static

Definition at line 8275 of file channel.c.

8276 {
8277  /* nothing to do */
8278 }
static void* tonepair_alloc ( struct ast_channel chan,
void *  params 
)
static

Definition at line 7869 of file channel.c.

References ast_calloc, AST_FLAG_WRITE_INT, AST_FORMAT_SLINEAR, 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, ast_channel::name, 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, tonepair_def::vol, and ast_channel::writeformat.

7870 {
7871  struct tonepair_state *ts;
7872  struct tonepair_def *td = params;
7873 
7874  if (!(ts = ast_calloc(1, sizeof(*ts))))
7875  return NULL;
7876  ts->origwfmt = chan->writeformat;
7878  ast_log(LOG_WARNING, "Unable to set '%s' to signed linear format (write)\n", chan->name);
7879  tonepair_release(NULL, ts);
7880  ts = NULL;
7881  } else {
7882  ts->fac1 = 2.0 * cos(2.0 * M_PI * (td->freq1 / 8000.0)) * 32768.0;
7883  ts->v1_1 = 0;
7884  ts->v2_1 = sin(-4.0 * M_PI * (td->freq1 / 8000.0)) * td->vol;
7885  ts->v3_1 = sin(-2.0 * M_PI * (td->freq1 / 8000.0)) * td->vol;
7886  ts->v2_1 = 0;
7887  ts->fac2 = 2.0 * cos(2.0 * M_PI * (td->freq2 / 8000.0)) * 32768.0;
7888  ts->v2_2 = sin(-4.0 * M_PI * (td->freq2 / 8000.0)) * td->vol;
7889  ts->v3_2 = sin(-2.0 * M_PI * (td->freq2 / 8000.0)) * td->vol;
7890  ts->duration = td->duration;
7891  ts->modulate = 0;
7892  }
7893  /* Let interrupts interrupt :) */
7895  return ts;
7896 }
format_t writeformat
Definition: channel.h:854
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define LOG_WARNING
Definition: logger.h:144
format_t origwfmt
Definition: channel.c:7851
#define M_PI
int ast_set_write_format(struct ast_channel *chan, format_t format)
Sets write format on channel chan Set write format for channel to whichever component of &quot;format&quot; is ...
Definition: channel.c:5307
int duration
Definition: channel.c:7838
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static void tonepair_release(struct ast_channel *chan, void *params)
Definition: channel.c:7860
#define AST_FORMAT_SLINEAR
Definition: frame.h:254
#define ast_calloc(a, b)
Definition: astmm.h:82
static unsigned int cos
Definition: chan_h323.c:147
static int tonepair_generator ( struct ast_channel chan,
void *  data,
int  len,
int  samples 
)
static

Definition at line 7898 of file channel.c.

References AST_FORMAT_SLINEAR, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log(), ast_write(), ast_frame_subclass::codec, ast_frame::data, tonepair_state::data, ast_frame::datalen, tonepair_state::duration, tonepair_state::f, tonepair_state::fac1, tonepair_state::fac2, 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.

7899 {
7900  struct tonepair_state *ts = data;
7901  int x;
7902 
7903  /* we need to prepare a frame with 16 * timelen samples as we're
7904  * generating SLIN audio
7905  */
7906  len = samples * 2;
7907 
7908  if (len > sizeof(ts->data) / 2 - 1) {
7909  ast_log(LOG_WARNING, "Can't generate that much data!\n");
7910  return -1;
7911  }
7912  memset(&ts->f, 0, sizeof(ts->f));
7913  for (x=0;x<len/2;x++) {
7914  ts->v1_1 = ts->v2_1;
7915  ts->v2_1 = ts->v3_1;
7916  ts->v3_1 = (ts->fac1 * ts->v2_1 >> 15) - ts->v1_1;
7917 
7918  ts->v1_2 = ts->v2_2;
7919  ts->v2_2 = ts->v3_2;
7920  ts->v3_2 = (ts->fac2 * ts->v2_2 >> 15) - ts->v1_2;
7921  if (ts->modulate) {
7922  int p;
7923  p = ts->v3_2 - 32768;
7924  if (p < 0) p = -p;
7925  p = ((p * 9) / 10) + 1;
7926  ts->data[x] = (ts->v3_1 * p) >> 15;
7927  } else
7928  ts->data[x] = ts->v3_1 + ts->v3_2;
7929  }
7930  ts->f.frametype = AST_FRAME_VOICE;
7932  ts->f.datalen = len;
7933  ts->f.samples = samples;
7935  ts->f.data.ptr = ts->data;
7936  ast_write(chan, &ts->f);
7937  ts->pos += x;
7938  if (ts->duration > 0) {
7939  if (ts->pos >= ts->duration * 8)
7940  return -1;
7941  }
7942  return 0;
7943 }
union ast_frame_subclass subclass
Definition: frame.h:146
int offset
Definition: frame.h:156
void * ptr
Definition: frame.h:160
#define LOG_WARNING
Definition: logger.h:144
format_t codec
Definition: frame.h:137
short data[4000]
Definition: channel.c:7857
struct ast_frame f
Definition: channel.c:7855
#define AST_FRIENDLY_OFFSET
Offset into a frame&#39;s data buffer.
Definition: frame.h:204
int datalen
Definition: frame.h:148
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
Definition: channel.c:4916
#define AST_FORMAT_SLINEAR
Definition: frame.h:254
enum ast_frame_type frametype
Definition: frame.h:144
union ast_frame::@172 data
int samples
Definition: frame.h:150
static void tonepair_release ( struct ast_channel chan,
void *  params 
)
static

Definition at line 7860 of file channel.c.

References ast_free, ast_set_write_format(), and tonepair_state::origwfmt.

Referenced by tonepair_alloc().

7861 {
7862  struct tonepair_state *ts = params;
7863 
7864  if (chan)
7865  ast_set_write_format(chan, ts->origwfmt);
7866  ast_free(ts);
7867 }
format_t origwfmt
Definition: channel.c:7851
int ast_set_write_format(struct ast_channel *chan, format_t format)
Sets write format on channel chan Set write format for channel to whichever component of &quot;format&quot; is ...
Definition: channel.c:5307
#define ast_free(a)
Definition: astmm.h:97
static void update_bridge_vars ( struct ast_channel c0,
struct ast_channel c1 
)
static

Definition at line 7441 of file channel.c.

References ast_channel_lock, ast_channel_unlock, ast_strdupa, ast_strlen_zero(), ast_channel_tech::get_pvt_uniqueid, ast_channel::name, pbx_builtin_getvar_helper(), pbx_builtin_setvar_helper(), and ast_channel::tech.

Referenced by ast_channel_bridge().

7442 {
7443  const char *c0_name;
7444  const char *c1_name;
7445  const char *c0_pvtid = NULL;
7446  const char *c1_pvtid = NULL;
7447 
7448  ast_channel_lock(c1);
7449  c1_name = ast_strdupa(c1->name);
7450  if (c1->tech->get_pvt_uniqueid) {
7451  c1_pvtid = ast_strdupa(c1->tech->get_pvt_uniqueid(c1));
7452  }
7453  ast_channel_unlock(c1);
7454 
7455  ast_channel_lock(c0);
7456  if (!ast_strlen_zero(pbx_builtin_getvar_helper(c0, "BRIDGEPEER"))) {
7457  pbx_builtin_setvar_helper(c0, "BRIDGEPEER", c1_name);
7458  }
7459  if (c1_pvtid) {
7460  pbx_builtin_setvar_helper(c0, "BRIDGEPVTCALLID", c1_pvtid);
7461  }
7462  c0_name = ast_strdupa(c0->name);
7463  if (c0->tech->get_pvt_uniqueid) {
7464  c0_pvtid = ast_strdupa(c0->tech->get_pvt_uniqueid(c0));
7465  }
7466  ast_channel_unlock(c0);
7467 
7468  ast_channel_lock(c1);
7469  if (!ast_strlen_zero(pbx_builtin_getvar_helper(c1, "BRIDGEPEER"))) {
7470  pbx_builtin_setvar_helper(c1, "BRIDGEPEER", c0_name);
7471  }
7472  if (c0_pvtid) {
7473  pbx_builtin_setvar_helper(c1, "BRIDGEPVTCALLID", c0_pvtid);
7474  }
7475  ast_channel_unlock(c1);
7476 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
Definition: pbx.c:10475
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
const char *(* get_pvt_uniqueid)(struct ast_channel *chan)
Get the unique identifier for the PVT, i.e. SIP call-ID for SIP.
Definition: channel.h:612
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
const ast_string_field name
Definition: channel.h:787
#define ast_channel_unlock(chan)
Definition: channel.h:2467
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...
Definition: pbx.c:10546
struct ast_channel_tech * tech
Definition: channel.h:743
static void xfer_ds_destroy ( void *  data)
static

Definition at line 6170 of file channel.c.

References ast_free, ast_party_connected_line_free(), xfer_masquerade_ds::target_id, and xfer_masquerade_ds::transferee_id.

6171 {
6172  struct xfer_masquerade_ds *ds = data;
6173 
6176  ast_free(ds);
6177 }
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition: channel.c:2353
struct ast_party_connected_line transferee_id
Definition: channel.c:6154
#define ast_free(a)
Definition: astmm.h:97
struct ast_party_connected_line target_id
Definition: channel.c:6152

Variable Documentation

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

Referenced by ast_do_masquerade().

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 = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, 1 } , }
static
struct causes_map causes[]
static

Definition at line 209 of file channel.c.

Referenced by ast_cause2str(), ast_str2cause(), and dump_cause().

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:9708
static void channel_cc_params_destroy(void *data)
Definition: channel.c:9719

Definition at line 9725 of file channel.c.

int chancount
static

Definition at line 102 of file channel.c.

Referenced by __ast_manager_event_multichan(), and generic_fax_exec().

struct ast_data_entry channel_providers[]
static
Initial value:
= {
AST_DATA_ENTRY("/asterisk/core/channels", &channels_provider),
AST_DATA_ENTRY("/asterisk/core/channeltypes", &channeltypes_provider),
}
static struct ast_data_handler channels_provider
Definition: channel.c:8192
#define AST_DATA_ENTRY(__path, __handler)
Definition: data.h:260
static struct ast_data_handler channeltypes_provider
Definition: channel.c:8201

Definition at line 8206 of file channel.c.

struct ast_data_handler channels_provider
static
Initial value:
= {
}
#define AST_DATA_HANDLER_VERSION
The Data API structures version.
Definition: data.h:204
static int data_channels_provider_handler(const struct ast_data_search *search, struct ast_data *root)
Definition: channel.c:8096

Definition at line 8192 of file channel.c.

struct ast_data_handler channeltypes_provider
static
Initial value:
= {
}
#define AST_DATA_HANDLER_VERSION
The Data API structures version.
Definition: data.h:204
static int data_channeltypes_provider_handler(const struct ast_data_search *search, struct ast_data *data_root)
Definition: channel.c:8134

Definition at line 8201 of file channel.c.

struct ast_cli_entry cli_channel[]
static
Initial value:
= {
AST_CLI_DEFINE(handle_cli_core_show_channeltypes, "List available channel types"),
AST_CLI_DEFINE(handle_cli_core_show_channeltype, "Give more details on that channel type")
}
#define AST_CLI_DEFINE(fn, txt,...)
Definition: cli.h:191
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:562
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:496

Definition at line 624 of file channel.c.

Referenced by ast_channels_init(), and channels_shutdown().

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

Referenced by __ast_channel_alloc_ap(), and handle_core_set_debug_channel().

unsigned long global_fout

Definition at line 104 of file channel.c.

Referenced by __ast_channel_alloc_ap(), and handle_core_set_debug_channel().

struct ast_channel_tech null_tech
static
Initial value:
= {
.type = "NULL",
.description = "Null channel (should not see this)",
}

Definition at line 1120 of file channel.c.

Referenced by __ast_channel_alloc_ap().

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:4825

Definition at line 4832 of file channel.c.

int shutting_down
static

Prevent new channel allocation if shutting down.

Definition at line 99 of file channel.c.

Referenced by ast_shutting_down().

struct ast_generator silence_generator
static
Initial value:
= {
}
static void silence_generator_release(struct ast_channel *chan, void *data)
Definition: channel.c:8275
static int silence_generator_generate(struct ast_channel *chan, void *data, int len, int samples)
Definition: channel.c:8280
static void * silence_generator_alloc(struct ast_channel *chan, void *data)
Definition: channel.c:8269

Definition at line 8299 of file channel.c.

struct ast_threadstorage state2str_threadbuf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_state2str_threadbuf , .custom_init = NULL , }
static

Definition at line 106 of file channel.c.

Referenced by ast_state2str().

struct ast_generator tonepair
static
Initial value:
= {
.alloc = tonepair_alloc,
.release = tonepair_release,
.generate = tonepair_generator,
}
static void * tonepair_alloc(struct ast_channel *chan, void *params)
Definition: channel.c:7869
static int tonepair_generator(struct ast_channel *chan, void *data, int len, int samples)
Definition: channel.c:7898
static void tonepair_release(struct ast_channel *chan, void *params)
Definition: channel.c:7860

Definition at line 7945 of file channel.c.

int uniqueint
static

Definition at line 101 of file channel.c.

struct ast_datastore_info xfer_ds_info
static
Initial value:
= {
.type = "xfer_colp",
.destroy = xfer_ds_destroy,
}
static void xfer_ds_destroy(void *data)
Definition: channel.c:6170

Definition at line 6179 of file channel.c.