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 00129 #include "asterisk/poll-compat.h" 00130 00131 #if defined(__cplusplus) || defined(c_plusplus) 00132 extern "C" { 00133 #endif 00134 00135 #define AST_MAX_EXTENSION 80 /*!< Max length of an extension */ 00136 #define AST_MAX_CONTEXT 80 /*!< Max length of a context */ 00137 #define AST_CHANNEL_NAME 80 /*!< Max length of an ast_channel name */ 00138 #define MAX_LANGUAGE 40 /*!< Max length of the language setting */ 00139 #define MAX_MUSICCLASS 80 /*!< Max length of the music class setting */ 00140 00141 #include "asterisk/frame.h" 00142 #include "asterisk/chanvars.h" 00143 #include "asterisk/config.h" 00144 #include "asterisk/lock.h" 00145 #include "asterisk/cdr.h" 00146 #include "asterisk/utils.h" 00147 #include "asterisk/linkedlists.h" 00148 #include "asterisk/stringfields.h" 00149 #include "asterisk/datastore.h" 00150 #include "asterisk/data.h" 00151 #include "asterisk/channelstate.h" 00152 #include "asterisk/ccss.h" 00153 #include "asterisk/framehook.h" 00154 00155 #define DATASTORE_INHERIT_FOREVER INT_MAX 00156 00157 #define AST_MAX_FDS 11 00158 /* 00159 * We have AST_MAX_FDS file descriptors in a channel. 00160 * Some of them have a fixed use: 00161 */ 00162 #define AST_ALERT_FD (AST_MAX_FDS-1) /*!< used for alertpipe */ 00163 #define AST_TIMING_FD (AST_MAX_FDS-2) /*!< used for timingfd */ 00164 #define AST_AGENT_FD (AST_MAX_FDS-3) /*!< used by agents for pass through */ 00165 #define AST_GENERATOR_FD (AST_MAX_FDS-4) /*!< used by generator */ 00166 #define AST_JITTERBUFFER_FD (AST_MAX_FDS-5) /*!< used by generator */ 00167 00168 enum ast_bridge_result { 00169 AST_BRIDGE_COMPLETE = 0, 00170 AST_BRIDGE_FAILED = -1, 00171 AST_BRIDGE_FAILED_NOWARN = -2, 00172 AST_BRIDGE_RETRY = -3, 00173 }; 00174 00175 typedef unsigned long long ast_group_t; 00176 00177 /*! \todo Add an explanation of an Asterisk generator 00178 */ 00179 struct ast_generator { 00180 void *(*alloc)(struct ast_channel *chan, void *params); 00181 /*! Channel is locked during this function callback. */ 00182 void (*release)(struct ast_channel *chan, void *data); 00183 /*! This function gets called with the channel unlocked, but is called in 00184 * the context of the channel thread so we know the channel is not going 00185 * to disappear. This callback is responsible for locking the channel as 00186 * necessary. */ 00187 int (*generate)(struct ast_channel *chan, void *data, int len, int samples); 00188 /*! This gets called when DTMF_END frames are read from the channel */ 00189 void (*digit)(struct ast_channel *chan, char digit); 00190 /*! This gets called when the write format on a channel is changed while 00191 * generating. The channel is locked during this callback. */ 00192 void (*write_format_change)(struct ast_channel *chan, void *data); 00193 }; 00194 00195 /*! Party name character set enumeration values (values from Q.SIG) */ 00196 enum AST_PARTY_CHAR_SET { 00197 AST_PARTY_CHAR_SET_UNKNOWN = 0, 00198 AST_PARTY_CHAR_SET_ISO8859_1 = 1, 00199 AST_PARTY_CHAR_SET_WITHDRAWN = 2,/* ITU withdrew this enum value. */ 00200 AST_PARTY_CHAR_SET_ISO8859_2 = 3, 00201 AST_PARTY_CHAR_SET_ISO8859_3 = 4, 00202 AST_PARTY_CHAR_SET_ISO8859_4 = 5, 00203 AST_PARTY_CHAR_SET_ISO8859_5 = 6, 00204 AST_PARTY_CHAR_SET_ISO8859_7 = 7, 00205 AST_PARTY_CHAR_SET_ISO10646_BMPSTRING = 8, 00206 AST_PARTY_CHAR_SET_ISO10646_UTF_8STRING = 9, 00207 }; 00208 00209 /*! 00210 * \since 1.8 00211 * \brief Information needed to specify a name in a call. 00212 * \note All string fields here are malloc'ed, so they need to be 00213 * freed when the structure is deleted. 00214 * \note NULL and "" must be considered equivalent. 00215 */ 00216 struct ast_party_name { 00217 /*! \brief Subscriber name (Malloced) */ 00218 char *str; 00219 /*! 00220 * \brief Character set the name is using. 00221 * \see enum AST_PARTY_CHAR_SET 00222 * \note 00223 * Set to AST_PARTY_CHAR_SET_ISO8859_1 if unsure what to use. 00224 * \todo Start using the party name character set value. Not currently used. 00225 */ 00226 int char_set; 00227 /*! 00228 * \brief Q.931 encoded presentation-indicator encoded field 00229 * \note Must tolerate the Q.931 screening-indicator field values being present. 00230 */ 00231 int presentation; 00232 /*! \brief TRUE if the name information is valid/present */ 00233 unsigned char valid; 00234 }; 00235 00236 /*! 00237 * \since 1.8 00238 * \brief Information needed to specify a number in a call. 00239 * \note All string fields here are malloc'ed, so they need to be 00240 * freed when the structure is deleted. 00241 * \note NULL and "" must be considered equivalent. 00242 */ 00243 struct ast_party_number { 00244 /*! \brief Subscriber phone number (Malloced) */ 00245 char *str; 00246 /*! \brief Q.931 Type-Of-Number and Numbering-Plan encoded fields */ 00247 int plan; 00248 /*! \brief Q.931 presentation-indicator and screening-indicator encoded fields */ 00249 int presentation; 00250 /*! \brief TRUE if the number information is valid/present */ 00251 unsigned char valid; 00252 }; 00253 00254 /*! 00255 * \since 1.8 00256 * \brief Information needed to specify a subaddress in a call. 00257 * \note All string fields here are malloc'ed, so they need to be 00258 * freed when the structure is deleted. 00259 * \note NULL and "" must be considered equivalent. 00260 */ 00261 struct ast_party_subaddress { 00262 /*! 00263 * \brief Malloced subaddress string. 00264 * \note If the subaddress type is user specified then the subaddress is 00265 * a string of ASCII hex because the actual subaddress is likely BCD encoded. 00266 */ 00267 char *str; 00268 /*! 00269 * \brief Q.931 subaddress type. 00270 * \details 00271 * nsap(0), 00272 * user_specified(2) 00273 */ 00274 int type; 00275 /*! 00276 * \brief TRUE if odd number of address signals 00277 * \note The odd/even indicator is used when the type of subaddress is 00278 * user_specified and the coding is BCD. 00279 */ 00280 unsigned char odd_even_indicator; 00281 /*! \brief TRUE if the subaddress information is valid/present */ 00282 unsigned char valid; 00283 }; 00284 00285 /*! 00286 * \since 1.8 00287 * \brief Information needed to identify an endpoint in a call. 00288 * \note All string fields here are malloc'ed, so they need to be 00289 * freed when the structure is deleted. 00290 * \note NULL and "" must be considered equivalent. 00291 */ 00292 struct ast_party_id { 00293 /*! \brief Subscriber name */ 00294 struct ast_party_name name; 00295 /*! \brief Subscriber phone number */ 00296 struct ast_party_number number; 00297 /*! \brief Subscriber subaddress. */ 00298 struct ast_party_subaddress subaddress; 00299 00300 /*! 00301 * \brief User-set "tag" 00302 * \details 00303 * A user-settable field used to help associate some extrinsic information 00304 * about the channel or user of the channel to the party ID. This information 00305 * is normally not transmitted over the wire and so is only useful within an 00306 * Asterisk environment. 00307 */ 00308 char *tag; 00309 }; 00310 00311 /*! 00312 * \since 1.8 00313 * \brief Indicate what information in ast_party_id should be set. 00314 */ 00315 struct ast_set_party_id { 00316 /*! TRUE if the ast_party_name information should be set. */ 00317 unsigned char name; 00318 /*! TRUE if the ast_party_number information should be set. */ 00319 unsigned char number; 00320 /*! TRUE if the ast_party_subaddress information should be set. */ 00321 unsigned char subaddress; 00322 }; 00323 00324 /*! 00325 * \since 1.8 00326 * \brief Dialed/Called Party information. 00327 * \note Dialed Number Identifier (DNID) 00328 * \note All string fields here are malloc'ed, so they need to be 00329 * freed when the structure is deleted. 00330 * \note NULL and "" must be considered equivalent. 00331 */ 00332 struct ast_party_dialed { 00333 /*! 00334 * \brief Dialed/Called number 00335 * \note Done this way in case we ever really need to use ast_party_number. 00336 * We currently do not need all of the ast_party_number fields. 00337 */ 00338 struct { 00339 /*! \brief Subscriber phone number (Malloced) */ 00340 char *str; 00341 /*! \brief Q.931 Type-Of-Number and Numbering-Plan encoded fields */ 00342 int plan; 00343 } number; 00344 /*! \brief Dialed/Called subaddress */ 00345 struct ast_party_subaddress subaddress; 00346 /*! 00347 * \brief Transit Network Select 00348 * \note Currently this value is just passed around the system. 00349 * You can read it and set it but it is never used for anything. 00350 */ 00351 int transit_network_select; 00352 }; 00353 00354 /*! 00355 * \since 1.8 00356 * \brief Caller Party information. 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 * \note SIP and IAX2 has UTF8 encoded Unicode Caller ID names. 00362 * In some cases, we also have an alternative (RPID) E.164 number that can 00363 * be used as Caller ID on numeric E.164 phone networks (DAHDI or SIP/IAX2 to 00364 * PSTN gateway). 00365 * 00366 * \todo Implement settings for transliteration between UTF8 Caller ID names in 00367 * to ASCII Caller ID's (DAHDI). Östen Åsklund might be transliterated into 00368 * Osten Asklund or Oesten Aasklund depending upon language and person... 00369 * We need automatic routines for incoming calls and static settings for 00370 * our own accounts. 00371 */ 00372 struct ast_party_caller { 00373 /*! \brief Caller party ID */ 00374 struct ast_party_id id; 00375 00376 /*! 00377 * \brief Automatic Number Identification (ANI) 00378 * \note The name subcomponent is only likely to be used by SIP. 00379 * \note The subaddress subcomponent is not likely to be used. 00380 */ 00381 struct ast_party_id ani; 00382 00383 /*! \brief Automatic Number Identification 2 (Info Digits) */ 00384 int ani2; 00385 }; 00386 00387 /*! 00388 * \since 1.8 00389 * \brief Indicate what information in ast_party_caller should be set. 00390 */ 00391 struct ast_set_party_caller { 00392 /*! What caller id information to set. */ 00393 struct ast_set_party_id id; 00394 /*! What ANI id information to set. */ 00395 struct ast_set_party_id ani; 00396 }; 00397 00398 /*! 00399 * \since 1.8 00400 * \brief Connected Line/Party information. 00401 * \note All string fields here are malloc'ed, so they need to be 00402 * freed when the structure is deleted. 00403 * \note NULL and "" must be considered equivalent. 00404 */ 00405 struct ast_party_connected_line { 00406 /*! \brief Connected party ID */ 00407 struct ast_party_id id; 00408 00409 /*! 00410 * \brief Automatic Number Identification (ANI) 00411 * \note Not really part of connected line data but needed to 00412 * save the corresponding caller id value. 00413 */ 00414 struct ast_party_id ani; 00415 00416 /*! 00417 * \brief Automatic Number Identification 2 (Info Digits) 00418 * \note Not really part of connected line data but needed to 00419 * save the corresponding caller id value. 00420 */ 00421 int ani2; 00422 00423 /*! 00424 * \brief Information about the source of an update. 00425 * \note enum AST_CONNECTED_LINE_UPDATE_SOURCE values 00426 * for Normal-Answer and Call-transfer. 00427 */ 00428 int source; 00429 }; 00430 00431 /*! 00432 * \since 1.8 00433 * \brief Indicate what information in ast_party_connected_line should be set. 00434 */ 00435 struct ast_set_party_connected_line { 00436 /*! What connected line id information to set. */ 00437 struct ast_set_party_id id; 00438 /*! What ANI id information to set. */ 00439 struct ast_set_party_id ani; 00440 }; 00441 00442 /*! 00443 * \since 1.8 00444 * \brief Redirecting Line information. 00445 * RDNIS (Redirecting Directory Number Information Service) 00446 * Where a call diversion or transfer was invoked. 00447 * \note All string fields here are malloc'ed, so they need to be 00448 * freed when the structure is deleted. 00449 * \note NULL and "" must be considered equivalent. 00450 */ 00451 struct ast_party_redirecting { 00452 /*! \brief Who originally redirected the call (Sent to the party the call is redirected toward) */ 00453 struct ast_party_id orig; 00454 00455 /*! \brief Who is redirecting the call (Sent to the party the call is redirected toward) */ 00456 struct ast_party_id from; 00457 00458 /*! \brief Call is redirecting to a new party (Sent to the caller) */ 00459 struct ast_party_id to; 00460 00461 /*! \brief Number of times the call was redirected */ 00462 int count; 00463 00464 /*! \brief enum AST_REDIRECTING_REASON value for redirection */ 00465 int reason; 00466 00467 /*! \brief enum AST_REDIRECTING_REASON value for redirection by original party */ 00468 int orig_reason; 00469 }; 00470 00471 /*! 00472 * \since 1.8 00473 * \brief Indicate what information in ast_party_redirecting should be set. 00474 */ 00475 struct ast_set_party_redirecting { 00476 /*! What redirecting-orig id information to set. */ 00477 struct ast_set_party_id orig; 00478 /*! What redirecting-from id information to set. */ 00479 struct ast_set_party_id from; 00480 /*! What redirecting-to id information to set. */ 00481 struct ast_set_party_id to; 00482 }; 00483 00484 /*! 00485 * \brief Typedef for a custom read function 00486 * \note data should be treated as const char *. 00487 */ 00488 typedef int (*ast_acf_read_fn_t)(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len); 00489 00490 /*! 00491 * \brief Typedef for a custom read2 function 00492 * \note data should be treated as const char *. 00493 */ 00494 typedef int (*ast_acf_read2_fn_t)(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **str, ssize_t len); 00495 00496 /*! 00497 * \brief Typedef for a custom write function 00498 * \note data should be treated as const char *. 00499 */ 00500 typedef int (*ast_acf_write_fn_t)(struct ast_channel *chan, const char *function, char *data, const char *value); 00501 00502 /*! \brief Structure to handle passing func_channel_write info to channels via setoption */ 00503 typedef struct { 00504 /*! \brief ast_chan_write_info_t version. Must be incremented if structure is changed */ 00505 #define AST_CHAN_WRITE_INFO_T_VERSION 1 00506 uint32_t version; 00507 ast_acf_write_fn_t write_fn; 00508 struct ast_channel *chan; 00509 const char *function; 00510 char *data; 00511 const char *value; 00512 } ast_chan_write_info_t; 00513 00514 /*! 00515 * \brief 00516 * Structure to describe a channel "technology", ie a channel driver 00517 * See for examples: 00518 * \arg chan_iax2.c - The Inter-Asterisk exchange protocol 00519 * \arg chan_sip.c - The SIP channel driver 00520 * \arg chan_dahdi.c - PSTN connectivity (TDM, PRI, T1/E1, FXO, FXS) 00521 * 00522 * \details 00523 * If you develop your own channel driver, this is where you 00524 * tell the PBX at registration of your driver what properties 00525 * this driver supports and where different callbacks are 00526 * implemented. 00527 */ 00528 struct ast_channel_tech { 00529 const char * const type; 00530 const char * const description; 00531 00532 struct ast_format_cap *capabilities; /*!< format capabilities this channel can handle */ 00533 00534 int properties; /*!< Technology Properties */ 00535 00536 /*! 00537 * \brief Requester - to set up call data structures (pvt's) 00538 * 00539 * \param type type of channel to request 00540 * \param cap Format capabilities for requested channel 00541 * \param requestor channel asking for data 00542 * \param addr destination of the call 00543 * \param cause Cause of failure 00544 * 00545 * \details 00546 * Request a channel of a given type, with addr as optional information used 00547 * by the low level module 00548 * 00549 * \retval NULL failure 00550 * \retval non-NULL channel on success 00551 */ 00552 struct ast_channel *(* const requester)(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *addr, int *cause); 00553 00554 int (* const devicestate)(const char *device_number); /*!< Devicestate call back */ 00555 00556 /*! 00557 * \brief Start sending a literal DTMF digit 00558 * 00559 * \note The channel is not locked when this function gets called. 00560 */ 00561 int (* const send_digit_begin)(struct ast_channel *chan, char digit); 00562 00563 /*! 00564 * \brief Stop sending a literal DTMF digit 00565 * 00566 * \note The channel is not locked when this function gets called. 00567 */ 00568 int (* const send_digit_end)(struct ast_channel *chan, char digit, unsigned int duration); 00569 00570 /*! 00571 * \brief Make a call 00572 * \note The channel is locked when called. 00573 * \param chan which channel to make the call on 00574 * \param addr destination of the call 00575 * \param timeout time to wait on for connect (Doesn't seem to be used.) 00576 * \retval 0 on success 00577 * \retval -1 on failure 00578 */ 00579 int (* const call)(struct ast_channel *chan, const char *addr, int timeout); 00580 00581 /*! \brief Hangup (and possibly destroy) the channel */ 00582 int (* const hangup)(struct ast_channel *chan); 00583 00584 /*! \brief Answer the channel */ 00585 int (* const answer)(struct ast_channel *chan); 00586 00587 /*! \brief Read a frame, in standard format (see frame.h) */ 00588 struct ast_frame * (* const read)(struct ast_channel *chan); 00589 00590 /*! \brief Write a frame, in standard format (see frame.h) */ 00591 int (* const write)(struct ast_channel *chan, struct ast_frame *frame); 00592 00593 /*! \brief Display or transmit text */ 00594 int (* const send_text)(struct ast_channel *chan, const char *text); 00595 00596 /*! \brief Display or send an image */ 00597 int (* const send_image)(struct ast_channel *chan, struct ast_frame *frame); 00598 00599 /*! \brief Send HTML data */ 00600 int (* const send_html)(struct ast_channel *chan, int subclass, const char *data, int len); 00601 00602 /*! \brief Handle an exception, reading a frame */ 00603 struct ast_frame * (* const exception)(struct ast_channel *chan); 00604 00605 /*! \brief Bridge two channels of the same type together */ 00606 enum ast_bridge_result (* const bridge)(struct ast_channel *c0, struct ast_channel *c1, int flags, 00607 struct ast_frame **fo, struct ast_channel **rc, int timeoutms); 00608 00609 /*! \brief Bridge two channels of the same type together (early) */ 00610 enum ast_bridge_result (* const early_bridge)(struct ast_channel *c0, struct ast_channel *c1); 00611 00612 /*! \brief Indicate a particular condition (e.g. AST_CONTROL_BUSY or AST_CONTROL_RINGING or AST_CONTROL_CONGESTION */ 00613 int (* const indicate)(struct ast_channel *c, int condition, const void *data, size_t datalen); 00614 00615 /*! \brief Fix up a channel: If a channel is consumed, this is called. Basically update any ->owner links */ 00616 int (* const fixup)(struct ast_channel *oldchan, struct ast_channel *newchan); 00617 00618 /*! \brief Set a given option. Called with chan locked */ 00619 int (* const setoption)(struct ast_channel *chan, int option, void *data, int datalen); 00620 00621 /*! \brief Query a given option. Called with chan locked */ 00622 int (* const queryoption)(struct ast_channel *chan, int option, void *data, int *datalen); 00623 00624 /*! \brief Blind transfer other side (see app_transfer.c and ast_transfer() */ 00625 int (* const transfer)(struct ast_channel *chan, const char *newdest); 00626 00627 /*! \brief Write a frame, in standard format */ 00628 int (* const write_video)(struct ast_channel *chan, struct ast_frame *frame); 00629 00630 /*! \brief Write a text frame, in standard format */ 00631 int (* const write_text)(struct ast_channel *chan, struct ast_frame *frame); 00632 00633 /*! \brief Find bridged channel */ 00634 struct ast_channel *(* const bridged_channel)(struct ast_channel *chan, struct ast_channel *bridge); 00635 00636 /*! 00637 * \brief Provide additional read items for CHANNEL() dialplan function 00638 * \note data should be treated as a const char *. 00639 */ 00640 int (* func_channel_read)(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len); 00641 00642 /*! 00643 * \brief Provide additional write items for CHANNEL() dialplan function 00644 * \note data should be treated as a const char *. 00645 */ 00646 int (* func_channel_write)(struct ast_channel *chan, const char *function, char *data, const char *value); 00647 00648 /*! \brief Retrieve base channel (agent and local) */ 00649 struct ast_channel* (* get_base_channel)(struct ast_channel *chan); 00650 00651 /*! \brief Set base channel (agent and local) */ 00652 int (* set_base_channel)(struct ast_channel *chan, struct ast_channel *base); 00653 00654 /*! \brief Get the unique identifier for the PVT, i.e. SIP call-ID for SIP */ 00655 const char * (* get_pvt_uniqueid)(struct ast_channel *chan); 00656 00657 /*! \brief Call a function with cc parameters as a function parameter 00658 * 00659 * \details 00660 * This is a highly specialized callback that is not likely to be needed in many 00661 * channel drivers. When dealing with a busy channel, for instance, most channel 00662 * drivers will successfully return a channel to the requester. Once called, the channel 00663 * can then queue a busy frame when it receives an appropriate message from the far end. 00664 * In such a case, the channel driver has the opportunity to also queue a CC frame. 00665 * The parameters for the CC channel can be retrieved from the channel structure. 00666 * 00667 * For other channel drivers, notably those that deal with "dumb" phones, the channel 00668 * driver will not return a channel when one is requested. In such a scenario, there is never 00669 * an opportunity for the channel driver to queue a CC frame since the channel is never 00670 * called. Furthermore, it is not possible to retrieve the CC configuration parameters 00671 * for the desired channel because no channel is ever allocated or returned to the 00672 * requester. In such a case, call completion may still be a viable option. What we do is 00673 * pass the same string that the requester used originally to request the channel to the 00674 * channel driver. The channel driver can then find any potential channels/devices that 00675 * match the input and return call the designated callback with the device's call completion 00676 * parameters as a parameter. 00677 */ 00678 int (* cc_callback)(struct ast_channel *inbound, const char *dest, ast_cc_callback_fn callback); 00679 00680 /*! 00681 * \brief Execute a Gosub call on the channel in a technology specific way before a call is placed. 00682 * \since 11.0 00683 * 00684 * \param chan Channel to execute Gosub in a tech specific way. 00685 * \param sub_args Gosub application parameter string. 00686 * 00687 * \note The chan is locked before calling. 00688 * 00689 * \retval 0 on success. 00690 * \retval -1 on error. 00691 */ 00692 int (*pre_call)(struct ast_channel *chan, const char *sub_args); 00693 }; 00694 00695 /*! Kill the channel channel driver technology descriptor. */ 00696 extern const struct ast_channel_tech ast_kill_tech; 00697 00698 struct ast_epoll_data; 00699 00700 /*! 00701 * The high bit of the frame count is used as a debug marker, so 00702 * increments of the counters must be done with care. 00703 * Please use c->fin = FRAMECOUNT_INC(c->fin) and the same for c->fout. 00704 */ 00705 #define DEBUGCHAN_FLAG 0x80000000 00706 00707 /* XXX not ideal to evaluate x twice... */ 00708 #define FRAMECOUNT_INC(x) ( ((x) & DEBUGCHAN_FLAG) | (((x)+1) & ~DEBUGCHAN_FLAG) ) 00709 00710 /*! 00711 * The current value of the debug flags is stored in the two 00712 * variables global_fin and global_fout (declared in main/channel.c) 00713 */ 00714 extern unsigned long global_fin, global_fout; 00715 00716 enum ast_channel_adsicpe { 00717 AST_ADSI_UNKNOWN, 00718 AST_ADSI_AVAILABLE, 00719 AST_ADSI_UNAVAILABLE, 00720 AST_ADSI_OFFHOOKONLY, 00721 }; 00722 00723 /*! 00724 * \brief Possible T38 states on channels 00725 */ 00726 enum ast_t38_state { 00727 T38_STATE_UNAVAILABLE, /*!< T38 is unavailable on this channel or disabled by configuration */ 00728 T38_STATE_UNKNOWN, /*!< The channel supports T38 but the current status is unknown */ 00729 T38_STATE_NEGOTIATING, /*!< T38 is being negotiated */ 00730 T38_STATE_REJECTED, /*!< Remote side has rejected our offer */ 00731 T38_STATE_NEGOTIATED, /*!< T38 established */ 00732 }; 00733 00734 AST_LIST_HEAD_NOLOCK(ast_datastore_list, ast_datastore); 00735 AST_LIST_HEAD_NOLOCK(ast_autochan_list, ast_autochan); 00736 AST_LIST_HEAD_NOLOCK(ast_readq_list, ast_frame); 00737 00738 typedef int(*ast_timing_func_t)(const void *data); 00739 /*! 00740 * \page AstChannel ast_channel locking and reference tracking 00741 * 00742 * \par Creating Channels 00743 * A channel is allocated using the ast_channel_alloc() function. When created, it is 00744 * automatically inserted into the main channels hash table that keeps track of all 00745 * active channels in the system. The hash key is based on the channel name. Because 00746 * of this, if you want to change the name, you _must_ use ast_change_name(), not change 00747 * the name field directly. When ast_channel_alloc() returns a channel pointer, you now 00748 * hold a reference to that channel. In most cases this reference is given to ast_pbx_run(). 00749 * 00750 * \par Channel Locking 00751 * There is a lock associated with every ast_channel. It is allocated internally via astobj2. 00752 * To lock or unlock a channel, you must use the ast_channel_lock() wrappers. 00753 * 00754 * Previously, before ast_channel was converted to astobj2, the channel lock was used in some 00755 * additional ways that are no longer necessary. Before, the only way to ensure that a channel 00756 * did not disappear out from under you if you were working with a channel outside of the channel 00757 * thread that owns it, was to hold the channel lock. Now, that is no longer necessary. 00758 * You simply must hold a reference to the channel to ensure it does not go away. 00759 * 00760 * The channel must be locked if you need to ensure that data that you reading from the channel 00761 * does not change while you access it. Further, you must hold the channel lock if you are 00762 * making a non-atomic change to channel data. 00763 * 00764 * \par Channel References 00765 * There are multiple ways to get a reference to a channel. The first is that you hold a reference 00766 * to a channel after creating it. The other ways involve using the channel search or the channel 00767 * traversal APIs. These functions are the ast_channel_get_*() functions or ast_channel_iterator_*() 00768 * functions. Once a reference is retrieved by one of these methods, you know that the channel will 00769 * not go away. So, the channel should only get locked as needed for data access or modification. 00770 * But, make sure that the reference gets released when you are done with it! 00771 * 00772 * There are different things you can do when you are done with a reference to a channel. The first 00773 * is to simply release the reference using ast_channel_unref(). The other option is to call 00774 * ast_channel_release(). This function is generally used where ast_channel_free() was used in 00775 * the past. The release function releases a reference as well as ensures that the channel is no 00776 * longer in the global channels container. That way, the channel will get destroyed as soon as any 00777 * other pending references get released. 00778 * 00779 * \par Exceptions to the rules 00780 * Even though ast_channel is reference counted, there are some places where pointers to an ast_channel 00781 * get stored, but the reference count does not reflect it. The reason is mostly historical. 00782 * The only places where this happens should be places where because of how the code works, we 00783 * _know_ that the pointer to the channel will get removed before the channel goes away. The main 00784 * example of this is in channel drivers. Channel drivers generally store a pointer to their owner 00785 * ast_channel in their technology specific pvt struct. In this case, the channel drivers _know_ 00786 * that this pointer to the channel will be removed in time, because the channel's hangup callback 00787 * gets called before the channel goes away. 00788 */ 00789 00790 struct ast_channel; 00791 00792 /*! \brief ast_channel_tech Properties */ 00793 enum { 00794 /*! 00795 * \brief Channels have this property if they can accept input with jitter; 00796 * i.e. most VoIP channels 00797 */ 00798 AST_CHAN_TP_WANTSJITTER = (1 << 0), 00799 /*! 00800 * \brief Channels have this property if they can create jitter; 00801 * i.e. most VoIP channels 00802 */ 00803 AST_CHAN_TP_CREATESJITTER = (1 << 1), 00804 }; 00805 00806 /*! \brief ast_channel flags */ 00807 enum { 00808 /*! Queue incoming DTMF, to be released when this flag is turned off */ 00809 AST_FLAG_DEFER_DTMF = (1 << 1), 00810 /*! write should be interrupt generator */ 00811 AST_FLAG_WRITE_INT = (1 << 2), 00812 /*! a thread is blocking on this channel */ 00813 AST_FLAG_BLOCKING = (1 << 3), 00814 /*! This is a zombie channel */ 00815 AST_FLAG_ZOMBIE = (1 << 4), 00816 /*! There is an exception pending */ 00817 AST_FLAG_EXCEPTION = (1 << 5), 00818 /*! Listening to moh XXX anthm promises me this will disappear XXX */ 00819 AST_FLAG_MOH = (1 << 6), 00820 /*! This channel is spying on another channel */ 00821 AST_FLAG_SPYING = (1 << 7), 00822 /*! This channel is in a native bridge */ 00823 AST_FLAG_NBRIDGE = (1 << 8), 00824 /*! the channel is in an auto-incrementing dialplan processor, 00825 * so when ->priority is set, it will get incremented before 00826 * finding the next priority to run */ 00827 AST_FLAG_IN_AUTOLOOP = (1 << 9), 00828 /*! This is an outgoing call */ 00829 AST_FLAG_OUTGOING = (1 << 10), 00830 /*! A DTMF_BEGIN frame has been read from this channel, but not yet an END */ 00831 AST_FLAG_IN_DTMF = (1 << 12), 00832 /*! A DTMF_END was received when not IN_DTMF, so the length of the digit is 00833 * currently being emulated */ 00834 AST_FLAG_EMULATE_DTMF = (1 << 13), 00835 /*! This is set to tell the channel not to generate DTMF begin frames, and 00836 * to instead only generate END frames. */ 00837 AST_FLAG_END_DTMF_ONLY = (1 << 14), 00838 /*! Flag to show channels that this call is hangup due to the fact that the call 00839 was indeed answered, but in another channel */ 00840 AST_FLAG_ANSWERED_ELSEWHERE = (1 << 15), 00841 /*! This flag indicates that on a masquerade, an active stream should not 00842 * be carried over */ 00843 AST_FLAG_MASQ_NOSTREAM = (1 << 16), 00844 /*! This flag indicates that the hangup exten was run when the bridge terminated, 00845 * a message aimed at preventing a subsequent hangup exten being run at the pbx_run 00846 * level */ 00847 AST_FLAG_BRIDGE_HANGUP_RUN = (1 << 17), 00848 /*! This flag indicates that the hangup exten should NOT be run when the 00849 * bridge terminates, this will allow the hangup in the pbx loop to be run instead. 00850 * */ 00851 AST_FLAG_BRIDGE_HANGUP_DONT = (1 << 18), 00852 /*! Disable certain workarounds. This reintroduces certain bugs, but allows 00853 * some non-traditional dialplans (like AGI) to continue to function. 00854 */ 00855 AST_FLAG_DISABLE_WORKAROUNDS = (1 << 20), 00856 }; 00857 00858 /*! \brief ast_bridge_config flags */ 00859 enum { 00860 AST_FEATURE_PLAY_WARNING = (1 << 0), 00861 AST_FEATURE_REDIRECT = (1 << 1), 00862 AST_FEATURE_DISCONNECT = (1 << 2), 00863 AST_FEATURE_ATXFER = (1 << 3), 00864 AST_FEATURE_AUTOMON = (1 << 4), 00865 AST_FEATURE_PARKCALL = (1 << 5), 00866 AST_FEATURE_AUTOMIXMON = (1 << 6), 00867 AST_FEATURE_NO_H_EXTEN = (1 << 7), 00868 AST_FEATURE_WARNING_ACTIVE = (1 << 8), 00869 }; 00870 00871 /*! \brief bridge configuration */ 00872 struct ast_bridge_config { 00873 struct ast_flags features_caller; 00874 struct ast_flags features_callee; 00875 struct timeval start_time; 00876 struct timeval nexteventts; 00877 struct timeval feature_start_time; 00878 long feature_timer; 00879 long timelimit; 00880 long play_warning; 00881 long warning_freq; 00882 const char *warning_sound; 00883 const char *end_sound; 00884 const char *start_sound; 00885 unsigned int flags; 00886 void (* end_bridge_callback)(void *); /*!< A callback that is called after a bridge attempt */ 00887 void *end_bridge_callback_data; /*!< Data passed to the callback */ 00888 /*! If the end_bridge_callback_data refers to a channel which no longer is going to 00889 * exist when the end_bridge_callback is called, then it needs to be fixed up properly 00890 */ 00891 void (*end_bridge_callback_data_fixup)(struct ast_bridge_config *bconfig, struct ast_channel *originator, struct ast_channel *terminator); 00892 }; 00893 00894 struct chanmon; 00895 00896 struct outgoing_helper { 00897 const char *context; 00898 const char *exten; 00899 int priority; 00900 const char *cid_num; 00901 const char *cid_name; 00902 const char *account; 00903 struct ast_variable *vars; 00904 struct ast_channel *parent_channel; 00905 }; 00906 00907 enum { 00908 /*! 00909 * Soft hangup requested by device or other internal reason. 00910 * Actual hangup needed. 00911 */ 00912 AST_SOFTHANGUP_DEV = (1 << 0), 00913 /*! 00914 * Used to break the normal frame flow so an async goto can be 00915 * done instead of actually hanging up. 00916 */ 00917 AST_SOFTHANGUP_ASYNCGOTO = (1 << 1), 00918 /*! 00919 * Soft hangup requested by system shutdown. Actual hangup 00920 * needed. 00921 */ 00922 AST_SOFTHANGUP_SHUTDOWN = (1 << 2), 00923 /*! 00924 * Used to break the normal frame flow after a timeout so an 00925 * implicit async goto can be done to the 'T' exten if it exists 00926 * instead of actually hanging up. If the exten does not exist 00927 * then actually hangup. 00928 */ 00929 AST_SOFTHANGUP_TIMEOUT = (1 << 3), 00930 /*! 00931 * Soft hangup requested by application/channel-driver being 00932 * unloaded. Actual hangup needed. 00933 */ 00934 AST_SOFTHANGUP_APPUNLOAD = (1 << 4), 00935 /*! 00936 * Soft hangup requested by non-associated party. Actual hangup 00937 * needed. 00938 */ 00939 AST_SOFTHANGUP_EXPLICIT = (1 << 5), 00940 /*! 00941 * Used to break a bridge so the channel can be spied upon 00942 * instead of actually hanging up. 00943 */ 00944 AST_SOFTHANGUP_UNBRIDGE = (1 << 6), 00945 00946 00947 /*! 00948 * \brief All softhangup flags. 00949 * 00950 * This can be used as an argument to ast_channel_clear_softhangup() 00951 * to clear all softhangup flags from a channel. 00952 */ 00953 AST_SOFTHANGUP_ALL = (0xFFFFFFFF) 00954 }; 00955 00956 00957 /*! \brief Channel reload reasons for manager events at load or reload of configuration */ 00958 enum channelreloadreason { 00959 CHANNEL_MODULE_LOAD, 00960 CHANNEL_MODULE_RELOAD, 00961 CHANNEL_CLI_RELOAD, 00962 CHANNEL_MANAGER_RELOAD, 00963 }; 00964 00965 /*! 00966 * \note None of the datastore API calls lock the ast_channel they are using. 00967 * So, the channel should be locked before calling the functions that 00968 * take a channel argument. 00969 */ 00970 00971 /*! 00972 * \brief Create a channel data store object 00973 * \deprecated You should use the ast_datastore_alloc() generic function instead. 00974 * \version 1.6.1 deprecated 00975 */ 00976 struct ast_datastore * attribute_malloc ast_channel_datastore_alloc(const struct ast_datastore_info *info, const char *uid) 00977 __attribute__((deprecated)); 00978 00979 /*! 00980 * \brief Free a channel data store object 00981 * \deprecated You should use the ast_datastore_free() generic function instead. 00982 * \version 1.6.1 deprecated 00983 */ 00984 int ast_channel_datastore_free(struct ast_datastore *datastore) 00985 __attribute__((deprecated)); 00986 00987 /*! \brief Inherit datastores from a parent to a child. */ 00988 int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to); 00989 00990 /*! 00991 * \brief Add a datastore to a channel 00992 * 00993 * \note The channel should be locked before calling this function. 00994 * 00995 * \retval 0 success 00996 * \retval non-zero failure 00997 */ 00998 int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore); 00999 01000 /*! 01001 * \brief Remove a datastore from a channel 01002 * 01003 * \note The channel should be locked before calling this function. 01004 * 01005 * \retval 0 success 01006 * \retval non-zero failure 01007 */ 01008 int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore); 01009 01010 /*! 01011 * \brief Find a datastore on a channel 01012 * 01013 * \note The channel should be locked before calling this function. 01014 * 01015 * \note The datastore returned from this function must not be used if the 01016 * reference to the channel is released. 01017 * 01018 * \retval pointer to the datastore if found 01019 * \retval NULL if not found 01020 */ 01021 struct ast_datastore *ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid); 01022 01023 /*! 01024 * \brief Create a channel structure 01025 * \since 1.8 01026 * 01027 * \retval NULL failure 01028 * \retval non-NULL successfully allocated channel 01029 * 01030 * \note Absolutely _NO_ channel locks should be held before calling this function. 01031 * \note By default, new channels are set to the "s" extension 01032 * and "default" context. 01033 */ 01034 struct ast_channel * attribute_malloc __attribute__((format(printf, 13, 14))) 01035 __ast_channel_alloc(int needqueue, int state, const char *cid_num, 01036 const char *cid_name, const char *acctcode, 01037 const char *exten, const char *context, 01038 const char *linkedid, const int amaflag, 01039 const char *file, int line, const char *function, 01040 const char *name_fmt, ...); 01041 01042 /*! 01043 * \brief Create a channel structure 01044 * 01045 * \retval NULL failure 01046 * \retval non-NULL successfully allocated channel 01047 * 01048 * \note Absolutely _NO_ channel locks should be held before calling this function. 01049 * \note By default, new channels are set to the "s" extension 01050 * and "default" context. 01051 */ 01052 #define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, linkedid, amaflag, ...) \ 01053 __ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, linkedid, amaflag, \ 01054 __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__) 01055 01056 #if defined(REF_DEBUG) || defined(__AST_DEBUG_MALLOC) 01057 /*! 01058 * \brief Create a fake channel structure 01059 * 01060 * \retval NULL failure 01061 * \retval non-NULL successfully allocated channel 01062 * 01063 * \note This function should ONLY be used to create a fake channel 01064 * that can then be populated with data for use in variable 01065 * substitution when a real channel does not exist. 01066 * 01067 * \note The created dummy channel should be destroyed by 01068 * ast_channel_unref(). Using ast_channel_release() needlessly 01069 * grabs the channel container lock and can cause a deadlock as 01070 * a result. Also grabbing the channel container lock reduces 01071 * system performance. 01072 */ 01073 #define ast_dummy_channel_alloc() __ast_dummy_channel_alloc(__FILE__, __LINE__, __PRETTY_FUNCTION__) 01074 struct ast_channel *__ast_dummy_channel_alloc(const char *file, int line, const char *function); 01075 #else 01076 /*! 01077 * \brief Create a fake channel structure 01078 * 01079 * \retval NULL failure 01080 * \retval non-NULL successfully allocated channel 01081 * 01082 * \note This function should ONLY be used to create a fake channel 01083 * that can then be populated with data for use in variable 01084 * substitution when a real channel does not exist. 01085 * 01086 * \note The created dummy channel should be destroyed by 01087 * ast_channel_unref(). Using ast_channel_release() needlessly 01088 * grabs the channel container lock and can cause a deadlock as 01089 * a result. Also grabbing the channel container lock reduces 01090 * system performance. 01091 */ 01092 struct ast_channel *ast_dummy_channel_alloc(void); 01093 #endif 01094 01095 /*! 01096 * \brief Queue one or more frames to a channel's frame queue 01097 * 01098 * \param chan the channel to queue the frame(s) on 01099 * \param f the frame(s) to queue. Note that the frame(s) will be duplicated 01100 * by this function. It is the responsibility of the caller to handle 01101 * freeing the memory associated with the frame(s) being passed if 01102 * necessary. 01103 * 01104 * \retval 0 success 01105 * \retval non-zero failure 01106 */ 01107 int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f); 01108 01109 /*! 01110 * \brief Queue one or more frames to the head of a channel's frame queue 01111 * 01112 * \param chan the channel to queue the frame(s) on 01113 * \param f the frame(s) to queue. Note that the frame(s) will be duplicated 01114 * by this function. It is the responsibility of the caller to handle 01115 * freeing the memory associated with the frame(s) being passed if 01116 * necessary. 01117 * 01118 * \retval 0 success 01119 * \retval non-zero failure 01120 */ 01121 int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *f); 01122 01123 /*! 01124 * \brief Queue a hangup frame 01125 * 01126 * \note The channel does not need to be locked before calling this function. 01127 */ 01128 int ast_queue_hangup(struct ast_channel *chan); 01129 01130 /*! 01131 * \brief Queue a hangup frame with hangupcause set 01132 * 01133 * \note The channel does not need to be locked before calling this function. 01134 * \param[in] chan channel to queue frame onto 01135 * \param[in] cause the hangup cause 01136 * \return 0 on success, -1 on error 01137 * \since 1.6.1 01138 */ 01139 int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause); 01140 01141 /*! 01142 * \brief Queue a control frame with payload 01143 * 01144 * \param chan channel to queue frame onto 01145 * \param control type of control frame 01146 * 01147 * \note The channel does not need to be locked before calling this function. 01148 * 01149 * \retval zero on success 01150 * \retval non-zero on failure 01151 */ 01152 int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control); 01153 01154 /*! 01155 * \brief Queue a control frame with payload 01156 * 01157 * \param chan channel to queue frame onto 01158 * \param control type of control frame 01159 * \param data pointer to payload data to be included in frame 01160 * \param datalen number of bytes of payload data 01161 * 01162 * \retval 0 success 01163 * \retval non-zero failure 01164 * 01165 * \details 01166 * The supplied payload data is copied into the frame, so the caller's copy 01167 * is not modified nor freed, and the resulting frame will retain a copy of 01168 * the data even if the caller frees their local copy. 01169 * 01170 * \note This method should be treated as a 'network transport'; in other 01171 * words, your frames may be transferred across an IAX2 channel to another 01172 * system, which may be a different endianness than yours. Because of this, 01173 * you should ensure that either your frames will never be expected to work 01174 * across systems, or that you always put your payload data into 'network byte 01175 * order' before calling this function. 01176 * 01177 * \note The channel does not need to be locked before calling this function. 01178 */ 01179 int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control, 01180 const void *data, size_t datalen); 01181 01182 /*! 01183 * \brief Change channel name 01184 * 01185 * \pre Absolutely all channels _MUST_ be unlocked before calling this function. 01186 * 01187 * \param chan the channel to change the name of 01188 * \param newname the name to change to 01189 * 01190 * \return nothing 01191 * 01192 * \note this function must _NEVER_ be used when any channels are locked 01193 * regardless if it is the channel who's name is being changed or not because 01194 * it invalidates our channel container locking order... lock container first, 01195 * then the individual channels, never the other way around. 01196 */ 01197 void ast_change_name(struct ast_channel *chan, const char *newname); 01198 01199 /*! 01200 * \brief Unlink and release reference to a channel 01201 * 01202 * This function will unlink the channel from the global channels container 01203 * if it is still there and also release the current reference to the channel. 01204 * 01205 * \return NULL, convenient for clearing invalid pointers 01206 * \note Absolutely _NO_ channel locks should be held before calling this function. 01207 * 01208 * \since 1.8 01209 */ 01210 struct ast_channel *ast_channel_release(struct ast_channel *chan); 01211 01212 /*! 01213 * \brief Requests a channel 01214 * 01215 * \param type type of channel to request 01216 * \param request_cap Format capabilities for requested channel 01217 * \param requestor channel asking for data 01218 * \param addr destination of the call 01219 * \param cause Cause of failure 01220 * 01221 * \details 01222 * Request a channel of a given type, with addr as optional information used 01223 * by the low level module 01224 * 01225 * \retval NULL failure 01226 * \retval non-NULL channel on success 01227 */ 01228 struct ast_channel *ast_request(const char *type, struct ast_format_cap *request_cap, const struct ast_channel *requestor, const char *addr, int *cause); 01229 01230 /*! 01231 * \brief Request a channel of a given type, with data as optional information used 01232 * by the low level module and attempt to place a call on it 01233 * 01234 * \param type type of channel to request 01235 * \param format capabilities for requested channel 01236 * \param requestor channel asking for data 01237 * \param addr destination of the call 01238 * \param timeout maximum amount of time to wait for an answer 01239 * \param reason why unsuccessful (if unsuccessful) 01240 * \param cid_num Caller-ID Number 01241 * \param cid_name Caller-ID Name (ascii) 01242 * 01243 * \return Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state 01244 * to know if the call was answered or not. 01245 */ 01246 struct ast_channel *ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *addr, 01247 int timeout, int *reason, const char *cid_num, const char *cid_name); 01248 01249 /*! 01250 * \brief Request a channel of a given type, with data as optional information used 01251 * by the low level module and attempt to place a call on it 01252 * \param type type of channel to request 01253 * \param format capabilities for requested channel 01254 * \param requestor channel requesting data 01255 * \param addr destination of the call 01256 * \param timeout maximum amount of time to wait for an answer 01257 * \param reason why unsuccessful (if unsuccessful) 01258 * \param cid_num Caller-ID Number 01259 * \param cid_name Caller-ID Name (ascii) 01260 * \param oh Outgoing helper 01261 * \return Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state 01262 * to know if the call was answered or not. 01263 */ 01264 struct ast_channel *__ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *addr, 01265 int timeout, int *reason, const char *cid_num, const char *cid_name, struct outgoing_helper *oh); 01266 01267 /*! 01268 * \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. 01269 * \param caller in channel that requested orig 01270 * \param orig channel being replaced by the call forward channel 01271 * \param timeout maximum amount of time to wait for setup of new forward channel 01272 * \param format capabilities for requested channel 01273 * \param oh outgoing helper used with original channel 01274 * \param outstate reason why unsuccessful (if uncuccessful) 01275 * \return Returns the forwarded call's ast_channel on success or NULL on failure 01276 */ 01277 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); 01278 01279 /*! 01280 * \brief Register a channel technology (a new channel driver) 01281 * Called by a channel module to register the kind of channels it supports. 01282 * \param tech Structure defining channel technology or "type" 01283 * \return Returns 0 on success, -1 on failure. 01284 */ 01285 int ast_channel_register(const struct ast_channel_tech *tech); 01286 01287 /*! 01288 * \brief Unregister a channel technology 01289 * \param tech Structure defining channel technology or "type" that was previously registered 01290 * \return No return value. 01291 */ 01292 void ast_channel_unregister(const struct ast_channel_tech *tech); 01293 01294 /*! 01295 * \brief Get a channel technology structure by name 01296 * \param name name of technology to find 01297 * \return a pointer to the structure, or NULL if no matching technology found 01298 */ 01299 const struct ast_channel_tech *ast_get_channel_tech(const char *name); 01300 01301 #ifdef CHANNEL_TRACE 01302 /*! 01303 * \brief Update the context backtrace if tracing is enabled 01304 * \return Returns 0 on success, -1 on failure 01305 */ 01306 int ast_channel_trace_update(struct ast_channel *chan); 01307 01308 /*! 01309 * \brief Enable context tracing in the channel 01310 * \return Returns 0 on success, -1 on failure 01311 */ 01312 int ast_channel_trace_enable(struct ast_channel *chan); 01313 01314 /*! 01315 * \brief Disable context tracing in the channel. 01316 * \note Does not remove current trace entries 01317 * \return Returns 0 on success, -1 on failure 01318 */ 01319 int ast_channel_trace_disable(struct ast_channel *chan); 01320 01321 /*! 01322 * \brief Whether or not context tracing is enabled 01323 * \return Returns -1 when the trace is enabled. 0 if not. 01324 */ 01325 int ast_channel_trace_is_enabled(struct ast_channel *chan); 01326 01327 /*! 01328 * \brief Put the channel backtrace in a string 01329 * \return Returns the amount of lines in the backtrace. -1 on error. 01330 */ 01331 int ast_channel_trace_serialize(struct ast_channel *chan, struct ast_str **out); 01332 #endif 01333 01334 /*! 01335 * \brief Hang up a channel 01336 * \note Absolutely _NO_ channel locks should be held before calling this function. 01337 * \note This function performs a hard hangup on a channel. Unlike the soft-hangup, this function 01338 * performs all stream stopping, etc, on the channel that needs to end. 01339 * chan is no longer valid after this call. 01340 * \param chan channel to hang up 01341 * \return Returns 0 on success, -1 on failure. 01342 */ 01343 int ast_hangup(struct ast_channel *chan); 01344 01345 /*! 01346 * \brief Softly hangup up a channel 01347 * 01348 * \param chan channel to be soft-hung-up 01349 * \param reason an AST_SOFTHANGUP_* reason code 01350 * 01351 * \details 01352 * Call the protocol layer, but don't destroy the channel structure 01353 * (use this if you are trying to 01354 * safely hangup a channel managed by another thread. 01355 * 01356 * \note The channel passed to this function does not need to be locked. 01357 * 01358 * \return Returns 0 regardless 01359 */ 01360 int ast_softhangup(struct ast_channel *chan, int reason); 01361 01362 /*! 01363 * \brief Softly hangup up a channel (no channel lock) 01364 * \param chan channel to be soft-hung-up 01365 * \param reason an AST_SOFTHANGUP_* reason code 01366 */ 01367 int ast_softhangup_nolock(struct ast_channel *chan, int reason); 01368 01369 /*! 01370 * \brief Clear a set of softhangup flags from a channel 01371 * 01372 * Never clear a softhangup flag from a channel directly. Instead, 01373 * use this function. This ensures that all aspects of the softhangup 01374 * process are aborted. 01375 * 01376 * \param chan the channel to clear the flag on 01377 * \param flag the flag or flags to clear 01378 * 01379 * \return Nothing. 01380 */ 01381 void ast_channel_clear_softhangup(struct ast_channel *chan, int flag); 01382 01383 /*! 01384 * \brief Set the source of the hangup in this channel and it's bridge 01385 * 01386 * \param chan channel to set the field on 01387 * \param source a string describing the source of the hangup for this channel 01388 * \param force 01389 * 01390 * \since 1.8 01391 * 01392 * Hangupsource is generally the channel name that caused the bridge to be 01393 * hung up, but it can also be other things such as "dialplan/agi" 01394 * This can then be logged in the CDR or CEL 01395 */ 01396 void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force); 01397 01398 /*! \brief Check to see if a channel is needing hang up 01399 * \param chan channel on which to check for hang up 01400 * This function determines if the channel is being requested to be hung up. 01401 * \return Returns 0 if not, or 1 if hang up is requested (including time-out). 01402 */ 01403 int ast_check_hangup(struct ast_channel *chan); 01404 01405 int ast_check_hangup_locked(struct ast_channel *chan); 01406 01407 /*! 01408 * \brief Lock the given channel, then request softhangup on the channel with the given causecode 01409 * \param obj channel on which to hang up 01410 * \param causecode cause code to use 01411 * \return 0 01412 */ 01413 int ast_channel_softhangup_withcause_locked(void *obj, int causecode); 01414 01415 /*! 01416 * \brief Compare a offset with the settings of when to hang a channel up 01417 * \param chan channel on which to check for hang up 01418 * \param offset offset in seconds from current time 01419 * \return 1, 0, or -1 01420 * \details 01421 * This function compares a offset from current time with the absolute time 01422 * out on a channel (when to hang up). If the absolute time out on a channel 01423 * is earlier than current time plus the offset, it returns 1, if the two 01424 * time values are equal, it return 0, otherwise, it return -1. 01425 * \sa ast_channel_cmpwhentohangup_tv() 01426 * \version 1.6.1 deprecated function (only had seconds precision) 01427 */ 01428 int ast_channel_cmpwhentohangup(struct ast_channel *chan, time_t offset) __attribute__((deprecated)); 01429 01430 /*! 01431 * \brief Compare a offset with the settings of when to hang a channel up 01432 * \param chan channel on which to check for hangup 01433 * \param offset offset in seconds and microseconds from current time 01434 * \return 1, 0, or -1 01435 * This function compares a offset from current time with the absolute time 01436 * out on a channel (when to hang up). If the absolute time out on a channel 01437 * is earlier than current time plus the offset, it returns 1, if the two 01438 * time values are equal, it return 0, otherwise, it return -1. 01439 * \since 1.6.1 01440 */ 01441 int ast_channel_cmpwhentohangup_tv(struct ast_channel *chan, struct timeval offset); 01442 01443 /*! 01444 * \brief Set when to hang a channel up 01445 * 01446 * \param chan channel on which to check for hang up 01447 * \param offset offset in seconds relative to the current time of when to hang up 01448 * 01449 * \details 01450 * This function sets the absolute time out on a channel (when to hang up). 01451 * 01452 * \note This function does not require that the channel is locked before 01453 * calling it. 01454 * 01455 * \return Nothing 01456 * \sa ast_channel_setwhentohangup_tv() 01457 * \version 1.6.1 deprecated function (only had seconds precision) 01458 */ 01459 void ast_channel_setwhentohangup(struct ast_channel *chan, time_t offset) __attribute__((deprecated)); 01460 01461 /*! 01462 * \brief Set when to hang a channel up 01463 * 01464 * \param chan channel on which to check for hang up 01465 * \param offset offset in seconds and useconds relative to the current time of when to hang up 01466 * 01467 * This function sets the absolute time out on a channel (when to hang up). 01468 * 01469 * \note This function does not require that the channel is locked before 01470 * calling it. 01471 * 01472 * \return Nothing 01473 * \since 1.6.1 01474 */ 01475 void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset); 01476 01477 /*! 01478 * \brief Answer a channel 01479 * 01480 * \param chan channel to answer 01481 * 01482 * \details 01483 * This function answers a channel and handles all necessary call 01484 * setup functions. 01485 * 01486 * \note The channel passed does not need to be locked, but is locked 01487 * by the function when needed. 01488 * 01489 * \note This function will wait up to 500 milliseconds for media to 01490 * arrive on the channel before returning to the caller, so that the 01491 * caller can properly assume the channel is 'ready' for media flow. 01492 * 01493 * \retval 0 on success 01494 * \retval non-zero on failure 01495 */ 01496 int ast_answer(struct ast_channel *chan); 01497 01498 /*! 01499 * \brief Answer a channel 01500 * 01501 * \param chan channel to answer 01502 * \param cdr_answer flag to control whether any associated CDR should be marked as 'answered' 01503 * 01504 * This function answers a channel and handles all necessary call 01505 * setup functions. 01506 * 01507 * \note The channel passed does not need to be locked, but is locked 01508 * by the function when needed. 01509 * 01510 * \note Unlike ast_answer(), this function will not wait for media 01511 * flow to begin. The caller should be careful before sending media 01512 * to the channel before incoming media arrives, as the outgoing 01513 * media may be lost. 01514 * 01515 * \retval 0 on success 01516 * \retval non-zero on failure 01517 */ 01518 int ast_raw_answer(struct ast_channel *chan, int cdr_answer); 01519 01520 /*! 01521 * \brief Answer a channel, with a selectable delay before returning 01522 * 01523 * \param chan channel to answer 01524 * \param delay maximum amount of time to wait for incoming media 01525 * \param cdr_answer flag to control whether any associated CDR should be marked as 'answered' 01526 * 01527 * This function answers a channel and handles all necessary call 01528 * setup functions. 01529 * 01530 * \note The channel passed does not need to be locked, but is locked 01531 * by the function when needed. 01532 * 01533 * \note This function will wait up to 'delay' milliseconds for media to 01534 * arrive on the channel before returning to the caller, so that the 01535 * caller can properly assume the channel is 'ready' for media flow. If 01536 * 'delay' is less than 500, the function will wait up to 500 milliseconds. 01537 * 01538 * \retval 0 on success 01539 * \retval non-zero on failure 01540 */ 01541 int __ast_answer(struct ast_channel *chan, unsigned int delay, int cdr_answer); 01542 01543 /*! 01544 * \brief Execute a Gosub call on the channel before a call is placed. 01545 * \since 11.0 01546 * 01547 * \details 01548 * This is called between ast_request() and ast_call() to 01549 * execute a predial routine on the newly created channel. 01550 * 01551 * \param chan Channel to execute Gosub. 01552 * \param sub_args Gosub application parameter string. 01553 * 01554 * \note Absolutely _NO_ channel locks should be held before calling this function. 01555 * 01556 * \retval 0 on success. 01557 * \retval -1 on error. 01558 */ 01559 int ast_pre_call(struct ast_channel *chan, const char *sub_args); 01560 01561 /*! 01562 * \brief Make a call 01563 * \note Absolutely _NO_ channel locks should be held before calling this function. 01564 * \param chan which channel to make the call on 01565 * \param addr destination of the call 01566 * \param timeout time to wait on for connect (Doesn't seem to be used.) 01567 * \details 01568 * Place a call, take no longer than timeout ms. 01569 * \retval 0 on success 01570 * \retval -1 on failure 01571 */ 01572 int ast_call(struct ast_channel *chan, const char *addr, int timeout); 01573 01574 /*! 01575 * \brief Indicates condition of channel 01576 * \note Absolutely _NO_ channel locks should be held before calling this function. 01577 * \note Indicate a condition such as AST_CONTROL_BUSY, AST_CONTROL_RINGING, or AST_CONTROL_CONGESTION on a channel 01578 * \param chan channel to change the indication 01579 * \param condition which condition to indicate on the channel 01580 * \return Returns 0 on success, -1 on failure 01581 */ 01582 int ast_indicate(struct ast_channel *chan, int condition); 01583 01584 /*! 01585 * \brief Indicates condition of channel, with payload 01586 * \note Absolutely _NO_ channel locks should be held before calling this function. 01587 * \note Indicate a condition such as AST_CONTROL_HOLD with payload being music on hold class 01588 * \param chan channel to change the indication 01589 * \param condition which condition to indicate on the channel 01590 * \param data pointer to payload data 01591 * \param datalen size of payload data 01592 * \return Returns 0 on success, -1 on failure 01593 */ 01594 int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen); 01595 01596 /* Misc stuff ------------------------------------------------ */ 01597 01598 /*! 01599 * \brief Wait for input on a channel 01600 * \param chan channel to wait on 01601 * \param ms length of time to wait on the channel 01602 * \details 01603 * Wait for input on a channel for a given # of milliseconds (<0 for indefinite). 01604 * \retval < 0 on failure 01605 * \retval 0 if nothing ever arrived 01606 * \retval the # of ms remaining otherwise 01607 */ 01608 int ast_waitfor(struct ast_channel *chan, int ms); 01609 01610 /*! 01611 * \brief Should we keep this frame for later? 01612 * 01613 * There are functions such as ast_safe_sleep which will 01614 * service a channel to ensure that it does not have a 01615 * large backlog of queued frames. When this happens, 01616 * we want to hold on to specific frame types and just drop 01617 * others. This function will tell if the frame we just 01618 * read should be held onto. 01619 * 01620 * \param frame The frame we just read 01621 * \retval 1 frame should be kept 01622 * \retval 0 frame should be dropped 01623 */ 01624 int ast_is_deferrable_frame(const struct ast_frame *frame); 01625 01626 /*! 01627 * \brief Wait for a specified amount of time, looking for hangups 01628 * \param chan channel to wait for 01629 * \param ms length of time in milliseconds to sleep 01630 * \details 01631 * Waits for a specified amount of time, servicing the channel as required. 01632 * \return returns -1 on hangup, otherwise 0. 01633 */ 01634 int ast_safe_sleep(struct ast_channel *chan, int ms); 01635 01636 /*! 01637 * \brief Wait for a specified amount of time, looking for hangups and a condition argument 01638 * \param chan channel to wait for 01639 * \param ms length of time in milliseconds to sleep 01640 * \param cond a function pointer for testing continue condition 01641 * \param data argument to be passed to the condition test function 01642 * \return returns -1 on hangup, otherwise 0. 01643 * \details 01644 * Waits for a specified amount of time, servicing the channel as required. If cond 01645 * returns 0, this function returns. 01646 */ 01647 int ast_safe_sleep_conditional(struct ast_channel *chan, int ms, int (*cond)(void*), void *data ); 01648 01649 /*! 01650 * \brief Waits for activity on a group of channels 01651 * \param chan an array of pointers to channels 01652 * \param n number of channels that are to be waited upon 01653 * \param fds an array of fds to wait upon 01654 * \param nfds the number of fds to wait upon 01655 * \param exception exception flag 01656 * \param outfd fd that had activity on it 01657 * \param ms how long the wait was 01658 * \details 01659 * Big momma function here. Wait for activity on any of the n channels, or any of the nfds 01660 * file descriptors. 01661 * \return Returns the channel with activity, or NULL on error or if an FD 01662 * came first. If the FD came first, it will be returned in outfd, otherwise, outfd 01663 * will be -1 01664 */ 01665 struct ast_channel *ast_waitfor_nandfds(struct ast_channel **chan, int n, 01666 int *fds, int nfds, int *exception, int *outfd, int *ms); 01667 01668 /*! 01669 * \brief Waits for input on a group of channels 01670 * Wait for input on an array of channels for a given # of milliseconds. 01671 * \return Return channel with activity, or NULL if none has activity. 01672 * \param chan an array of pointers to channels 01673 * \param n number of channels that are to be waited upon 01674 * \param ms time "ms" is modified in-place, if applicable 01675 */ 01676 struct ast_channel *ast_waitfor_n(struct ast_channel **chan, int n, int *ms); 01677 01678 /*! 01679 * \brief Waits for input on an fd 01680 * \note This version works on fd's only. Be careful with it. 01681 */ 01682 int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception); 01683 01684 01685 /*! 01686 * \brief Reads a frame 01687 * \param chan channel to read a frame from 01688 * \return Returns a frame, or NULL on error. If it returns NULL, you 01689 * best just stop reading frames and assume the channel has been 01690 * disconnected. 01691 */ 01692 struct ast_frame *ast_read(struct ast_channel *chan); 01693 01694 /*! 01695 * \brief Reads a frame, returning AST_FRAME_NULL frame if audio. 01696 * \param chan channel to read a frame from 01697 * \return Returns a frame, or NULL on error. If it returns NULL, you 01698 * best just stop reading frames and assume the channel has been 01699 * disconnected. 01700 * \note Audio is replaced with AST_FRAME_NULL to avoid 01701 * transcode when the resulting audio is not necessary. 01702 */ 01703 struct ast_frame *ast_read_noaudio(struct ast_channel *chan); 01704 01705 /*! 01706 * \brief Write a frame to a channel 01707 * This function writes the given frame to the indicated channel. 01708 * \param chan destination channel of the frame 01709 * \param frame frame that will be written 01710 * \return It returns 0 on success, -1 on failure. 01711 */ 01712 int ast_write(struct ast_channel *chan, struct ast_frame *frame); 01713 01714 /*! 01715 * \brief Write video frame to a channel 01716 * This function writes the given frame to the indicated channel. 01717 * \param chan destination channel of the frame 01718 * \param frame frame that will be written 01719 * \return It returns 1 on success, 0 if not implemented, and -1 on failure. 01720 */ 01721 int ast_write_video(struct ast_channel *chan, struct ast_frame *frame); 01722 01723 /*! 01724 * \brief Write text frame to a channel 01725 * This function writes the given frame to the indicated channel. 01726 * \param chan destination channel of the frame 01727 * \param frame frame that will be written 01728 * \return It returns 1 on success, 0 if not implemented, and -1 on failure. 01729 */ 01730 int ast_write_text(struct ast_channel *chan, struct ast_frame *frame); 01731 01732 /*! \brief Send empty audio to prime a channel driver */ 01733 int ast_prod(struct ast_channel *chan); 01734 01735 /*! 01736 * \brief Sets read format on channel chan from capabilities 01737 * Set read format for channel to whichever component of "format" is best. 01738 * \param chan channel to change 01739 * \param formats new formats to pick from for reading 01740 * \return Returns 0 on success, -1 on failure 01741 */ 01742 int ast_set_read_format_from_cap(struct ast_channel *chan, struct ast_format_cap *formats); 01743 01744 /*! 01745 * \brief Sets read format on channel chan 01746 * \param chan channel to change 01747 * \param formats, format to set for reading 01748 * \return Returns 0 on success, -1 on failure 01749 */ 01750 int ast_set_read_format(struct ast_channel *chan, struct ast_format *format); 01751 01752 /*! 01753 * \brief Sets read format on channel chan by id 01754 * \param chan channel to change 01755 * \param format id to set for reading, only used for formats without attributes 01756 * \return Returns 0 on success, -1 on failure 01757 */ 01758 int ast_set_read_format_by_id(struct ast_channel *chan, enum ast_format_id id); 01759 01760 /*! 01761 * \brief Sets write format on channel chan 01762 * Set write format for channel to whichever component of "format" is best. 01763 * \param chan channel to change 01764 * \param formats new formats to pick from for writing 01765 * \return Returns 0 on success, -1 on failure 01766 */ 01767 int ast_set_write_format_from_cap(struct ast_channel *chan, struct ast_format_cap *formats); 01768 01769 /*! 01770 * \brief Sets write format on channel chan 01771 * \param chan channel to change 01772 * \param formats, format to set for writing 01773 * \return Returns 0 on success, -1 on failure 01774 */ 01775 int ast_set_write_format(struct ast_channel *chan, struct ast_format *format); 01776 01777 /*! 01778 * \brief Sets write format on channel chan 01779 * \param chan channel to change 01780 * \param format id to set for writing, only used for formats without attributes 01781 * \return Returns 0 on success, -1 on failure 01782 */ 01783 int ast_set_write_format_by_id(struct ast_channel *chan, enum ast_format_id id); 01784 01785 /*! 01786 * \brief Sends text to a channel 01787 * 01788 * \param chan channel to act upon 01789 * \param text string of text to send on the channel 01790 * 01791 * \details 01792 * Write text to a display on a channel 01793 * 01794 * \note The channel does not need to be locked before calling this function. 01795 * 01796 * \retval 0 on success 01797 * \retval -1 on failure 01798 */ 01799 int ast_sendtext(struct ast_channel *chan, const char *text); 01800 01801 /*! 01802 * \brief Receives a text character from a channel 01803 * \param chan channel to act upon 01804 * \param timeout timeout in milliseconds (0 for infinite wait) 01805 * \details 01806 * Read a char of text from a channel 01807 * \return 0 on success, -1 on failure 01808 */ 01809 int ast_recvchar(struct ast_channel *chan, int timeout); 01810 01811 /*! 01812 * \brief Send a DTMF digit to a channel. 01813 * \param chan channel to act upon 01814 * \param digit the DTMF digit to send, encoded in ASCII 01815 * \param duration the duration of the digit ending in ms 01816 * \return 0 on success, -1 on failure 01817 */ 01818 int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration); 01819 01820 /*! 01821 * \brief Send a DTMF digit to a channel. 01822 * \param chan channel to act upon 01823 * \param digit the DTMF digit to send, encoded in ASCII 01824 * \return 0 on success, -1 on failure 01825 */ 01826 int ast_senddigit_begin(struct ast_channel *chan, char digit); 01827 01828 /*! 01829 * \brief Send a DTMF digit to a channel. 01830 * \param chan channel to act upon 01831 * \param digit the DTMF digit to send, encoded in ASCII 01832 * \param duration the duration of the digit ending in ms 01833 * \return Returns 0 on success, -1 on failure 01834 */ 01835 int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration); 01836 01837 /*! 01838 * \brief Receives a text string from a channel 01839 * Read a string of text from a channel 01840 * \param chan channel to act upon 01841 * \param timeout timeout in milliseconds (0 for infinite wait) 01842 * \return the received text, or NULL to signify failure. 01843 */ 01844 char *ast_recvtext(struct ast_channel *chan, int timeout); 01845 01846 /*! 01847 * \brief Waits for a digit 01848 * \param c channel to wait for a digit on 01849 * \param ms how many milliseconds to wait 01850 * \return Returns <0 on error, 0 on no entry, and the digit on success. 01851 */ 01852 int ast_waitfordigit(struct ast_channel *c, int ms); 01853 01854 /*! 01855 * \brief Wait for a digit 01856 * Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to monitor for reading. 01857 * \param c channel to wait for a digit on 01858 * \param ms how many milliseconds to wait 01859 * \param audiofd audio file descriptor to write to if audio frames are received 01860 * \param ctrlfd control file descriptor to monitor for reading 01861 * \return Returns 1 if ctrlfd becomes available 01862 */ 01863 int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int ctrlfd); 01864 01865 /*! 01866 * \brief Reads multiple digits 01867 * \param c channel to read from 01868 * \param s string to read in to. Must be at least the size of your length 01869 * \param len how many digits to read (maximum) 01870 * \param timeout how long to timeout between digits 01871 * \param rtimeout timeout to wait on the first digit 01872 * \param enders digits to end the string 01873 * \details 01874 * Read in a digit string "s", max length "len", maximum timeout between 01875 * digits "timeout" (-1 for none), terminated by anything in "enders". Give them rtimeout 01876 * for the first digit. 01877 * \return Returns 0 on normal return, or 1 on a timeout. In the case of 01878 * a timeout, any digits that were read before the timeout will still be available in s. 01879 * RETURNS 2 in full version when ctrlfd is available, NOT 1 01880 */ 01881 int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders); 01882 int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders, int audiofd, int ctrlfd); 01883 01884 /*! \brief Report DTMF on channel 0 */ 01885 #define AST_BRIDGE_DTMF_CHANNEL_0 (1 << 0) 01886 /*! \brief Report DTMF on channel 1 */ 01887 #define AST_BRIDGE_DTMF_CHANNEL_1 (1 << 1) 01888 /*! \brief Return all voice frames on channel 0 */ 01889 #define AST_BRIDGE_REC_CHANNEL_0 (1 << 2) 01890 /*! \brief Return all voice frames on channel 1 */ 01891 #define AST_BRIDGE_REC_CHANNEL_1 (1 << 3) 01892 /*! \brief Ignore all signal frames except NULL */ 01893 #define AST_BRIDGE_IGNORE_SIGS (1 << 4) 01894 01895 01896 /*! 01897 * \brief Makes two channel formats compatible 01898 * \param c0 first channel to make compatible 01899 * \param c1 other channel to make compatible 01900 * \details 01901 * Set two channels to compatible formats -- call before ast_channel_bridge in general. 01902 * \return Returns 0 on success and -1 if it could not be done 01903 */ 01904 int ast_channel_make_compatible(struct ast_channel *c0, struct ast_channel *c1); 01905 01906 /*! 01907 * \brief Bridge two channels together (early) 01908 * \param c0 first channel to bridge 01909 * \param c1 second channel to bridge 01910 * \details 01911 * Bridge two channels (c0 and c1) together early. This implies either side may not be answered yet. 01912 * \return Returns 0 on success and -1 if it could not be done 01913 */ 01914 int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1); 01915 01916 /*! 01917 * \brief Bridge two channels together 01918 * \param c0 first channel to bridge 01919 * \param c1 second channel to bridge 01920 * \param config config for the channels 01921 * \param fo destination frame(?) 01922 * \param rc destination channel(?) 01923 * \details 01924 * Bridge two channels (c0 and c1) together. If an important frame occurs, we return that frame in 01925 * *rf (remember, it could be NULL) and which channel (0 or 1) in rc 01926 */ 01927 /* int ast_channel_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc); */ 01928 int ast_channel_bridge(struct ast_channel *c0,struct ast_channel *c1, 01929 struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc); 01930 01931 /*! 01932 * \brief Weird function made for call transfers 01933 * 01934 * \param original channel to make a copy of 01935 * \param clone copy of the original channel 01936 * 01937 * \details 01938 * This is a very strange and freaky function used primarily for transfer. Suppose that 01939 * "original" and "clone" are two channels in random situations. This function takes 01940 * the guts out of "clone" and puts them into the "original" channel, then alerts the 01941 * channel driver of the change, asking it to fixup any private information (like the 01942 * p->owner pointer) that is affected by the change. The physical layer of the original 01943 * channel is hung up. 01944 * 01945 * \note Neither channel passed here should be locked before 01946 * calling this function. This function performs deadlock 01947 * avoidance involving these two channels. 01948 */ 01949 int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone); 01950 01951 /*! 01952 * \brief Setup a masquerade to transfer a call. 01953 * \since 1.8 01954 * 01955 * \param target_chan Target of the call transfer. (Masquerade original channel) 01956 * \param target_id New connected line information for the target channel. 01957 * \param target_held TRUE if the target call is on hold. 01958 * \param transferee_chan Transferee of the call transfer. (Masquerade clone channel) 01959 * \param transferee_id New connected line information for the transferee channel. 01960 * \param transferee_held TRUE if the transferee call is on hold. 01961 * 01962 * \details 01963 * Party A - Transferee 01964 * Party B - Transferer 01965 * Party C - Target of transfer 01966 * 01967 * Party B transfers A to C. 01968 * 01969 * Party A is connected to bridged channel B1. 01970 * Party B is connected to channels C1 and C2. 01971 * Party C is connected to bridged channel B2. 01972 * 01973 * Party B -- C1 == B1 -- Party A 01974 * __/ 01975 * / 01976 * Party B -- C2 == B2 -- Party C 01977 * 01978 * Bridged channel B1 is masqueraded into channel C2. Where B1 01979 * is the masquerade clone channel and C2 is the masquerade 01980 * original channel. 01981 * 01982 * \see ast_channel_masquerade() 01983 * 01984 * \note Has the same locking requirements as ast_channel_masquerade(). 01985 * 01986 * \retval 0 on success. 01987 * \retval -1 on error. 01988 */ 01989 int ast_channel_transfer_masquerade( 01990 struct ast_channel *target_chan, 01991 const struct ast_party_connected_line *target_id, 01992 int target_held, 01993 struct ast_channel *transferee_chan, 01994 const struct ast_party_connected_line *transferee_id, 01995 int transferee_held); 01996 01997 /*! 01998 * \brief Gives the string form of a given cause code. 01999 * 02000 * \param state cause to get the description of 02001 * \return the text form of the binary cause code given 02002 */ 02003 const char *ast_cause2str(int state) attribute_pure; 02004 02005 /*! 02006 * \brief Convert the string form of a cause code to a number 02007 * 02008 * \param name string form of the cause 02009 * \return the cause code 02010 */ 02011 int ast_str2cause(const char *name) attribute_pure; 02012 02013 /*! 02014 * \brief Gives the string form of a given channel state 02015 * 02016 * \param ast_channel_state state to get the name of 02017 * \return the text form of the binary state given 02018 */ 02019 const char *ast_state2str(enum ast_channel_state); 02020 02021 /*! 02022 * \brief Gives the string form of a given transfer capability 02023 * 02024 * \param transfercapability transfer capability to get the name of 02025 * \return the text form of the binary transfer capability 02026 */ 02027 char *ast_transfercapability2str(int transfercapability) attribute_const; 02028 02029 /* 02030 * Options: Some low-level drivers may implement "options" allowing fine tuning of the 02031 * low level channel. See frame.h for options. Note that many channel drivers may support 02032 * none or a subset of those features, and you should not count on this if you want your 02033 * asterisk application to be portable. They're mainly useful for tweaking performance 02034 */ 02035 02036 /*! 02037 * \brief Sets an option on a channel 02038 * 02039 * \param channel channel to set options on 02040 * \param option option to change 02041 * \param data data specific to option 02042 * \param datalen length of the data 02043 * \param block blocking or not 02044 * \details 02045 * Set an option on a channel (see frame.h), optionally blocking awaiting the reply 02046 * \return 0 on success and -1 on failure 02047 */ 02048 int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block); 02049 02050 /*! 02051 * \brief Pick the best codec 02052 * 02053 * \param capabilities to pick best codec out of 02054 * \param result stucture to store the best codec in. 02055 * \retval on success, pointer to result structure 02056 * \retval on failure, NULL 02057 */ 02058 struct ast_format *ast_best_codec(struct ast_format_cap *cap, struct ast_format *result); 02059 02060 02061 /*! 02062 * \brief Checks the value of an option 02063 * 02064 * Query the value of an option 02065 * Works similarly to setoption except only reads the options. 02066 */ 02067 int ast_channel_queryoption(struct ast_channel *channel, int option, void *data, int *datalen, int block); 02068 02069 /*! 02070 * \brief Checks for HTML support on a channel 02071 * \return 0 if channel does not support HTML or non-zero if it does 02072 */ 02073 int ast_channel_supports_html(struct ast_channel *channel); 02074 02075 /*! 02076 * \brief Sends HTML on given channel 02077 * Send HTML or URL on link. 02078 * \return 0 on success or -1 on failure 02079 */ 02080 int ast_channel_sendhtml(struct ast_channel *channel, int subclass, const char *data, int datalen); 02081 02082 /*! 02083 * \brief Sends a URL on a given link 02084 * Send URL on link. 02085 * \return 0 on success or -1 on failure 02086 */ 02087 int ast_channel_sendurl(struct ast_channel *channel, const char *url); 02088 02089 /*! 02090 * \brief Defers DTMF so that you only read things like hangups and audio. 02091 * \return non-zero if channel was already DTMF-deferred or 02092 * 0 if channel is just now being DTMF-deferred 02093 */ 02094 int ast_channel_defer_dtmf(struct ast_channel *chan); 02095 02096 /*! Undo defer. ast_read will return any DTMF characters that were queued */ 02097 void ast_channel_undefer_dtmf(struct ast_channel *chan); 02098 02099 /*! Initiate system shutdown -- prevents new channels from being allocated. 02100 * \param hangup If "hangup" is non-zero, all existing channels will receive soft 02101 * hangups */ 02102 void ast_begin_shutdown(int hangup); 02103 02104 /*! Cancels an existing shutdown and returns to normal operation */ 02105 void ast_cancel_shutdown(void); 02106 02107 /*! \return number of active/allocated channels */ 02108 int ast_active_channels(void); 02109 02110 /*! \return non-zero if Asterisk is being shut down */ 02111 int ast_shutting_down(void); 02112 02113 /*! Activate a given generator */ 02114 int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params); 02115 02116 /*! Deactivate an active generator */ 02117 void ast_deactivate_generator(struct ast_channel *chan); 02118 02119 /*! 02120 * \brief Set caller ID number, name and ANI and generate AMI event. 02121 * 02122 * \note Use ast_channel_set_caller() and ast_channel_set_caller_event() instead. 02123 * \note The channel does not need to be locked before calling this function. 02124 */ 02125 void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani); 02126 02127 /*! 02128 * \brief Set the caller id information in the Asterisk channel 02129 * \since 1.8 02130 * 02131 * \param chan Asterisk channel to set caller id information 02132 * \param caller Caller id information 02133 * \param update What caller information to update. NULL if all. 02134 * 02135 * \return Nothing 02136 * 02137 * \note The channel does not need to be locked before calling this function. 02138 */ 02139 void ast_channel_set_caller(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update); 02140 02141 /*! 02142 * \brief Set the caller id information in the Asterisk channel and generate an AMI event 02143 * if the caller id name or number changed. 02144 * \since 1.8 02145 * 02146 * \param chan Asterisk channel to set caller id information 02147 * \param caller Caller id information 02148 * \param update What caller information to update. NULL if all. 02149 * 02150 * \return Nothing 02151 * 02152 * \note The channel does not need to be locked before calling this function. 02153 */ 02154 void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update); 02155 02156 /*! Set the file descriptor on the channel */ 02157 void ast_channel_set_fd(struct ast_channel *chan, int which, int fd); 02158 02159 /*! Add a channel to an optimized waitfor */ 02160 void ast_poll_channel_add(struct ast_channel *chan0, struct ast_channel *chan1); 02161 02162 /*! Delete a channel from an optimized waitfor */ 02163 void ast_poll_channel_del(struct ast_channel *chan0, struct ast_channel *chan1); 02164 02165 /*! Start a tone going */ 02166 int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol); 02167 /*! Stop a tone from playing */ 02168 void ast_tonepair_stop(struct ast_channel *chan); 02169 /*! Play a tone pair for a given amount of time */ 02170 int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol); 02171 02172 /*! 02173 * \brief Automatically service a channel for us... 02174 * 02175 * \retval 0 success 02176 * \retval -1 failure, or the channel is already being autoserviced 02177 */ 02178 int ast_autoservice_start(struct ast_channel *chan); 02179 02180 /*! 02181 * \brief Stop servicing a channel for us... 02182 * 02183 * \note if chan is locked prior to calling ast_autoservice_stop, it 02184 * is likely that there will be a deadlock between the thread that calls 02185 * ast_autoservice_stop and the autoservice thread. It is important 02186 * that chan is not locked prior to this call 02187 * 02188 * \param chan 02189 * \retval 0 success 02190 * \retval -1 error, or the channel has been hungup 02191 */ 02192 int ast_autoservice_stop(struct ast_channel *chan); 02193 02194 /*! 02195 * \brief Ignore certain frame types 02196 * \note Normally, we cache DTMF, IMAGE, HTML, TEXT, and CONTROL frames 02197 * while a channel is in autoservice and queue them up when taken out of 02198 * autoservice. When this is not desireable, this API may be used to 02199 * cause the channel to ignore those frametypes after the channel is put 02200 * into autoservice, but before autoservice is stopped. 02201 * \retval 0 success 02202 * \retval -1 channel is not in autoservice 02203 */ 02204 int ast_autoservice_ignore(struct ast_channel *chan, enum ast_frame_type ftype); 02205 02206 /*! 02207 * \brief Enable or disable timer ticks for a channel 02208 * 02209 * \param c channel 02210 * \param rate number of timer ticks per second 02211 * \param func callback function 02212 * \param data 02213 * 02214 * \details 02215 * If timers are supported, force a scheduled expiration on the 02216 * timer fd, at which point we call the callback function / data 02217 * 02218 * \note Call this function with a rate of 0 to turn off the timer ticks 02219 * 02220 * \version 1.6.1 changed samples parameter to rate, accomodates new timing methods 02221 */ 02222 int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const void *data), void *data); 02223 02224 /*! 02225 * \brief Transfer a channel (if supported). 02226 * \retval -1 on error 02227 * \retval 0 if not supported 02228 * \retval 1 if supported and requested 02229 * \param chan current channel 02230 * \param dest destination extension for transfer 02231 */ 02232 int ast_transfer(struct ast_channel *chan, char *dest); 02233 02234 /*! 02235 * \brief Start masquerading a channel 02236 * \note absolutely _NO_ channel locks should be held before calling this function. 02237 * \details 02238 * XXX This is a seriously whacked out operation. We're essentially putting the guts of 02239 * the clone channel into the original channel. Start by killing off the original 02240 * channel's backend. I'm not sure we're going to keep this function, because 02241 * while the features are nice, the cost is very high in terms of pure nastiness. XXX 02242 * \param chan Channel to masquerade 02243 */ 02244 int ast_do_masquerade(struct ast_channel *chan); 02245 02246 /*! 02247 * \brief Find bridged channel 02248 * 02249 * \note This function does _not_ return a reference to the bridged channel. 02250 * The reason for this is mostly historical. It _should_ return a reference, 02251 * but it will take a lot of work to make the code base account for that. 02252 * So, for now, the old rules still apply for how to handle this function. 02253 * If this function is being used from the channel thread that owns the channel, 02254 * then a reference is already held, and channel locking is not required to 02255 * guarantee that the channel will stay around. If this function is used 02256 * outside of the associated channel thread, the channel parameter 'chan' 02257 * MUST be locked before calling this function. Also, 'chan' must remain locked 02258 * for the entire time that the result of this function is being used. 02259 * 02260 * \param chan Current channel 02261 * 02262 * \return A pointer to the bridged channel 02263 */ 02264 struct ast_channel *ast_bridged_channel(struct ast_channel *chan); 02265 02266 /*! 02267 * \brief Inherits channel variable from parent to child channel 02268 * \param parent Parent channel 02269 * \param child Child channel 02270 * 02271 * \details 02272 * Scans all channel variables in the parent channel, looking for those 02273 * that should be copied into the child channel. 02274 * Variables whose names begin with a single '_' are copied into the 02275 * child channel with the prefix removed. 02276 * Variables whose names begin with '__' are copied into the child 02277 * channel with their names unchanged. 02278 */ 02279 void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child); 02280 02281 /*! 02282 * \brief adds a list of channel variables to a channel 02283 * \param chan the channel 02284 * \param vars a linked list of variables 02285 * 02286 * \details 02287 * Variable names can be for a regular channel variable or a dialplan function 02288 * that has the ability to be written to. 02289 */ 02290 void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars); 02291 02292 /*! 02293 * \brief An opaque 'object' structure use by silence generators on channels. 02294 */ 02295 struct ast_silence_generator; 02296 02297 /*! 02298 * \brief Starts a silence generator on the given channel. 02299 * \param chan The channel to generate silence on 02300 * \return An ast_silence_generator pointer, or NULL if an error occurs 02301 * 02302 * \details 02303 * This function will cause SLINEAR silence to be generated on the supplied 02304 * channel until it is disabled; if the channel cannot be put into SLINEAR 02305 * mode then the function will fail. 02306 * 02307 * \note 02308 * The pointer returned by this function must be preserved and passed to 02309 * ast_channel_stop_silence_generator when you wish to stop the silence 02310 * generation. 02311 */ 02312 struct ast_silence_generator *ast_channel_start_silence_generator(struct ast_channel *chan); 02313 02314 /*! 02315 * \brief Stops a previously-started silence generator on the given channel. 02316 * \param chan The channel to operate on 02317 * \param state The ast_silence_generator pointer return by a previous call to 02318 * ast_channel_start_silence_generator. 02319 * \return nothing 02320 * 02321 * \details 02322 * This function will stop the operating silence generator and return the channel 02323 * to its previous write format. 02324 */ 02325 void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state); 02326 02327 /*! 02328 * \brief Check if the channel can run in internal timing mode. 02329 * \param chan The channel to check 02330 * \return boolean 02331 * 02332 * \details 02333 * This function will return 1 if internal timing is enabled and the timing 02334 * device is available. 02335 */ 02336 int ast_internal_timing_enabled(struct ast_channel *chan); 02337 02338 /* Misc. functions below */ 02339 02340 /*! 02341 * \brief if fd is a valid descriptor, set *pfd with the descriptor 02342 * \return Return 1 (not -1!) if added, 0 otherwise (so we can add the 02343 * return value to the index into the array) 02344 */ 02345 static inline int ast_add_fd(struct pollfd *pfd, int fd) 02346 { 02347 pfd->fd = fd; 02348 pfd->events = POLLIN | POLLPRI; 02349 return fd >= 0; 02350 } 02351 02352 /*! \brief Helper function for migrating select to poll */ 02353 static inline int ast_fdisset(struct pollfd *pfds, int fd, int maximum, int *start) 02354 { 02355 int x; 02356 int dummy = 0; 02357 02358 if (fd < 0) 02359 return 0; 02360 if (!start) 02361 start = &dummy; 02362 for (x = *start; x < maximum; x++) 02363 if (pfds[x].fd == fd) { 02364 if (x == *start) 02365 (*start)++; 02366 return pfds[x].revents; 02367 } 02368 return 0; 02369 } 02370 02371 /*! \brief Retrieves the current T38 state of a channel */ 02372 static inline enum ast_t38_state ast_channel_get_t38_state(struct ast_channel *chan) 02373 { 02374 enum ast_t38_state state = T38_STATE_UNAVAILABLE; 02375 int datalen = sizeof(state); 02376 02377 ast_channel_queryoption(chan, AST_OPTION_T38_STATE, &state, &datalen, 0); 02378 02379 return state; 02380 } 02381 02382 #define CHECK_BLOCKING(c) do { \ 02383 if (ast_test_flag(ast_channel_flags(c), AST_FLAG_BLOCKING)) {\ 02384 ast_debug(1, "Thread %ld Blocking '%s', already blocked by thread %ld in procedure %s\n", (long) pthread_self(), ast_channel_name(c), (long) ast_channel_blocker(c), ast_channel_blockproc(c)); \ 02385 } else { \ 02386 ast_channel_blocker_set((c), pthread_self()); \ 02387 ast_channel_blockproc_set((c), __PRETTY_FUNCTION__); \ 02388 ast_set_flag(ast_channel_flags(c), AST_FLAG_BLOCKING); \ 02389 } } while (0) 02390 02391 ast_group_t ast_get_group(const char *s); 02392 02393 /*! \brief print call- and pickup groups into buffer */ 02394 char *ast_print_group(char *buf, int buflen, ast_group_t group); 02395 02396 /*! 02397 * \brief Convert enum channelreloadreason to text string for manager event 02398 * \param reason The reason for reload (manager, cli, start etc) 02399 */ 02400 const char *channelreloadreason2txt(enum channelreloadreason reason); 02401 02402 /*! \brief return an ast_variable list of channeltypes */ 02403 struct ast_variable *ast_channeltype_list(void); 02404 02405 /*! 02406 * \brief return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument 02407 * \param reason The integer argument, usually taken from AST_CONTROL_ macros 02408 * \return char pointer explaining the code 02409 */ 02410 const char *ast_channel_reason2str(int reason); 02411 02412 /*! \brief channel group info */ 02413 struct ast_group_info { 02414 struct ast_channel *chan; 02415 char *category; 02416 char *group; 02417 AST_LIST_ENTRY(ast_group_info) group_list; 02418 }; 02419 02420 #define ast_channel_lock(chan) ao2_lock(chan) 02421 #define ast_channel_unlock(chan) ao2_unlock(chan) 02422 #define ast_channel_trylock(chan) ao2_trylock(chan) 02423 02424 /*! 02425 * \brief Lock two channels. 02426 */ 02427 #define ast_channel_lock_both(chan1, chan2) do { \ 02428 ast_channel_lock(chan1); \ 02429 while (ast_channel_trylock(chan2)) { \ 02430 ast_channel_unlock(chan1); \ 02431 sched_yield(); \ 02432 ast_channel_lock(chan1); \ 02433 } \ 02434 } while (0) 02435 02436 /*! 02437 * \brief Increase channel reference count 02438 * 02439 * \param c the channel 02440 * 02441 * \retval c always 02442 * 02443 * \since 1.8 02444 */ 02445 #define ast_channel_ref(c) ({ ao2_ref(c, +1); (c); }) 02446 02447 /*! 02448 * \brief Decrease channel reference count 02449 * 02450 * \param c the channel 02451 * 02452 * \retval NULL always 02453 * 02454 * \since 1.8 02455 */ 02456 #define ast_channel_unref(c) ({ ao2_ref(c, -1); (struct ast_channel *) (NULL); }) 02457 02458 /*! Channel Iterating @{ */ 02459 02460 /*! 02461 * \brief A channel iterator 02462 * 02463 * This is an opaque type. 02464 */ 02465 struct ast_channel_iterator; 02466 02467 /*! 02468 * \brief Destroy a channel iterator 02469 * 02470 * \param i the itereator to destroy 02471 * 02472 * \details 02473 * This function is used to destroy a channel iterator that was retrieved by 02474 * using one of the channel_iterator_xxx_new() functions. 02475 * 02476 * \return NULL, for convenience to clear out the pointer to the iterator that 02477 * was just destroyed. 02478 * 02479 * \since 1.8 02480 */ 02481 struct ast_channel_iterator *ast_channel_iterator_destroy(struct ast_channel_iterator *i); 02482 02483 /*! 02484 * \brief Create a new channel iterator based on extension 02485 * 02486 * \param exten The extension that channels must be in 02487 * \param context The context that channels must be in 02488 * 02489 * \details 02490 * After creating an iterator using this function, the ast_channel_iterator_next() 02491 * function can be used to iterate through all channels that are currently 02492 * in the specified context and extension. 02493 * 02494 * \note You must call ast_channel_iterator_destroy() when done. 02495 * 02496 * \retval NULL on failure 02497 * \retval a new channel iterator based on the specified parameters 02498 * 02499 * \since 1.8 02500 */ 02501 struct ast_channel_iterator *ast_channel_iterator_by_exten_new(const char *exten, const char *context); 02502 02503 /*! 02504 * \brief Create a new channel iterator based on name 02505 * 02506 * \param name channel name or channel uniqueid to match 02507 * \param name_len number of characters in the channel name to match on. This 02508 * would be used to match based on name prefix. If matching on the full 02509 * channel name is desired, then this parameter should be 0. 02510 * 02511 * \details 02512 * After creating an iterator using this function, the ast_channel_iterator_next() 02513 * function can be used to iterate through all channels that exist that have 02514 * the specified name or name prefix. 02515 * 02516 * \note You must call ast_channel_iterator_destroy() when done. 02517 * 02518 * \retval NULL on failure 02519 * \retval a new channel iterator based on the specified parameters 02520 * 02521 * \since 1.8 02522 */ 02523 struct ast_channel_iterator *ast_channel_iterator_by_name_new(const char *name, size_t name_len); 02524 02525 /*! 02526 * \brief Create a new channel iterator 02527 * 02528 * \details 02529 * After creating an iterator using this function, the ast_channel_iterator_next() 02530 * function can be used to iterate through all channels that exist. 02531 * 02532 * \note You must call ast_channel_iterator_destroy() when done. 02533 * 02534 * \retval NULL on failure 02535 * \retval a new channel iterator 02536 * 02537 * \since 1.8 02538 */ 02539 struct ast_channel_iterator *ast_channel_iterator_all_new(void); 02540 02541 /*! 02542 * \brief Get the next channel for a channel iterator 02543 * 02544 * \param i the channel iterator that was created using one of the 02545 * channel_iterator_xxx_new() functions. 02546 * 02547 * \details 02548 * This function should be used to iterate through all channels that match a 02549 * specified set of parameters that were provided when the iterator was created. 02550 * 02551 * \retval the next channel that matches the parameters used when the iterator 02552 * was created. 02553 * \retval NULL, if no more channels match the iterator parameters. 02554 * 02555 * \since 1.8 02556 */ 02557 struct ast_channel *ast_channel_iterator_next(struct ast_channel_iterator *i); 02558 02559 /*! @} End channel iterator definitions. */ 02560 02561 /*! 02562 * \brief Call a function with every active channel 02563 * 02564 * \details 02565 * This function executes a callback one time for each active channel on the 02566 * system. The channel is provided as an argument to the function. 02567 * 02568 * \note Absolutely _NO_ channel locks should be held before calling this function. 02569 * \since 1.8 02570 */ 02571 struct ast_channel *ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg, 02572 void *data, int ao2_flags); 02573 02574 /*! @{ Channel search functions */ 02575 02576 /*! 02577 * \brief Find a channel by name 02578 * 02579 * \param name the name or uniqueid of the channel to search for 02580 * 02581 * \details 02582 * Find a channel that has the same name as the provided argument. 02583 * 02584 * \retval a channel with the name specified by the argument 02585 * \retval NULL if no channel was found 02586 * 02587 * \since 1.8 02588 */ 02589 struct ast_channel *ast_channel_get_by_name(const char *name); 02590 02591 /*! 02592 * \brief Find a channel by a name prefix 02593 * 02594 * \param name The channel name or uniqueid prefix to search for 02595 * \param name_len Only search for up to this many characters from the name 02596 * 02597 * \details 02598 * Find a channel that has the same name prefix as specified by the arguments. 02599 * 02600 * \retval a channel with the name prefix specified by the arguments 02601 * \retval NULL if no channel was found 02602 * 02603 * \since 1.8 02604 */ 02605 struct ast_channel *ast_channel_get_by_name_prefix(const char *name, size_t name_len); 02606 02607 /*! 02608 * \brief Find a channel by extension and context 02609 * 02610 * \param exten the extension to search for 02611 * \param context the context to search for 02612 * 02613 * \details 02614 * Return a channel that is currently at the specified extension and context. 02615 * 02616 * \retval a channel that is at the specified extension and context 02617 * \retval NULL if no channel was found 02618 * 02619 * \since 1.8 02620 */ 02621 struct ast_channel *ast_channel_get_by_exten(const char *exten, const char *context); 02622 02623 /*! @} End channel search functions. */ 02624 02625 /*! 02626 \brief propagate the linked id between chan and peer 02627 */ 02628 void ast_channel_set_linkgroup(struct ast_channel *chan, struct ast_channel *peer); 02629 02630 02631 /*! 02632 * \brief Initialize the given name structure. 02633 * \since 1.8 02634 * 02635 * \param init Name structure to initialize. 02636 * 02637 * \return Nothing 02638 */ 02639 void ast_party_name_init(struct ast_party_name *init); 02640 02641 /*! 02642 * \brief Copy the source party name information to the destination party name. 02643 * \since 1.8 02644 * 02645 * \param dest Destination party name 02646 * \param src Source party name 02647 * 02648 * \return Nothing 02649 */ 02650 void ast_party_name_copy(struct ast_party_name *dest, const struct ast_party_name *src); 02651 02652 /*! 02653 * \brief Initialize the given party name structure using the given guide 02654 * for a set update operation. 02655 * \since 1.8 02656 * 02657 * \details 02658 * The initialization is needed to allow a set operation to know if a 02659 * value needs to be updated. Simple integers need the guide's original 02660 * value in case the set operation is not trying to set a new value. 02661 * String values are simply set to NULL pointers if they are not going 02662 * to be updated. 02663 * 02664 * \param init Party name structure to initialize. 02665 * \param guide Source party name to use as a guide in initializing. 02666 * 02667 * \return Nothing 02668 */ 02669 void ast_party_name_set_init(struct ast_party_name *init, const struct ast_party_name *guide); 02670 02671 /*! 02672 * \brief Set the source party name information into the destination party name. 02673 * \since 1.8 02674 * 02675 * \param dest The name one wishes to update 02676 * \param src The new name values to update the dest 02677 * 02678 * \return Nothing 02679 */ 02680 void ast_party_name_set(struct ast_party_name *dest, const struct ast_party_name *src); 02681 02682 /*! 02683 * \brief Destroy the party name contents 02684 * \since 1.8 02685 * 02686 * \param doomed The party name to destroy. 02687 * 02688 * \return Nothing 02689 */ 02690 void ast_party_name_free(struct ast_party_name *doomed); 02691 02692 /*! 02693 * \brief Initialize the given number structure. 02694 * \since 1.8 02695 * 02696 * \param init Number structure to initialize. 02697 * 02698 * \return Nothing 02699 */ 02700 void ast_party_number_init(struct ast_party_number *init); 02701 02702 /*! 02703 * \brief Copy the source party number information to the destination party number. 02704 * \since 1.8 02705 * 02706 * \param dest Destination party number 02707 * \param src Source party number 02708 * 02709 * \return Nothing 02710 */ 02711 void ast_party_number_copy(struct ast_party_number *dest, const struct ast_party_number *src); 02712 02713 /*! 02714 * \brief Initialize the given party number structure using the given guide 02715 * for a set update operation. 02716 * \since 1.8 02717 * 02718 * \details 02719 * The initialization is needed to allow a set operation to know if a 02720 * value needs to be updated. Simple integers need the guide's original 02721 * value in case the set operation is not trying to set a new value. 02722 * String values are simply set to NULL pointers if they are not going 02723 * to be updated. 02724 * 02725 * \param init Party number structure to initialize. 02726 * \param guide Source party number to use as a guide in initializing. 02727 * 02728 * \return Nothing 02729 */ 02730 void ast_party_number_set_init(struct ast_party_number *init, const struct ast_party_number *guide); 02731 02732 /*! 02733 * \brief Set the source party number information into the destination party number. 02734 * \since 1.8 02735 * 02736 * \param dest The number one wishes to update 02737 * \param src The new number values to update the dest 02738 * 02739 * \return Nothing 02740 */ 02741 void ast_party_number_set(struct ast_party_number *dest, const struct ast_party_number *src); 02742 02743 /*! 02744 * \brief Destroy the party number contents 02745 * \since 1.8 02746 * 02747 * \param doomed The party number to destroy. 02748 * 02749 * \return Nothing 02750 */ 02751 void ast_party_number_free(struct ast_party_number *doomed); 02752 02753 /*! 02754 * \since 1.8 02755 * \brief Initialize the given subaddress structure. 02756 * 02757 * \param init Subaddress structure to initialize. 02758 * 02759 * \return Nothing 02760 */ 02761 void ast_party_subaddress_init(struct ast_party_subaddress *init); 02762 02763 /*! 02764 * \since 1.8 02765 * \brief Copy the source party subaddress information to the destination party subaddress. 02766 * 02767 * \param dest Destination party subaddress 02768 * \param src Source party subaddress 02769 * 02770 * \return Nothing 02771 */ 02772 void ast_party_subaddress_copy(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src); 02773 02774 /*! 02775 * \since 1.8 02776 * \brief Initialize the given party subaddress structure using the given guide 02777 * for a set update operation. 02778 * 02779 * \details 02780 * The initialization is needed to allow a set operation to know if a 02781 * value needs to be updated. Simple integers need the guide's original 02782 * value in case the set operation is not trying to set a new value. 02783 * String values are simply set to NULL pointers if they are not going 02784 * to be updated. 02785 * 02786 * \param init Party subaddress structure to initialize. 02787 * \param guide Source party subaddress to use as a guide in initializing. 02788 * 02789 * \return Nothing 02790 */ 02791 void ast_party_subaddress_set_init(struct ast_party_subaddress *init, const struct ast_party_subaddress *guide); 02792 02793 /*! 02794 * \since 1.8 02795 * \brief Set the source party subaddress information into the destination party subaddress. 02796 * 02797 * \param dest The subaddress one wishes to update 02798 * \param src The new subaddress values to update the dest 02799 * 02800 * \return Nothing 02801 */ 02802 void ast_party_subaddress_set(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src); 02803 02804 /*! 02805 * \since 1.8 02806 * \brief Destroy the party subaddress contents 02807 * 02808 * \param doomed The party subaddress to destroy. 02809 * 02810 * \return Nothing 02811 */ 02812 void ast_party_subaddress_free(struct ast_party_subaddress *doomed); 02813 02814 /*! 02815 * \brief Initialize the given party id structure. 02816 * \since 1.8 02817 * 02818 * \param init Party id structure to initialize. 02819 * 02820 * \return Nothing 02821 */ 02822 void ast_party_id_init(struct ast_party_id *init); 02823 02824 /*! 02825 * \brief Copy the source party id information to the destination party id. 02826 * \since 1.8 02827 * 02828 * \param dest Destination party id 02829 * \param src Source party id 02830 * 02831 * \return Nothing 02832 */ 02833 void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src); 02834 02835 /*! 02836 * \brief Initialize the given party id structure using the given guide 02837 * for a set update operation. 02838 * \since 1.8 02839 * 02840 * \details 02841 * The initialization is needed to allow a set operation to know if a 02842 * value needs to be updated. Simple integers need the guide's original 02843 * value in case the set operation is not trying to set a new value. 02844 * String values are simply set to NULL pointers if they are not going 02845 * to be updated. 02846 * 02847 * \param init Party id structure to initialize. 02848 * \param guide Source party id to use as a guide in initializing. 02849 * 02850 * \return Nothing 02851 */ 02852 void ast_party_id_set_init(struct ast_party_id *init, const struct ast_party_id *guide); 02853 02854 /*! 02855 * \brief Set the source party id information into the destination party id. 02856 * \since 1.8 02857 * 02858 * \param dest The id one wishes to update 02859 * \param src The new id values to update the dest 02860 * \param update What id information to update. NULL if all. 02861 * 02862 * \return Nothing 02863 */ 02864 void ast_party_id_set(struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update); 02865 02866 /*! 02867 * \brief Destroy the party id contents 02868 * \since 1.8 02869 * 02870 * \param doomed The party id to destroy. 02871 * 02872 * \return Nothing 02873 */ 02874 void ast_party_id_free(struct ast_party_id *doomed); 02875 02876 /*! 02877 * \brief Determine the overall presentation value for the given party. 02878 * \since 1.8 02879 * 02880 * \param id Party to determine the overall presentation value. 02881 * 02882 * \return Overall presentation value for the given party. 02883 */ 02884 int ast_party_id_presentation(const struct ast_party_id *id); 02885 02886 /*! 02887 * \brief Initialize the given dialed structure. 02888 * \since 1.8 02889 * 02890 * \param init Dialed structure to initialize. 02891 * 02892 * \return Nothing 02893 */ 02894 void ast_party_dialed_init(struct ast_party_dialed *init); 02895 02896 /*! 02897 * \brief Copy the source dialed party information to the destination dialed party. 02898 * \since 1.8 02899 * 02900 * \param dest Destination dialed party 02901 * \param src Source dialed party 02902 * 02903 * \return Nothing 02904 */ 02905 void ast_party_dialed_copy(struct ast_party_dialed *dest, const struct ast_party_dialed *src); 02906 02907 /*! 02908 * \brief Initialize the given dialed structure using the given 02909 * guide for a set update operation. 02910 * \since 1.8 02911 * 02912 * \details 02913 * The initialization is needed to allow a set operation to know if a 02914 * value needs to be updated. Simple integers need the guide's original 02915 * value in case the set operation is not trying to set a new value. 02916 * String values are simply set to NULL pointers if they are not going 02917 * to be updated. 02918 * 02919 * \param init Caller structure to initialize. 02920 * \param guide Source dialed to use as a guide in initializing. 02921 * 02922 * \return Nothing 02923 */ 02924 void ast_party_dialed_set_init(struct ast_party_dialed *init, const struct ast_party_dialed *guide); 02925 02926 /*! 02927 * \brief Set the dialed information based on another dialed source 02928 * \since 1.8 02929 * 02930 * This is similar to ast_party_dialed_copy, except that NULL values for 02931 * strings in the src parameter indicate not to update the corresponding dest values. 02932 * 02933 * \param dest The dialed one wishes to update 02934 * \param src The new dialed values to update the dest 02935 * 02936 * \return Nada 02937 */ 02938 void ast_party_dialed_set(struct ast_party_dialed *dest, const struct ast_party_dialed *src); 02939 02940 /*! 02941 * \brief Destroy the dialed party contents 02942 * \since 1.8 02943 * 02944 * \param doomed The dialed party to destroy. 02945 * 02946 * \return Nothing 02947 */ 02948 void ast_party_dialed_free(struct ast_party_dialed *doomed); 02949 02950 /*! 02951 * \since 1.8 02952 * \brief Initialize the given caller structure. 02953 * 02954 * \param init Caller structure to initialize. 02955 * 02956 * \return Nothing 02957 */ 02958 void ast_party_caller_init(struct ast_party_caller *init); 02959 02960 /*! 02961 * \since 1.8 02962 * \brief Copy the source caller information to the destination caller. 02963 * 02964 * \param dest Destination caller 02965 * \param src Source caller 02966 * 02967 * \return Nothing 02968 */ 02969 void ast_party_caller_copy(struct ast_party_caller *dest, const struct ast_party_caller *src); 02970 02971 /*! 02972 * \brief Initialize the given caller structure using the given 02973 * guide for a set update operation. 02974 * \since 1.8 02975 * 02976 * \details 02977 * The initialization is needed to allow a set operation to know if a 02978 * value needs to be updated. Simple integers need the guide's original 02979 * value in case the set operation is not trying to set a new value. 02980 * String values are simply set to NULL pointers if they are not going 02981 * to be updated. 02982 * 02983 * \param init Caller structure to initialize. 02984 * \param guide Source caller to use as a guide in initializing. 02985 * 02986 * \return Nothing 02987 */ 02988 void ast_party_caller_set_init(struct ast_party_caller *init, const struct ast_party_caller *guide); 02989 02990 /*! 02991 * \brief Set the caller information based on another caller source 02992 * \since 1.8 02993 * 02994 * This is similar to ast_party_caller_copy, except that NULL values for 02995 * strings in the src parameter indicate not to update the corresponding dest values. 02996 * 02997 * \param dest The caller one wishes to update 02998 * \param src The new caller values to update the dest 02999 * \param update What caller information to update. NULL if all. 03000 * 03001 * \return Nada 03002 */ 03003 void ast_party_caller_set(struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update); 03004 03005 /*! 03006 * \brief Destroy the caller party contents 03007 * \since 1.8 03008 * 03009 * \param doomed The caller party to destroy. 03010 * 03011 * \return Nothing 03012 */ 03013 void ast_party_caller_free(struct ast_party_caller *doomed); 03014 03015 /*! 03016 * \since 1.8 03017 * \brief Initialize the given connected line structure. 03018 * 03019 * \param init Connected line structure to initialize. 03020 * 03021 * \return Nothing 03022 */ 03023 void ast_party_connected_line_init(struct ast_party_connected_line *init); 03024 03025 /*! 03026 * \since 1.8 03027 * \brief Copy the source connected line information to the destination connected line. 03028 * 03029 * \param dest Destination connected line 03030 * \param src Source connected line 03031 * 03032 * \return Nothing 03033 */ 03034 void ast_party_connected_line_copy(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src); 03035 03036 /*! 03037 * \since 1.8 03038 * \brief Initialize the given connected line structure using the given 03039 * guide for a set update operation. 03040 * 03041 * \details 03042 * The initialization is needed to allow a set operation to know if a 03043 * value needs to be updated. Simple integers need the guide's original 03044 * value in case the set operation is not trying to set a new value. 03045 * String values are simply set to NULL pointers if they are not going 03046 * to be updated. 03047 * 03048 * \param init Connected line structure to initialize. 03049 * \param guide Source connected line to use as a guide in initializing. 03050 * 03051 * \return Nothing 03052 */ 03053 void ast_party_connected_line_set_init(struct ast_party_connected_line *init, const struct ast_party_connected_line *guide); 03054 03055 /*! 03056 * \since 1.8 03057 * \brief Set the connected line information based on another connected line source 03058 * 03059 * This is similar to ast_party_connected_line_copy, except that NULL values for 03060 * strings in the src parameter indicate not to update the corresponding dest values. 03061 * 03062 * \param dest The connected line one wishes to update 03063 * \param src The new connected line values to update the dest 03064 * \param update What connected line information to update. NULL if all. 03065 * 03066 * \return Nothing 03067 */ 03068 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); 03069 03070 /*! 03071 * \since 1.8 03072 * \brief Collect the caller party information into a connected line structure. 03073 * 03074 * \param connected Collected caller information for the connected line 03075 * \param caller Caller information. 03076 * 03077 * \return Nothing 03078 * 03079 * \warning This is a shallow copy. 03080 * \warning DO NOT call ast_party_connected_line_free() on the filled in 03081 * connected line structure! 03082 */ 03083 void ast_party_connected_line_collect_caller(struct ast_party_connected_line *connected, struct ast_party_caller *caller); 03084 03085 /*! 03086 * \since 1.8 03087 * \brief Destroy the connected line information contents 03088 * 03089 * \param doomed The connected line information to destroy. 03090 * 03091 * \return Nothing 03092 */ 03093 void ast_party_connected_line_free(struct ast_party_connected_line *doomed); 03094 03095 /*! 03096 * \brief Initialize the given redirecting structure. 03097 * \since 1.8 03098 * 03099 * \param init Redirecting structure to initialize. 03100 * 03101 * \return Nothing 03102 */ 03103 void ast_party_redirecting_init(struct ast_party_redirecting *init); 03104 03105 /*! 03106 * \since 1.8 03107 * \brief Copy the source redirecting information to the destination redirecting. 03108 * 03109 * \param dest Destination redirecting 03110 * \param src Source redirecting 03111 * 03112 * \return Nothing 03113 */ 03114 void ast_party_redirecting_copy(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src); 03115 03116 /*! 03117 * \since 1.8 03118 * \brief Initialize the given redirecting id structure using the given guide 03119 * for a set update operation. 03120 * 03121 * \details 03122 * The initialization is needed to allow a set operation to know if a 03123 * value needs to be updated. Simple integers need the guide's original 03124 * value in case the set operation is not trying to set a new value. 03125 * String values are simply set to NULL pointers if they are not going 03126 * to be updated. 03127 * 03128 * \param init Redirecting id structure to initialize. 03129 * \param guide Source redirecting id to use as a guide in initializing. 03130 * 03131 * \return Nothing 03132 */ 03133 void ast_party_redirecting_set_init(struct ast_party_redirecting *init, const struct ast_party_redirecting *guide); 03134 03135 /*! 03136 * \brief Set the redirecting information based on another redirecting source 03137 * \since 1.8 03138 * 03139 * This is similar to ast_party_redirecting_copy, except that NULL values for 03140 * strings in the src parameter indicate not to update the corresponding dest values. 03141 * 03142 * \param dest The redirecting one wishes to update 03143 * \param src The new redirecting values to update the dest 03144 * \param update What redirecting information to update. NULL if all. 03145 * 03146 * \return Nothing 03147 */ 03148 void ast_party_redirecting_set(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src, const struct ast_set_party_redirecting *update); 03149 03150 /*! 03151 * \since 1.8 03152 * \brief Destroy the redirecting information contents 03153 * 03154 * \param doomed The redirecting information to destroy. 03155 * 03156 * \return Nothing 03157 */ 03158 void ast_party_redirecting_free(struct ast_party_redirecting *doomed); 03159 03160 /*! 03161 * \since 1.8 03162 * \brief Copy the caller information to the connected line information. 03163 * 03164 * \param dest Destination connected line information 03165 * \param src Source caller information 03166 * 03167 * \return Nothing 03168 * 03169 * \note Assumes locks are already acquired 03170 */ 03171 void ast_connected_line_copy_from_caller(struct ast_party_connected_line *dest, const struct ast_party_caller *src); 03172 03173 /*! 03174 * \since 1.8 03175 * \brief Copy the connected line information to the caller information. 03176 * 03177 * \param dest Destination caller information 03178 * \param src Source connected line information 03179 * 03180 * \return Nothing 03181 * 03182 * \note Assumes locks are already acquired 03183 */ 03184 void ast_connected_line_copy_to_caller(struct ast_party_caller *dest, const struct ast_party_connected_line *src); 03185 03186 /*! 03187 * \since 1.8 03188 * \brief Set the connected line information in the Asterisk channel 03189 * 03190 * \param chan Asterisk channel to set connected line information 03191 * \param connected Connected line information 03192 * \param update What connected line information to update. NULL if all. 03193 * 03194 * \return Nothing 03195 * 03196 * \note The channel does not need to be locked before calling this function. 03197 */ 03198 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); 03199 03200 /*! 03201 * \since 1.8 03202 * \brief Build the connected line information data frame. 03203 * 03204 * \param data Buffer to fill with the frame data 03205 * \param datalen Size of the buffer to fill 03206 * \param connected Connected line information 03207 * \param update What connected line information to build. NULL if all. 03208 * 03209 * \retval -1 if error 03210 * \retval Amount of data buffer used 03211 */ 03212 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); 03213 03214 /*! 03215 * \since 1.8 03216 * \brief Parse connected line indication frame data 03217 * 03218 * \param data Buffer with the frame data to parse 03219 * \param datalen Size of the buffer 03220 * \param connected Extracted connected line information 03221 * 03222 * \retval 0 on success. 03223 * \retval -1 on error. 03224 * 03225 * \note The filled in connected line structure needs to be initialized by 03226 * ast_party_connected_line_set_init() before calling. If defaults are not 03227 * required use ast_party_connected_line_init(). 03228 * \note The filled in connected line structure needs to be destroyed by 03229 * ast_party_connected_line_free() when it is no longer needed. 03230 */ 03231 int ast_connected_line_parse_data(const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected); 03232 03233 /*! 03234 * \since 1.8 03235 * \brief Indicate that the connected line information has changed 03236 * 03237 * \param chan Asterisk channel to indicate connected line information 03238 * \param connected Connected line information 03239 * \param update What connected line information to update. NULL if all. 03240 * 03241 * \return Nothing 03242 */ 03243 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); 03244 03245 /*! 03246 * \since 1.8 03247 * \brief Queue a connected line update frame on a channel 03248 * 03249 * \param chan Asterisk channel to indicate connected line information 03250 * \param connected Connected line information 03251 * \param update What connected line information to update. NULL if all. 03252 * 03253 * \return Nothing 03254 */ 03255 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); 03256 03257 /*! 03258 * \since 1.8 03259 * \brief Set the redirecting id information in the Asterisk channel 03260 * 03261 * \param chan Asterisk channel to set redirecting id information 03262 * \param redirecting Redirecting id information 03263 * \param update What redirecting information to update. NULL if all. 03264 * 03265 * \return Nothing 03266 * 03267 * \note The channel does not need to be locked before calling this function. 03268 */ 03269 void ast_channel_set_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update); 03270 03271 /*! 03272 * \since 1.8 03273 * \brief Build the redirecting id data frame. 03274 * 03275 * \param data Buffer to fill with the frame data 03276 * \param datalen Size of the buffer to fill 03277 * \param redirecting Redirecting id information 03278 * \param update What redirecting information to build. NULL if all. 03279 * 03280 * \retval -1 if error 03281 * \retval Amount of data buffer used 03282 */ 03283 int ast_redirecting_build_data(unsigned char *data, size_t datalen, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update); 03284 03285 /*! 03286 * \since 1.8 03287 * \brief Parse redirecting indication frame data 03288 * 03289 * \param data Buffer with the frame data to parse 03290 * \param datalen Size of the buffer 03291 * \param redirecting Extracted redirecting id information 03292 * 03293 * \retval 0 on success. 03294 * \retval -1 on error. 03295 * 03296 * \note The filled in id structure needs to be initialized by 03297 * ast_party_redirecting_set_init() before calling. 03298 * \note The filled in id structure needs to be destroyed by 03299 * ast_party_redirecting_free() when it is no longer needed. 03300 */ 03301 int ast_redirecting_parse_data(const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting); 03302 03303 /*! 03304 * \since 1.8 03305 * \brief Indicate that the redirecting id has changed 03306 * 03307 * \param chan Asterisk channel to indicate redirecting id information 03308 * \param redirecting Redirecting id information 03309 * \param update What redirecting information to update. NULL if all. 03310 * 03311 * \return Nothing 03312 */ 03313 void ast_channel_update_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update); 03314 03315 /*! 03316 * \since 1.8 03317 * \brief Queue a redirecting update frame on a channel 03318 * 03319 * \param chan Asterisk channel to indicate redirecting id information 03320 * \param redirecting Redirecting id information 03321 * \param update What redirecting information to update. NULL if all. 03322 * 03323 * \return Nothing 03324 */ 03325 void ast_channel_queue_redirecting_update(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update); 03326 03327 /*! 03328 * \since 1.8 03329 * \brief Run a connected line interception macro and update a channel's connected line 03330 * information 03331 * \deprecated You should use the ast_channel_connected_line_sub() function instead. 03332 * 03333 * Whenever we want to update a channel's connected line information, we may need to run 03334 * a macro so that an administrator can manipulate the information before sending it 03335 * out. This function both runs the macro and sends the update to the channel. 03336 * 03337 * \param autoservice_chan Channel to place into autoservice while the macro is running. 03338 * It is perfectly safe for this to be NULL 03339 * \param macro_chan The channel to run the macro on. Also the channel from which we 03340 * determine which macro we need to run. 03341 * \param connected_info Either an ast_party_connected_line or ast_frame pointer of type 03342 * AST_CONTROL_CONNECTED_LINE 03343 * \param is_caller If true, then run CONNECTED_LINE_CALLER_SEND_MACRO with arguments from 03344 * CONNECTED_LINE_CALLER_SEND_MACRO_ARGS, otherwise run CONNECTED_LINE_CALLEE_SEND_MACRO 03345 * with arguments from CONNECTED_LINE_CALLEE_SEND_MACRO_ARGS 03346 * \param frame If true, then connected_info is an ast_frame pointer, otherwise it is an 03347 * ast_party_connected_line pointer. 03348 * \retval 0 Success 03349 * \retval -1 Either the macro does not exist, or there was an error while attempting to 03350 * run the macro 03351 * 03352 * \todo Have multiple return codes based on the MACRO_RESULT 03353 * \todo Make constants so that caller and frame can be more expressive than just '1' and 03354 * '0' 03355 */ 03356 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); 03357 03358 /*! 03359 * \since 11 03360 * \brief Run a connected line interception subroutine and update a channel's connected line 03361 * information 03362 * 03363 * Whenever we want to update a channel's connected line information, we may need to run 03364 * a subroutine so that an administrator can manipulate the information before sending it 03365 * out. This function both runs the subroutine specified by CONNECTED_LINE_SEND_SUB and 03366 * sends the update to the channel. 03367 * 03368 * \param autoservice_chan Channel to place into autoservice while the sub is running. 03369 * It is perfectly safe for this to be NULL 03370 * \param sub_chan The channel to run the subroutine on. Also the channel from which we 03371 * determine which subroutine we need to run. 03372 * \param connected_info Either an ast_party_connected_line or ast_frame pointer of type 03373 * AST_CONTROL_CONNECTED_LINE 03374 * \param frame If true, then connected_info is an ast_frame pointer, otherwise it is an 03375 * ast_party_connected_line pointer. 03376 * \retval 0 Success 03377 * \retval -1 Either the subroutine does not exist, or there was an error while attempting to 03378 * run the subroutine 03379 */ 03380 int ast_channel_connected_line_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *connected_info, int frame); 03381 03382 /*! 03383 * \brief Insert into an astdata tree, the channel structure. 03384 * \param[in] tree The ast data tree. 03385 * \param[in] chan The channel structure to add to tree. 03386 * \param[in] add_bridged Add the bridged channel to the structure. 03387 * \retval <0 on error. 03388 * \retval 0 on success. 03389 */ 03390 int ast_channel_data_add_structure(struct ast_data *tree, struct ast_channel *chan, int add_bridged); 03391 03392 /*! 03393 * \brief Compare to channel structures using the data api. 03394 * \param[in] tree The search tree generated by the data api. 03395 * \param[in] chan The channel to compare. 03396 * \param[in] structure_name The name of the node of the channel structure. 03397 * \retval 0 The structure matches. 03398 * \retval 1 The structure doesn't matches. 03399 */ 03400 int ast_channel_data_cmp_structure(const struct ast_data_search *tree, struct ast_channel *chan, 03401 const char *structure_name); 03402 03403 /*! 03404 * \since 1.8 03405 * \brief Run a redirecting interception macro and update a channel's redirecting information 03406 * \deprecated You should use the ast_channel_redirecting_sub() function instead. 03407 * 03408 * \details 03409 * Whenever we want to update a channel's redirecting information, we may need to run 03410 * a macro so that an administrator can manipulate the information before sending it 03411 * out. This function both runs the macro and sends the update to the channel. 03412 * 03413 * \param autoservice_chan Channel to place into autoservice while the macro is running. 03414 * It is perfectly safe for this to be NULL 03415 * \param macro_chan The channel to run the macro on. Also the channel from which we 03416 * determine which macro we need to run. 03417 * \param redirecting_info Either an ast_party_redirecting or ast_frame pointer of type 03418 * AST_CONTROL_REDIRECTING 03419 * \param is_caller If true, then run REDIRECTING_CALLER_SEND_MACRO with arguments from 03420 * REDIRECTING_CALLER_SEND_MACRO_ARGS, otherwise run REDIRECTING_CALLEE_SEND_MACRO with 03421 * arguments from REDIRECTING_CALLEE_SEND_MACRO_ARGS 03422 * \param is_frame If true, then redirecting_info is an ast_frame pointer, otherwise it is an 03423 * ast_party_redirecting pointer. 03424 * 03425 * \retval 0 Success 03426 * \retval -1 Either the macro does not exist, or there was an error while attempting to 03427 * run the macro 03428 * 03429 * \todo Have multiple return codes based on the MACRO_RESULT 03430 * \todo Make constants so that caller and frame can be more expressive than just '1' and 03431 * '0' 03432 */ 03433 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); 03434 03435 /*! 03436 * \since 11 03437 * \brief Run a redirecting interception subroutine and update a channel's redirecting information 03438 * 03439 * \details 03440 * Whenever we want to update a channel's redirecting information, we may need to run 03441 * a subroutine so that an administrator can manipulate the information before sending it 03442 * out. This function both runs the subroutine specified by REDIRECTING_SEND_SUB and 03443 * sends the update to the channel. 03444 * 03445 * \param autoservice_chan Channel to place into autoservice while the subroutine is running. 03446 * It is perfectly safe for this to be NULL 03447 * \param sub_chan The channel to run the subroutine on. Also the channel from which we 03448 * determine which subroutine we need to run. 03449 * \param redirecting_info Either an ast_party_redirecting or ast_frame pointer of type 03450 * AST_CONTROL_REDIRECTING 03451 * \param is_frame If true, then redirecting_info is an ast_frame pointer, otherwise it is an 03452 * ast_party_redirecting pointer. 03453 * 03454 * \retval 0 Success 03455 * \retval -1 Either the subroutine does not exist, or there was an error while attempting to 03456 * run the subroutine 03457 */ 03458 int ast_channel_redirecting_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *redirecting_info, int is_frame); 03459 03460 #include "asterisk/ccss.h" 03461 03462 /*! 03463 * \since 1.8 03464 * \brief Set up datastore with CCSS parameters for a channel 03465 * 03466 * \note 03467 * If base_params is NULL, the channel will get the default 03468 * values for all CCSS parameters. 03469 * 03470 * \details 03471 * This function makes use of datastore operations on the channel, so 03472 * it is important to lock the channel before calling this function. 03473 * 03474 * \param chan The channel to create the datastore on 03475 * \param base_params CCSS parameters we wish to copy into the channel 03476 * \retval 0 Success 03477 * \retval -1 Failure 03478 */ 03479 int ast_channel_cc_params_init(struct ast_channel *chan, 03480 const struct ast_cc_config_params *base_params); 03481 03482 /*! 03483 * \since 1.8 03484 * \brief Get the CCSS parameters from a channel 03485 * 03486 * \details 03487 * This function makes use of datastore operations on the channel, so 03488 * it is important to lock the channel before calling this function. 03489 * 03490 * \param chan Channel to retrieve parameters from 03491 * \retval NULL Failure 03492 * \retval non-NULL The parameters desired 03493 */ 03494 struct ast_cc_config_params *ast_channel_get_cc_config_params(struct ast_channel *chan); 03495 03496 03497 /*! 03498 * \since 1.8 03499 * \brief Get a device name given its channel structure 03500 * 03501 * \details 03502 * A common practice in Asterisk is to determine the device being talked 03503 * to by dissecting the channel name. For certain channel types, this is not 03504 * accurate. For instance, an ISDN channel is named based on what B channel is 03505 * used, not the device being communicated with. 03506 * 03507 * This function interfaces with a channel tech's queryoption callback to 03508 * retrieve the name of the device being communicated with. If the channel does not 03509 * implement this specific option, then the traditional method of using the channel 03510 * name is used instead. 03511 * 03512 * \param chan The channel to retrieve the information from 03513 * \param[out] device_name The buffer to place the device's name into 03514 * \param name_buffer_length The allocated space for the device_name 03515 * \return 0 always 03516 */ 03517 int ast_channel_get_device_name(struct ast_channel *chan, char *device_name, size_t name_buffer_length); 03518 03519 /*! 03520 * \since 1.8 03521 * \brief Find the appropriate CC agent type to use given a channel 03522 * 03523 * \details 03524 * During call completion, we will need to create a call completion agent structure. To 03525 * figure out the type of agent to construct, we need to ask the channel driver for the 03526 * appropriate type. 03527 * 03528 * Prior to adding this function, the call completion core attempted to figure this 03529 * out for itself by stripping the technology off the channel's name. However, in the 03530 * case of chan_dahdi, there are multiple agent types registered, and so simply searching 03531 * for an agent type called "DAHDI" is not possible. In a case where multiple agent types 03532 * are defined, the channel driver must have a queryoption callback defined in its 03533 * channel_tech, and the queryoption callback must handle AST_OPTION_CC_AGENT_TYPE 03534 * 03535 * If a channel driver does not have a queryoption callback or if the queryoption callback 03536 * does not handle AST_OPTION_CC_AGENT_TYPE, then the old behavior of using the technology 03537 * portion of the channel name is used instead. This is perfectly suitable for channel drivers 03538 * whose channel technologies are a one-to-one match with the agent types defined within. 03539 * 03540 * Note that this function is only called when the agent policy on a given channel is set 03541 * to "native." Generic agents' type can be determined automatically by the core. 03542 * 03543 * \param chan The channel for which we wish to retrieve the agent type 03544 * \param[out] agent_type The type of agent the channel driver wants us to use 03545 * \param size The size of the buffer to write to 03546 */ 03547 int ast_channel_get_cc_agent_type(struct ast_channel *chan, char *agent_type, size_t size); 03548 #if defined(__cplusplus) || defined(c_plusplus) 03549 } 03550 #endif 03551 03552 /*! 03553 * \brief Remove a channel from the global channels container 03554 * 03555 * \param chan channel to remove 03556 * 03557 * In a case where it is desired that a channel not be available in any lookups 03558 * in the global channels conatiner, use this function. 03559 */ 03560 void ast_channel_unlink(struct ast_channel *chan); 03561 03562 /* ACCESSOR FUNTIONS */ 03563 /*! \brief Set the channel name */ 03564 void ast_channel_name_set(struct ast_channel *chan, const char *name); 03565 03566 #define DECLARE_STRINGFIELD_SETTERS_FOR(field) \ 03567 void ast_channel_##field##_set(struct ast_channel *chan, const char *field); \ 03568 void ast_channel_##field##_build_va(struct ast_channel *chan, const char *fmt, va_list ap) __attribute__((format(printf, 2, 0))); \ 03569 void ast_channel_##field##_build(struct ast_channel *chan, const char *fmt, ...) __attribute__((format(printf, 2, 3))) 03570 03571 DECLARE_STRINGFIELD_SETTERS_FOR(name); 03572 DECLARE_STRINGFIELD_SETTERS_FOR(language); 03573 DECLARE_STRINGFIELD_SETTERS_FOR(musicclass); 03574 DECLARE_STRINGFIELD_SETTERS_FOR(accountcode); 03575 DECLARE_STRINGFIELD_SETTERS_FOR(peeraccount); 03576 DECLARE_STRINGFIELD_SETTERS_FOR(userfield); 03577 DECLARE_STRINGFIELD_SETTERS_FOR(call_forward); 03578 DECLARE_STRINGFIELD_SETTERS_FOR(uniqueid); 03579 DECLARE_STRINGFIELD_SETTERS_FOR(linkedid); 03580 DECLARE_STRINGFIELD_SETTERS_FOR(parkinglot); 03581 DECLARE_STRINGFIELD_SETTERS_FOR(hangupsource); 03582 DECLARE_STRINGFIELD_SETTERS_FOR(dialcontext); 03583 03584 const char *ast_channel_name(const struct ast_channel *chan); 03585 const char *ast_channel_language(const struct ast_channel *chan); 03586 const char *ast_channel_musicclass(const struct ast_channel *chan); 03587 const char *ast_channel_accountcode(const struct ast_channel *chan); 03588 const char *ast_channel_peeraccount(const struct ast_channel *chan); 03589 const char *ast_channel_userfield(const struct ast_channel *chan); 03590 const char *ast_channel_call_forward(const struct ast_channel *chan); 03591 const char *ast_channel_uniqueid(const struct ast_channel *chan); 03592 const char *ast_channel_linkedid(const struct ast_channel *chan); 03593 const char *ast_channel_parkinglot(const struct ast_channel *chan); 03594 const char *ast_channel_hangupsource(const struct ast_channel *chan); 03595 const char *ast_channel_dialcontext(const struct ast_channel *chan); 03596 03597 const char *ast_channel_appl(const struct ast_channel *chan); 03598 void ast_channel_appl_set(struct ast_channel *chan, const char *value); 03599 const char *ast_channel_blockproc(const struct ast_channel *chan); 03600 void ast_channel_blockproc_set(struct ast_channel *chan, const char *value); 03601 const char *ast_channel_data(const struct ast_channel *chan); 03602 void ast_channel_data_set(struct ast_channel *chan, const char *value); 03603 03604 const char *ast_channel_context(const struct ast_channel *chan); 03605 void ast_channel_context_set(struct ast_channel *chan, const char *value); 03606 const char *ast_channel_exten(const struct ast_channel *chan); 03607 void ast_channel_exten_set(struct ast_channel *chan, const char *value); 03608 const char *ast_channel_macrocontext(const struct ast_channel *chan); 03609 void ast_channel_macrocontext_set(struct ast_channel *chan, const char *value); 03610 const char *ast_channel_macroexten(const struct ast_channel *chan); 03611 void ast_channel_macroexten_set(struct ast_channel *chan, const char *value); 03612 03613 char ast_channel_dtmf_digit_to_emulate(const struct ast_channel *chan); 03614 void ast_channel_dtmf_digit_to_emulate_set(struct ast_channel *chan, char value); 03615 int ast_channel_amaflags(const struct ast_channel *chan); 03616 void ast_channel_amaflags_set(struct ast_channel *chan, int value); 03617 int ast_channel_epfd(const struct ast_channel *chan); 03618 void ast_channel_epfd_set(struct ast_channel *chan, int value); 03619 int ast_channel_fdno(const struct ast_channel *chan); 03620 void ast_channel_fdno_set(struct ast_channel *chan, int value); 03621 int ast_channel_hangupcause(const struct ast_channel *chan); 03622 void ast_channel_hangupcause_set(struct ast_channel *chan, int value); 03623 int ast_channel_macropriority(const struct ast_channel *chan); 03624 void ast_channel_macropriority_set(struct ast_channel *chan, int value); 03625 int ast_channel_priority(const struct ast_channel *chan); 03626 void ast_channel_priority_set(struct ast_channel *chan, int value); 03627 int ast_channel_rings(const struct ast_channel *chan); 03628 void ast_channel_rings_set(struct ast_channel *chan, int value); 03629 int ast_channel_streamid(const struct ast_channel *chan); 03630 void ast_channel_streamid_set(struct ast_channel *chan, int value); 03631 int ast_channel_timingfd(const struct ast_channel *chan); 03632 void ast_channel_timingfd_set(struct ast_channel *chan, int value); 03633 int ast_channel_visible_indication(const struct ast_channel *chan); 03634 void ast_channel_visible_indication_set(struct ast_channel *chan, int value); 03635 int ast_channel_vstreamid(const struct ast_channel *chan); 03636 void ast_channel_vstreamid_set(struct ast_channel *chan, int value); 03637 unsigned short ast_channel_transfercapability(const struct ast_channel *chan); 03638 void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value); 03639 unsigned int ast_channel_emulate_dtmf_duration(const struct ast_channel *chan); 03640 void ast_channel_emulate_dtmf_duration_set(struct ast_channel *chan, unsigned int value); 03641 unsigned int ast_channel_fin(const struct ast_channel *chan); 03642 void ast_channel_fin_set(struct ast_channel *chan, unsigned int value); 03643 unsigned int ast_channel_fout(const struct ast_channel *chan); 03644 void ast_channel_fout_set(struct ast_channel *chan, unsigned int value); 03645 unsigned long ast_channel_insmpl(const struct ast_channel *chan); 03646 void ast_channel_insmpl_set(struct ast_channel *chan, unsigned long value); 03647 unsigned long ast_channel_outsmpl(const struct ast_channel *chan); 03648 void ast_channel_outsmpl_set(struct ast_channel *chan, unsigned long value); 03649 void *ast_channel_generatordata(const struct ast_channel *chan); 03650 void ast_channel_generatordata_set(struct ast_channel *chan, void *value); 03651 void *ast_channel_music_state(const struct ast_channel *chan); 03652 void ast_channel_music_state_set(struct ast_channel *chan, void *value); 03653 void *ast_channel_tech_pvt(const struct ast_channel *chan); 03654 void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value); 03655 void *ast_channel_timingdata(const struct ast_channel *chan); 03656 void ast_channel_timingdata_set(struct ast_channel *chan, void *value); 03657 struct ast_audiohook_list *ast_channel_audiohooks(const struct ast_channel *chan); 03658 void ast_channel_audiohooks_set(struct ast_channel *chan, struct ast_audiohook_list *value); 03659 struct ast_cdr *ast_channel_cdr(const struct ast_channel *chan); 03660 void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr *value); 03661 struct ast_channel *ast_channel__bridge(const struct ast_channel *chan); 03662 void ast_channel__bridge_set(struct ast_channel *chan, struct ast_channel *value); 03663 struct ast_channel *ast_channel_masq(const struct ast_channel *chan); 03664 void ast_channel_masq_set(struct ast_channel *chan, struct ast_channel *value); 03665 struct ast_channel *ast_channel_masqr(const struct ast_channel *chan); 03666 void ast_channel_masqr_set(struct ast_channel *chan, struct ast_channel *value); 03667 struct ast_channel_monitor *ast_channel_monitor(const struct ast_channel *chan); 03668 void ast_channel_monitor_set(struct ast_channel *chan, struct ast_channel_monitor *value); 03669 struct ast_filestream *ast_channel_stream(const struct ast_channel *chan); 03670 void ast_channel_stream_set(struct ast_channel *chan, struct ast_filestream *value); 03671 struct ast_filestream *ast_channel_vstream(const struct ast_channel *chan); 03672 void ast_channel_vstream_set(struct ast_channel *chan, struct ast_filestream *value); 03673 struct ast_format_cap *ast_channel_nativeformats(const struct ast_channel *chan); 03674 void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value); 03675 struct ast_framehook_list *ast_channel_framehooks(const struct ast_channel *chan); 03676 void ast_channel_framehooks_set(struct ast_channel *chan, struct ast_framehook_list *value); 03677 struct ast_generator *ast_channel_generator(const struct ast_channel *chan); 03678 void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator *value); 03679 struct ast_pbx *ast_channel_pbx(const struct ast_channel *chan); 03680 void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx *value); 03681 struct ast_sched_context *ast_channel_sched(const struct ast_channel *chan); 03682 void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context *value); 03683 struct ast_timer *ast_channel_timer(const struct ast_channel *chan); 03684 void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer *value); 03685 struct ast_tone_zone *ast_channel_zone(const struct ast_channel *chan); 03686 void ast_channel_zone_set(struct ast_channel *chan, struct ast_tone_zone *value); 03687 struct ast_trans_pvt *ast_channel_readtrans(const struct ast_channel *chan); 03688 void ast_channel_readtrans_set(struct ast_channel *chan, struct ast_trans_pvt *value); 03689 struct ast_trans_pvt *ast_channel_writetrans(const struct ast_channel *chan); 03690 void ast_channel_writetrans_set(struct ast_channel *chan, struct ast_trans_pvt *value); 03691 const struct ast_channel_tech *ast_channel_tech(const struct ast_channel *chan); 03692 void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value); 03693 enum ast_channel_adsicpe ast_channel_adsicpe(const struct ast_channel *chan); 03694 void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value); 03695 enum ast_channel_state ast_channel_state(const struct ast_channel *chan); 03696 03697 /* XXX Internal use only, make sure to move later */ 03698 void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state); 03699 void ast_channel_softhangup_internal_flag_set(struct ast_channel *chan, int value); 03700 void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value); 03701 void ast_channel_softhangup_internal_flag_clear(struct ast_channel *chan, int value); 03702 int ast_channel_softhangup_internal_flag(struct ast_channel *chan); 03703 03704 /* Format getters */ 03705 struct ast_format *ast_channel_oldwriteformat(struct ast_channel *chan); 03706 struct ast_format *ast_channel_rawreadformat(struct ast_channel *chan); 03707 struct ast_format *ast_channel_rawwriteformat(struct ast_channel *chan); 03708 struct ast_format *ast_channel_readformat(struct ast_channel *chan); 03709 struct ast_format *ast_channel_writeformat(struct ast_channel *chan); 03710 03711 /* Other struct getters */ 03712 struct ast_frame *ast_channel_dtmff(struct ast_channel *chan); 03713 struct ast_jb *ast_channel_jb(struct ast_channel *chan); 03714 struct ast_party_caller *ast_channel_caller(struct ast_channel *chan); 03715 struct ast_party_connected_line *ast_channel_connected(struct ast_channel *chan); 03716 struct ast_party_dialed *ast_channel_dialed(struct ast_channel *chan); 03717 struct ast_party_redirecting *ast_channel_redirecting(struct ast_channel *chan); 03718 struct timeval *ast_channel_dtmf_tv(struct ast_channel *chan); 03719 struct timeval *ast_channel_whentohangup(struct ast_channel *chan); 03720 struct varshead *ast_channel_varshead(struct ast_channel *chan); 03721 03722 void ast_channel_dtmff_set(struct ast_channel *chan, struct ast_frame *value); 03723 void ast_channel_jb_set(struct ast_channel *chan, struct ast_jb *value); 03724 void ast_channel_caller_set(struct ast_channel *chan, struct ast_party_caller *value); 03725 void ast_channel_connected_set(struct ast_channel *chan, struct ast_party_connected_line *value); 03726 void ast_channel_dialed_set(struct ast_channel *chan, struct ast_party_dialed *value); 03727 void ast_channel_redirecting_set(struct ast_channel *chan, struct ast_party_redirecting *value); 03728 void ast_channel_dtmf_tv_set(struct ast_channel *chan, struct timeval *value); 03729 void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value); 03730 void ast_channel_varshead_set(struct ast_channel *chan, struct varshead *value); 03731 03732 /* List getters */ 03733 struct ast_datastore_list *ast_channel_datastores(struct ast_channel *chan); 03734 struct ast_autochan_list *ast_channel_autochans(struct ast_channel *chan); 03735 struct ast_readq_list *ast_channel_readq(struct ast_channel *chan); 03736 03737 /* Typedef accessors */ 03738 ast_group_t ast_channel_callgroup(const struct ast_channel *chan); 03739 void ast_channel_callgroup_set(struct ast_channel *chan, ast_group_t value); 03740 ast_group_t ast_channel_pickupgroup(const struct ast_channel *chan); 03741 void ast_channel_pickupgroup_set(struct ast_channel *chan, ast_group_t value); 03742 03743 /* Alertpipe accessors--the "internal" functions for channel.c use only */ 03744 typedef enum { 03745 AST_ALERT_READ_SUCCESS = 0, 03746 AST_ALERT_NOT_READABLE, 03747 AST_ALERT_READ_FAIL, 03748 AST_ALERT_READ_FATAL, 03749 } ast_alert_status_t; 03750 int ast_channel_alert_write(struct ast_channel *chan); 03751 int ast_channel_alert_writable(struct ast_channel *chan); 03752 ast_alert_status_t ast_channel_internal_alert_read(struct ast_channel *chan); 03753 int ast_channel_internal_alert_readable(struct ast_channel *chan); 03754 void ast_channel_internal_alertpipe_clear(struct ast_channel *chan); 03755 void ast_channel_internal_alertpipe_close(struct ast_channel *chan); 03756 int ast_channel_internal_alert_readfd(struct ast_channel *chan); 03757 int ast_channel_internal_alertpipe_init(struct ast_channel *chan); 03758 /*! \brief Swap the interal alertpipe between two channels 03759 * \note Handle all of the necessary locking before calling this 03760 */ 03761 void ast_channel_internal_alertpipe_swap(struct ast_channel *chan1, struct ast_channel *chan2); 03762 03763 /* file descriptor array accessors */ 03764 void ast_channel_internal_fd_clear(struct ast_channel *chan, int which); 03765 void ast_channel_internal_fd_clear_all(struct ast_channel *chan); 03766 void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value); 03767 int ast_channel_fd(const struct ast_channel *chan, int which); 03768 int ast_channel_fd_isset(const struct ast_channel *chan, int which); 03769 03770 /* epoll data internal accessors */ 03771 #ifdef HAVE_EPOLL 03772 struct ast_epoll_data *ast_channel_internal_epfd_data(const struct ast_channel *chan, int which); 03773 void ast_channel_internal_epfd_data_set(struct ast_channel *chan, int which , struct ast_epoll_data *value); 03774 #endif 03775 03776 pthread_t ast_channel_blocker(const struct ast_channel *chan); 03777 void ast_channel_blocker_set(struct ast_channel *chan, pthread_t value); 03778 03779 ast_timing_func_t ast_channel_timingfunc(const struct ast_channel *chan); 03780 void ast_channel_timingfunc_set(struct ast_channel *chan, ast_timing_func_t value); 03781 03782 struct ast_bridge *ast_channel_internal_bridge(const struct ast_channel *chan); 03783 void ast_channel_internal_bridge_set(struct ast_channel *chan, struct ast_bridge *value); 03784 03785 struct ast_channel *ast_channel_internal_bridged_channel(const struct ast_channel *chan); 03786 void ast_channel_internal_bridged_channel_set(struct ast_channel *chan, struct ast_channel *value); 03787 03788 struct ast_flags *ast_channel_flags(struct ast_channel *chan); 03789 #endif /* _ASTERISK_CHANNEL_H */
1.5.6