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