channel.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 1999 - 2006, Digium, Inc.
00005  *
00006  * Mark Spencer <markster@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! \file
00020  * \brief General Asterisk PBX channel definitions.
00021  * \par See also:
00022  *  \arg \ref Def_Channel
00023  *  \arg \ref channel_drivers
00024  */
00025 
00026 /*! \page Def_Channel Asterisk Channels
00027    \par What is a Channel?
00028    A phone call through Asterisk consists of an incoming
00029    connection and an outbound connection. Each call comes
00030    in through a channel driver that supports one technology,
00031    like SIP, DAHDI, IAX2 etc.
00032    \par
00033    Each channel driver, technology, has it's own private
00034    channel or dialog structure, that is technology-dependent.
00035    Each private structure is "owned" by a generic Asterisk
00036    channel structure, defined in channel.h and handled by
00037    channel.c .
00038    \par Call scenario
00039    This happens when an incoming call arrives to Asterisk
00040    -# Call arrives on a channel driver interface
00041    -# Channel driver creates a PBX channel and starts a
00042       pbx thread on the channel
00043    -# The dial plan is executed
00044    -# At this point at least two things can happen:
00045       -# The call is answered by Asterisk and
00046          Asterisk plays a media stream or reads media
00047       -# The dial plan forces Asterisk to create an outbound
00048          call somewhere with the dial (see \ref app_dial.c)
00049          application
00050    .
00051 
00052    \par Bridging channels
00053    If Asterisk dials out this happens:
00054    -# Dial creates an outbound PBX channel and asks one of the
00055       channel drivers to create a call
00056    -# When the call is answered, Asterisk bridges the media streams
00057       so the caller on the first channel can speak with the callee
00058       on the second, outbound channel
00059    -# In some cases where we have the same technology on both
00060       channels and compatible codecs, a native bridge is used.
00061       In a native bridge, the channel driver handles forwarding
00062       of incoming audio to the outbound stream internally, without
00063       sending audio frames through the PBX.
00064    -# In SIP, theres an "external native bridge" where Asterisk
00065       redirects the endpoint, so audio flows directly between the
00066       caller's phone and the callee's phone. Signalling stays in
00067       Asterisk in order to be able to provide a proper CDR record
00068       for the call.
00069 
00070 
00071    \par Masquerading channels
00072    In some cases, a channel can masquerade itself into another
00073    channel. This happens frequently in call transfers, where
00074    a new channel takes over a channel that is already involved
00075    in a call. The new channel sneaks in and takes over the bridge
00076    and the old channel, now a zombie, is hung up.
00077 
00078    \par Reference
00079    \arg channel.c - generic functions
00080    \arg channel.h - declarations of functions, flags and structures
00081    \arg translate.h - Transcoding support functions
00082    \arg \ref channel_drivers - Implemented channel drivers
00083    \arg \ref Def_Frame Asterisk Multimedia Frames
00084    \arg \ref Def_Bridge
00085 
00086 */
00087 /*! \page Def_Bridge Asterisk Channel Bridges
00088 
00089    In Asterisk, there's several media bridges.
00090 
00091    The Core bridge handles two channels (a "phone call") and bridge
00092    them together.
00093 
00094    The conference bridge (meetme) handles several channels simultaneously
00095    with the support of an external timer (DAHDI timer). This is used
00096    not only by the Conference application (meetme) but also by the
00097    page application and the SLA system introduced in 1.4.
00098    The conference bridge does not handle video.
00099 
00100    When two channels of the same type connect, the channel driver
00101    or the media subsystem used by the channel driver (i.e. RTP)
00102    can create a native bridge without sending media through the
00103    core.
00104 
00105    Native bridging can be disabled by a number of reasons,
00106    like DTMF being needed by the core or codecs being incompatible
00107    so a transcoding module is needed.
00108 
00109 References:
00110    \li \see ast_channel_early_bridge()
00111    \li \see ast_channel_bridge()
00112    \li \see app_meetme.c
00113    \li \ref AstRTPbridge
00114    \li \see ast_rtp_bridge()
00115    \li \ref Def_Channel
00116 */
00117 
00118 /*! \page AstFileDesc File descriptors
00119    Asterisk File descriptors are connected to each channel (see \ref Def_Channel)
00120    in the \ref ast_channel structure.
00121 */
00122 
00123 #ifndef _ASTERISK_CHANNEL_H
00124 #define _ASTERISK_CHANNEL_H
00125 
00126 #include "asterisk/abstract_jb.h"
00127 #include "asterisk/astobj2.h"
00128 #include "asterisk/poll-compat.h"
00129 
00130 #if defined(__cplusplus) || defined(c_plusplus)
00131 extern "C" {
00132 #endif
00133 
00134 #define AST_MAX_EXTENSION       80  /*!< Max length of an extension */
00135 #define AST_MAX_CONTEXT         80  /*!< Max length of a context */
00136 
00137 /*!
00138  * Max length of a channel uniqueid reported to the outside world.
00139  *
00140  * \details
00141  * 149 = 127 (max systemname) + "-" + 10 (epoch timestamp)
00142  *     + "." + 10 (monotonically incrementing integer).
00143  *
00144  * \note If this value is ever changed, MAX_CHANNEL_ID should
00145  * be updated in rtp_engine.h.
00146  */
00147 #define AST_MAX_PUBLIC_UNIQUEID 149
00148 
00149 /*!
00150  * Maximum size of an internal Asterisk channel unique ID.
00151  *
00152  * \details
00153  * Add two for the Local;2 channel to append a ';2' if needed
00154  * plus nul terminator.
00155  *
00156  * \note If this value is ever changed, MAX_CHANNEL_ID should
00157  * be updated in rtp_engine.h.
00158  */
00159 #define AST_MAX_UNIQUEID        (AST_MAX_PUBLIC_UNIQUEID + 2 + 1)
00160 
00161 #define AST_MAX_ACCOUNT_CODE    20  /*!< Max length of an account code */
00162 #define AST_CHANNEL_NAME        80  /*!< Max length of an ast_channel name */
00163 #define MAX_LANGUAGE            40  /*!< Max length of the language setting */
00164 #define MAX_MUSICCLASS          80  /*!< Max length of the music class setting */
00165 #define AST_MAX_USER_FIELD      256 /*!< Max length of the channel user field */
00166 
00167 #include "asterisk/frame.h"
00168 #include "asterisk/chanvars.h"
00169 #include "asterisk/config.h"
00170 #include "asterisk/lock.h"
00171 #include "asterisk/cdr.h"
00172 #include "asterisk/utils.h"
00173 #include "asterisk/linkedlists.h"
00174 #include "asterisk/stringfields.h"
00175 #include "asterisk/datastore.h"
00176 #include "asterisk/data.h"
00177 #include "asterisk/channelstate.h"
00178 #include "asterisk/ccss.h"
00179 #include "asterisk/framehook.h"
00180 #include "asterisk/stasis.h"
00181 #include "asterisk/json.h"
00182 #include "asterisk/endpoints.h"
00183 
00184 #define DATASTORE_INHERIT_FOREVER   INT_MAX
00185 
00186 #define AST_MAX_FDS     11
00187 /*
00188  * We have AST_MAX_FDS file descriptors in a channel.
00189  * Some of them have a fixed use:
00190  */
00191 #define AST_ALERT_FD (AST_MAX_FDS-1)      /*!< used for alertpipe */
00192 #define AST_TIMING_FD   (AST_MAX_FDS-2)      /*!< used for timingfd */
00193 #define AST_AGENT_FD (AST_MAX_FDS-3)      /*!< used by agents for pass through */
00194 #define AST_GENERATOR_FD   (AST_MAX_FDS-4)   /*!< used by generator */
00195 #define AST_JITTERBUFFER_FD   (AST_MAX_FDS-5)   /*!< used by generator */
00196 
00197 enum ast_bridge_result {
00198    AST_BRIDGE_COMPLETE = 0,
00199    AST_BRIDGE_FAILED = -1,
00200    AST_BRIDGE_FAILED_NOWARN = -2,
00201    AST_BRIDGE_RETRY = -3,
00202 };
00203 
00204 typedef unsigned long long ast_group_t;
00205 
00206 /*! \todo Add an explanation of an Asterisk generator
00207 */
00208 struct ast_generator {
00209    void *(*alloc)(struct ast_channel *chan, void *params);
00210    /*! Channel is locked during this function callback. */
00211    void (*release)(struct ast_channel *chan, void *data);
00212    /*! This function gets called with the channel unlocked, but is called in
00213     *  the context of the channel thread so we know the channel is not going
00214     *  to disappear.  This callback is responsible for locking the channel as
00215     *  necessary. */
00216    int (*generate)(struct ast_channel *chan, void *data, int len, int samples);
00217    /*! This gets called when DTMF_END frames are read from the channel */
00218    void (*digit)(struct ast_channel *chan, char digit);
00219    /*! This gets called when the write format on a channel is changed while
00220     * generating. The channel is locked during this callback. */
00221    void (*write_format_change)(struct ast_channel *chan, void *data);
00222 };
00223 
00224 /*! Party name character set enumeration values (values from Q.SIG) */
00225 enum AST_PARTY_CHAR_SET {
00226    AST_PARTY_CHAR_SET_UNKNOWN = 0,
00227    AST_PARTY_CHAR_SET_ISO8859_1 = 1,
00228    AST_PARTY_CHAR_SET_WITHDRAWN = 2,/* ITU withdrew this enum value. */
00229    AST_PARTY_CHAR_SET_ISO8859_2 = 3,
00230    AST_PARTY_CHAR_SET_ISO8859_3 = 4,
00231    AST_PARTY_CHAR_SET_ISO8859_4 = 5,
00232    AST_PARTY_CHAR_SET_ISO8859_5 = 6,
00233    AST_PARTY_CHAR_SET_ISO8859_7 = 7,
00234    AST_PARTY_CHAR_SET_ISO10646_BMPSTRING = 8,
00235    AST_PARTY_CHAR_SET_ISO10646_UTF_8STRING = 9,
00236 };
00237 
00238 /*!
00239  * \since 1.8
00240  * \brief Information needed to specify a name in a call.
00241  * \note All string fields here are malloc'ed, so they need to be
00242  * freed when the structure is deleted.
00243  * \note NULL and "" must be considered equivalent.
00244  */
00245 struct ast_party_name {
00246    /*! \brief Subscriber name (Malloced) */
00247    char *str;
00248    /*!
00249     * \brief Character set the name is using.
00250     * \see enum AST_PARTY_CHAR_SET
00251     * \note
00252     * Set to AST_PARTY_CHAR_SET_ISO8859_1 if unsure what to use.
00253     * \todo Start using the party name character set value.  Not currently used.
00254     */
00255    int char_set;
00256    /*!
00257     * \brief Q.931 encoded presentation-indicator encoded field
00258     * \note Must tolerate the Q.931 screening-indicator field values being present.
00259     */
00260    int presentation;
00261    /*! \brief TRUE if the name information is valid/present */
00262    unsigned char valid;
00263 };
00264 
00265 /*!
00266  * \since 1.8
00267  * \brief Information needed to specify a number in a call.
00268  * \note All string fields here are malloc'ed, so they need to be
00269  * freed when the structure is deleted.
00270  * \note NULL and "" must be considered equivalent.
00271  */
00272 struct ast_party_number {
00273    /*! \brief Subscriber phone number (Malloced) */
00274    char *str;
00275    /*! \brief Q.931 Type-Of-Number and Numbering-Plan encoded fields */
00276    int plan;
00277    /*! \brief Q.931 presentation-indicator and screening-indicator encoded fields */
00278    int presentation;
00279    /*! \brief TRUE if the number information is valid/present */
00280    unsigned char valid;
00281 };
00282 
00283 /*!
00284  * \since 1.8
00285  * \brief Information needed to specify a subaddress in a call.
00286  * \note All string fields here are malloc'ed, so they need to be
00287  * freed when the structure is deleted.
00288  * \note NULL and "" must be considered equivalent.
00289  */
00290 struct ast_party_subaddress {
00291    /*!
00292     * \brief Malloced subaddress string.
00293     * \note If the subaddress type is user specified then the subaddress is
00294     * a string of ASCII hex because the actual subaddress is likely BCD encoded.
00295     */
00296    char *str;
00297    /*!
00298     * \brief Q.931 subaddress type.
00299     * \details
00300     * nsap(0),
00301     * user_specified(2)
00302     */
00303    int type;
00304    /*!
00305     * \brief TRUE if odd number of address signals
00306     * \note The odd/even indicator is used when the type of subaddress is
00307     * user_specified and the coding is BCD.
00308     */
00309    unsigned char odd_even_indicator;
00310    /*! \brief TRUE if the subaddress information is valid/present */
00311    unsigned char valid;
00312 };
00313 
00314 /*!
00315  * \since 1.8
00316  * \brief Information needed to identify an endpoint in a call.
00317  * \note All string fields here are malloc'ed, so they need to be
00318  * freed when the structure is deleted.
00319  * \note NULL and "" must be considered equivalent.
00320  */
00321 struct ast_party_id {
00322    /*! \brief Subscriber name */
00323    struct ast_party_name name;
00324    /*! \brief Subscriber phone number */
00325    struct ast_party_number number;
00326    /*! \brief Subscriber subaddress. */
00327    struct ast_party_subaddress subaddress;
00328 
00329    /*!
00330     * \brief User-set "tag"
00331     * \details
00332     * A user-settable field used to help associate some extrinsic information
00333     * about the channel or user of the channel to the party ID.  This information
00334     * is normally not transmitted over the wire and so is only useful within an
00335     * Asterisk environment.
00336     */
00337    char *tag;
00338 };
00339 
00340 /*!
00341  * \since 1.8
00342  * \brief Indicate what information in ast_party_id should be set.
00343  */
00344 struct ast_set_party_id {
00345    /*! TRUE if the ast_party_name information should be set. */
00346    unsigned char name;
00347    /*! TRUE if the ast_party_number information should be set. */
00348    unsigned char number;
00349    /*! TRUE if the ast_party_subaddress information should be set. */
00350    unsigned char subaddress;
00351 };
00352 
00353 /*!
00354  * \since 1.8
00355  * \brief Dialed/Called Party information.
00356  * \note Dialed Number Identifier (DNID)
00357  * \note All string fields here are malloc'ed, so they need to be
00358  * freed when the structure is deleted.
00359  * \note NULL and "" must be considered equivalent.
00360  */
00361 struct ast_party_dialed {
00362    /*!
00363     * \brief Dialed/Called number
00364     * \note Done this way in case we ever really need to use ast_party_number.
00365     * We currently do not need all of the ast_party_number fields.
00366     */
00367    struct {
00368       /*! \brief Subscriber phone number (Malloced) */
00369       char *str;
00370       /*! \brief Q.931 Type-Of-Number and Numbering-Plan encoded fields */
00371       int plan;
00372    } number;
00373    /*! \brief Dialed/Called subaddress */
00374    struct ast_party_subaddress subaddress;
00375    /*!
00376     * \brief Transit Network Select
00377     * \note Currently this value is just passed around the system.
00378     * You can read it and set it but it is never used for anything.
00379     */
00380    int transit_network_select;
00381 };
00382 
00383 /*!
00384  * \since 1.8
00385  * \brief Caller Party information.
00386  * \note All string fields here are malloc'ed, so they need to be
00387  * freed when the structure is deleted.
00388  * \note NULL and "" must be considered equivalent.
00389  *
00390  * \note SIP and IAX2 has UTF8 encoded Unicode Caller ID names.
00391  * In some cases, we also have an alternative (RPID) E.164 number that can
00392  * be used as Caller ID on numeric E.164 phone networks (DAHDI or SIP/IAX2 to
00393  * PSTN gateway).
00394  *
00395  * \todo Implement settings for transliteration between UTF8 Caller ID names in
00396  *       to ASCII Caller ID's (DAHDI). Östen Åsklund might be transliterated into
00397  *       Osten Asklund or Oesten Aasklund depending upon language and person...
00398  *       We need automatic routines for incoming calls and static settings for
00399  *       our own accounts.
00400  */
00401 struct ast_party_caller {
00402    /*! \brief Caller party ID */
00403    struct ast_party_id id;
00404 
00405    /*!
00406     * \brief Automatic Number Identification (ANI)
00407     * \note The name subcomponent is only likely to be used by SIP.
00408     * \note The subaddress subcomponent is not likely to be used.
00409     */
00410    struct ast_party_id ani;
00411 
00412    /*! \brief Private caller party ID */
00413    struct ast_party_id priv;
00414 
00415    /*! \brief Automatic Number Identification 2 (Info Digits) */
00416    int ani2;
00417 };
00418 
00419 /*!
00420  * \since 1.8
00421  * \brief Indicate what information in ast_party_caller should be set.
00422  */
00423 struct ast_set_party_caller {
00424    /*! What caller id information to set. */
00425    struct ast_set_party_id id;
00426    /*! What ANI id information to set. */
00427    struct ast_set_party_id ani;
00428    /*! What private caller id information to set. */
00429    struct ast_set_party_id priv;
00430 };
00431 
00432 /*!
00433  * \since 1.8
00434  * \brief Connected Line/Party information.
00435  * \note All string fields here are malloc'ed, so they need to be
00436  * freed when the structure is deleted.
00437  * \note NULL and "" must be considered equivalent.
00438  */
00439 struct ast_party_connected_line {
00440    /*! \brief Connected party ID */
00441    struct ast_party_id id;
00442 
00443    /*!
00444     * \brief Automatic Number Identification (ANI)
00445     * \note Not really part of connected line data but needed to
00446     * save the corresponding caller id value.
00447     */
00448    struct ast_party_id ani;
00449 
00450    /*! \brief Private connected party ID */
00451    struct ast_party_id priv;
00452 
00453    /*!
00454     * \brief Automatic Number Identification 2 (Info Digits)
00455     * \note Not really part of connected line data but needed to
00456     * save the corresponding caller id value.
00457     */
00458    int ani2;
00459 
00460    /*!
00461     * \brief Information about the source of an update.
00462     * \note enum AST_CONNECTED_LINE_UPDATE_SOURCE values
00463     * for Normal-Answer and Call-transfer.
00464     */
00465    int source;
00466 };
00467 
00468 /*!
00469  * \since 1.8
00470  * \brief Indicate what information in ast_party_connected_line should be set.
00471  */
00472 struct ast_set_party_connected_line {
00473    /*! What connected line id information to set. */
00474    struct ast_set_party_id id;
00475    /*! What ANI id information to set. */
00476    struct ast_set_party_id ani;
00477    /*! What private connected line id information to set. */
00478    struct ast_set_party_id priv;
00479 };
00480 
00481 /*!
00482  * \brief Redirecting reason information
00483  */
00484 struct ast_party_redirecting_reason {
00485    /*! \brief a string value for the redirecting reason
00486     *
00487     * Useful for cases where an endpoint has specified a redirecting reason
00488     * that does not correspond to an enum AST_REDIRECTING_REASON
00489     */
00490    char *str;
00491 
00492    /*! \brief enum AST_REDIRECTING_REASON value for redirection */
00493    int code;
00494 };
00495 
00496 /*!
00497  * \since 1.8
00498  * \brief Redirecting Line information.
00499  * RDNIS (Redirecting Directory Number Information Service)
00500  * Where a call diversion or transfer was invoked.
00501  * \note All string fields here are malloc'ed, so they need to be
00502  * freed when the structure is deleted.
00503  * \note NULL and "" must be considered equivalent.
00504  */
00505 struct ast_party_redirecting {
00506    /*! \brief Who originally redirected the call (Sent to the party the call is redirected toward) */
00507    struct ast_party_id orig;
00508 
00509    /*! \brief Who is redirecting the call (Sent to the party the call is redirected toward) */
00510    struct ast_party_id from;
00511 
00512    /*! \brief Call is redirecting to a new party (Sent to the caller) */
00513    struct ast_party_id to;
00514 
00515    /*! \brief Who originally redirected the call (Sent to the party the call is redirected toward) - private representation */
00516    struct ast_party_id priv_orig;
00517 
00518    /*! \brief Who is redirecting the call (Sent to the party the call is redirected toward) - private representation */
00519    struct ast_party_id priv_from;
00520 
00521    /*! \brief Call is redirecting to a new party (Sent to the caller)  - private representation */
00522    struct ast_party_id priv_to;
00523 
00524    /*! \brief Reason for the redirection */
00525    struct ast_party_redirecting_reason reason;
00526 
00527    /*! \brief Reason for the redirection by the original party */
00528    struct ast_party_redirecting_reason orig_reason;
00529 
00530    /*! \brief Number of times the call was redirected */
00531    int count;
00532 };
00533 
00534 /*!
00535  * \since 1.8
00536  * \brief Indicate what information in ast_party_redirecting should be set.
00537  */
00538 struct ast_set_party_redirecting {
00539    /*! What redirecting-orig id information to set. */
00540    struct ast_set_party_id orig;
00541    /*! What redirecting-from id information to set. */
00542    struct ast_set_party_id from;
00543    /*! What redirecting-to id information to set. */
00544    struct ast_set_party_id to;
00545    /*! What private redirecting-orig id information to set. */
00546    struct ast_set_party_id priv_orig;
00547    /*! What private redirecting-from id information to set. */
00548    struct ast_set_party_id priv_from;
00549    /*! What private redirecting-to id information to set. */
00550    struct ast_set_party_id priv_to;
00551 };
00552 
00553 /*!
00554  * \brief Typedef for a custom read function
00555  * \note data should be treated as const char *.
00556  */
00557 typedef int (*ast_acf_read_fn_t)(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len);
00558 
00559 /*!
00560  * \brief Typedef for a custom read2 function
00561  * \note data should be treated as const char *.
00562  */
00563 typedef int (*ast_acf_read2_fn_t)(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **str, ssize_t len);
00564 
00565 /*!
00566  * \brief Typedef for a custom write function
00567  * \note data should be treated as const char *.
00568  */
00569 typedef int (*ast_acf_write_fn_t)(struct ast_channel *chan, const char *function, char *data, const char *value);
00570 
00571 /*! \brief Structure to handle passing func_channel_write info to channels via setoption */
00572 typedef struct {
00573    /*! \brief ast_chan_write_info_t version. Must be incremented if structure is changed */
00574    #define AST_CHAN_WRITE_INFO_T_VERSION 1
00575    uint32_t version;
00576    ast_acf_write_fn_t write_fn;
00577    struct ast_channel *chan;
00578    const char *function;
00579    char *data;
00580    const char *value;
00581 } ast_chan_write_info_t;
00582 
00583 /*!
00584  * \brief Structure to pass both assignedid values to channel drivers
00585  * \note The second value is used only by core_unreal (LOCAL)
00586  */
00587 struct ast_assigned_ids {
00588    const char *uniqueid;
00589    const char *uniqueid2;
00590 };
00591 
00592 /*!
00593  * \brief
00594  * Structure to describe a channel "technology", ie a channel driver
00595  * See for examples:
00596  * \arg chan_iax2.c - The Inter-Asterisk exchange protocol
00597  * \arg chan_sip.c - The SIP channel driver
00598  * \arg chan_dahdi.c - PSTN connectivity (TDM, PRI, T1/E1, FXO, FXS)
00599  *
00600  * \details
00601  * If you develop your own channel driver, this is where you
00602  * tell the PBX at registration of your driver what properties
00603  * this driver supports and where different callbacks are
00604  * implemented.
00605  */
00606 struct ast_channel_tech {
00607    const char * const type;
00608    const char * const description;
00609 
00610    struct ast_format_cap *capabilities;  /*!< format capabilities this channel can handle */
00611 
00612    int properties;         /*!< Technology Properties */
00613 
00614    /*!
00615     * \brief Requester - to set up call data structures (pvt's)
00616     *
00617     * \param type type of channel to request
00618     * \param cap Format capabilities for requested channel
00619     * \param assignedid Unique ID string to assign to channel
00620     * \param requestor channel asking for data
00621     * \param addr destination of the call
00622     * \param cause Cause of failure
00623     *
00624     * \details
00625     * Request a channel of a given type, with addr as optional information used
00626     * by the low level module
00627     *
00628     * \retval NULL failure
00629     * \retval non-NULL channel on success
00630     */
00631    struct ast_channel *(* const requester)(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause);
00632 
00633    int (* const devicestate)(const char *device_number); /*!< Devicestate call back */
00634    int (* const presencestate)(const char *presence_provider, char **subtype, char **message); /*!< Presencestate callback */
00635 
00636    /*!
00637     * \brief Start sending a literal DTMF digit
00638     *
00639     * \note The channel is not locked when this function gets called.
00640     */
00641    int (* const send_digit_begin)(struct ast_channel *chan, char digit);
00642 
00643    /*!
00644     * \brief Stop sending a literal DTMF digit
00645     *
00646     * \note The channel is not locked when this function gets called.
00647     */
00648    int (* const send_digit_end)(struct ast_channel *chan, char digit, unsigned int duration);
00649 
00650    /*!
00651     * \brief Make a call
00652     * \note The channel is locked when called.
00653     * \param chan which channel to make the call on
00654     * \param addr destination of the call
00655     * \param timeout time to wait on for connect (Doesn't seem to be used.)
00656     * \retval 0 on success
00657     * \retval -1 on failure
00658     */
00659    int (* const call)(struct ast_channel *chan, const char *addr, int timeout);
00660 
00661    /*! \brief Hangup (and possibly destroy) the channel */
00662    int (* const hangup)(struct ast_channel *chan);
00663 
00664    /*! \brief Answer the channel */
00665    int (* const answer)(struct ast_channel *chan);
00666 
00667    /*! \brief Read a frame, in standard format (see frame.h) */
00668    struct ast_frame * (* const read)(struct ast_channel *chan);
00669 
00670    /*! \brief Write a frame, in standard format (see frame.h) */
00671    int (* const write)(struct ast_channel *chan, struct ast_frame *frame);
00672 
00673    /*! \brief Display or transmit text */
00674    int (* const send_text)(struct ast_channel *chan, const char *text);
00675 
00676    /*! \brief Display or send an image */
00677    int (* const send_image)(struct ast_channel *chan, struct ast_frame *frame);
00678 
00679    /*! \brief Send HTML data */
00680    int (* const send_html)(struct ast_channel *chan, int subclass, const char *data, int len);
00681 
00682    /*! \brief Handle an exception, reading a frame */
00683    struct ast_frame * (* const exception)(struct ast_channel *chan);
00684 
00685    /*! \brief Bridge two channels of the same type together (early) */
00686    enum ast_bridge_result (* const early_bridge)(struct ast_channel *c0, struct ast_channel *c1);
00687 
00688    /*! \brief Indicate a particular condition (e.g. AST_CONTROL_BUSY or AST_CONTROL_RINGING or AST_CONTROL_CONGESTION */
00689    int (* const indicate)(struct ast_channel *c, int condition, const void *data, size_t datalen);
00690 
00691    /*! \brief Fix up a channel:  If a channel is consumed, this is called.  Basically update any ->owner links */
00692    int (* const fixup)(struct ast_channel *oldchan, struct ast_channel *newchan);
00693 
00694    /*! \brief Set a given option. Called with chan locked */
00695    int (* const setoption)(struct ast_channel *chan, int option, void *data, int datalen);
00696 
00697    /*! \brief Query a given option. Called with chan locked */
00698    int (* const queryoption)(struct ast_channel *chan, int option, void *data, int *datalen);
00699 
00700    /*! \brief Blind transfer other side (see app_transfer.c and ast_transfer() */
00701    int (* const transfer)(struct ast_channel *chan, const char *newdest);
00702 
00703    /*! \brief Write a frame, in standard format */
00704    int (* const write_video)(struct ast_channel *chan, struct ast_frame *frame);
00705 
00706    /*! \brief Write a text frame, in standard format */
00707    int (* const write_text)(struct ast_channel *chan, struct ast_frame *frame);
00708 
00709    /*!
00710     * \brief Provide additional read items for CHANNEL() dialplan function
00711     * \note data should be treated as a const char *.
00712     */
00713    int (* func_channel_read)(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len);
00714 
00715    /*!
00716     * \brief Provide additional write items for CHANNEL() dialplan function
00717     * \note data should be treated as a const char *.
00718     */
00719    int (* func_channel_write)(struct ast_channel *chan, const char *function, char *data, const char *value);
00720 
00721    /*! \brief Get the unique identifier for the PVT, i.e. SIP call-ID for SIP */
00722    const char * (* get_pvt_uniqueid)(struct ast_channel *chan);
00723 
00724    /*! \brief Call a function with cc parameters as a function parameter
00725     *
00726     * \details
00727     * This is a highly specialized callback that is not likely to be needed in many
00728     * channel drivers. When dealing with a busy channel, for instance, most channel
00729     * drivers will successfully return a channel to the requester. Once called, the channel
00730     * can then queue a busy frame when it receives an appropriate message from the far end.
00731     * In such a case, the channel driver has the opportunity to also queue a CC frame.
00732     * The parameters for the CC channel can be retrieved from the channel structure.
00733     *
00734     * For other channel drivers, notably those that deal with "dumb" phones, the channel
00735     * driver will not return a channel when one is requested. In such a scenario, there is never
00736     * an opportunity for the channel driver to queue a CC frame since the channel is never
00737     * called. Furthermore, it is not possible to retrieve the CC configuration parameters
00738     * for the desired channel because no channel is ever allocated or returned to the
00739     * requester. In such a case, call completion may still be a viable option. What we do is
00740     * pass the same string that the requester used originally to request the channel to the
00741     * channel driver. The channel driver can then find any potential channels/devices that
00742     * match the input and return call the designated callback with the device's call completion
00743     * parameters as a parameter.
00744     */
00745    int (* cc_callback)(struct ast_channel *inbound, const char *dest, ast_cc_callback_fn callback);
00746 
00747    /*!
00748     * \brief Execute a Gosub call on the channel in a technology specific way before a call is placed.
00749     * \since 11.0
00750     *
00751     * \param chan Channel to execute Gosub in a tech specific way.
00752     * \param sub_args Gosub application parameter string.
00753     *
00754     * \note The chan is locked before calling.
00755     *
00756     * \retval 0 on success.
00757     * \retval -1 on error.
00758     */
00759    int (*pre_call)(struct ast_channel *chan, const char *sub_args);
00760 };
00761 
00762 /*! Kill the channel channel driver technology descriptor. */
00763 extern const struct ast_channel_tech ast_kill_tech;
00764 
00765 struct ast_epoll_data;
00766 
00767 /*!
00768  * The high bit of the frame count is used as a debug marker, so
00769  * increments of the counters must be done with care.
00770  * Please use c->fin = FRAMECOUNT_INC(c->fin) and the same for c->fout.
00771  */
00772 #define  DEBUGCHAN_FLAG  0x80000000
00773 
00774 /* XXX not ideal to evaluate x twice... */
00775 #define  FRAMECOUNT_INC(x) ( ((x) & DEBUGCHAN_FLAG) | (((x)+1) & ~DEBUGCHAN_FLAG) )
00776 
00777 /*!
00778  * The current value of the debug flags is stored in the two
00779  * variables global_fin and global_fout (declared in main/channel.c)
00780  */
00781 extern unsigned long global_fin, global_fout;
00782 
00783 enum ast_channel_adsicpe {
00784    AST_ADSI_UNKNOWN,
00785    AST_ADSI_AVAILABLE,
00786    AST_ADSI_UNAVAILABLE,
00787    AST_ADSI_OFFHOOKONLY,
00788 };
00789 
00790 /*!
00791  * \brief Possible T38 states on channels
00792  */
00793 enum ast_t38_state {
00794    T38_STATE_UNAVAILABLE,  /*!< T38 is unavailable on this channel or disabled by configuration */
00795    T38_STATE_UNKNOWN,   /*!< The channel supports T38 but the current status is unknown */
00796    T38_STATE_NEGOTIATING,  /*!< T38 is being negotiated */
00797    T38_STATE_REJECTED,  /*!< Remote side has rejected our offer */
00798    T38_STATE_NEGOTIATED,   /*!< T38 established */
00799 };
00800 
00801 /*! Hangup handler instance node. */
00802 struct ast_hangup_handler {
00803    /*! Next hangup handler node. */
00804    AST_LIST_ENTRY(ast_hangup_handler) node;
00805    /*! Hangup handler arg string passed to the Gosub application */
00806    char args[0];
00807 };
00808 
00809 AST_LIST_HEAD_NOLOCK(ast_hangup_handler_list, ast_hangup_handler);
00810 AST_LIST_HEAD_NOLOCK(ast_datastore_list, ast_datastore);
00811 AST_LIST_HEAD_NOLOCK(ast_autochan_list, ast_autochan);
00812 AST_LIST_HEAD_NOLOCK(ast_readq_list, ast_frame);
00813 
00814 typedef int(*ast_timing_func_t)(const void *data);
00815 /*!
00816  * \page AstChannel ast_channel locking and reference tracking
00817  *
00818  * \par Creating Channels
00819  * A channel is allocated using the ast_channel_alloc() function.  When created, it is
00820  * automatically inserted into the main channels hash table that keeps track of all
00821  * active channels in the system.  The hash key is based on the channel name.  Because
00822  * of this, if you want to change the name, you _must_ use ast_change_name(), not change
00823  * the name field directly.  When ast_channel_alloc() returns a channel pointer, you now
00824  * hold both a reference to that channel and a lock on the channel. Once the channel has
00825  * been set up the lock can be released. In most cases the reference is given to ast_pbx_run().
00826  *
00827  * \par Channel Locking
00828  * There is a lock associated with every ast_channel.  It is allocated internally via astobj2.
00829  * To lock or unlock a channel, you must use the ast_channel_lock() wrappers.
00830  *
00831  * Previously, before ast_channel was converted to astobj2, the channel lock was used in some
00832  * additional ways that are no longer necessary.  Before, the only way to ensure that a channel
00833  * did not disappear out from under you if you were working with a channel outside of the channel
00834  * thread that owns it, was to hold the channel lock.  Now, that is no longer necessary.
00835  * You simply must hold a reference to the channel to ensure it does not go away.
00836  *
00837  * The channel must be locked if you need to ensure that data that you reading from the channel
00838  * does not change while you access it.  Further, you must hold the channel lock if you are
00839  * making a non-atomic change to channel data.
00840  *
00841  * \par Channel References
00842  * There are multiple ways to get a reference to a channel.  The first is that you hold a reference
00843  * to a channel after creating it.  The other ways involve using the channel search or the channel
00844  * traversal APIs.  These functions are the ast_channel_get_*() functions or ast_channel_iterator_*()
00845  * functions.  Once a reference is retrieved by one of these methods, you know that the channel will
00846  * not go away.  So, the channel should only get locked as needed for data access or modification.
00847  * But, make sure that the reference gets released when you are done with it!
00848  *
00849  * There are different things you can do when you are done with a reference to a channel.  The first
00850  * is to simply release the reference using ast_channel_unref().  The other option is to call
00851  * ast_channel_release().  This function is generally used where ast_channel_free() was used in
00852  * the past.  The release function releases a reference as well as ensures that the channel is no
00853  * longer in the global channels container.  That way, the channel will get destroyed as soon as any
00854  * other pending references get released.
00855  *
00856  * \par Exceptions to the rules
00857  * Even though ast_channel is reference counted, there are some places where pointers to an ast_channel
00858  * get stored, but the reference count does not reflect it.  The reason is mostly historical.
00859  * The only places where this happens should be places where because of how the code works, we
00860  * _know_ that the pointer to the channel will get removed before the channel goes away.  The main
00861  * example of this is in channel drivers.  Channel drivers generally store a pointer to their owner
00862  * ast_channel in their technology specific pvt struct.  In this case, the channel drivers _know_
00863  * that this pointer to the channel will be removed in time, because the channel's hangup callback
00864  * gets called before the channel goes away.
00865  */
00866 
00867 struct ast_channel;
00868 
00869 /*! \brief ast_channel_tech Properties */
00870 enum {
00871    /*!
00872     * \brief Channels have this property if they can accept input with jitter;
00873     * i.e. most VoIP channels
00874     */
00875    AST_CHAN_TP_WANTSJITTER = (1 << 0),
00876    /*!
00877     * \brief Channels have this property if they can create jitter;
00878     * i.e. most VoIP channels
00879     */
00880    AST_CHAN_TP_CREATESJITTER = (1 << 1),
00881    /*!
00882     * \brief Channels with this particular technology are an implementation detail of
00883     * Asterisk and should generally not be exposed or manipulated by the outside
00884     * world
00885     */
00886    AST_CHAN_TP_INTERNAL = (1 << 2),
00887 };
00888 
00889 /*! \brief ast_channel flags */
00890 enum {
00891    /*! Queue incoming DTMF, to be released when this flag is turned off */
00892    AST_FLAG_DEFER_DTMF =    (1 << 1),
00893    /*! write should be interrupt generator */
00894    AST_FLAG_WRITE_INT =     (1 << 2),
00895    /*! a thread is blocking on this channel */
00896    AST_FLAG_BLOCKING =      (1 << 3),
00897    /*! This is a zombie channel */
00898    AST_FLAG_ZOMBIE =        (1 << 4),
00899    /*! There is an exception pending */
00900    AST_FLAG_EXCEPTION =     (1 << 5),
00901    /*! Listening to moh XXX anthm promises me this will disappear XXX */
00902    AST_FLAG_MOH =           (1 << 6),
00903    /*! This channel is spying on another channel */
00904    AST_FLAG_SPYING =        (1 << 7),
00905    /*! the channel is in an auto-incrementing dialplan processor,
00906     *  so when ->priority is set, it will get incremented before
00907     *  finding the next priority to run */
00908    AST_FLAG_IN_AUTOLOOP =   (1 << 9),
00909    /*! This is an outgoing call */
00910    AST_FLAG_OUTGOING =      (1 << 10),
00911    /*! A DTMF_BEGIN frame has been read from this channel, but not yet an END */
00912    AST_FLAG_IN_DTMF =       (1 << 12),
00913    /*! A DTMF_END was received when not IN_DTMF, so the length of the digit is
00914     *  currently being emulated */
00915    AST_FLAG_EMULATE_DTMF =  (1 << 13),
00916    /*! This is set to tell the channel not to generate DTMF begin frames, and
00917     *  to instead only generate END frames. */
00918    AST_FLAG_END_DTMF_ONLY = (1 << 14),
00919    /* OBSOLETED in favor of AST_CAUSE_ANSWERED_ELSEWHERE
00920     * Flag to show channels that this call is hangup due to the fact that the call
00921     * was indeed answered, but in another channel */
00922    /* AST_FLAG_ANSWERED_ELSEWHERE = (1 << 15), */
00923    /*! This flag indicates that on a masquerade, an active stream should not
00924     *  be carried over */
00925    AST_FLAG_MASQ_NOSTREAM = (1 << 16),
00926    /*! This flag indicates that the hangup exten was run when the bridge terminated,
00927     *  a message aimed at preventing a subsequent hangup exten being run at the pbx_run
00928     *  level */
00929    AST_FLAG_BRIDGE_HANGUP_RUN = (1 << 17),
00930    /*! Disable certain workarounds.  This reintroduces certain bugs, but allows
00931     *  some non-traditional dialplans (like AGI) to continue to function.
00932     */
00933    AST_FLAG_DISABLE_WORKAROUNDS = (1 << 20),
00934    /*!
00935     * Disable device state event caching.  This allows channel
00936     * drivers to selectively prevent device state events from being
00937     * cached by certain channels such as anonymous calls which have
00938     * no persistent represenatation that can be tracked.
00939     */
00940    AST_FLAG_DISABLE_DEVSTATE_CACHE = (1 << 21),
00941    /*!
00942     * This flag indicates that a dual channel redirect is in
00943     * progress.  The bridge needs to wait until the flag is cleared
00944     * to continue.
00945     */
00946    AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT = (1 << 22),
00947    /*!
00948     * This flag indicates that the channel was originated.
00949     */
00950    AST_FLAG_ORIGINATED = (1 << 23),
00951    /*!
00952     * The channel is well and truly dead. Once this is set and published, no further
00953     * actions should be taken upon the channel, and no further publications should
00954     * occur.
00955     */
00956    AST_FLAG_DEAD = (1 << 24),
00957    /*!
00958     * Channel snapshot should not be published, it is being staged for an explicit
00959     * publish.
00960     */
00961    AST_FLAG_SNAPSHOT_STAGE = (1 << 25),
00962    /*!
00963     * The data on chan->timingdata is an astobj2 object.
00964     */
00965    AST_FLAG_TIMINGDATA_IS_AO2_OBJ = (1 << 26),
00966    /*!
00967     * The channel is executing a subroutine or macro
00968     */
00969    AST_FLAG_SUBROUTINE_EXEC = (1 << 27),
00970 };
00971 
00972 /*! \brief ast_bridge_config flags */
00973 enum {
00974    AST_FEATURE_PLAY_WARNING = (1 << 0),
00975    AST_FEATURE_REDIRECT =     (1 << 1),
00976    AST_FEATURE_DISCONNECT =   (1 << 2),
00977    AST_FEATURE_ATXFER =       (1 << 3),
00978    AST_FEATURE_AUTOMON =      (1 << 4),
00979    AST_FEATURE_PARKCALL =     (1 << 5),
00980    AST_FEATURE_AUTOMIXMON =   (1 << 6),
00981 };
00982 
00983 #define AST_FEATURE_DTMF_MASK (AST_FEATURE_REDIRECT | AST_FEATURE_DISCONNECT |\
00984    AST_FEATURE_ATXFER | AST_FEATURE_AUTOMON | AST_FEATURE_PARKCALL | AST_FEATURE_AUTOMIXMON)
00985 
00986 /*! \brief bridge configuration */
00987 struct ast_bridge_config {
00988    struct ast_flags features_caller;
00989    struct ast_flags features_callee;
00990    struct timeval start_time;
00991    struct timeval nexteventts;
00992    struct timeval feature_start_time;
00993    long feature_timer;
00994    long timelimit;
00995    long play_warning;
00996    long warning_freq;
00997    const char *warning_sound;
00998    const char *end_sound;
00999    const char *start_sound;
01000    unsigned int flags;
01001    void (* end_bridge_callback)(void *);   /*!< A callback that is called after a bridge attempt */
01002    void *end_bridge_callback_data;         /*!< Data passed to the callback */
01003    /*! If the end_bridge_callback_data refers to a channel which no longer is going to
01004     * exist when the end_bridge_callback is called, then it needs to be fixed up properly
01005     */
01006    void (*end_bridge_callback_data_fixup)(struct ast_bridge_config *bconfig, struct ast_channel *originator, struct ast_channel *terminator);
01007 };
01008 
01009 struct chanmon;
01010 
01011 struct outgoing_helper {
01012    const char *context;
01013    const char *exten;
01014    int priority;
01015    int connect_on_early_media;   /* If set, treat session progress as answer */
01016    const char *cid_num;
01017    const char *cid_name;
01018    const char *account;
01019    struct ast_variable *vars;
01020    struct ast_channel *parent_channel;
01021 };
01022 
01023 enum {
01024    /*!
01025     * Soft hangup requested by device or other internal reason.
01026     * Actual hangup needed.
01027     */
01028    AST_SOFTHANGUP_DEV =       (1 << 0),
01029    /*!
01030     * Used to break the normal frame flow so an async goto can be
01031     * done instead of actually hanging up.
01032     */
01033    AST_SOFTHANGUP_ASYNCGOTO = (1 << 1),
01034    /*!
01035     * Soft hangup requested by system shutdown.  Actual hangup
01036     * needed.
01037     */
01038    AST_SOFTHANGUP_SHUTDOWN =  (1 << 2),
01039    /*!
01040     * Used to break the normal frame flow after a timeout so an
01041     * implicit async goto can be done to the 'T' exten if it exists
01042     * instead of actually hanging up.  If the exten does not exist
01043     * then actually hangup.
01044     */
01045    AST_SOFTHANGUP_TIMEOUT =   (1 << 3),
01046    /*!
01047     * Soft hangup requested by application/channel-driver being
01048     * unloaded.  Actual hangup needed.
01049     */
01050    AST_SOFTHANGUP_APPUNLOAD = (1 << 4),
01051    /*!
01052     * Soft hangup requested by non-associated party.  Actual hangup
01053     * needed.
01054     */
01055    AST_SOFTHANGUP_EXPLICIT =  (1 << 5),
01056    /*!
01057     * Used to indicate that the channel is currently executing hangup
01058     * logic in the dialplan. The channel has been hungup when this is
01059     * set.
01060     */
01061    AST_SOFTHANGUP_HANGUP_EXEC = (1 << 7),
01062    /*!
01063     * \brief All softhangup flags.
01064     *
01065     * This can be used as an argument to ast_channel_clear_softhangup()
01066     * to clear all softhangup flags from a channel.
01067     */
01068    AST_SOFTHANGUP_ALL =       (0xFFFFFFFF)
01069 };
01070 
01071 
01072 /*! \brief Channel reload reasons for manager events at load or reload of configuration */
01073 enum channelreloadreason {
01074    CHANNEL_MODULE_LOAD,
01075    CHANNEL_MODULE_RELOAD,
01076    CHANNEL_CLI_RELOAD,
01077    CHANNEL_MANAGER_RELOAD,
01078    CHANNEL_ACL_RELOAD,
01079 };
01080 
01081 /*!
01082  * \brief Channel AMA Flags
01083  */
01084 enum ama_flags {
01085    AST_AMA_NONE = 0,
01086    AST_AMA_OMIT,
01087    AST_AMA_BILLING,
01088    AST_AMA_DOCUMENTATION,
01089 };
01090 
01091 /*!
01092  * \note None of the datastore API calls lock the ast_channel they are using.
01093  *       So, the channel should be locked before calling the functions that
01094  *       take a channel argument.
01095  */
01096 
01097 /*!
01098  * \brief Create a channel data store object
01099  * \deprecated You should use the ast_datastore_alloc() generic function instead.
01100  * \version 1.6.1 deprecated
01101  */
01102 struct ast_datastore * attribute_malloc ast_channel_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
01103    __attribute__((deprecated));
01104 
01105 /*!
01106  * \brief Free a channel data store object
01107  * \deprecated You should use the ast_datastore_free() generic function instead.
01108  * \version 1.6.1 deprecated
01109  */
01110 int ast_channel_datastore_free(struct ast_datastore *datastore)
01111    __attribute__((deprecated));
01112 
01113 /*! \brief Inherit datastores from a parent to a child. */
01114 int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to);
01115 
01116 /*!
01117  * \brief Add a datastore to a channel
01118  *
01119  * \note The channel should be locked before calling this function.
01120  *
01121  * \retval 0 success
01122  * \retval non-zero failure
01123  */
01124 int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore);
01125 
01126 /*!
01127  * \brief Remove a datastore from a channel
01128  *
01129  * \note The channel should be locked before calling this function.
01130  *
01131  * \retval 0 success
01132  * \retval non-zero failure
01133  */
01134 int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore);
01135 
01136 /*!
01137  * \brief Find a datastore on a channel
01138  *
01139  * \note The channel should be locked before calling this function.
01140  *
01141  * \note The datastore returned from this function must not be used if the
01142  *       reference to the channel is released.
01143  *
01144  * \retval pointer to the datastore if found
01145  * \retval NULL if not found
01146  */
01147 struct ast_datastore *ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid);
01148 
01149 /*!
01150  * \brief Create a channel structure
01151  * \since 1.8
01152  *
01153  * \retval NULL failure
01154  * \retval non-NULL successfully allocated channel
01155  *
01156  * \note Absolutely _NO_ channel locks should be held before calling this function.
01157  * \note By default, new channels are set to the "s" extension
01158  *       and "default" context.
01159  * \note Since 12.0.0 this function returns with the newly created channel locked.
01160  */
01161 struct ast_channel * attribute_malloc __attribute__((format(printf, 15, 16)))
01162    __ast_channel_alloc(int needqueue, int state, const char *cid_num,
01163       const char *cid_name, const char *acctcode,
01164       const char *exten, const char *context, const struct ast_assigned_ids *assignedids,
01165       const struct ast_channel *requestor, enum ama_flags amaflag,
01166       struct ast_endpoint *endpoint,
01167       const char *file, int line, const char *function,
01168       const char *name_fmt, ...);
01169 
01170 /*!
01171  * \brief Create a channel structure
01172  *
01173  * \retval NULL failure
01174  * \retval non-NULL successfully allocated channel
01175  *
01176  * \note Absolutely _NO_ channel locks should be held before calling this function.
01177  * \note By default, new channels are set to the "s" extension
01178  *       and "default" context.
01179  * \note Since 12.0.0 this function returns with the newly created channel locked.
01180  */
01181 #define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag, ...) \
01182    __ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag, NULL, \
01183       __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__)
01184 
01185 #define ast_channel_alloc_with_endpoint(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag, endpoint, ...) \
01186    __ast_channel_alloc((needqueue), (state), (cid_num), (cid_name), (acctcode), (exten), (context), (assignedids), (requestor), (amaflag), (endpoint), \
01187       __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__)
01188 
01189 
01190 #if defined(REF_DEBUG) || defined(__AST_DEBUG_MALLOC)
01191 /*!
01192  * \brief Create a fake channel structure
01193  *
01194  * \retval NULL failure
01195  * \retval non-NULL successfully allocated channel
01196  *
01197  * \note This function should ONLY be used to create a fake channel
01198  *       that can then be populated with data for use in variable
01199  *       substitution when a real channel does not exist.
01200  *
01201  * \note The created dummy channel should be destroyed by
01202  * ast_channel_unref().  Using ast_channel_release() needlessly
01203  * grabs the channel container lock and can cause a deadlock as
01204  * a result.  Also grabbing the channel container lock reduces
01205  * system performance.
01206  */
01207 #define ast_dummy_channel_alloc()   __ast_dummy_channel_alloc(__FILE__, __LINE__, __PRETTY_FUNCTION__)
01208 struct ast_channel *__ast_dummy_channel_alloc(const char *file, int line, const char *function);
01209 #else
01210 /*!
01211  * \brief Create a fake channel structure
01212  *
01213  * \retval NULL failure
01214  * \retval non-NULL successfully allocated channel
01215  *
01216  * \note This function should ONLY be used to create a fake channel
01217  *       that can then be populated with data for use in variable
01218  *       substitution when a real channel does not exist.
01219  *
01220  * \note The created dummy channel should be destroyed by
01221  * ast_channel_unref().  Using ast_channel_release() needlessly
01222  * grabs the channel container lock and can cause a deadlock as
01223  * a result.  Also grabbing the channel container lock reduces
01224  * system performance.
01225  */
01226 struct ast_channel *ast_dummy_channel_alloc(void);
01227 #endif
01228 
01229 /*!
01230  * \brief Queue one or more frames to a channel's frame queue
01231  *
01232  * \param chan the channel to queue the frame(s) on
01233  * \param f the frame(s) to queue.  Note that the frame(s) will be duplicated
01234  *        by this function.  It is the responsibility of the caller to handle
01235  *        freeing the memory associated with the frame(s) being passed if
01236  *        necessary.
01237  *
01238  * \retval 0 success
01239  * \retval non-zero failure
01240  */
01241 int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f);
01242 
01243 /*!
01244  * \brief Queue one or more frames to the head of a channel's frame queue
01245  *
01246  * \param chan the channel to queue the frame(s) on
01247  * \param f the frame(s) to queue.  Note that the frame(s) will be duplicated
01248  *        by this function.  It is the responsibility of the caller to handle
01249  *        freeing the memory associated with the frame(s) being passed if
01250  *        necessary.
01251  *
01252  * \retval 0 success
01253  * \retval non-zero failure
01254  */
01255 int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *f);
01256 
01257 /*!
01258  * \brief Queue a hangup frame
01259  *
01260  * \note The channel does not need to be locked before calling this function.
01261  */
01262 int ast_queue_hangup(struct ast_channel *chan);
01263 
01264 /*!
01265  * \brief Queue a hangup frame with hangupcause set
01266  *
01267  * \note The channel does not need to be locked before calling this function.
01268  * \param[in] chan channel to queue frame onto
01269  * \param[in] cause the hangup cause
01270  * \return 0 on success, -1 on error
01271  * \since 1.6.1
01272  */
01273 int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause);
01274 
01275 /*!
01276  * \brief Queue a hold frame
01277  *
01278  * \param chan channel to queue frame onto
01279  * \param musicclass The suggested musicclass for the other end to use
01280  *
01281  * \note The channel does not need to be locked before calling this function.
01282  *
01283  * \retval zero on success
01284  * \retval non-zero on failure
01285  */
01286 int ast_queue_hold(struct ast_channel *chan, const char *musicclass);
01287 
01288 /*!
01289  * \brief Queue an unhold frame
01290  *
01291  * \param chan channel to queue frame onto
01292  *
01293  * \note The channel does not need to be locked before calling this function.
01294  *
01295  * \retval zero on success
01296  * \retval non-zero on failure
01297  */
01298 int ast_queue_unhold(struct ast_channel *chan);
01299 
01300 /*!
01301  * \brief Queue a control frame without payload
01302  *
01303  * \param chan channel to queue frame onto
01304  * \param control type of control frame
01305  *
01306  * \note The channel does not need to be locked before calling this function.
01307  *
01308  * \retval zero on success
01309  * \retval non-zero on failure
01310  */
01311 int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control);
01312 
01313 /*!
01314  * \brief Queue a control frame with payload
01315  *
01316  * \param chan channel to queue frame onto
01317  * \param control type of control frame
01318  * \param data pointer to payload data to be included in frame
01319  * \param datalen number of bytes of payload data
01320  *
01321  * \retval 0 success
01322  * \retval non-zero failure
01323  *
01324  * \details
01325  * The supplied payload data is copied into the frame, so the caller's copy
01326  * is not modified nor freed, and the resulting frame will retain a copy of
01327  * the data even if the caller frees their local copy.
01328  *
01329  * \note This method should be treated as a 'network transport'; in other
01330  * words, your frames may be transferred across an IAX2 channel to another
01331  * system, which may be a different endianness than yours. Because of this,
01332  * you should ensure that either your frames will never be expected to work
01333  * across systems, or that you always put your payload data into 'network byte
01334  * order' before calling this function.
01335  *
01336  * \note The channel does not need to be locked before calling this function.
01337  */
01338 int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control,
01339             const void *data, size_t datalen);
01340 
01341 /*!
01342  * \brief Change channel name
01343  *
01344  * \pre Absolutely all channels _MUST_ be unlocked before calling this function.
01345  *
01346  * \param chan the channel to change the name of
01347  * \param newname the name to change to
01348  *
01349  * \return nothing
01350  *
01351  * \note this function must _NEVER_ be used when any channels are locked
01352  * regardless if it is the channel who's name is being changed or not because
01353  * it invalidates our channel container locking order... lock container first,
01354  * then the individual channels, never the other way around.
01355  */
01356 void ast_change_name(struct ast_channel *chan, const char *newname);
01357 
01358 /*!
01359  * \brief Unlink and release reference to a channel
01360  *
01361  * This function will unlink the channel from the global channels container
01362  * if it is still there and also release the current reference to the channel.
01363  *
01364  * \return NULL, convenient for clearing invalid pointers
01365  * \note Absolutely _NO_ channel locks should be held before calling this function.
01366  *
01367  * \since 1.8
01368  */
01369 struct ast_channel *ast_channel_release(struct ast_channel *chan);
01370 
01371 /*!
01372  * \brief Requests a channel
01373  *
01374  * \param type type of channel to request
01375  * \param request_cap Format capabilities for requested channel
01376  * \param assignedids Unique ID to create channel with
01377  * \param requestor channel asking for data
01378  * \param addr destination of the call
01379  * \param cause Cause of failure
01380  *
01381  * \details
01382  * Request a channel of a given type, with addr as optional information used
01383  * by the low level module
01384  *
01385  * \retval NULL failure
01386  * \retval non-NULL channel on success
01387  */
01388 struct ast_channel *ast_request(const char *type, struct ast_format_cap *request_cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause);
01389 
01390 enum ast_channel_requestor_relationship {
01391    /*! The requestor is the future bridge peer of the channel. */
01392    AST_CHANNEL_REQUESTOR_BRIDGE_PEER,
01393    /*! The requestor is to be replaced by the channel. */
01394    AST_CHANNEL_REQUESTOR_REPLACEMENT,
01395 };
01396 
01397 /*!
01398  * \brief Setup new channel accountcodes from the requestor channel after ast_request().
01399  * \since 13.0.0
01400  *
01401  * \param chan New channel to get accountcodes setup.
01402  * \param requestor Requesting channel to get accountcodes from.
01403  * \param relationship What the new channel was created for.
01404  *
01405  * \pre The chan and requestor channels are already locked.
01406  *
01407  * \note Pre-existing accountcodes on chan will be overwritten.
01408  *
01409  * \return Nothing
01410  */
01411 void ast_channel_req_accountcodes(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship);
01412 
01413 /*!
01414  * \brief Setup new channel accountcodes from the requestor channel after ast_request().
01415  * \since 13.0.0
01416  *
01417  * \param chan New channel to get accountcodes setup.
01418  * \param requestor Requesting channel to get accountcodes from.
01419  * \param relationship What the new channel was created for.
01420  *
01421  * \pre The chan and requestor channels are already locked.
01422  *
01423  * \note Pre-existing accountcodes on chan will not be overwritten.
01424  *
01425  * \return Nothing
01426  */
01427 void ast_channel_req_accountcodes_precious(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship);
01428 
01429 /*!
01430  * \brief Request a channel of a given type, with data as optional information used
01431  *        by the low level module and attempt to place a call on it
01432  *
01433  * \param type type of channel to request
01434  * \param cap format capabilities for requested channel
01435  * \param assignedids Unique Id to assign to channel
01436  * \param requestor channel asking for data
01437  * \param addr destination of the call
01438  * \param timeout maximum amount of time to wait for an answer
01439  * \param reason why unsuccessful (if unsuccessful)
01440  * \param cid_num Caller-ID Number
01441  * \param cid_name Caller-ID Name (ascii)
01442  *
01443  * \return Returns an ast_channel on success or no answer, NULL on failure.  Check the value of chan->_state
01444  * to know if the call was answered or not.
01445  */
01446 struct ast_channel *ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr,
01447    int timeout, int *reason, const char *cid_num, const char *cid_name);
01448 
01449 /*!
01450  * \brief Request a channel of a given type, with data as optional information used
01451  * by the low level module and attempt to place a call on it
01452  * \param type type of channel to request
01453  * \param cap format capabilities for requested channel
01454  * \param assignedids Unique Id to assign to channel
01455  * \param requestor channel requesting data
01456  * \param addr destination of the call
01457  * \param timeout maximum amount of time to wait for an answer
01458  * \param reason why unsuccessful (if unsuccessful)
01459  * \param cid_num Caller-ID Number
01460  * \param cid_name Caller-ID Name (ascii)
01461  * \param oh Outgoing helper
01462  * \return Returns an ast_channel on success or no answer, NULL on failure.  Check the value of chan->_state
01463  * to know if the call was answered or not.
01464  */
01465 struct ast_channel *__ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr,
01466    int timeout, int *reason, const char *cid_num, const char *cid_name, struct outgoing_helper *oh);
01467 
01468 /*!
01469  * \brief Forwards a call to a new channel specified by the original channel's call_forward str.  If possible, the new forwarded channel is created and returned while the original one is terminated.
01470  * \param caller in channel that requested orig
01471  * \param orig channel being replaced by the call forward channel
01472  * \param timeout maximum amount of time to wait for setup of new forward channel
01473  * \param cap format capabilities for requested channel
01474  * \param oh outgoing helper used with original channel
01475  * \param outstate reason why unsuccessful (if uncuccessful)
01476  * \return Returns the forwarded call's ast_channel on success or NULL on failure
01477  */
01478 struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, struct ast_format_cap *cap, struct outgoing_helper *oh, int *outstate);
01479 
01480 /*!
01481  * \brief Register a channel technology (a new channel driver)
01482  * Called by a channel module to register the kind of channels it supports.
01483  * \param tech Structure defining channel technology or "type"
01484  * \return Returns 0 on success, -1 on failure.
01485  */
01486 int ast_channel_register(const struct ast_channel_tech *tech);
01487 
01488 /*!
01489  * \brief Unregister a channel technology
01490  * \param tech Structure defining channel technology or "type" that was previously registered
01491  * \return No return value.
01492  */
01493 void ast_channel_unregister(const struct ast_channel_tech *tech);
01494 
01495 /*!
01496  * \brief Get a channel technology structure by name
01497  * \param name name of technology to find
01498  * \return a pointer to the structure, or NULL if no matching technology found
01499  */
01500 const struct ast_channel_tech *ast_get_channel_tech(const char *name);
01501 
01502 /*!
01503  * \brief Hang up a channel
01504  * \note Absolutely _NO_ channel locks should be held before calling this function.
01505  * \note This function performs a hard hangup on a channel.  Unlike the soft-hangup, this function
01506  * performs all stream stopping, etc, on the channel that needs to end.
01507  * chan is no longer valid after this call.
01508  * \param chan channel to hang up (NULL tolerant)
01509  * \return Nothing
01510  */
01511 void ast_hangup(struct ast_channel *chan);
01512 
01513 /*!
01514  * \brief Soft hangup all active channels.
01515  * \since 13.3.0
01516  *
01517  * \return Nothing
01518  */
01519 void ast_softhangup_all(void);
01520 
01521 /*!
01522  * \brief Softly hangup up a channel
01523  *
01524  * \param chan channel to be soft-hung-up
01525  * \param reason an AST_SOFTHANGUP_* reason code
01526  *
01527  * \details
01528  * Call the protocol layer, but don't destroy the channel structure
01529  * (use this if you are trying to
01530  * safely hangup a channel managed by another thread.
01531  *
01532  * \note The channel passed to this function does not need to be locked.
01533  *
01534  * \return Returns 0 regardless
01535  */
01536 int ast_softhangup(struct ast_channel *chan, int reason);
01537 
01538 /*!
01539  * \brief Softly hangup up a channel (no channel lock)
01540  * \param chan channel to be soft-hung-up
01541  * \param reason an AST_SOFTHANGUP_* reason code
01542  */
01543 int ast_softhangup_nolock(struct ast_channel *chan, int reason);
01544 
01545 /*!
01546  * \brief Clear a set of softhangup flags from a channel
01547  *
01548  * Never clear a softhangup flag from a channel directly.  Instead,
01549  * use this function.  This ensures that all aspects of the softhangup
01550  * process are aborted.
01551  *
01552  * \param chan the channel to clear the flag on
01553  * \param flag the flag or flags to clear
01554  *
01555  * \return Nothing.
01556  */
01557 void ast_channel_clear_softhangup(struct ast_channel *chan, int flag);
01558 
01559 /*!
01560  * \brief Set the source of the hangup in this channel and it's bridge
01561  *
01562  * \param chan channel to set the field on
01563  * \param source a string describing the source of the hangup for this channel
01564  * \param force
01565  *
01566  * \note Absolutely _NO_ channel locks should be held before calling this function.
01567  *
01568  * \since 1.8
01569  *
01570  * Hangupsource is generally the channel name that caused the bridge to be
01571  * hung up, but it can also be other things such as "dialplan/agi"
01572  * This can then be logged in the CDR or CEL
01573  */
01574 void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force);
01575 
01576 /*! \brief Check to see if a channel is needing hang up
01577  * \param chan channel on which to check for hang up
01578  * This function determines if the channel is being requested to be hung up.
01579  * \return Returns 0 if not, or 1 if hang up is requested (including time-out).
01580  */
01581 int ast_check_hangup(struct ast_channel *chan);
01582 
01583 int ast_check_hangup_locked(struct ast_channel *chan);
01584 
01585 /*! \brief This function will check if the bridge needs to be re-evaluated due to
01586  *         external changes.
01587  *
01588  *  \param chan Channel on which to check the unbridge_eval flag
01589  *
01590  *  \return Returns 0 if the flag is down or 1 if the flag is up.
01591  */
01592 int ast_channel_unbridged(struct ast_channel *chan);
01593 
01594 /*! \brief ast_channel_unbridged variant. Use this if the channel
01595  *         is already locked prior to calling.
01596  *
01597  *  \param chan Channel on which to check the unbridge flag
01598  *
01599  *  \return Returns 0 if the flag is down or 1 if the flag is up.
01600  */
01601 int ast_channel_unbridged_nolock(struct ast_channel *chan);
01602 
01603 /*! \brief Sets the unbridged flag and queues a NULL frame on the channel to trigger
01604  *         a check by bridge_channel_wait
01605  *
01606  *  \param chan Which channel is having its unbridged value set
01607  *  \param value What the unbridge value is being set to
01608  */
01609 void ast_channel_set_unbridged(struct ast_channel *chan, int value);
01610 
01611 /*! \brief Variant of ast_channel_set_unbridged. Use this if the channel
01612  *         is already locked prior to calling.
01613  *
01614  *  \param chan Which channel is having its unbridged value set
01615  *  \param value What the unbridge value is being set to
01616  */
01617 void ast_channel_set_unbridged_nolock(struct ast_channel *chan, int value);
01618 
01619 /*!
01620  * \brief Lock the given channel, then request softhangup on the channel with the given causecode
01621  * \param chan channel on which to hang up
01622  * \param causecode cause code to use (Zero if don't use cause code)
01623  * \return Nothing
01624  */
01625 void ast_channel_softhangup_withcause_locked(struct ast_channel *chan, int causecode);
01626 
01627 /*!
01628  * \brief Compare a offset with the settings of when to hang a channel up
01629  * \param chan channel on which to check for hang up
01630  * \param offset offset in seconds from current time
01631  * \return 1, 0, or -1
01632  * \details
01633  * This function compares a offset from current time with the absolute time
01634  * out on a channel (when to hang up). If the absolute time out on a channel
01635  * is earlier than current time plus the offset, it returns 1, if the two
01636  * time values are equal, it return 0, otherwise, it return -1.
01637  * \sa ast_channel_cmpwhentohangup_tv()
01638  * \version 1.6.1 deprecated function (only had seconds precision)
01639  */
01640 int ast_channel_cmpwhentohangup(struct ast_channel *chan, time_t offset) __attribute__((deprecated));
01641 
01642 /*!
01643  * \brief Compare a offset with the settings of when to hang a channel up
01644  * \param chan channel on which to check for hangup
01645  * \param offset offset in seconds and microseconds from current time
01646  * \return 1, 0, or -1
01647  * This function compares a offset from current time with the absolute time
01648  * out on a channel (when to hang up). If the absolute time out on a channel
01649  * is earlier than current time plus the offset, it returns 1, if the two
01650  * time values are equal, it return 0, otherwise, it return -1.
01651  * \since 1.6.1
01652  */
01653 int ast_channel_cmpwhentohangup_tv(struct ast_channel *chan, struct timeval offset);
01654 
01655 /*!
01656  * \brief Set when to hang a channel up
01657  *
01658  * \param chan channel on which to check for hang up
01659  * \param offset offset in seconds relative to the current time of when to hang up
01660  *
01661  * \details
01662  * This function sets the absolute time out on a channel (when to hang up).
01663  *
01664  * \pre chan is locked
01665  *
01666  * \return Nothing
01667  * \sa ast_channel_setwhentohangup_tv()
01668  * \version 1.6.1 deprecated function (only had seconds precision)
01669  */
01670 void ast_channel_setwhentohangup(struct ast_channel *chan, time_t offset) __attribute__((deprecated));
01671 
01672 /*!
01673  * \brief Set when to hang a channel up
01674  *
01675  * \param chan channel on which to check for hang up
01676  * \param offset offset in seconds and useconds relative to the current time of when to hang up
01677  *
01678  * This function sets the absolute time out on a channel (when to hang up).
01679  *
01680  * \pre chan is locked
01681  *
01682  * \return Nothing
01683  * \since 1.6.1
01684  */
01685 void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset);
01686 
01687 /*!
01688  * \brief Answer a channel
01689  *
01690  * \param chan channel to answer
01691  *
01692  * \details
01693  * This function answers a channel and handles all necessary call
01694  * setup functions.
01695  *
01696  * \note The channel passed does not need to be locked, but is locked
01697  * by the function when needed.
01698  *
01699  * \note This function will wait up to 500 milliseconds for media to
01700  * arrive on the channel before returning to the caller, so that the
01701  * caller can properly assume the channel is 'ready' for media flow.
01702  *
01703  * \retval 0 on success
01704  * \retval non-zero on failure
01705  */
01706 int ast_answer(struct ast_channel *chan);
01707 
01708 /*!
01709  * \brief Answer a channel, if it's not already answered.
01710  *
01711  * \param chan channel to answer
01712  *
01713  * \details See ast_answer()
01714  *
01715  * \retval 0 on success
01716  * \retval non-zero on failure
01717  */
01718 int ast_auto_answer(struct ast_channel *chan);
01719 
01720 /*!
01721  * \brief Answer a channel
01722  *
01723  * \param chan channel to answer
01724  *
01725  * This function answers a channel and handles all necessary call
01726  * setup functions.
01727  *
01728  * \note The channel passed does not need to be locked, but is locked
01729  * by the function when needed.
01730  *
01731  * \note Unlike ast_answer(), this function will not wait for media
01732  * flow to begin. The caller should be careful before sending media
01733  * to the channel before incoming media arrives, as the outgoing
01734  * media may be lost.
01735  *
01736  * \retval 0 on success
01737  * \retval non-zero on failure
01738  */
01739 int ast_raw_answer(struct ast_channel *chan);
01740 
01741 /*!
01742  * \brief Answer a channel, with a selectable delay before returning
01743  *
01744  * \param chan channel to answer
01745  * \param delay maximum amount of time to wait for incoming media
01746  *
01747  * This function answers a channel and handles all necessary call
01748  * setup functions.
01749  *
01750  * \note The channel passed does not need to be locked, but is locked
01751  * by the function when needed.
01752  *
01753  * \note This function will wait up to 'delay' milliseconds for media to
01754  * arrive on the channel before returning to the caller, so that the
01755  * caller can properly assume the channel is 'ready' for media flow. If
01756  * 'delay' is less than 500, the function will wait up to 500 milliseconds.
01757  *
01758  * \retval 0 on success
01759  * \retval non-zero on failure
01760  */
01761 int __ast_answer(struct ast_channel *chan, unsigned int delay);
01762 
01763 /*!
01764  * \brief Execute a Gosub call on the channel before a call is placed.
01765  * \since 11.0
01766  *
01767  * \details
01768  * This is called between ast_request() and ast_call() to
01769  * execute a predial routine on the newly created channel.
01770  *
01771  * \param chan Channel to execute Gosub.
01772  * \param sub_args Gosub application parameter string.
01773  *
01774  * \note Absolutely _NO_ channel locks should be held before calling this function.
01775  *
01776  * \retval 0 on success.
01777  * \retval -1 on error.
01778  */
01779 int ast_pre_call(struct ast_channel *chan, const char *sub_args);
01780 
01781 /*!
01782  * \brief Make a call
01783  * \note Absolutely _NO_ channel locks should be held before calling this function.
01784  * \param chan which channel to make the call on
01785  * \param addr destination of the call
01786  * \param timeout time to wait on for connect (Doesn't seem to be used.)
01787  * \details
01788  * Place a call, take no longer than timeout ms.
01789  * \retval 0 on success
01790  * \retval -1 on failure
01791  */
01792 int ast_call(struct ast_channel *chan, const char *addr, int timeout);
01793 
01794 /*!
01795  * \brief Indicates condition of channel
01796  * \note Absolutely _NO_ channel locks should be held before calling this function.
01797  * \note Indicate a condition such as AST_CONTROL_BUSY, AST_CONTROL_RINGING, or AST_CONTROL_CONGESTION on a channel
01798  * \param chan channel to change the indication
01799  * \param condition which condition to indicate on the channel
01800  * \return Returns 0 on success, -1 on failure
01801  */
01802 int ast_indicate(struct ast_channel *chan, int condition);
01803 
01804 /*!
01805  * \brief Indicates condition of channel, with payload
01806  * \note Absolutely _NO_ channel locks should be held before calling this function.
01807  * \note Indicate a condition such as AST_CONTROL_HOLD with payload being music on hold class
01808  * \param chan channel to change the indication
01809  * \param condition which condition to indicate on the channel
01810  * \param data pointer to payload data
01811  * \param datalen size of payload data
01812  * \return Returns 0 on success, -1 on failure
01813  */
01814 int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen);
01815 
01816 /* Misc stuff ------------------------------------------------ */
01817 
01818 /*!
01819  * \brief Wait for input on a channel
01820  * \param chan channel to wait on
01821  * \param ms length of time to wait on the channel
01822  * \details
01823  * Wait for input on a channel for a given # of milliseconds (<0 for indefinite).
01824  * \retval < 0 on failure
01825  * \retval 0 if nothing ever arrived
01826  * \retval the # of ms remaining otherwise
01827  */
01828 int ast_waitfor(struct ast_channel *chan, int ms);
01829 
01830 /*!
01831  * \brief Should we keep this frame for later?
01832  *
01833  * There are functions such as ast_safe_sleep which will
01834  * service a channel to ensure that it does not have a
01835  * large backlog of queued frames. When this happens,
01836  * we want to hold on to specific frame types and just drop
01837  * others. This function will tell if the frame we just
01838  * read should be held onto.
01839  *
01840  * \param frame The frame we just read
01841  * \retval 1 frame should be kept
01842  * \retval 0 frame should be dropped
01843  */
01844 int ast_is_deferrable_frame(const struct ast_frame *frame);
01845 
01846 /*!
01847  * \brief Wait for a specified amount of time, looking for hangups
01848  * \param chan channel to wait for
01849  * \param ms length of time in milliseconds to sleep. This should never be less than zero.
01850  * \details
01851  * Waits for a specified amount of time, servicing the channel as required.
01852  * \return returns -1 on hangup, otherwise 0.
01853  */
01854 int ast_safe_sleep(struct ast_channel *chan, int ms);
01855 
01856 /*!
01857  * \brief Wait for a specified amount of time, looking for hangups and a condition argument
01858  * \param chan channel to wait for
01859  * \param ms length of time in milliseconds to sleep.
01860  * \param cond a function pointer for testing continue condition
01861  * \param data argument to be passed to the condition test function
01862  * \return returns -1 on hangup, otherwise 0.
01863  * \details
01864  * Waits for a specified amount of time, servicing the channel as required. If cond
01865  * returns 0, this function returns.
01866  */
01867 int ast_safe_sleep_conditional(struct ast_channel *chan, int ms, int (*cond)(void*), void *data );
01868 
01869 /*!
01870  * \brief Waits for activity on a group of channels
01871  * \param chan an array of pointers to channels
01872  * \param n number of channels that are to be waited upon
01873  * \param fds an array of fds to wait upon
01874  * \param nfds the number of fds to wait upon
01875  * \param exception exception flag
01876  * \param outfd fd that had activity on it
01877  * \param ms how long the wait was
01878  * \details
01879  * Big momma function here.  Wait for activity on any of the n channels, or any of the nfds
01880  * file descriptors.
01881  * \return Returns the channel with activity, or NULL on error or if an FD
01882  * came first.  If the FD came first, it will be returned in outfd, otherwise, outfd
01883  * will be -1
01884  */
01885 struct ast_channel *ast_waitfor_nandfds(struct ast_channel **chan, int n,
01886    int *fds, int nfds, int *exception, int *outfd, int *ms);
01887 
01888 /*!
01889  * \brief Waits for input on a group of channels
01890  * Wait for input on an array of channels for a given # of milliseconds.
01891  * \return Return channel with activity, or NULL if none has activity.
01892  * \param chan an array of pointers to channels
01893  * \param n number of channels that are to be waited upon
01894  * \param ms time "ms" is modified in-place, if applicable
01895  */
01896 struct ast_channel *ast_waitfor_n(struct ast_channel **chan, int n, int *ms);
01897 
01898 /*!
01899  * \brief Waits for input on an fd
01900  * \note This version works on fd's only.  Be careful with it.
01901  */
01902 int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception);
01903 
01904 
01905 /*!
01906  * \brief Reads a frame
01907  * \param chan channel to read a frame from
01908  * \return Returns a frame, or NULL on error.  If it returns NULL, you
01909  * best just stop reading frames and assume the channel has been
01910  * disconnected.
01911  */
01912 struct ast_frame *ast_read(struct ast_channel *chan);
01913 
01914 /*!
01915  * \brief Reads a frame, returning AST_FRAME_NULL frame if audio.
01916  * \param chan channel to read a frame from
01917  * \return  Returns a frame, or NULL on error.  If it returns NULL, you
01918  * best just stop reading frames and assume the channel has been
01919  * disconnected.
01920  * \note Audio is replaced with AST_FRAME_NULL to avoid
01921  * transcode when the resulting audio is not necessary.
01922  */
01923 struct ast_frame *ast_read_noaudio(struct ast_channel *chan);
01924 
01925 /*!
01926  * \brief Write a frame to a channel
01927  * This function writes the given frame to the indicated channel.
01928  * \param chan destination channel of the frame
01929  * \param frame frame that will be written
01930  * \return It returns 0 on success, -1 on failure.
01931  */
01932 int ast_write(struct ast_channel *chan, struct ast_frame *frame);
01933 
01934 /*!
01935  * \brief Write video frame to a channel
01936  * This function writes the given frame to the indicated channel.
01937  * \param chan destination channel of the frame
01938  * \param frame frame that will be written
01939  * \return It returns 1 on success, 0 if not implemented, and -1 on failure.
01940  */
01941 int ast_write_video(struct ast_channel *chan, struct ast_frame *frame);
01942 
01943 /*!
01944  * \brief Write text frame to a channel
01945  * This function writes the given frame to the indicated channel.
01946  * \param chan destination channel of the frame
01947  * \param frame frame that will be written
01948  * \return It returns 1 on success, 0 if not implemented, and -1 on failure.
01949  */
01950 int ast_write_text(struct ast_channel *chan, struct ast_frame *frame);
01951 
01952 /*! \brief Send empty audio to prime a channel driver */
01953 int ast_prod(struct ast_channel *chan);
01954 
01955 /*!
01956  * \brief Set specific read path on channel.
01957  * \since 13.4.0
01958  *
01959  * \param chan Channel to setup read path.
01960  * \param raw_format Format to expect from the channel driver.
01961  * \param core_format What the core wants to read.
01962  *
01963  * \pre chan is locked
01964  *
01965  * \retval 0 on success.
01966  * \retval -1 on error.
01967  */
01968 int ast_set_read_format_path(struct ast_channel *chan, struct ast_format *raw_format, struct ast_format *core_format);
01969 
01970 /*!
01971  * \brief Sets read format on channel chan from capabilities
01972  * Set read format for channel to whichever component of "format" is best.
01973  * \param chan channel to change
01974  * \param formats new formats to pick from for reading
01975  * \return Returns 0 on success, -1 on failure
01976  */
01977 int ast_set_read_format_from_cap(struct ast_channel *chan, struct ast_format_cap *formats);
01978 
01979 /*!
01980  * \brief Sets read format on channel chan
01981  * \param chan channel to change
01982  * \param format format to set for reading
01983  * \return Returns 0 on success, -1 on failure
01984  */
01985 int ast_set_read_format(struct ast_channel *chan, struct ast_format *format);
01986 
01987 /*!
01988  * \brief Sets write format on channel chan
01989  * Set write format for channel to whichever component of "format" is best.
01990  * \param chan channel to change
01991  * \param formats new formats to pick from for writing
01992  * \return Returns 0 on success, -1 on failure
01993  */
01994 int ast_set_write_format_from_cap(struct ast_channel *chan, struct ast_format_cap *formats);
01995 
01996 /*!
01997  * \brief Sets write format on channel chan
01998  * \param chan channel to change
01999  * \param format format to set for writing
02000  * \return Returns 0 on success, -1 on failure
02001  */
02002 int ast_set_write_format(struct ast_channel *chan, struct ast_format *format);
02003 
02004 /*!
02005  * \brief Sends text to a channel
02006  *
02007  * \param chan channel to act upon
02008  * \param text string of text to send on the channel
02009  *
02010  * \details
02011  * Write text to a display on a channel
02012  *
02013  * \note The channel does not need to be locked before calling this function.
02014  *
02015  * \retval 0 on success
02016  * \retval -1 on failure
02017  */
02018 int ast_sendtext(struct ast_channel *chan, const char *text);
02019 
02020 /*!
02021  * \brief Receives a text character from a channel
02022  * \param chan channel to act upon
02023  * \param timeout timeout in milliseconds (0 for infinite wait)
02024  * \details
02025  * Read a char of text from a channel
02026  * \return 0 on success, -1 on failure
02027  */
02028 int ast_recvchar(struct ast_channel *chan, int timeout);
02029 
02030 /*!
02031  * \brief Send a DTMF digit to a channel.
02032  * \param chan channel to act upon
02033  * \param digit the DTMF digit to send, encoded in ASCII
02034  * \param duration the duration of the digit ending in ms
02035  * \return 0 on success, -1 on failure
02036  */
02037 int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration);
02038 
02039 /*!
02040  * \brief Send a DTMF digit to a channel.
02041  * \param chan channel to act upon
02042  * \param digit the DTMF digit to send, encoded in ASCII
02043  * \return 0 on success, -1 on failure
02044  */
02045 int ast_senddigit_begin(struct ast_channel *chan, char digit);
02046 
02047 /*!
02048  * \brief Send a DTMF digit to a channel.
02049  * \param chan channel to act upon
02050  * \param digit the DTMF digit to send, encoded in ASCII
02051  * \param duration the duration of the digit ending in ms
02052  * \return Returns 0 on success, -1 on failure
02053  */
02054 int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration);
02055 
02056 /*!
02057  * \brief Receives a text string from a channel
02058  * Read a string of text from a channel
02059  * \param chan channel to act upon
02060  * \param timeout timeout in milliseconds (0 for infinite wait)
02061  * \return the received text, or NULL to signify failure.
02062  */
02063 char *ast_recvtext(struct ast_channel *chan, int timeout);
02064 
02065 /*!
02066  * \brief Waits for a digit
02067  * \param c channel to wait for a digit on
02068  * \param ms how many milliseconds to wait (<0 for indefinite).
02069  * \return Returns <0 on error, 0 on no entry, and the digit on success.
02070  */
02071 int ast_waitfordigit(struct ast_channel *c, int ms);
02072 
02073 /*!
02074  * \brief Wait for a digit
02075  * Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to monitor for reading.
02076  * \param c channel to wait for a digit on
02077  * \param ms how many milliseconds to wait (<0 for indefinite).
02078  * \param audiofd audio file descriptor to write to if audio frames are received
02079  * \param ctrlfd control file descriptor to monitor for reading
02080  * \return Returns 1 if ctrlfd becomes available
02081  */
02082 int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int ctrlfd);
02083 
02084 /*!
02085  * \brief Reads multiple digits
02086  * \param c channel to read from
02087  * \param s string to read in to.  Must be at least the size of your length
02088  * \param len how many digits to read (maximum)
02089  * \param timeout how long to timeout between digits
02090  * \param rtimeout timeout to wait on the first digit
02091  * \param enders digits to end the string
02092  * \details
02093  * Read in a digit string "s", max length "len", maximum timeout between
02094  * digits "timeout" (-1 for none), terminated by anything in "enders".  Give them rtimeout
02095  * for the first digit.
02096  * \return Returns 0 on normal return, or 1 on a timeout.  In the case of
02097  * a timeout, any digits that were read before the timeout will still be available in s.
02098  * RETURNS 2 in full version when ctrlfd is available, NOT 1
02099  */
02100 int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders);
02101 int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders, int audiofd, int ctrlfd);
02102 
02103 /*! \brief Report DTMF on channel 0 */
02104 #define AST_BRIDGE_DTMF_CHANNEL_0      (1 << 0)
02105 /*! \brief Report DTMF on channel 1 */
02106 #define AST_BRIDGE_DTMF_CHANNEL_1      (1 << 1)
02107 
02108 
02109 /*!
02110  * \brief Make the frame formats of two channels compatible.
02111  *
02112  * \param chan First channel to make compatible.  Should be the calling party.
02113  * \param peer Other channel to make compatible.  Should be the called party.
02114  *
02115  * \note Absolutely _NO_ channel locks should be held before calling this function.
02116  *
02117  * \details
02118  * Set two channels to compatible frame formats in both
02119  * directions.  The path from peer to chan is made compatible
02120  * first to allow for in-band audio in case the other direction
02121  * cannot be made compatible.
02122  *
02123  * \retval 0 on success.
02124  * \retval -1 on error.
02125  */
02126 int ast_channel_make_compatible(struct ast_channel *chan, struct ast_channel *peer);
02127 
02128 /*!
02129  * \brief Bridge two channels together (early)
02130  * \param c0 first channel to bridge
02131  * \param c1 second channel to bridge
02132  * \details
02133  * Bridge two channels (c0 and c1) together early. This implies either side may not be answered yet.
02134  * \return Returns 0 on success and -1 if it could not be done
02135  */
02136 int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1);
02137 
02138 /*!
02139  * \brief Gives the string form of a given cause code.
02140  *
02141  * \param state cause to get the description of
02142  * \return the text form of the binary cause code given
02143  */
02144 const char *ast_cause2str(int state) attribute_pure;
02145 
02146 /*!
02147  * \brief Convert the string form of a cause code to a number
02148  *
02149  * \param name string form of the cause
02150  * \return the cause code
02151  */
02152 int ast_str2cause(const char *name) attribute_pure;
02153 
02154 /*!
02155  * \brief Gives the string form of a given channel state
02156  *
02157  * \param ast_channel_state state to get the name of
02158  * \return the text form of the binary state given
02159  */
02160 const char *ast_state2str(enum ast_channel_state);
02161 
02162 /*!
02163  * \brief Gives the string form of a given transfer capability
02164  *
02165  * \param transfercapability transfer capability to get the name of
02166  * \return the text form of the binary transfer capability
02167  */
02168 char *ast_transfercapability2str(int transfercapability) attribute_const;
02169 
02170 /*
02171  * Options: Some low-level drivers may implement "options" allowing fine tuning of the
02172  * low level channel.  See frame.h for options.  Note that many channel drivers may support
02173  * none or a subset of those features, and you should not count on this if you want your
02174  * asterisk application to be portable.  They're mainly useful for tweaking performance
02175  */
02176 
02177 /*!
02178  * \brief Sets an option on a channel
02179  *
02180  * \param channel channel to set options on
02181  * \param option option to change
02182  * \param data data specific to option
02183  * \param datalen length of the data
02184  * \param block blocking or not
02185  * \details
02186  * Set an option on a channel (see frame.h), optionally blocking awaiting the reply
02187  * \return 0 on success and -1 on failure
02188  */
02189 int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block);
02190 
02191 /*!
02192  * \brief Checks the value of an option
02193  *
02194  * Query the value of an option
02195  * Works similarly to setoption except only reads the options.
02196  */
02197 int ast_channel_queryoption(struct ast_channel *channel, int option, void *data, int *datalen, int block);
02198 
02199 /*!
02200  * \brief Checks for HTML support on a channel
02201  * \return 0 if channel does not support HTML or non-zero if it does
02202  */
02203 int ast_channel_supports_html(struct ast_channel *channel);
02204 
02205 /*!
02206  * \brief Sends HTML on given channel
02207  * Send HTML or URL on link.
02208  * \return 0 on success or -1 on failure
02209  */
02210 int ast_channel_sendhtml(struct ast_channel *channel, int subclass, const char *data, int datalen);
02211 
02212 /*!
02213  * \brief Sends a URL on a given link
02214  * Send URL on link.
02215  * \return 0 on success or -1 on failure
02216  */
02217 int ast_channel_sendurl(struct ast_channel *channel, const char *url);
02218 
02219 /*!
02220  * \brief Defers DTMF so that you only read things like hangups and audio.
02221  * \return non-zero if channel was already DTMF-deferred or
02222  * 0 if channel is just now being DTMF-deferred
02223  */
02224 int ast_channel_defer_dtmf(struct ast_channel *chan);
02225 
02226 /*! Undo defer.  ast_read will return any DTMF characters that were queued */
02227 void ast_channel_undefer_dtmf(struct ast_channel *chan);
02228 
02229 /*! \return number of channels available for lookup */
02230 int ast_active_channels(void);
02231 
02232 /*! \return the number of channels not yet destroyed */
02233 int ast_undestroyed_channels(void);
02234 
02235 /*! Activate a given generator */
02236 int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params);
02237 
02238 /*! Deactivate an active generator */
02239 void ast_deactivate_generator(struct ast_channel *chan);
02240 
02241 /*!
02242  * \since 12
02243  * \brief Obtain how long the channel since the channel was created
02244  *
02245  * \param chan The channel object
02246  *
02247  * \retval 0 if the time value cannot be computed (or you called this really fast)
02248  * \retval The number of seconds the channel has been up
02249  */
02250 int ast_channel_get_duration(struct ast_channel *chan);
02251 
02252 /*!
02253  * \since 12
02254  * \brief Obtain how long it has been since the channel was answered
02255  *
02256  * \param chan The channel object
02257  *
02258  * \retval 0 if the channel isn't answered (or you called this really fast)
02259  * \retval The number of seconds the channel has been up
02260  */
02261 int ast_channel_get_up_time(struct ast_channel *chan);
02262 
02263 /*!
02264  * \brief Set caller ID number, name and ANI and generate AMI event.
02265  *
02266  * \note Use ast_channel_set_caller() and ast_channel_set_caller_event() instead.
02267  * \note The channel does not need to be locked before calling this function.
02268  */
02269 void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani);
02270 
02271 /*!
02272  * \brief Set the caller id information in the Asterisk channel
02273  * \since 1.8
02274  *
02275  * \param chan Asterisk channel to set caller id information
02276  * \param caller Caller id information
02277  * \param update What caller information to update.  NULL if all.
02278  *
02279  * \return Nothing
02280  *
02281  * \note The channel does not need to be locked before calling this function.
02282  */
02283 void ast_channel_set_caller(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update);
02284 
02285 /*!
02286  * \brief Set the caller id information in the Asterisk channel and generate an AMI event
02287  * if the caller id name or number changed.
02288  * \since 1.8
02289  *
02290  * \param chan Asterisk channel to set caller id information
02291  * \param caller Caller id information
02292  * \param update What caller information to update.  NULL if all.
02293  *
02294  * \return Nothing
02295  *
02296  * \note The channel does not need to be locked before calling this function.
02297  */
02298 void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update);
02299 
02300 /*! Set the file descriptor on the channel */
02301 void ast_channel_set_fd(struct ast_channel *chan, int which, int fd);
02302 
02303 /*! Add a channel to an optimized waitfor */
02304 void ast_poll_channel_add(struct ast_channel *chan0, struct ast_channel *chan1);
02305 
02306 /*! Delete a channel from an optimized waitfor */
02307 void ast_poll_channel_del(struct ast_channel *chan0, struct ast_channel *chan1);
02308 
02309 /*! Start a tone going */
02310 int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);
02311 /*! Stop a tone from playing */
02312 void ast_tonepair_stop(struct ast_channel *chan);
02313 /*! Play a tone pair for a given amount of time */
02314 int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);
02315 
02316 /*!
02317  * \brief Automatically service a channel for us...
02318  *
02319  * \retval 0 success
02320  * \retval -1 failure, or the channel is already being autoserviced
02321  */
02322 int ast_autoservice_start(struct ast_channel *chan);
02323 
02324 /*!
02325  * \brief Stop servicing a channel for us...
02326  *
02327  * \note if chan is locked prior to calling ast_autoservice_stop, it
02328  * is likely that there will be a deadlock between the thread that calls
02329  * ast_autoservice_stop and the autoservice thread. It is important
02330  * that chan is not locked prior to this call
02331  *
02332  * \param chan
02333  * \retval 0 success
02334  * \retval -1 error, or the channel has been hungup
02335  */
02336 int ast_autoservice_stop(struct ast_channel *chan);
02337 
02338 /*!
02339  * \brief Put chan into autoservice while hanging up peer.
02340  * \since 11.0
02341  *
02342  * \param chan Chan to put into autoservice.
02343  * \param peer Chan to run hangup handlers and hangup.
02344  *
02345  * \return Nothing
02346  */
02347 void ast_autoservice_chan_hangup_peer(struct ast_channel *chan, struct ast_channel *peer);
02348 
02349 /*!
02350  * \brief Ignore certain frame types
02351  * \note Normally, we cache DTMF, IMAGE, HTML, TEXT, and CONTROL frames
02352  * while a channel is in autoservice and queue them up when taken out of
02353  * autoservice.  When this is not desireable, this API may be used to
02354  * cause the channel to ignore those frametypes after the channel is put
02355  * into autoservice, but before autoservice is stopped.
02356  * \retval 0 success
02357  * \retval -1 channel is not in autoservice
02358  */
02359 int ast_autoservice_ignore(struct ast_channel *chan, enum ast_frame_type ftype);
02360 
02361 /*!
02362  * \brief Enable or disable timer ticks for a channel
02363  *
02364  * \param c channel
02365  * \param rate number of timer ticks per second
02366  * \param func callback function
02367  * \param data
02368  *
02369  * \details
02370  * If timers are supported, force a scheduled expiration on the
02371  * timer fd, at which point we call the callback function / data
02372  *
02373  * \note Call this function with a rate of 0 to turn off the timer ticks
02374  *
02375  * \version 1.6.1 changed samples parameter to rate, accomodates new timing methods
02376  */
02377 int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const void *data), void *data);
02378 int ast_settimeout_full(struct ast_channel *c, unsigned int rate, int (*func)(const void *data), void *data, unsigned int is_ao2_obj);
02379 
02380 /*!
02381  * \brief Transfer a channel (if supported).
02382  * \retval -1 on error
02383  * \retval 0 if not supported
02384  * \retval 1 if supported and requested
02385  * \param chan current channel
02386  * \param dest destination extension for transfer
02387  */
02388 int ast_transfer(struct ast_channel *chan, char *dest);
02389 
02390 /*!
02391  * \brief Inherits channel variable from parent to child channel
02392  * \param parent Parent channel
02393  * \param child Child channel
02394  *
02395  * \details
02396  * Scans all channel variables in the parent channel, looking for those
02397  * that should be copied into the child channel.
02398  * Variables whose names begin with a single '_' are copied into the
02399  * child channel with the prefix removed.
02400  * Variables whose names begin with '__' are copied into the child
02401  * channel with their names unchanged.
02402  */
02403 void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child);
02404 
02405 /*!
02406  * \brief adds a list of channel variables to a channel
02407  * \param chan the channel
02408  * \param vars a linked list of variables
02409  *
02410  * \pre chan is locked
02411  *
02412  * \details
02413  * Variable names can be for a regular channel variable or a dialplan function
02414  * that has the ability to be written to.
02415  */
02416 void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars);
02417 
02418 /*!
02419  * \brief An opaque 'object' structure use by silence generators on channels.
02420  */
02421 struct ast_silence_generator;
02422 
02423 /*!
02424  * \brief Starts a silence generator on the given channel.
02425  * \param chan The channel to generate silence on
02426  * \return An ast_silence_generator pointer, or NULL if an error occurs
02427  *
02428  * \details
02429  * This function will cause SLINEAR silence to be generated on the supplied
02430  * channel until it is disabled; if the channel cannot be put into SLINEAR
02431  * mode then the function will fail.
02432  *
02433  * \note
02434  * The pointer returned by this function must be preserved and passed to
02435  * ast_channel_stop_silence_generator when you wish to stop the silence
02436  * generation.
02437  */
02438 struct ast_silence_generator *ast_channel_start_silence_generator(struct ast_channel *chan);
02439 
02440 /*!
02441  * \brief Stops a previously-started silence generator on the given channel.
02442  * \param chan The channel to operate on
02443  * \param state The ast_silence_generator pointer return by a previous call to
02444  * ast_channel_start_silence_generator.
02445  * \return nothing
02446  *
02447  * \details
02448  * This function will stop the operating silence generator and return the channel
02449  * to its previous write format.
02450  */
02451 void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state);
02452 
02453 /*!
02454  * \brief Determine which channel has an older linkedid
02455  * \param a First channel
02456  * \param b Second channel
02457  * \return Returns an ast_channel structure that has oldest linkedid
02458  */
02459 struct ast_channel *ast_channel_internal_oldest_linkedid(struct ast_channel *a, struct ast_channel *b);
02460 
02461 /*!
02462  * \brief Copy the full linkedid channel id structure from one channel to another
02463  * \param dest Destination to copy linkedid to
02464  * \param source Source channel to copy linkedid from
02465  * \return void
02466  */
02467 void ast_channel_internal_copy_linkedid(struct ast_channel *dest, struct ast_channel *source);
02468 
02469 /*!
02470  * \brief Swap uniqueid and linkedid beteween two channels
02471  * \param a First channel
02472  * \param b Second channel
02473  * \return void
02474  *
02475  * \note
02476  * This is used in masquerade to exchange identities
02477  */
02478 void ast_channel_internal_swap_uniqueid_and_linkedid(struct ast_channel *a, struct ast_channel *b);
02479 
02480 /*!
02481  * \brief Swap topics beteween two channels
02482  * \param a First channel
02483  * \param b Second channel
02484  * \return void
02485  *
02486  * \note
02487  * This is used in masquerade to exchange topics for message routing
02488  */
02489 void ast_channel_internal_swap_topics(struct ast_channel *a, struct ast_channel *b);
02490 
02491 /*!
02492  * \brief Set uniqueid and linkedid string value only (not time)
02493  * \param chan The channel to set the uniqueid to
02494  * \param uniqueid The uniqueid to set
02495  * \param linkedid The linkedid to set
02496  * \return void
02497  *
02498  * \note
02499  * This is used only by ast_cel_fabricate_channel_from_event()
02500  * to create a temporary fake channel - time values are invalid
02501  */
02502 void ast_channel_internal_set_fake_ids(struct ast_channel *chan, const char *uniqueid, const char *linkedid);
02503 
02504 /* Misc. functions below */
02505 
02506 /*!
02507  * \brief if fd is a valid descriptor, set *pfd with the descriptor
02508  * \return Return 1 (not -1!) if added, 0 otherwise (so we can add the
02509  * return value to the index into the array)
02510  */
02511 static inline int ast_add_fd(struct pollfd *pfd, int fd)
02512 {
02513    pfd->fd = fd;
02514    pfd->events = POLLIN | POLLPRI;
02515    return fd >= 0;
02516 }
02517 
02518 /*! \brief Helper function for migrating select to poll */
02519 static inline int ast_fdisset(struct pollfd *pfds, int fd, int maximum, int *start)
02520 {
02521    int x;
02522    int dummy = 0;
02523 
02524    if (fd < 0)
02525       return 0;
02526    if (!start)
02527       start = &dummy;
02528    for (x = *start; x < maximum; x++)
02529       if (pfds[x].fd == fd) {
02530          if (x == *start)
02531             (*start)++;
02532          return pfds[x].revents;
02533       }
02534    return 0;
02535 }
02536 
02537 /*! \brief Retrieves the current T38 state of a channel */
02538 static inline enum ast_t38_state ast_channel_get_t38_state(struct ast_channel *chan)
02539 {
02540    enum ast_t38_state state = T38_STATE_UNAVAILABLE;
02541    int datalen = sizeof(state);
02542 
02543    ast_channel_queryoption(chan, AST_OPTION_T38_STATE, &state, &datalen, 0);
02544 
02545    return state;
02546 }
02547 
02548 #define CHECK_BLOCKING(c) do {    \
02549    if (ast_test_flag(ast_channel_flags(c), AST_FLAG_BLOCKING)) {\
02550       ast_debug(1, "Thread %p is blocking '%s', already blocked by thread %p in procedure %s\n", \
02551          (void *) pthread_self(), ast_channel_name(c), (void *) ast_channel_blocker(c), ast_channel_blockproc(c)); \
02552    } else { \
02553       ast_channel_blocker_set((c), pthread_self()); \
02554       ast_channel_blockproc_set((c), __PRETTY_FUNCTION__); \
02555       ast_set_flag(ast_channel_flags(c), AST_FLAG_BLOCKING); \
02556    } } while (0)
02557 
02558 ast_group_t ast_get_group(const char *s);
02559 
02560 /*! \brief Print call and pickup groups into buffer */
02561 char *ast_print_group(char *buf, int buflen, ast_group_t group);
02562 
02563 /*! \brief Opaque struct holding a namedgroups set, i.e. a set of group names */
02564 struct ast_namedgroups;
02565 
02566 /*! \brief Create an ast_namedgroups set with group names from comma separated string */
02567 struct ast_namedgroups *ast_get_namedgroups(const char *s);
02568 struct ast_namedgroups *ast_unref_namedgroups(struct ast_namedgroups *groups);
02569 struct ast_namedgroups *ast_ref_namedgroups(struct ast_namedgroups *groups);
02570 /*! \brief Return TRUE if group a and b contain at least one common groupname */
02571 int ast_namedgroups_intersect(struct ast_namedgroups *a, struct ast_namedgroups *b);
02572 
02573 /*! \brief Print named call groups and named pickup groups */
02574 char *ast_print_namedgroups(struct ast_str **buf, struct ast_namedgroups *groups);
02575 
02576 /*!
02577  * \brief Convert enum channelreloadreason to text string for manager event
02578  * \param reason The reason for reload (manager, cli, start etc)
02579  */
02580 const char *channelreloadreason2txt(enum channelreloadreason reason);
02581 
02582 /*! \brief return an ast_variable list of channeltypes */
02583 struct ast_variable *ast_channeltype_list(void);
02584 
02585 /*!
02586  * \brief return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument
02587  * \param reason  The integer argument, usually taken from AST_CONTROL_ macros
02588  * \return char pointer explaining the code
02589  */
02590 const char *ast_channel_reason2str(int reason);
02591 
02592 /*! \brief channel group info */
02593 struct ast_group_info {
02594    struct ast_channel *chan;
02595    char *category;
02596    char *group;
02597    AST_LIST_ENTRY(ast_group_info) group_list;
02598 };
02599 
02600 #define ast_channel_lock(chan) ao2_lock(chan)
02601 #define ast_channel_unlock(chan) ao2_unlock(chan)
02602 #define ast_channel_trylock(chan) ao2_trylock(chan)
02603 
02604 /*!
02605  * \brief Lock two channels.
02606  */
02607 #define ast_channel_lock_both(chan1, chan2) do { \
02608       ast_channel_lock(chan1); \
02609       while (ast_channel_trylock(chan2)) { \
02610          ast_channel_unlock(chan1); \
02611          sched_yield(); \
02612          ast_channel_lock(chan1); \
02613       } \
02614    } while (0)
02615 
02616 /*!
02617  * \brief Increase channel reference count
02618  *
02619  * \param c the channel
02620  *
02621  * \retval c always
02622  *
02623  * \since 1.8
02624  */
02625 #define ast_channel_ref(c) ({ ao2_ref(c, +1); (c); })
02626 
02627 /*!
02628  * \brief Decrease channel reference count
02629  *
02630  * \param c the channel
02631  *
02632  * \retval NULL always
02633  *
02634  * \since 1.8
02635  */
02636 #define ast_channel_unref(c) ({ ao2_ref(c, -1); (struct ast_channel *) (NULL); })
02637 
02638 /*!
02639  * \brief Cleanup a channel reference
02640  *
02641  * \param c the channel (NULL tolerant)
02642  *
02643  * \retval NULL always
02644  *
02645  * \since 12.0.0
02646  */
02647 #define ast_channel_cleanup(c) ({ ao2_cleanup(c); (struct ast_channel *) (NULL); })
02648 
02649 /*! Channel Iterating @{ */
02650 
02651 /*!
02652  * \brief A channel iterator
02653  *
02654  * This is an opaque type.
02655  */
02656 struct ast_channel_iterator;
02657 
02658 /*!
02659  * \brief Destroy a channel iterator
02660  *
02661  * \param i the itereator to destroy
02662  *
02663  * \details
02664  * This function is used to destroy a channel iterator that was retrieved by
02665  * using one of the channel_iterator_xxx_new() functions.
02666  *
02667  * \return NULL, for convenience to clear out the pointer to the iterator that
02668  * was just destroyed.
02669  *
02670  * \since 1.8
02671  */
02672 struct ast_channel_iterator *ast_channel_iterator_destroy(struct ast_channel_iterator *i);
02673 
02674 /*!
02675  * \brief Create a new channel iterator based on extension
02676  *
02677  * \param exten The extension that channels must be in
02678  * \param context The context that channels must be in
02679  *
02680  * \details
02681  * After creating an iterator using this function, the ast_channel_iterator_next()
02682  * function can be used to iterate through all channels that are currently
02683  * in the specified context and extension.
02684  *
02685  * \note You must call ast_channel_iterator_destroy() when done.
02686  *
02687  * \retval NULL on failure
02688  * \retval a new channel iterator based on the specified parameters
02689  *
02690  * \since 1.8
02691  */
02692 struct ast_channel_iterator *ast_channel_iterator_by_exten_new(const char *exten, const char *context);
02693 
02694 /*!
02695  * \brief Create a new channel iterator based on name
02696  *
02697  * \param name channel name or channel uniqueid to match
02698  * \param name_len number of characters in the channel name to match on.  This
02699  *      would be used to match based on name prefix.  If matching on the full
02700  *      channel name is desired, then this parameter should be 0.
02701  *
02702  * \details
02703  * After creating an iterator using this function, the ast_channel_iterator_next()
02704  * function can be used to iterate through all channels that exist that have
02705  * the specified name or name prefix.
02706  *
02707  * \note You must call ast_channel_iterator_destroy() when done.
02708  *
02709  * \retval NULL on failure
02710  * \retval a new channel iterator based on the specified parameters
02711  *
02712  * \since 1.8
02713  */
02714 struct ast_channel_iterator *ast_channel_iterator_by_name_new(const char *name,  size_t name_len);
02715 
02716 /*!
02717  * \brief Create a new channel iterator
02718  *
02719  * \details
02720  * After creating an iterator using this function, the ast_channel_iterator_next()
02721  * function can be used to iterate through all channels that exist.
02722  *
02723  * \note You must call ast_channel_iterator_destroy() when done.
02724  *
02725  * \retval NULL on failure
02726  * \retval a new channel iterator
02727  *
02728  * \since 1.8
02729  */
02730 struct ast_channel_iterator *ast_channel_iterator_all_new(void);
02731 
02732 /*!
02733  * \brief Get the next channel for a channel iterator
02734  *
02735  * \param i the channel iterator that was created using one of the
02736  *  channel_iterator_xxx_new() functions.
02737  *
02738  * \details
02739  * This function should be used to iterate through all channels that match a
02740  * specified set of parameters that were provided when the iterator was created.
02741  *
02742  * \retval the next channel that matches the parameters used when the iterator
02743  *         was created.
02744  * \retval NULL, if no more channels match the iterator parameters.
02745  *
02746  * \since 1.8
02747  */
02748 struct ast_channel *ast_channel_iterator_next(struct ast_channel_iterator *i);
02749 
02750 /*! @} End channel iterator definitions. */
02751 
02752 /*!
02753  * \brief Call a function with every active channel
02754  *
02755  * \details
02756  * This function executes a callback one time for each active channel on the
02757  * system.  The channel is provided as an argument to the function.
02758  *
02759  * \note Absolutely _NO_ channel locks should be held before calling this function.
02760  * \since 1.8
02761  */
02762 struct ast_channel *ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg,
02763       void *data, int ao2_flags);
02764 
02765 /*! @{ Channel search functions */
02766 
02767 /*!
02768  * \brief Find a channel by name
02769  *
02770  * \param name the name or uniqueid of the channel to search for
02771  *
02772  * \details
02773  * Find a channel that has the same name as the provided argument.
02774  *
02775  * \retval a channel with the name specified by the argument
02776  * \retval NULL if no channel was found
02777  *
02778  * \since 1.8
02779  */
02780 struct ast_channel *ast_channel_get_by_name(const char *name);
02781 
02782 /*!
02783  * \brief Find a channel by a name prefix
02784  *
02785  * \param name The channel name or uniqueid prefix to search for
02786  * \param name_len Only search for up to this many characters from the name
02787  *
02788  * \details
02789  * Find a channel that has the same name prefix as specified by the arguments.
02790  *
02791  * \retval a channel with the name prefix specified by the arguments
02792  * \retval NULL if no channel was found
02793  *
02794  * \since 1.8
02795  */
02796 struct ast_channel *ast_channel_get_by_name_prefix(const char *name, size_t name_len);
02797 
02798 /*!
02799  * \brief Find a channel by extension and context
02800  *
02801  * \param exten the extension to search for
02802  * \param context the context to search for
02803  *
02804  * \details
02805  * Return a channel that is currently at the specified extension and context.
02806  *
02807  * \retval a channel that is at the specified extension and context
02808  * \retval NULL if no channel was found
02809  *
02810  * \since 1.8
02811  */
02812 struct ast_channel *ast_channel_get_by_exten(const char *exten, const char *context);
02813 
02814 /*! @} End channel search functions. */
02815 
02816 /*!
02817  * \brief Initialize the given name structure.
02818  * \since 1.8
02819  *
02820  * \param init Name structure to initialize.
02821  *
02822  * \return Nothing
02823  */
02824 void ast_party_name_init(struct ast_party_name *init);
02825 
02826 /*!
02827  * \brief Copy the source party name information to the destination party name.
02828  * \since 1.8
02829  *
02830  * \param dest Destination party name
02831  * \param src Source party name
02832  *
02833  * \return Nothing
02834  */
02835 void ast_party_name_copy(struct ast_party_name *dest, const struct ast_party_name *src);
02836 
02837 /*!
02838  * \brief Initialize the given party name structure using the given guide
02839  * for a set update operation.
02840  * \since 1.8
02841  *
02842  * \details
02843  * The initialization is needed to allow a set operation to know if a
02844  * value needs to be updated.  Simple integers need the guide's original
02845  * value in case the set operation is not trying to set a new value.
02846  * String values are simply set to NULL pointers if they are not going
02847  * to be updated.
02848  *
02849  * \param init Party name structure to initialize.
02850  * \param guide Source party name to use as a guide in initializing.
02851  *
02852  * \return Nothing
02853  */
02854 void ast_party_name_set_init(struct ast_party_name *init, const struct ast_party_name *guide);
02855 
02856 /*!
02857  * \brief Set the source party name information into the destination party name.
02858  * \since 1.8
02859  *
02860  * \param dest The name one wishes to update
02861  * \param src The new name values to update the dest
02862  *
02863  * \return Nothing
02864  */
02865 void ast_party_name_set(struct ast_party_name *dest, const struct ast_party_name *src);
02866 
02867 /*!
02868  * \brief Destroy the party name contents
02869  * \since 1.8
02870  *
02871  * \param doomed The party name to destroy.
02872  *
02873  * \return Nothing
02874  */
02875 void ast_party_name_free(struct ast_party_name *doomed);
02876 
02877 /*!
02878  * \brief Initialize the given number structure.
02879  * \since 1.8
02880  *
02881  * \param init Number structure to initialize.
02882  *
02883  * \return Nothing
02884  */
02885 void ast_party_number_init(struct ast_party_number *init);
02886 
02887 /*!
02888  * \brief Copy the source party number information to the destination party number.
02889  * \since 1.8
02890  *
02891  * \param dest Destination party number
02892  * \param src Source party number
02893  *
02894  * \return Nothing
02895  */
02896 void ast_party_number_copy(struct ast_party_number *dest, const struct ast_party_number *src);
02897 
02898 /*!
02899  * \brief Initialize the given party number structure using the given guide
02900  * for a set update operation.
02901  * \since 1.8
02902  *
02903  * \details
02904  * The initialization is needed to allow a set operation to know if a
02905  * value needs to be updated.  Simple integers need the guide's original
02906  * value in case the set operation is not trying to set a new value.
02907  * String values are simply set to NULL pointers if they are not going
02908  * to be updated.
02909  *
02910  * \param init Party number structure to initialize.
02911  * \param guide Source party number to use as a guide in initializing.
02912  *
02913  * \return Nothing
02914  */
02915 void ast_party_number_set_init(struct ast_party_number *init, const struct ast_party_number *guide);
02916 
02917 /*!
02918  * \brief Set the source party number information into the destination party number.
02919  * \since 1.8
02920  *
02921  * \param dest The number one wishes to update
02922  * \param src The new number values to update the dest
02923  *
02924  * \return Nothing
02925  */
02926 void ast_party_number_set(struct ast_party_number *dest, const struct ast_party_number *src);
02927 
02928 /*!
02929  * \brief Destroy the party number contents
02930  * \since 1.8
02931  *
02932  * \param doomed The party number to destroy.
02933  *
02934  * \return Nothing
02935  */
02936 void ast_party_number_free(struct ast_party_number *doomed);
02937 
02938 /*!
02939  * \since 1.8
02940  * \brief Initialize the given subaddress structure.
02941  *
02942  * \param init Subaddress structure to initialize.
02943  *
02944  * \return Nothing
02945  */
02946 void ast_party_subaddress_init(struct ast_party_subaddress *init);
02947 
02948 /*!
02949  * \since 1.8
02950  * \brief Copy the source party subaddress information to the destination party subaddress.
02951  *
02952  * \param dest Destination party subaddress
02953  * \param src Source party subaddress
02954  *
02955  * \return Nothing
02956  */
02957 void ast_party_subaddress_copy(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src);
02958 
02959 /*!
02960  * \since 1.8
02961  * \brief Initialize the given party subaddress structure using the given guide
02962  * for a set update operation.
02963  *
02964  * \details
02965  * The initialization is needed to allow a set operation to know if a
02966  * value needs to be updated.  Simple integers need the guide's original
02967  * value in case the set operation is not trying to set a new value.
02968  * String values are simply set to NULL pointers if they are not going
02969  * to be updated.
02970  *
02971  * \param init Party subaddress structure to initialize.
02972  * \param guide Source party subaddress to use as a guide in initializing.
02973  *
02974  * \return Nothing
02975  */
02976 void ast_party_subaddress_set_init(struct ast_party_subaddress *init, const struct ast_party_subaddress *guide);
02977 
02978 /*!
02979  * \since 1.8
02980  * \brief Set the source party subaddress information into the destination party subaddress.
02981  *
02982  * \param dest The subaddress one wishes to update
02983  * \param src The new subaddress values to update the dest
02984  *
02985  * \return Nothing
02986  */
02987 void ast_party_subaddress_set(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src);
02988 
02989 /*!
02990  * \since 1.8
02991  * \brief Destroy the party subaddress contents
02992  *
02993  * \param doomed The party subaddress to destroy.
02994  *
02995  * \return Nothing
02996  */
02997 void ast_party_subaddress_free(struct ast_party_subaddress *doomed);
02998 
02999 /*!
03000  * \brief Set the update marker to update all information of a corresponding party id.
03001  * \since 11.0
03002  *
03003  * \param update_id The update marker for a corresponding party id.
03004  *
03005  * \return Nothing
03006  */
03007 void ast_set_party_id_all(struct ast_set_party_id *update_id);
03008 
03009 /*!
03010  * \brief Initialize the given party id structure.
03011  * \since 1.8
03012  *
03013  * \param init Party id structure to initialize.
03014  *
03015  * \return Nothing
03016  */
03017 void ast_party_id_init(struct ast_party_id *init);
03018 
03019 /*!
03020  * \brief Copy the source party id information to the destination party id.
03021  * \since 1.8
03022  *
03023  * \param dest Destination party id
03024  * \param src Source party id
03025  *
03026  * \return Nothing
03027  */
03028 void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src);
03029 
03030 /*!
03031  * \brief Initialize the given party id structure using the given guide
03032  * for a set update operation.
03033  * \since 1.8
03034  *
03035  * \details
03036  * The initialization is needed to allow a set operation to know if a
03037  * value needs to be updated.  Simple integers need the guide's original
03038  * value in case the set operation is not trying to set a new value.
03039  * String values are simply set to NULL pointers if they are not going
03040  * to be updated.
03041  *
03042  * \param init Party id structure to initialize.
03043  * \param guide Source party id to use as a guide in initializing.
03044  *
03045  * \return Nothing
03046  */
03047 void ast_party_id_set_init(struct ast_party_id *init, const struct ast_party_id *guide);
03048 
03049 /*!
03050  * \brief Set the source party id information into the destination party id.
03051  * \since 1.8
03052  *
03053  * \param dest The id one wishes to update
03054  * \param src The new id values to update the dest
03055  * \param update What id information to update.  NULL if all.
03056  *
03057  * \return Nothing
03058  */
03059 void ast_party_id_set(struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update);
03060 
03061 /*!
03062  * \brief Destroy the party id contents
03063  * \since 1.8
03064  *
03065  * \param doomed The party id to destroy.
03066  *
03067  * \return Nothing
03068  */
03069 void ast_party_id_free(struct ast_party_id *doomed);
03070 
03071 /*!
03072  * \brief Determine the overall presentation value for the given party.
03073  * \since 1.8
03074  *
03075  * \param id Party to determine the overall presentation value.
03076  *
03077  * \return Overall presentation value for the given party.
03078  */
03079 int ast_party_id_presentation(const struct ast_party_id *id);
03080 
03081 /*!
03082  * \brief Invalidate all components of the given party id.
03083  * \since 11.0
03084  *
03085  * \param id The party id to invalidate.
03086  *
03087  * \return Nothing
03088  */
03089 void ast_party_id_invalidate(struct ast_party_id *id);
03090 
03091 /*!
03092  * \brief Destroy and initialize the given party id structure.
03093  * \since 11.0
03094  *
03095  * \param id The party id to reset.
03096  *
03097  * \return Nothing
03098  */
03099 void ast_party_id_reset(struct ast_party_id *id);
03100 
03101 /*!
03102  * \brief Merge a given party id into another given party id.
03103  * \since 11.0
03104  *
03105  * \details
03106  * This function will generate an effective party id.
03107  *
03108  * Each party id component of the party id 'base' is overwritten
03109  * by components of the party id 'overlay' if the overlay
03110  * component is marked as valid.  However the component 'tag' of
03111  * the base party id remains untouched.
03112  *
03113  * \param base The party id which is merged.
03114  * \param overlay The party id which is used to merge into.
03115  *
03116  * \return The merged party id as a struct, not as a pointer.
03117  * \note The merged party id returned is a shallow copy and must not be freed.
03118  */
03119 struct ast_party_id ast_party_id_merge(struct ast_party_id *base, struct ast_party_id *overlay);
03120 
03121 /*!
03122  * \brief Copy a merge of a given party id into another given party id to a given destination party id.
03123  * \since 11.0
03124  *
03125  * \details
03126  * Each party id component of the party id 'base' is overwritten by components
03127  * of the party id 'overlay' if the 'overlay' component is marked as valid.
03128  * However the component 'tag' of the 'base' party id remains untouched.
03129  * The result is copied into the given party id 'dest'.
03130  *
03131  * \note The resulting merged party id is a real copy and has to be freed.
03132  *
03133  * \param dest The resulting merged party id.
03134  * \param base The party id which is merged.
03135  * \param overlay The party id which is used to merge into.
03136  *
03137  * \return Nothing
03138  */
03139 void ast_party_id_merge_copy(struct ast_party_id *dest, struct ast_party_id *base, struct ast_party_id *overlay);
03140 
03141 /*!
03142  * \brief Initialize the given dialed structure.
03143  * \since 1.8
03144  *
03145  * \param init Dialed structure to initialize.
03146  *
03147  * \return Nothing
03148  */
03149 void ast_party_dialed_init(struct ast_party_dialed *init);
03150 
03151 /*!
03152  * \brief Copy the source dialed party information to the destination dialed party.
03153  * \since 1.8
03154  *
03155  * \param dest Destination dialed party
03156  * \param src Source dialed party
03157  *
03158  * \return Nothing
03159  */
03160 void ast_party_dialed_copy(struct ast_party_dialed *dest, const struct ast_party_dialed *src);
03161 
03162 /*!
03163  * \brief Initialize the given dialed structure using the given
03164  * guide for a set update operation.
03165  * \since 1.8
03166  *
03167  * \details
03168  * The initialization is needed to allow a set operation to know if a
03169  * value needs to be updated.  Simple integers need the guide's original
03170  * value in case the set operation is not trying to set a new value.
03171  * String values are simply set to NULL pointers if they are not going
03172  * to be updated.
03173  *
03174  * \param init Caller structure to initialize.
03175  * \param guide Source dialed to use as a guide in initializing.
03176  *
03177  * \return Nothing
03178  */
03179 void ast_party_dialed_set_init(struct ast_party_dialed *init, const struct ast_party_dialed *guide);
03180 
03181 /*!
03182  * \brief Set the dialed information based on another dialed source
03183  * \since 1.8
03184  *
03185  * This is similar to ast_party_dialed_copy, except that NULL values for
03186  * strings in the src parameter indicate not to update the corresponding dest values.
03187  *
03188  * \param dest The dialed one wishes to update
03189  * \param src The new dialed values to update the dest
03190  *
03191  * \return Nada
03192  */
03193 void ast_party_dialed_set(struct ast_party_dialed *dest, const struct ast_party_dialed *src);
03194 
03195 /*!
03196  * \brief Destroy the dialed party contents
03197  * \since 1.8
03198  *
03199  * \param doomed The dialed party to destroy.
03200  *
03201  * \return Nothing
03202  */
03203 void ast_party_dialed_free(struct ast_party_dialed *doomed);
03204 
03205 /*!
03206  * \since 1.8
03207  * \brief Initialize the given caller structure.
03208  *
03209  * \param init Caller structure to initialize.
03210  *
03211  * \return Nothing
03212  */
03213 void ast_party_caller_init(struct ast_party_caller *init);
03214 
03215 /*!
03216  * \since 1.8
03217  * \brief Copy the source caller information to the destination caller.
03218  *
03219  * \param dest Destination caller
03220  * \param src Source caller
03221  *
03222  * \return Nothing
03223  */
03224 void ast_party_caller_copy(struct ast_party_caller *dest, const struct ast_party_caller *src);
03225 
03226 /*!
03227  * \brief Initialize the given caller structure using the given
03228  * guide for a set update operation.
03229  * \since 1.8
03230  *
03231  * \details
03232  * The initialization is needed to allow a set operation to know if a
03233  * value needs to be updated.  Simple integers need the guide's original
03234  * value in case the set operation is not trying to set a new value.
03235  * String values are simply set to NULL pointers if they are not going
03236  * to be updated.
03237  *
03238  * \param init Caller structure to initialize.
03239  * \param guide Source caller to use as a guide in initializing.
03240  *
03241  * \return Nothing
03242  */
03243 void ast_party_caller_set_init(struct ast_party_caller *init, const struct ast_party_caller *guide);
03244 
03245 /*!
03246  * \brief Set the caller information based on another caller source
03247  * \since 1.8
03248  *
03249  * This is similar to ast_party_caller_copy, except that NULL values for
03250  * strings in the src parameter indicate not to update the corresponding dest values.
03251  *
03252  * \param dest The caller one wishes to update
03253  * \param src The new caller values to update the dest
03254  * \param update What caller information to update.  NULL if all.
03255  *
03256  * \return Nada
03257  */
03258 void ast_party_caller_set(struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update);
03259 
03260 /*!
03261  * \brief Destroy the caller party contents
03262  * \since 1.8
03263  *
03264  * \param doomed The caller party to destroy.
03265  *
03266  * \return Nothing
03267  */
03268 void ast_party_caller_free(struct ast_party_caller *doomed);
03269 
03270 /*!
03271  * \since 1.8
03272  * \brief Initialize the given connected line structure.
03273  *
03274  * \param init Connected line structure to initialize.
03275  *
03276  * \return Nothing
03277  */
03278 void ast_party_connected_line_init(struct ast_party_connected_line *init);
03279 
03280 /*!
03281  * \since 1.8
03282  * \brief Copy the source connected line information to the destination connected line.
03283  *
03284  * \param dest Destination connected line
03285  * \param src Source connected line
03286  *
03287  * \return Nothing
03288  */
03289 void ast_party_connected_line_copy(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src);
03290 
03291 /*!
03292  * \since 1.8
03293  * \brief Initialize the given connected line structure using the given
03294  * guide for a set update operation.
03295  *
03296  * \details
03297  * The initialization is needed to allow a set operation to know if a
03298  * value needs to be updated.  Simple integers need the guide's original
03299  * value in case the set operation is not trying to set a new value.
03300  * String values are simply set to NULL pointers if they are not going
03301  * to be updated.
03302  *
03303  * \param init Connected line structure to initialize.
03304  * \param guide Source connected line to use as a guide in initializing.
03305  *
03306  * \return Nothing
03307  */
03308 void ast_party_connected_line_set_init(struct ast_party_connected_line *init, const struct ast_party_connected_line *guide);
03309 
03310 /*!
03311  * \since 1.8
03312  * \brief Set the connected line information based on another connected line source
03313  *
03314  * This is similar to ast_party_connected_line_copy, except that NULL values for
03315  * strings in the src parameter indicate not to update the corresponding dest values.
03316  *
03317  * \param dest The connected line one wishes to update
03318  * \param src The new connected line values to update the dest
03319  * \param update What connected line information to update.  NULL if all.
03320  *
03321  * \return Nothing
03322  */
03323 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);
03324 
03325 /*!
03326  * \since 1.8
03327  * \brief Collect the caller party information into a connected line structure.
03328  *
03329  * \param connected Collected caller information for the connected line
03330  * \param caller Caller information.
03331  *
03332  * \return Nothing
03333  *
03334  * \warning This is a shallow copy.
03335  * \warning DO NOT call ast_party_connected_line_free() on the filled in
03336  * connected line structure!
03337  */
03338 void ast_party_connected_line_collect_caller(struct ast_party_connected_line *connected, struct ast_party_caller *caller);
03339 
03340 /*!
03341  * \since 1.8
03342  * \brief Destroy the connected line information contents
03343  *
03344  * \param doomed The connected line information to destroy.
03345  *
03346  * \return Nothing
03347  */
03348 void ast_party_connected_line_free(struct ast_party_connected_line *doomed);
03349 
03350 /*!
03351  * \brief Initialize the given redirecting reason structure
03352  *
03353  * \param init Redirecting reason structure to initialize
03354  *
03355  * \return Nothing
03356  */
03357 void ast_party_redirecting_reason_init(struct ast_party_redirecting_reason *init);
03358 
03359 /*!
03360  * \brief Copy the source redirecting reason information to the destination redirecting reason.
03361  *
03362  * \param dest Destination redirecting reason
03363  * \param src Source redirecting reason
03364  *
03365  * \return Nothing
03366  */
03367 void ast_party_redirecting_reason_copy(struct ast_party_redirecting_reason *dest,
03368       const struct ast_party_redirecting_reason *src);
03369 
03370 /*!
03371  * \brief Initialize the given redirecting reason structure using the given guide
03372  * for a set update operation.
03373  *
03374  * \details
03375  * The initialization is needed to allow a set operation to know if a
03376  * value needs to be updated.  Simple integers need the guide's original
03377  * value in case the set operation is not trying to set a new value.
03378  * String values are simply set to NULL pointers if they are not going
03379  * to be updated.
03380  *
03381  * \param init Redirecting reason structure to initialize.
03382  * \param guide Source redirecting reason to use as a guide in initializing.
03383  *
03384  * \return Nothing
03385  */
03386 void ast_party_redirecting_reason_set_init(struct ast_party_redirecting_reason *init,
03387       const struct ast_party_redirecting_reason *guide);
03388 
03389 /*!
03390  * \brief Set the redirecting reason information based on another redirecting reason source
03391  *
03392  * This is similar to ast_party_redirecting_reason_copy, except that NULL values for
03393  * strings in the src parameter indicate not to update the corresponding dest values.
03394  *
03395  * \param dest The redirecting reason one wishes to update
03396  * \param src The new redirecting reason values to update the dest
03397  *
03398  * \return Nothing
03399  */
03400 void ast_party_redirecting_reason_set(struct ast_party_redirecting_reason *dest,
03401       const struct ast_party_redirecting_reason *src);
03402 
03403 /*!
03404  * \brief Destroy the redirecting reason contents
03405  *
03406  * \param doomed The redirecting reason to destroy.
03407  *
03408  * \return Nothing
03409  */
03410 void ast_party_redirecting_reason_free(struct ast_party_redirecting_reason *doomed);
03411 
03412 /*!
03413  * \brief Initialize the given redirecting structure.
03414  * \since 1.8
03415  *
03416  * \param init Redirecting structure to initialize.
03417  *
03418  * \return Nothing
03419  */
03420 void ast_party_redirecting_init(struct ast_party_redirecting *init);
03421 
03422 /*!
03423  * \since 1.8
03424  * \brief Copy the source redirecting information to the destination redirecting.
03425  *
03426  * \param dest Destination redirecting
03427  * \param src Source redirecting
03428  *
03429  * \return Nothing
03430  */
03431 void ast_party_redirecting_copy(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src);
03432 
03433 /*!
03434  * \since 1.8
03435  * \brief Initialize the given redirecting id structure using the given guide
03436  * for a set update operation.
03437  *
03438  * \details
03439  * The initialization is needed to allow a set operation to know if a
03440  * value needs to be updated.  Simple integers need the guide's original
03441  * value in case the set operation is not trying to set a new value.
03442  * String values are simply set to NULL pointers if they are not going
03443  * to be updated.
03444  *
03445  * \param init Redirecting id structure to initialize.
03446  * \param guide Source redirecting id to use as a guide in initializing.
03447  *
03448  * \return Nothing
03449  */
03450 void ast_party_redirecting_set_init(struct ast_party_redirecting *init, const struct ast_party_redirecting *guide);
03451 
03452 /*!
03453  * \brief Set the redirecting information based on another redirecting source
03454  * \since 1.8
03455  *
03456  * This is similar to ast_party_redirecting_copy, except that NULL values for
03457  * strings in the src parameter indicate not to update the corresponding dest values.
03458  *
03459  * \param dest The redirecting one wishes to update
03460  * \param src The new redirecting values to update the dest
03461  * \param update What redirecting information to update.  NULL if all.
03462  *
03463  * \return Nothing
03464  */
03465 void ast_party_redirecting_set(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src, const struct ast_set_party_redirecting *update);
03466 
03467 /*!
03468  * \since 1.8
03469  * \brief Destroy the redirecting information contents
03470  *
03471  * \param doomed The redirecting information to destroy.
03472  *
03473  * \return Nothing
03474  */
03475 void ast_party_redirecting_free(struct ast_party_redirecting *doomed);
03476 
03477 /*!
03478  * \since 1.8
03479  * \brief Copy the caller information to the connected line information.
03480  *
03481  * \param dest Destination connected line information
03482  * \param src Source caller information
03483  *
03484  * \return Nothing
03485  *
03486  * \note Assumes locks are already acquired
03487  */
03488 void ast_connected_line_copy_from_caller(struct ast_party_connected_line *dest, const struct ast_party_caller *src);
03489 
03490 /*!
03491  * \since 1.8
03492  * \brief Copy the connected line information to the caller information.
03493  *
03494  * \param dest Destination caller information
03495  * \param src Source connected line information
03496  *
03497  * \return Nothing
03498  *
03499  * \note Assumes locks are already acquired
03500  */
03501 void ast_connected_line_copy_to_caller(struct ast_party_caller *dest, const struct ast_party_connected_line *src);
03502 
03503 /*!
03504  * \since 1.8
03505  * \brief Set the connected line information in the Asterisk channel
03506  *
03507  * \param chan Asterisk channel to set connected line information
03508  * \param connected Connected line information
03509  * \param update What connected line information to update.  NULL if all.
03510  *
03511  * \return Nothing
03512  *
03513  * \note The channel does not need to be locked before calling this function.
03514  */
03515 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);
03516 
03517 /*!
03518  * \since 1.8
03519  * \brief Build the connected line information data frame.
03520  *
03521  * \param data Buffer to fill with the frame data
03522  * \param datalen Size of the buffer to fill
03523  * \param connected Connected line information
03524  * \param update What connected line information to build.  NULL if all.
03525  *
03526  * \retval -1 if error
03527  * \retval Amount of data buffer used
03528  */
03529 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);
03530 
03531 /*!
03532  * \since 1.8
03533  * \brief Parse connected line indication frame data
03534  *
03535  * \param data Buffer with the frame data to parse
03536  * \param datalen Size of the buffer
03537  * \param connected Extracted connected line information
03538  *
03539  * \retval 0 on success.
03540  * \retval -1 on error.
03541  *
03542  * \note The filled in connected line structure needs to be initialized by
03543  * ast_party_connected_line_set_init() before calling.  If defaults are not
03544  * required use ast_party_connected_line_init().
03545  * \note The filled in connected line structure needs to be destroyed by
03546  * ast_party_connected_line_free() when it is no longer needed.
03547  */
03548 int ast_connected_line_parse_data(const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected);
03549 
03550 /*!
03551  * \since 1.8
03552  * \brief Indicate that the connected line information has changed
03553  *
03554  * \param chan Asterisk channel to indicate connected line information
03555  * \param connected Connected line information
03556  * \param update What connected line information to update.  NULL if all.
03557  *
03558  * \return Nothing
03559  */
03560 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);
03561 
03562 /*!
03563  * \since 1.8
03564  * \brief Queue a connected line update frame on a channel
03565  *
03566  * \param chan Asterisk channel to indicate connected line information
03567  * \param connected Connected line information
03568  * \param update What connected line information to update.  NULL if all.
03569  *
03570  * \return Nothing
03571  */
03572 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);
03573 
03574 /*!
03575  * \since 1.8
03576  * \brief Set the redirecting id information in the Asterisk channel
03577  *
03578  * \param chan Asterisk channel to set redirecting id information
03579  * \param redirecting Redirecting id information
03580  * \param update What redirecting information to update.  NULL if all.
03581  *
03582  * \return Nothing
03583  *
03584  * \note The channel does not need to be locked before calling this function.
03585  */
03586 void ast_channel_set_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
03587 
03588 /*!
03589  * \since 1.8
03590  * \brief Build the redirecting id data frame.
03591  *
03592  * \param data Buffer to fill with the frame data
03593  * \param datalen Size of the buffer to fill
03594  * \param redirecting Redirecting id information
03595  * \param update What redirecting information to build.  NULL if all.
03596  *
03597  * \retval -1 if error
03598  * \retval Amount of data buffer used
03599  */
03600 int ast_redirecting_build_data(unsigned char *data, size_t datalen, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
03601 
03602 /*!
03603  * \since 1.8
03604  * \brief Parse redirecting indication frame data
03605  *
03606  * \param data Buffer with the frame data to parse
03607  * \param datalen Size of the buffer
03608  * \param redirecting Extracted redirecting id information
03609  *
03610  * \retval 0 on success.
03611  * \retval -1 on error.
03612  *
03613  * \note The filled in id structure needs to be initialized by
03614  * ast_party_redirecting_set_init() before calling.
03615  * \note The filled in id structure needs to be destroyed by
03616  * ast_party_redirecting_free() when it is no longer needed.
03617  */
03618 int ast_redirecting_parse_data(const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting);
03619 
03620 /*!
03621  * \since 1.8
03622  * \brief Indicate that the redirecting id has changed
03623  *
03624  * \param chan Asterisk channel to indicate redirecting id information
03625  * \param redirecting Redirecting id information
03626  * \param update What redirecting information to update.  NULL if all.
03627  *
03628  * \return Nothing
03629  */
03630 void ast_channel_update_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
03631 
03632 /*!
03633  * \since 1.8
03634  * \brief Queue a redirecting update frame on a channel
03635  *
03636  * \param chan Asterisk channel to indicate redirecting id information
03637  * \param redirecting Redirecting id information
03638  * \param update What redirecting information to update.  NULL if all.
03639  *
03640  * \return Nothing
03641  */
03642 void ast_channel_queue_redirecting_update(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
03643 
03644 /*!
03645  * \since 1.8
03646  * \brief Run a connected line interception macro and update a channel's connected line
03647  * information
03648  * \deprecated You should use the ast_channel_connected_line_sub() function instead.
03649  *
03650  * Whenever we want to update a channel's connected line information, we may need to run
03651  * a macro so that an administrator can manipulate the information before sending it
03652  * out. This function both runs the macro and sends the update to the channel.
03653  *
03654  * \param autoservice_chan Channel to place into autoservice while the macro is running.
03655  * It is perfectly safe for this to be NULL
03656  * \param macro_chan The channel to run the macro on. Also the channel from which we
03657  * determine which macro we need to run.
03658  * \param connected_info Either an ast_party_connected_line or ast_frame pointer of type
03659  * AST_CONTROL_CONNECTED_LINE
03660  * \param is_caller If true, then run CONNECTED_LINE_CALLER_SEND_MACRO with arguments from
03661  * CONNECTED_LINE_CALLER_SEND_MACRO_ARGS, otherwise run CONNECTED_LINE_CALLEE_SEND_MACRO
03662  * with arguments from CONNECTED_LINE_CALLEE_SEND_MACRO_ARGS
03663  * \param frame If true, then connected_info is an ast_frame pointer, otherwise it is an
03664  * ast_party_connected_line pointer.
03665  * \retval 0 Success
03666  * \retval -1 Either the macro does not exist, or there was an error while attempting to
03667  * run the macro
03668  *
03669  * \todo Have multiple return codes based on the MACRO_RESULT
03670  * \todo Make constants so that caller and frame can be more expressive than just '1' and
03671  * '0'
03672  */
03673 int ast_channel_connected_line_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *connected_info, int is_caller, int frame);
03674 
03675 /*!
03676  * \since 11
03677  * \brief Run a connected line interception subroutine and update a channel's connected line
03678  * information
03679  *
03680  * Whenever we want to update a channel's connected line information, we may need to run
03681  * a subroutine so that an administrator can manipulate the information before sending it
03682  * out. This function both runs the subroutine specified by CONNECTED_LINE_SEND_SUB and
03683  * sends the update to the channel.
03684  *
03685  * \param autoservice_chan Channel to place into autoservice while the sub is running.
03686  * It is perfectly safe for this to be NULL
03687  * \param sub_chan The channel to run the subroutine on. Also the channel from which we
03688  * determine which subroutine we need to run.
03689  * \param connected_info Either an ast_party_connected_line or ast_frame pointer of type
03690  * AST_CONTROL_CONNECTED_LINE
03691  * \param frame If true, then connected_info is an ast_frame pointer, otherwise it is an
03692  * ast_party_connected_line pointer.
03693  * \retval 0 Success
03694  * \retval -1 Either the subroutine does not exist, or there was an error while attempting to
03695  * run the subroutine
03696  */
03697 int ast_channel_connected_line_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *connected_info, int frame);
03698 
03699 /*!
03700  * \brief Insert into an astdata tree, the channel structure.
03701  * \param[in] tree The ast data tree.
03702  * \param[in] chan The channel structure to add to tree.
03703  * \param[in] add_bridged Add the bridged channel to the structure.
03704  * \retval <0 on error.
03705  * \retval 0 on success.
03706  */
03707 int ast_channel_data_add_structure(struct ast_data *tree, struct ast_channel *chan, int add_bridged);
03708 
03709 /*!
03710  * \brief Compare to channel structures using the data api.
03711  * \param[in] tree The search tree generated by the data api.
03712  * \param[in] chan The channel to compare.
03713  * \param[in] structure_name The name of the node of the channel structure.
03714  * \retval 0 The structure matches.
03715  * \retval 1 The structure doesn't matches.
03716  */
03717 int ast_channel_data_cmp_structure(const struct ast_data_search *tree, struct ast_channel *chan,
03718    const char *structure_name);
03719 
03720 /*!
03721  * \since 1.8
03722  * \brief Run a redirecting interception macro and update a channel's redirecting information
03723  * \deprecated You should use the ast_channel_redirecting_sub() function instead.
03724  *
03725  * \details
03726  * Whenever we want to update a channel's redirecting information, we may need to run
03727  * a macro so that an administrator can manipulate the information before sending it
03728  * out. This function both runs the macro and sends the update to the channel.
03729  *
03730  * \param autoservice_chan Channel to place into autoservice while the macro is running.
03731  * It is perfectly safe for this to be NULL
03732  * \param macro_chan The channel to run the macro on. Also the channel from which we
03733  * determine which macro we need to run.
03734  * \param redirecting_info Either an ast_party_redirecting or ast_frame pointer of type
03735  * AST_CONTROL_REDIRECTING
03736  * \param is_caller If true, then run REDIRECTING_CALLER_SEND_MACRO with arguments from
03737  * REDIRECTING_CALLER_SEND_MACRO_ARGS, otherwise run REDIRECTING_CALLEE_SEND_MACRO with
03738  * arguments from REDIRECTING_CALLEE_SEND_MACRO_ARGS
03739  * \param is_frame If true, then redirecting_info is an ast_frame pointer, otherwise it is an
03740  * ast_party_redirecting pointer.
03741  *
03742  * \retval 0 Success
03743  * \retval -1 Either the macro does not exist, or there was an error while attempting to
03744  * run the macro
03745  *
03746  * \todo Have multiple return codes based on the MACRO_RESULT
03747  * \todo Make constants so that caller and frame can be more expressive than just '1' and
03748  * '0'
03749  */
03750 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);
03751 
03752 /*!
03753  * \since 11
03754  * \brief Run a redirecting interception subroutine and update a channel's redirecting information
03755  *
03756  * \details
03757  * Whenever we want to update a channel's redirecting information, we may need to run
03758  * a subroutine so that an administrator can manipulate the information before sending it
03759  * out. This function both runs the subroutine specified by REDIRECTING_SEND_SUB and
03760  * sends the update to the channel.
03761  *
03762  * \param autoservice_chan Channel to place into autoservice while the subroutine is running.
03763  * It is perfectly safe for this to be NULL
03764  * \param sub_chan The channel to run the subroutine on. Also the channel from which we
03765  * determine which subroutine we need to run.
03766  * \param redirecting_info Either an ast_party_redirecting or ast_frame pointer of type
03767  * AST_CONTROL_REDIRECTING
03768  * \param is_frame If true, then redirecting_info is an ast_frame pointer, otherwise it is an
03769  * ast_party_redirecting pointer.
03770  *
03771  * \retval 0 Success
03772  * \retval -1 Either the subroutine does not exist, or there was an error while attempting to
03773  * run the subroutine
03774  */
03775 int ast_channel_redirecting_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *redirecting_info, int is_frame);
03776 
03777 #include "asterisk/ccss.h"
03778 
03779 /*!
03780  * \since 1.8
03781  * \brief Set up datastore with CCSS parameters for a channel
03782  *
03783  * \note
03784  * If base_params is NULL, the channel will get the default
03785  * values for all CCSS parameters.
03786  *
03787  * \details
03788  * This function makes use of datastore operations on the channel, so
03789  * it is important to lock the channel before calling this function.
03790  *
03791  * \param chan The channel to create the datastore on
03792  * \param base_params CCSS parameters we wish to copy into the channel
03793  * \retval 0 Success
03794  * \retval -1 Failure
03795  */
03796 int ast_channel_cc_params_init(struct ast_channel *chan,
03797       const struct ast_cc_config_params *base_params);
03798 
03799 /*!
03800  * \since 1.8
03801  * \brief Get the CCSS parameters from a channel
03802  *
03803  * \details
03804  * This function makes use of datastore operations on the channel, so
03805  * it is important to lock the channel before calling this function.
03806  *
03807  * \param chan Channel to retrieve parameters from
03808  * \retval NULL Failure
03809  * \retval non-NULL The parameters desired
03810  */
03811 struct ast_cc_config_params *ast_channel_get_cc_config_params(struct ast_channel *chan);
03812 
03813 
03814 /*!
03815  * \since 1.8
03816  * \brief Get a device name given its channel structure
03817  *
03818  * \details
03819  * A common practice in Asterisk is to determine the device being talked
03820  * to by dissecting the channel name. For certain channel types, this is not
03821  * accurate. For instance, an ISDN channel is named based on what B channel is
03822  * used, not the device being communicated with.
03823  *
03824  * This function interfaces with a channel tech's queryoption callback to
03825  * retrieve the name of the device being communicated with. If the channel does not
03826  * implement this specific option, then the traditional method of using the channel
03827  * name is used instead.
03828  *
03829  * \param chan The channel to retrieve the information from
03830  * \param[out] device_name The buffer to place the device's name into
03831  * \param name_buffer_length The allocated space for the device_name
03832  * \return 0 always
03833  */
03834 int ast_channel_get_device_name(struct ast_channel *chan, char *device_name, size_t name_buffer_length);
03835 
03836 /*!
03837  * \since 1.8
03838  * \brief Find the appropriate CC agent type to use given a channel
03839  *
03840  * \details
03841  * During call completion, we will need to create a call completion agent structure. To
03842  * figure out the type of agent to construct, we need to ask the channel driver for the
03843  * appropriate type.
03844  *
03845  * Prior to adding this function, the call completion core attempted to figure this
03846  * out for itself by stripping the technology off the channel's name. However, in the
03847  * case of chan_dahdi, there are multiple agent types registered, and so simply searching
03848  * for an agent type called "DAHDI" is not possible. In a case where multiple agent types
03849  * are defined, the channel driver must have a queryoption callback defined in its
03850  * channel_tech, and the queryoption callback must handle AST_OPTION_CC_AGENT_TYPE
03851  *
03852  * If a channel driver does not have a queryoption callback or if the queryoption callback
03853  * does not handle AST_OPTION_CC_AGENT_TYPE, then the old behavior of using the technology
03854  * portion of the channel name is used instead. This is perfectly suitable for channel drivers
03855  * whose channel technologies are a one-to-one match with the agent types defined within.
03856  *
03857  * Note that this function is only called when the agent policy on a given channel is set
03858  * to "native." Generic agents' type can be determined automatically by the core.
03859  *
03860  * \param chan The channel for which we wish to retrieve the agent type
03861  * \param[out] agent_type The type of agent the channel driver wants us to use
03862  * \param size The size of the buffer to write to
03863  */
03864 int ast_channel_get_cc_agent_type(struct ast_channel *chan, char *agent_type, size_t size);
03865 #if defined(__cplusplus) || defined(c_plusplus)
03866 }
03867 #endif
03868 
03869 /*!
03870  * \brief Remove a channel from the global channels container
03871  *
03872  * \param chan channel to remove
03873  *
03874  * In a case where it is desired that a channel not be available in any lookups
03875  * in the global channels conatiner, use this function.
03876  */
03877 void ast_channel_unlink(struct ast_channel *chan);
03878 
03879 /*!
03880  * \brief Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash
03881  * on the given channel
03882  *
03883  * \param chan channel on which to set the cause information
03884  * \param cause_code ast_control_pvt_cause_code structure containing cause information
03885  * \param datalen total length of the structure since it may vary
03886  */
03887 void ast_channel_hangupcause_hash_set(struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen);
03888 
03889 /*!
03890  * \since 12
03891  * \brief Convert a string to a detail record AMA flag
03892  *
03893  * \param flag string form of flag
03894  *
03895  * \retval the enum (integer) form of the flag
03896  */
03897 enum ama_flags ast_channel_string2amaflag(const char *flag);
03898 
03899 /*!
03900  * \since 12
03901  * \brief Convert the enum representation of an AMA flag to a string representation
03902  *
03903  * \param flags integer flag
03904  *
03905  * \retval A string representation of the flag
03906  */
03907 const char *ast_channel_amaflags2string(enum ama_flags flags);
03908 
03909 /* ACCESSOR FUNTIONS */
03910 /*! \brief Set the channel name */
03911 void ast_channel_name_set(struct ast_channel *chan, const char *name);
03912 
03913 #define DECLARE_STRINGFIELD_SETTERS_FOR(field)  \
03914    void ast_channel_##field##_set(struct ast_channel *chan, const char *field); \
03915    void ast_channel_##field##_build_va(struct ast_channel *chan, const char *fmt, va_list ap) __attribute__((format(printf, 2, 0))); \
03916    void ast_channel_##field##_build(struct ast_channel *chan, const char *fmt, ...) __attribute__((format(printf, 2, 3)))
03917 
03918 /*!
03919  * The following string fields result in channel snapshot creation and
03920  * should have the channel locked when called:
03921  *
03922  * \li language
03923  * \li accountcode
03924  * \li peeracccount
03925  * \li linkedid
03926  */
03927 DECLARE_STRINGFIELD_SETTERS_FOR(name);
03928 DECLARE_STRINGFIELD_SETTERS_FOR(language);
03929 DECLARE_STRINGFIELD_SETTERS_FOR(musicclass);
03930 DECLARE_STRINGFIELD_SETTERS_FOR(latest_musicclass);
03931 DECLARE_STRINGFIELD_SETTERS_FOR(accountcode);
03932 DECLARE_STRINGFIELD_SETTERS_FOR(peeraccount);
03933 DECLARE_STRINGFIELD_SETTERS_FOR(userfield);
03934 DECLARE_STRINGFIELD_SETTERS_FOR(call_forward);
03935 DECLARE_STRINGFIELD_SETTERS_FOR(uniqueid);
03936 DECLARE_STRINGFIELD_SETTERS_FOR(linkedid);
03937 DECLARE_STRINGFIELD_SETTERS_FOR(parkinglot);
03938 DECLARE_STRINGFIELD_SETTERS_FOR(hangupsource);
03939 DECLARE_STRINGFIELD_SETTERS_FOR(dialcontext);
03940 
03941 const char *ast_channel_name(const struct ast_channel *chan);
03942 const char *ast_channel_language(const struct ast_channel *chan);
03943 const char *ast_channel_musicclass(const struct ast_channel *chan);
03944 const char *ast_channel_latest_musicclass(const struct ast_channel *chan);
03945 const char *ast_channel_accountcode(const struct ast_channel *chan);
03946 const char *ast_channel_peeraccount(const struct ast_channel *chan);
03947 const char *ast_channel_userfield(const struct ast_channel *chan);
03948 const char *ast_channel_call_forward(const struct ast_channel *chan);
03949 const char *ast_channel_uniqueid(const struct ast_channel *chan);
03950 const char *ast_channel_linkedid(const struct ast_channel *chan);
03951 const char *ast_channel_parkinglot(const struct ast_channel *chan);
03952 const char *ast_channel_hangupsource(const struct ast_channel *chan);
03953 const char *ast_channel_dialcontext(const struct ast_channel *chan);
03954 
03955 const char *ast_channel_appl(const struct ast_channel *chan);
03956 void ast_channel_appl_set(struct ast_channel *chan, const char *value);
03957 const char *ast_channel_blockproc(const struct ast_channel *chan);
03958 void ast_channel_blockproc_set(struct ast_channel *chan, const char *value);
03959 const char *ast_channel_data(const struct ast_channel *chan);
03960 void ast_channel_data_set(struct ast_channel *chan, const char *value);
03961 
03962 const char *ast_channel_context(const struct ast_channel *chan);
03963 void ast_channel_context_set(struct ast_channel *chan, const char *value);
03964 const char *ast_channel_exten(const struct ast_channel *chan);
03965 void ast_channel_exten_set(struct ast_channel *chan, const char *value);
03966 const char *ast_channel_macrocontext(const struct ast_channel *chan);
03967 void ast_channel_macrocontext_set(struct ast_channel *chan, const char *value);
03968 const char *ast_channel_macroexten(const struct ast_channel *chan);
03969 void ast_channel_macroexten_set(struct ast_channel *chan, const char *value);
03970 
03971 char ast_channel_dtmf_digit_to_emulate(const struct ast_channel *chan);
03972 void ast_channel_dtmf_digit_to_emulate_set(struct ast_channel *chan, char value);
03973 char ast_channel_sending_dtmf_digit(const struct ast_channel *chan);
03974 void ast_channel_sending_dtmf_digit_set(struct ast_channel *chan, char value);
03975 struct timeval ast_channel_sending_dtmf_tv(const struct ast_channel *chan);
03976 void ast_channel_sending_dtmf_tv_set(struct ast_channel *chan, struct timeval value);
03977 enum ama_flags ast_channel_amaflags(const struct ast_channel *chan);
03978 
03979 /*!
03980  * \pre chan is locked
03981  */
03982 void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value);
03983 int ast_channel_epfd(const struct ast_channel *chan);
03984 void ast_channel_epfd_set(struct ast_channel *chan, int value);
03985 int ast_channel_fdno(const struct ast_channel *chan);
03986 void ast_channel_fdno_set(struct ast_channel *chan, int value);
03987 int ast_channel_hangupcause(const struct ast_channel *chan);
03988 void ast_channel_hangupcause_set(struct ast_channel *chan, int value);
03989 int ast_channel_macropriority(const struct ast_channel *chan);
03990 void ast_channel_macropriority_set(struct ast_channel *chan, int value);
03991 int ast_channel_priority(const struct ast_channel *chan);
03992 void ast_channel_priority_set(struct ast_channel *chan, int value);
03993 int ast_channel_rings(const struct ast_channel *chan);
03994 void ast_channel_rings_set(struct ast_channel *chan, int value);
03995 int ast_channel_streamid(const struct ast_channel *chan);
03996 void ast_channel_streamid_set(struct ast_channel *chan, int value);
03997 int ast_channel_timingfd(const struct ast_channel *chan);
03998 void ast_channel_timingfd_set(struct ast_channel *chan, int value);
03999 int ast_channel_visible_indication(const struct ast_channel *chan);
04000 void ast_channel_visible_indication_set(struct ast_channel *chan, int value);
04001 int ast_channel_hold_state(const struct ast_channel *chan);
04002 void ast_channel_hold_state_set(struct ast_channel *chan, int value);
04003 int ast_channel_vstreamid(const struct ast_channel *chan);
04004 void ast_channel_vstreamid_set(struct ast_channel *chan, int value);
04005 unsigned short ast_channel_transfercapability(const struct ast_channel *chan);
04006 void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value);
04007 unsigned int ast_channel_emulate_dtmf_duration(const struct ast_channel *chan);
04008 void ast_channel_emulate_dtmf_duration_set(struct ast_channel *chan, unsigned int value);
04009 unsigned int ast_channel_fin(const struct ast_channel *chan);
04010 void ast_channel_fin_set(struct ast_channel *chan, unsigned int value);
04011 unsigned int ast_channel_fout(const struct ast_channel *chan);
04012 void ast_channel_fout_set(struct ast_channel *chan, unsigned int value);
04013 unsigned long ast_channel_insmpl(const struct ast_channel *chan);
04014 void ast_channel_insmpl_set(struct ast_channel *chan, unsigned long value);
04015 unsigned long ast_channel_outsmpl(const struct ast_channel *chan);
04016 void ast_channel_outsmpl_set(struct ast_channel *chan, unsigned long value);
04017 void *ast_channel_generatordata(const struct ast_channel *chan);
04018 void ast_channel_generatordata_set(struct ast_channel *chan, void *value);
04019 void *ast_channel_music_state(const struct ast_channel *chan);
04020 void ast_channel_music_state_set(struct ast_channel *chan, void *value);
04021 void *ast_channel_tech_pvt(const struct ast_channel *chan);
04022 void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value);
04023 void *ast_channel_timingdata(const struct ast_channel *chan);
04024 void ast_channel_timingdata_set(struct ast_channel *chan, void *value);
04025 struct ast_audiohook_list *ast_channel_audiohooks(const struct ast_channel *chan);
04026 void ast_channel_audiohooks_set(struct ast_channel *chan, struct ast_audiohook_list *value);
04027 struct ast_cdr *ast_channel_cdr(const struct ast_channel *chan);
04028 void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr *value);
04029 struct ast_channel *ast_channel__bridge(const struct ast_channel *chan);
04030 void ast_channel__bridge_set(struct ast_channel *chan, struct ast_channel *value);
04031 struct ast_channel *ast_channel_masq(const struct ast_channel *chan);
04032 void ast_channel_masq_set(struct ast_channel *chan, struct ast_channel *value);
04033 struct ast_channel *ast_channel_masqr(const struct ast_channel *chan);
04034 void ast_channel_masqr_set(struct ast_channel *chan, struct ast_channel *value);
04035 struct ast_channel_monitor *ast_channel_monitor(const struct ast_channel *chan);
04036 void ast_channel_monitor_set(struct ast_channel *chan, struct ast_channel_monitor *value);
04037 struct ast_filestream *ast_channel_stream(const struct ast_channel *chan);
04038 void ast_channel_stream_set(struct ast_channel *chan, struct ast_filestream *value);
04039 struct ast_filestream *ast_channel_vstream(const struct ast_channel *chan);
04040 void ast_channel_vstream_set(struct ast_channel *chan, struct ast_filestream *value);
04041 struct ast_format_cap *ast_channel_nativeformats(const struct ast_channel *chan);
04042 void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value);
04043 struct ast_framehook_list *ast_channel_framehooks(const struct ast_channel *chan);
04044 void ast_channel_framehooks_set(struct ast_channel *chan, struct ast_framehook_list *value);
04045 struct ast_generator *ast_channel_generator(const struct ast_channel *chan);
04046 void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator *value);
04047 struct ast_pbx *ast_channel_pbx(const struct ast_channel *chan);
04048 void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx *value);
04049 struct ast_sched_context *ast_channel_sched(const struct ast_channel *chan);
04050 void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context *value);
04051 struct ast_timer *ast_channel_timer(const struct ast_channel *chan);
04052 void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer *value);
04053 struct ast_tone_zone *ast_channel_zone(const struct ast_channel *chan);
04054 void ast_channel_zone_set(struct ast_channel *chan, struct ast_tone_zone *value);
04055 struct ast_trans_pvt *ast_channel_readtrans(const struct ast_channel *chan);
04056 void ast_channel_readtrans_set(struct ast_channel *chan, struct ast_trans_pvt *value);
04057 struct ast_trans_pvt *ast_channel_writetrans(const struct ast_channel *chan);
04058 void ast_channel_writetrans_set(struct ast_channel *chan, struct ast_trans_pvt *value);
04059 const struct ast_channel_tech *ast_channel_tech(const struct ast_channel *chan);
04060 void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value);
04061 enum ast_channel_adsicpe ast_channel_adsicpe(const struct ast_channel *chan);
04062 void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value);
04063 enum ast_channel_state ast_channel_state(const struct ast_channel *chan);
04064 ast_callid ast_channel_callid(const struct ast_channel *chan);
04065 
04066 /*!
04067  * \pre chan is locked
04068  */
04069 void ast_channel_callid_set(struct ast_channel *chan, ast_callid value);
04070 
04071 /* XXX Internal use only, make sure to move later */
04072 void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state);
04073 void ast_channel_softhangup_internal_flag_set(struct ast_channel *chan, int value);
04074 void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value);
04075 void ast_channel_softhangup_internal_flag_clear(struct ast_channel *chan, int value);
04076 void ast_channel_callid_cleanup(struct ast_channel *chan);
04077 int ast_channel_softhangup_internal_flag(struct ast_channel *chan);
04078 
04079 /* Format getters */
04080 struct ast_format *ast_channel_oldwriteformat(struct ast_channel *chan);
04081 struct ast_format *ast_channel_rawreadformat(struct ast_channel *chan);
04082 struct ast_format *ast_channel_rawwriteformat(struct ast_channel *chan);
04083 struct ast_format *ast_channel_readformat(struct ast_channel *chan);
04084 struct ast_format *ast_channel_writeformat(struct ast_channel *chan);
04085 
04086 /* Format setters - all of these functions will increment the reference count of the format passed in */
04087 void ast_channel_set_oldwriteformat(struct ast_channel *chan, struct ast_format *format);
04088 void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format);
04089 void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format);
04090 void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format);
04091 void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format);
04092 
04093 /* Other struct getters */
04094 struct ast_frame *ast_channel_dtmff(struct ast_channel *chan);
04095 struct ast_jb *ast_channel_jb(struct ast_channel *chan);
04096 struct ast_party_caller *ast_channel_caller(struct ast_channel *chan);
04097 struct ast_party_connected_line *ast_channel_connected(struct ast_channel *chan);
04098 struct ast_party_connected_line *ast_channel_connected_indicated(struct ast_channel *chan);
04099 struct ast_party_id ast_channel_connected_effective_id(struct ast_channel *chan);
04100 struct ast_party_dialed *ast_channel_dialed(struct ast_channel *chan);
04101 struct ast_party_redirecting *ast_channel_redirecting(struct ast_channel *chan);
04102 struct ast_party_id ast_channel_redirecting_effective_orig(struct ast_channel *chan);
04103 struct ast_party_id ast_channel_redirecting_effective_from(struct ast_channel *chan);
04104 struct ast_party_id ast_channel_redirecting_effective_to(struct ast_channel *chan);
04105 struct timeval *ast_channel_dtmf_tv(struct ast_channel *chan);
04106 struct timeval *ast_channel_whentohangup(struct ast_channel *chan);
04107 struct varshead *ast_channel_varshead(struct ast_channel *chan);
04108 
04109 void ast_channel_dtmff_set(struct ast_channel *chan, struct ast_frame *value);
04110 void ast_channel_jb_set(struct ast_channel *chan, struct ast_jb *value);
04111 void ast_channel_caller_set(struct ast_channel *chan, struct ast_party_caller *value);
04112 void ast_channel_connected_set(struct ast_channel *chan, struct ast_party_connected_line *value);
04113 void ast_channel_dialed_set(struct ast_channel *chan, struct ast_party_dialed *value);
04114 void ast_channel_redirecting_set(struct ast_channel *chan, struct ast_party_redirecting *value);
04115 void ast_channel_dtmf_tv_set(struct ast_channel *chan, struct timeval *value);
04116 
04117 /*!
04118  * \pre chan is locked
04119  */
04120 void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value);
04121 void ast_channel_varshead_set(struct ast_channel *chan, struct varshead *value);
04122 struct timeval ast_channel_creationtime(struct ast_channel *chan);
04123 void ast_channel_creationtime_set(struct ast_channel *chan, struct timeval *value);
04124 struct timeval ast_channel_answertime(struct ast_channel *chan);
04125 void ast_channel_answertime_set(struct ast_channel *chan, struct timeval *value);
04126 
04127 /* List getters */
04128 struct ast_hangup_handler_list *ast_channel_hangup_handlers(struct ast_channel *chan);
04129 struct ast_datastore_list *ast_channel_datastores(struct ast_channel *chan);
04130 struct ast_autochan_list *ast_channel_autochans(struct ast_channel *chan);
04131 struct ast_readq_list *ast_channel_readq(struct ast_channel *chan);
04132 
04133 /* Typedef accessors */
04134 ast_group_t ast_channel_callgroup(const struct ast_channel *chan);
04135 /*!
04136  * \pre chan is locked
04137  */
04138 void ast_channel_callgroup_set(struct ast_channel *chan, ast_group_t value);
04139 ast_group_t ast_channel_pickupgroup(const struct ast_channel *chan);
04140 /*!
04141  * \pre chan is locked
04142  */
04143 void ast_channel_pickupgroup_set(struct ast_channel *chan, ast_group_t value);
04144 struct ast_namedgroups *ast_channel_named_callgroups(const struct ast_channel *chan);
04145 void ast_channel_named_callgroups_set(struct ast_channel *chan, struct ast_namedgroups *value);
04146 struct ast_namedgroups *ast_channel_named_pickupgroups(const struct ast_channel *chan);
04147 void ast_channel_named_pickupgroups_set(struct ast_channel *chan, struct ast_namedgroups *value);
04148 
04149 /* Alertpipe accessors--the "internal" functions for channel.c use only */
04150 typedef enum {
04151    AST_ALERT_READ_SUCCESS = 0,
04152    AST_ALERT_NOT_READABLE,
04153    AST_ALERT_READ_FAIL,
04154    AST_ALERT_READ_FATAL,
04155 } ast_alert_status_t;
04156 int ast_channel_alert_write(struct ast_channel *chan);
04157 int ast_channel_alert_writable(struct ast_channel *chan);
04158 ast_alert_status_t ast_channel_internal_alert_read(struct ast_channel *chan);
04159 int ast_channel_internal_alert_readable(struct ast_channel *chan);
04160 void ast_channel_internal_alertpipe_clear(struct ast_channel *chan);
04161 void ast_channel_internal_alertpipe_close(struct ast_channel *chan);
04162 int ast_channel_internal_alert_readfd(struct ast_channel *chan);
04163 int ast_channel_internal_alertpipe_init(struct ast_channel *chan);
04164 /*! \brief Swap the interal alertpipe between two channels
04165  * \note Handle all of the necessary locking before calling this
04166  */
04167 void ast_channel_internal_alertpipe_swap(struct ast_channel *chan1, struct ast_channel *chan2);
04168 
04169 /* file descriptor array accessors */
04170 void ast_channel_internal_fd_clear(struct ast_channel *chan, int which);
04171 void ast_channel_internal_fd_clear_all(struct ast_channel *chan);
04172 void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value);
04173 int ast_channel_fd(const struct ast_channel *chan, int which);
04174 int ast_channel_fd_isset(const struct ast_channel *chan, int which);
04175 
04176 /* epoll data internal accessors */
04177 #ifdef HAVE_EPOLL
04178 struct ast_epoll_data *ast_channel_internal_epfd_data(const struct ast_channel *chan, int which);
04179 void ast_channel_internal_epfd_data_set(struct ast_channel *chan, int which , struct ast_epoll_data *value);
04180 #endif
04181 
04182 pthread_t ast_channel_blocker(const struct ast_channel *chan);
04183 void ast_channel_blocker_set(struct ast_channel *chan, pthread_t value);
04184 
04185 ast_timing_func_t ast_channel_timingfunc(const struct ast_channel *chan);
04186 void ast_channel_timingfunc_set(struct ast_channel *chan, ast_timing_func_t value);
04187 
04188 struct ast_bridge *ast_channel_internal_bridge(const struct ast_channel *chan);
04189 /*!
04190  * \pre chan is locked
04191  */
04192 void ast_channel_internal_bridge_set(struct ast_channel *chan, struct ast_bridge *value);
04193 
04194 struct ast_bridge_channel *ast_channel_internal_bridge_channel(const struct ast_channel *chan);
04195 void ast_channel_internal_bridge_channel_set(struct ast_channel *chan, struct ast_bridge_channel *value);
04196 
04197 struct ast_channel *ast_channel_internal_bridged_channel(const struct ast_channel *chan);
04198 void ast_channel_internal_bridged_channel_set(struct ast_channel *chan, struct ast_channel *value);
04199 
04200 /*!
04201  * \since 11
04202  * \brief Retrieve a comma-separated list of channels for which dialed cause information is available
04203  *
04204  * \details
04205  * This function makes use of datastore operations on the channel, so
04206  * it is important to lock the channel before calling this function.
04207  *
04208  * \param chan The channel from which to retrieve information
04209  * \retval NULL on allocation failure
04210  * \retval Pointer to an ast_str object containing the desired information which must be freed
04211  */
04212 struct ast_str *ast_channel_dialed_causes_channels(const struct ast_channel *chan);
04213 
04214 /*!
04215  * \since 11
04216  * \brief Retrieve a ref-counted cause code information structure
04217  *
04218  * \details
04219  * This function makes use of datastore operations on the channel, so
04220  * it is important to lock the channel before calling this function.
04221  * This function increases the ref count of the returned object, so the
04222  * calling function must decrease the reference count when it is finished
04223  * with the object.
04224  *
04225  * \param chan The channel from which to retrieve information
04226  * \param chan_name The name of the channel about which to retrieve information
04227  * \retval NULL on search failure
04228  * \retval Pointer to a ref-counted ast_control_pvt_cause_code object containing the desired information
04229  */
04230 struct ast_control_pvt_cause_code *ast_channel_dialed_causes_find(const struct ast_channel *chan, const char *chan_name);
04231 
04232 /*!
04233  * \since 11
04234  * \brief Add cause code information to the channel
04235  *
04236  * \details
04237  * This function makes use of datastore operations on the channel, so
04238  * it is important to lock the channel before calling this function.
04239  * The passed in data is copied and so is still owned by the caller.
04240  *
04241  * \param chan The channel on which to add information
04242  * \param cause_code The cause information to be added to the channel
04243  * \param datalen The total length of the structure since its length is variable
04244  * \retval 0 on success
04245  * \retval -1 on error
04246  */
04247 int ast_channel_dialed_causes_add(const struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen);
04248 
04249 /*!
04250  * \since 11
04251  * \brief Clear all cause information from the channel
04252  *
04253  * \details
04254  * This function makes use of datastore operations on the channel, so
04255  * it is important to lock the channel before calling this function.
04256  *
04257  * \param chan The channel from which to clear information
04258  */
04259 void ast_channel_dialed_causes_clear(const struct ast_channel *chan);
04260 
04261 struct ast_flags *ast_channel_flags(struct ast_channel *chan);
04262 
04263 /*!
04264  * \since 12.4.0
04265  * \brief Return whether or not any manager variables have been set
04266  *
04267  * \retval 0 if no manager variables are expected
04268  * \retval 1 if manager variables are expected
04269  */
04270 int ast_channel_has_manager_vars(void);
04271 
04272 /*!
04273  * \since 12
04274  * \brief Sets the variables to be stored in the \a manager_vars field of all
04275  * snapshots.
04276  * \param varc Number of variable names.
04277  * \param vars Array of variable names.
04278  */
04279 void ast_channel_set_manager_vars(size_t varc, char **vars);
04280 
04281 /*!
04282  * \since 12
04283  * \brief Gets the variables for a given channel, as specified by ast_channel_set_manager_vars().
04284  *
04285  * The returned variable list is an AO2 object, so ao2_cleanup() to free it.
04286  *
04287  * \param chan Channel to get variables for.
04288  * \return List of channel variables.
04289  * \return \c NULL on error
04290  */
04291 struct varshead *ast_channel_get_manager_vars(struct ast_channel *chan);
04292 
04293 /*!
04294  * \since 12
04295  * \brief Gets the variables for a given channel, as set using pbx_builtin_setvar_helper().
04296  *
04297  * The returned variable list is an AO2 object, so ao2_cleanup() to free it.
04298  *
04299  * \param chan Channel to get variables for
04300  * \return List of channel variables.
04301  * \return \c NULL on error
04302  */
04303 struct varshead *ast_channel_get_vars(struct ast_channel *chan);
04304 
04305 /*!
04306  * \since 12
04307  * \brief A topic which publishes the events for a particular channel.
04308  *
04309  * If the given \a chan is \c NULL, ast_channel_topic_all() is returned.
04310  *
04311  * \param chan Channel, or \c NULL.
04312  *
04313  * \retval Topic for channel's events.
04314  * \retval ast_channel_topic_all() if \a chan is \c NULL.
04315  */
04316 struct stasis_topic *ast_channel_topic(struct ast_channel *chan);
04317 
04318 /*!
04319  * \since 12
04320  * \brief A topic which publishes the events for a particular channel.
04321  *
04322  * \ref ast_channel_snapshot messages are replaced with \ref stasis_cache_update
04323  *
04324  * If the given \a chan is \c NULL, ast_channel_topic_all_cached() is returned.
04325  *
04326  * \param chan Channel, or \c NULL.
04327  *
04328  * \retval Topic for channel's events.
04329  * \retval ast_channel_topic_all() if \a chan is \c NULL.
04330  */
04331 struct stasis_topic *ast_channel_topic_cached(struct ast_channel *chan);
04332 
04333 /*!
04334  * \brief Get the bridge associated with a channel
04335  * \since 12.0.0
04336  *
04337  * \param chan The channel whose bridge we want
04338  *
04339  * \details
04340  * The bridge returned has its reference count incremented.  Use
04341  * ao2_cleanup() or ao2_ref() in order to decrement the
04342  * reference count when you are finished with the bridge.
04343  *
04344  * \note This function expects the channel to be locked prior to
04345  * being called and will not grab the channel lock.
04346  *
04347  * \retval NULL No bridge present on the channel
04348  * \retval non-NULL The bridge the channel is in
04349  */
04350 struct ast_bridge *ast_channel_get_bridge(const struct ast_channel *chan);
04351 
04352 /*!
04353  * \brief Determine if a channel is in a bridge
04354  * \since 12.0.0
04355  *
04356  * \param chan The channel to test
04357  *
04358  * \note This function expects the channel to be locked prior to
04359  * being called and will not grab the channel lock.
04360  *
04361  * \retval 0 The channel is not bridged
04362  * \retval non-zero The channel is bridged
04363  */
04364 int ast_channel_is_bridged(const struct ast_channel *chan);
04365 
04366 /*!
04367  * \brief Determine if a channel is leaving a bridge, but \em not hung up
04368  * \since 12.4.0
04369  *
04370  * \param chan The channel to test
04371  *
04372  * \note If a channel is hung up, it is implicitly leaving any bridge it
04373  * may be in. This function is used to test if a channel is leaving a bridge
04374  * but may survive the experience, if it has a place to go to (dialplan or
04375  * otherwise)
04376  *
04377  * \retval 0 The channel is not leaving the bridge or is hung up
04378  * \retval non-zero The channel is leaving the bridge
04379  */
04380 int ast_channel_is_leaving_bridge(struct ast_channel *chan);
04381 
04382 /*!
04383  * \brief Get the channel's bridge peer only if the bridge is two-party.
04384  * \since 12.0.0
04385  *
04386  * \param chan Channel desiring the bridge peer channel.
04387  *
04388  * \note The returned peer channel is the current peer in the
04389  * bridge when called.
04390  *
04391  * \note Absolutely _NO_ channel locks should be held when calling this function.
04392  *
04393  * \retval NULL Channel not in a bridge or the bridge is not two-party.
04394  * \retval non-NULL Reffed peer channel at time of calling.
04395  */
04396 struct ast_channel *ast_channel_bridge_peer(struct ast_channel *chan);
04397 
04398 /*!
04399  * \brief Get a reference to the channel's bridge pointer.
04400  * \since 12.0.0
04401  *
04402  * \param chan The channel whose bridge channel is desired
04403  *
04404  * \note This increases the reference count of the bridge_channel.
04405  * Use ao2_ref() or ao2_cleanup() to decrement the refcount when
04406  * you are finished with it.
04407  *
04408  * \note It is expected that the channel is locked prior to
04409  * placing this call.
04410  *
04411  * \retval NULL The channel has no bridge_channel
04412  * \retval non-NULL A reference to the bridge_channel
04413  */
04414 struct ast_bridge_channel *ast_channel_get_bridge_channel(struct ast_channel *chan);
04415 
04416 /*!
04417  * \since 12
04418  * \brief Gain control of a channel in the system
04419  *
04420  * The intention of this function is to take a channel that currently
04421  * is running in one thread and gain control of it in the current thread.
04422  * This can be used to redirect a channel to a different place in the dialplan,
04423  * for instance.
04424  *
04425  * \note This function is NOT intended to be used on bridged channels. If you
04426  * need to control a bridged channel, you can set a callback to be called
04427  * once the channel exits the bridge, and run your controlling logic in that
04428  * callback
04429  *
04430  * XXX Put name of callback-setting function in above paragraph once it is written
04431  *
04432  * \note When this function returns successfully, the yankee channel is in a state where
04433  * it cannot be used any further. Always use the returned channel instead.
04434  *
04435  * \note absolutely _NO_ channel locks should be held before calling this function.
04436  *
04437  * \param yankee The channel to gain control of
04438  * \retval NULL Could not gain control of the channel
04439  * \retval non-NULL The channel
04440  */
04441 struct ast_channel *ast_channel_yank(struct ast_channel *yankee);
04442 
04443 /*!
04444  * \since 12
04445  * \brief Move a channel from its current location to a new location
04446  *
04447  * The intention of this function is to have the destination channel
04448  * take on the identity of the source channel.
04449  *
04450  * \note This function is NOT intended to be used on bridged channels. If you
04451  * wish to move an unbridged channel into the place of a bridged channel, then
04452  * use ast_bridge_join() or ast_bridge_impart(). If you wish to move a bridged
04453  * channel into the place of another bridged channel, then use ast_bridge_move().
04454  *
04455  * \note When this function returns succesfully, the source channel is in a
04456  * state where its continued use is unreliable.
04457  *
04458  * \note absolutely _NO_ channel locks should be held before calling this function.
04459  *
04460  * \param dest The place to move the source channel
04461  * \param source The channel to move
04462  * \retval 0 Success
04463  * \retval non-zero Failure
04464  */
04465 int ast_channel_move(struct ast_channel *dest, struct ast_channel *source);
04466 
04467 /*!
04468  * \since 12
04469  * \brief Forward channel stasis messages to the given endpoint
04470  *
04471  * \param chan The channel to forward from
04472  * \param endpoint The endpoint to forward to
04473  *
04474  * \retval 0 Success
04475  * \retval non-zero Failure
04476  */
04477 int ast_channel_forward_endpoint(struct ast_channel *chan, struct ast_endpoint *endpoint);
04478 
04479 /*!
04480  * \brief Return the oldest linkedid between two channels.
04481  *
04482  * A channel linkedid is derived from the channel uniqueid which is formed like this:
04483  * [systemname-]ctime.seq
04484  *
04485  * The systemname, and the dash are optional, followed by the epoch time followed by an
04486  * integer sequence.  Note that this is not a decimal number, since 1.2 is less than 1.11
04487  * in uniqueid land.
04488  *
04489  * To compare two uniqueids, we parse out the integer values of the time and the sequence
04490  * numbers and compare them, with time trumping sequence.
04491  *
04492  * \param a The linkedid value of the first channel to compare
04493  * \param b The linkedid value of the second channel to compare
04494  *
04495  * \retval NULL on failure
04496  * \retval The oldest linkedid value
04497  * \since 12.0.0
04498 */
04499 const char *ast_channel_oldest_linkedid(const char *a, const char *b);
04500 
04501 /*!
04502  * \brief Check if the channel has active audiohooks, active framehooks, or a monitor.
04503  * \since 12.0.0
04504  *
04505  * \param chan The channel to check.
04506  *
04507  * \retval non-zero if channel has active audiohooks, framehooks, or monitor.
04508  */
04509 int ast_channel_has_audio_frame_or_monitor(struct ast_channel *chan);
04510 
04511 /*!
04512  * \brief Check if the channel has any active hooks that require audio.
04513  * \since 12.3.0
04514  *
04515  * \param chan The channel to check.
04516  *
04517  * \retval non-zero if channel has active audiohooks, audio framehooks, or monitor.
04518  */
04519 int ast_channel_has_hook_requiring_audio(struct ast_channel *chan);
04520 
04521 /*!
04522  * \brief Removes the trailing identifiers from a channel name string
04523  * \since 12.0.0
04524  *
04525  * \param channel_name string that you wish to turn into a dial string.
04526  *                     This string will be edited in place.
04527  */
04528 void ast_channel_name_to_dial_string(char *channel_name);
04529 
04530 #define AST_MUTE_DIRECTION_READ (1 << 0)
04531 #define AST_MUTE_DIRECTION_WRITE (1 << 1)
04532 
04533 /*!
04534  * \brief Suppress passing of a frame type on a channel
04535  *
04536  * \note The channel should be locked before calling this function.
04537  *
04538  * \param chan The channel to suppress
04539  * \param direction The direction in which to suppress
04540  * \param frametype The type of frame (AST_FRAME_VOICE, etc) to suppress
04541  *
04542  * \retval 0 Success
04543  * \retval -1 Failure
04544  */
04545 int ast_channel_suppress(struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype);
04546 
04547 /*!
04548  * \brief Stop suppressing of a frame type on a channel
04549  *
04550  * \note The channel should be locked before calling this function.
04551  *
04552  * \param chan The channel to stop suppressing
04553  * \param direction The direction in which to stop suppressing
04554  * \param frametype The type of frame (AST_FRAME_VOICE, etc) to stop suppressing
04555  *
04556  * \retval 0 Success
04557  * \retval -1 Failure
04558  */
04559 int ast_channel_unsuppress(struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype);
04560 
04561 /*!
04562  * \brief Simulate a DTMF end on a broken bridge channel.
04563  *
04564  * \param chan Channel sending DTMF that has not ended.
04565  * \param digit DTMF digit to stop.
04566  * \param start DTMF digit start time.
04567  * \param why Reason bridge broken.
04568  *
04569  * \return Nothing
04570  */
04571 void ast_channel_end_dtmf(struct ast_channel *chan, char digit, struct timeval start, const char *why);
04572 
04573 struct ast_bridge_features;
04574 
04575 /*!
04576  * \brief Gets the channel-attached features a channel has access to upon being bridged.
04577  *
04578  * \note The channel must be locked when calling this function.
04579  *
04580  * \param chan Which channel to get features for
04581  *
04582  * \retval non-NULL The features currently set for this channel
04583  * \retval NULL if the features have not been set
04584  */
04585 struct ast_bridge_features *ast_channel_feature_hooks_get(struct ast_channel *chan);
04586 
04587 /*!
04588  * \brief Appends to the channel-attached features a channel has access to upon being bridged.
04589  *
04590  * \note The channel must be locked when calling this function.
04591  *
04592  * \param chan Which channel to set features for
04593  * \param features The feature set to append to the channel's features
04594  *
04595  * \retval 0 on success
04596  * \retval -1 on failure
04597  */
04598 int ast_channel_feature_hooks_append(struct ast_channel *chan, struct ast_bridge_features *features);
04599 
04600 /*!
04601  * \brief Sets the channel-attached features a channel has access to upon being bridged.
04602  *
04603  * \note The channel must be locked when calling this function.
04604  *
04605  * \param chan Which channel to set features for
04606  * \param features The feature set with which to replace the channel's features
04607  *
04608  * \retval 0 on success
04609  * \retval -1 on failure
04610  */
04611 int ast_channel_feature_hooks_replace(struct ast_channel *chan, struct ast_bridge_features *features);
04612 
04613 #endif /* _ASTERISK_CHANNEL_H */

Generated on Thu Apr 16 06:27:29 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6