Wed Jan 8 2020 09:49:46

Asterisk developer's documentation


channel.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2006, Digium, Inc.
5  *
6  * Mark Spencer <markster@digium.com>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 
19 /*! \file
20  * \brief General Asterisk PBX channel definitions.
21  * \par See also:
22  * \arg \ref Def_Channel
23  * \arg \ref channel_drivers
24  */
25 
26 /*! \page Def_Channel Asterisk Channels
27  \par What is a Channel?
28  A phone call through Asterisk consists of an incoming
29  connection and an outbound connection. Each call comes
30  in through a channel driver that supports one technology,
31  like SIP, DAHDI, IAX2 etc.
32  \par
33  Each channel driver, technology, has it's own private
34  channel or dialog structure, that is technology-dependent.
35  Each private structure is "owned" by a generic Asterisk
36  channel structure, defined in channel.h and handled by
37  channel.c .
38  \par Call scenario
39  This happens when an incoming call arrives to Asterisk
40  -# Call arrives on a channel driver interface
41  -# Channel driver creates a PBX channel and starts a
42  pbx thread on the channel
43  -# The dial plan is executed
44  -# At this point at least two things can happen:
45  -# The call is answered by Asterisk and
46  Asterisk plays a media stream or reads media
47  -# The dial plan forces Asterisk to create an outbound
48  call somewhere with the dial (see \ref app_dial.c)
49  application
50  .
51 
52  \par Bridging channels
53  If Asterisk dials out this happens:
54  -# Dial creates an outbound PBX channel and asks one of the
55  channel drivers to create a call
56  -# When the call is answered, Asterisk bridges the media streams
57  so the caller on the first channel can speak with the callee
58  on the second, outbound channel
59  -# In some cases where we have the same technology on both
60  channels and compatible codecs, a native bridge is used.
61  In a native bridge, the channel driver handles forwarding
62  of incoming audio to the outbound stream internally, without
63  sending audio frames through the PBX.
64  -# In SIP, theres an "external native bridge" where Asterisk
65  redirects the endpoint, so audio flows directly between the
66  caller's phone and the callee's phone. Signalling stays in
67  Asterisk in order to be able to provide a proper CDR record
68  for the call.
69 
70 
71  \par Masquerading channels
72  In some cases, a channel can masquerade itself into another
73  channel. This happens frequently in call transfers, where
74  a new channel takes over a channel that is already involved
75  in a call. The new channel sneaks in and takes over the bridge
76  and the old channel, now a zombie, is hung up.
77 
78  \par Reference
79  \arg channel.c - generic functions
80  \arg channel.h - declarations of functions, flags and structures
81  \arg translate.h - Transcoding support functions
82  \arg \ref channel_drivers - Implemented channel drivers
83  \arg \ref Def_Frame Asterisk Multimedia Frames
84  \arg \ref Def_Bridge
85 
86 */
87 /*! \page Def_Bridge Asterisk Channel Bridges
88 
89  In Asterisk, there's several media bridges.
90 
91  The Core bridge handles two channels (a "phone call") and bridge
92  them together.
93 
94  The conference bridge (meetme) handles several channels simultaneously
95  with the support of an external timer (DAHDI timer). This is used
96  not only by the Conference application (meetme) but also by the
97  page application and the SLA system introduced in 1.4.
98  The conference bridge does not handle video.
99 
100  When two channels of the same type connect, the channel driver
101  or the media subsystem used by the channel driver (i.e. RTP)
102  can create a native bridge without sending media through the
103  core.
104 
105  Native bridging can be disabled by a number of reasons,
106  like DTMF being needed by the core or codecs being incompatible
107  so a transcoding module is needed.
108 
109 References:
110  \li \see ast_channel_early_bridge()
111  \li \see ast_channel_bridge()
112  \li \see app_meetme.c
113  \li \ref AstRTPbridge
114  \li \see ast_rtp_bridge()
115  \li \ref Def_Channel
116 */
117 
118 /*! \page AstFileDesc File descriptors
119  Asterisk File descriptors are connected to each channel (see \ref Def_Channel)
120  in the \ref ast_channel structure.
121 */
122 
123 #ifndef _ASTERISK_CHANNEL_H
124 #define _ASTERISK_CHANNEL_H
125 
126 #include "asterisk/abstract_jb.h"
127 #include "asterisk/astobj2.h"
128 
129 #include "asterisk/poll-compat.h"
130 
131 #if defined(__cplusplus) || defined(c_plusplus)
132 extern "C" {
133 #endif
134 
135 #define AST_MAX_EXTENSION 80 /*!< Max length of an extension */
136 #define AST_MAX_CONTEXT 80 /*!< Max length of a context */
137 #define AST_CHANNEL_NAME 80 /*!< Max length of an ast_channel name */
138 #define MAX_LANGUAGE 40 /*!< Max length of the language setting */
139 #define MAX_MUSICCLASS 80 /*!< Max length of the music class setting */
140 
141 #include "asterisk/frame.h"
142 #include "asterisk/sched.h"
143 #include "asterisk/chanvars.h"
144 #include "asterisk/config.h"
145 #include "asterisk/lock.h"
146 #include "asterisk/cdr.h"
147 #include "asterisk/utils.h"
148 #include "asterisk/linkedlists.h"
149 #include "asterisk/stringfields.h"
150 #include "asterisk/datastore.h"
151 #include "asterisk/data.h"
152 #include "asterisk/channelstate.h"
153 #include "asterisk/ccss.h"
154 #include "asterisk/framehook.h"
155 
156 #define DATASTORE_INHERIT_FOREVER INT_MAX
157 
158 #define AST_MAX_FDS 10
159 /*
160  * We have AST_MAX_FDS file descriptors in a channel.
161  * Some of them have a fixed use:
162  */
163 #define AST_ALERT_FD (AST_MAX_FDS-1) /*!< used for alertpipe */
164 #define AST_TIMING_FD (AST_MAX_FDS-2) /*!< used for timingfd */
165 #define AST_AGENT_FD (AST_MAX_FDS-3) /*!< used by agents for pass through */
166 #define AST_GENERATOR_FD (AST_MAX_FDS-4) /*!< used by generator */
167 
173 };
174 
175 typedef unsigned long long ast_group_t;
176 
177 /*! \todo Add an explanation of an Asterisk generator
178 */
180  void *(*alloc)(struct ast_channel *chan, void *params);
181  void (*release)(struct ast_channel *chan, void *data);
182  /*! This function gets called with the channel unlocked, but is called in
183  * the context of the channel thread so we know the channel is not going
184  * to disappear. This callback is responsible for locking the channel as
185  * necessary. */
186  int (*generate)(struct ast_channel *chan, void *data, int len, int samples);
187  /*! This gets called when DTMF_END frames are read from the channel */
188  void (*digit)(struct ast_channel *chan, char digit);
189 };
190 
191 /*! Party name character set enumeration values (values from Q.SIG) */
195  AST_PARTY_CHAR_SET_WITHDRAWN = 2,/* ITU withdrew this enum value. */
203 };
204 
205 /*!
206  * \since 1.8
207  * \brief Information needed to specify a name in a call.
208  * \note All string fields here are malloc'ed, so they need to be
209  * freed when the structure is deleted.
210  * \note NULL and "" must be considered equivalent.
211  */
213  /*! \brief Subscriber name (Malloced) */
214  char *str;
215  /*!
216  * \brief Character set the name is using.
217  * \see enum AST_PARTY_CHAR_SET
218  * \note
219  * Set to AST_PARTY_CHAR_SET_ISO8859_1 if unsure what to use.
220  * \todo Start using the party name character set value. Not currently used.
221  */
222  int char_set;
223  /*!
224  * \brief Q.931 encoded presentation-indicator encoded field
225  * \note Must tolerate the Q.931 screening-indicator field values being present.
226  */
228  /*! \brief TRUE if the name information is valid/present */
229  unsigned char valid;
230 };
231 
232 /*!
233  * \since 1.8
234  * \brief Information needed to specify a number in a call.
235  * \note All string fields here are malloc'ed, so they need to be
236  * freed when the structure is deleted.
237  * \note NULL and "" must be considered equivalent.
238  */
240  /*! \brief Subscriber phone number (Malloced) */
241  char *str;
242  /*! \brief Q.931 Type-Of-Number and Numbering-Plan encoded fields */
243  int plan;
244  /*! \brief Q.931 presentation-indicator and screening-indicator encoded fields */
246  /*! \brief TRUE if the number information is valid/present */
247  unsigned char valid;
248 };
249 
250 /*!
251  * \since 1.8
252  * \brief Information needed to specify a subaddress in a call.
253  * \note All string fields here are malloc'ed, so they need to be
254  * freed when the structure is deleted.
255  * \note NULL and "" must be considered equivalent.
256  */
258  /*!
259  * \brief Malloced subaddress string.
260  * \note If the subaddress type is user specified then the subaddress is
261  * a string of ASCII hex because the actual subaddress is likely BCD encoded.
262  */
263  char *str;
264  /*!
265  * \brief Q.931 subaddress type.
266  * \details
267  * nsap(0),
268  * user_specified(2)
269  */
270  int type;
271  /*!
272  * \brief TRUE if odd number of address signals
273  * \note The odd/even indicator is used when the type of subaddress is
274  * user_specified and the coding is BCD.
275  */
276  unsigned char odd_even_indicator;
277  /*! \brief TRUE if the subaddress information is valid/present */
278  unsigned char valid;
279 };
280 
281 /*!
282  * \since 1.8
283  * \brief Information needed to identify an endpoint in a call.
284  * \note All string fields here are malloc'ed, so they need to be
285  * freed when the structure is deleted.
286  * \note NULL and "" must be considered equivalent.
287  */
288 struct ast_party_id {
289  /*! \brief Subscriber name */
291  /*! \brief Subscriber phone number */
293  /*! \brief Subscriber subaddress. */
295 
296  /*!
297  * \brief User-set "tag"
298  * \details
299  * A user-settable field used to help associate some extrinsic information
300  * about the channel or user of the channel to the party ID. This information
301  * is normally not transmitted over the wire and so is only useful within an
302  * Asterisk environment.
303  */
304  char *tag;
305 };
306 
307 /*!
308  * \since 1.8
309  * \brief Indicate what information in ast_party_id should be set.
310  */
312  /*! TRUE if the ast_party_name information should be set. */
313  unsigned char name;
314  /*! TRUE if the ast_party_number information should be set. */
315  unsigned char number;
316  /*! TRUE if the ast_party_subaddress information should be set. */
317  unsigned char subaddress;
318 };
319 
320 /*!
321  * \since 1.8
322  * \brief Dialed/Called Party information.
323  * \note Dialed Number Identifier (DNID)
324  * \note All string fields here are malloc'ed, so they need to be
325  * freed when the structure is deleted.
326  * \note NULL and "" must be considered equivalent.
327  */
329  /*!
330  * \brief Dialed/Called number
331  * \note Done this way in case we ever really need to use ast_party_number.
332  * We currently do not need all of the ast_party_number fields.
333  */
334  struct {
335  /*! \brief Subscriber phone number (Malloced) */
336  char *str;
337  /*! \brief Q.931 Type-Of-Number and Numbering-Plan encoded fields */
338  int plan;
339  } number;
340  /*! \brief Dialed/Called subaddress */
342  /*!
343  * \brief Transit Network Select
344  * \note Currently this value is just passed around the system.
345  * You can read it and set it but it is never used for anything.
346  */
348 };
349 
350 /*!
351  * \since 1.8
352  * \brief Caller Party information.
353  * \note All string fields here are malloc'ed, so they need to be
354  * freed when the structure is deleted.
355  * \note NULL and "" must be considered equivalent.
356  *
357  * \note SIP and IAX2 has UTF8 encoded Unicode Caller ID names.
358  * In some cases, we also have an alternative (RPID) E.164 number that can
359  * be used as Caller ID on numeric E.164 phone networks (DAHDI or SIP/IAX2 to
360  * PSTN gateway).
361  *
362  * \todo Implement settings for transliteration between UTF8 Caller ID names in
363  * to ASCII Caller ID's (DAHDI). Östen Åsklund might be transliterated into
364  * Osten Asklund or Oesten Aasklund depending upon language and person...
365  * We need automatic routines for incoming calls and static settings for
366  * our own accounts.
367  */
369  /*! \brief Caller party ID */
370  struct ast_party_id id;
371 
372  /*!
373  * \brief Automatic Number Identification (ANI)
374  * \note The name subcomponent is only likely to be used by SIP.
375  * \note The subaddress subcomponent is not likely to be used.
376  */
378 
379  /*! \brief Automatic Number Identification 2 (Info Digits) */
380  int ani2;
381 };
382 
383 /*!
384  * \since 1.8
385  * \brief Indicate what information in ast_party_caller should be set.
386  */
388  /*! What caller id information to set. */
390  /*! What ANI id information to set. */
392 };
393 
394 /*!
395  * \since 1.8
396  * \brief Connected Line/Party information.
397  * \note All string fields here are malloc'ed, so they need to be
398  * freed when the structure is deleted.
399  * \note NULL and "" must be considered equivalent.
400  */
402  /*! \brief Connected party ID */
403  struct ast_party_id id;
404 
405  /*!
406  * \brief Automatic Number Identification (ANI)
407  * \note Not really part of connected line data but needed to
408  * save the corresponding caller id value.
409  */
411 
412  /*!
413  * \brief Automatic Number Identification 2 (Info Digits)
414  * \note Not really part of connected line data but needed to
415  * save the corresponding caller id value.
416  */
417  int ani2;
418 
419  /*!
420  * \brief Information about the source of an update.
421  * \note enum AST_CONNECTED_LINE_UPDATE_SOURCE values
422  * for Normal-Answer and Call-transfer.
423  */
424  int source;
425 };
426 
427 /*!
428  * \since 1.8
429  * \brief Indicate what information in ast_party_connected_line should be set.
430  */
432  /*! What connected line id information to set. */
434  /*! What ANI id information to set. */
436 };
437 
438 /*!
439  * \since 1.8
440  * \brief Redirecting Line information.
441  * RDNIS (Redirecting Directory Number Information Service)
442  * Where a call diversion or transfer was invoked.
443  * \note All string fields here are malloc'ed, so they need to be
444  * freed when the structure is deleted.
445  * \note NULL and "" must be considered equivalent.
446  */
448  /*! \brief Who is redirecting the call (Sent to the party the call is redirected toward) */
450 
451  /*! \brief Call is redirecting to a new party (Sent to the caller) */
452  struct ast_party_id to;
453 
454  /*! \brief Number of times the call was redirected */
455  int count;
456 
457  /*! \brief enum AST_REDIRECTING_REASON value for redirection */
458  int reason;
459 };
460 
461 /*!
462  * \since 1.8
463  * \brief Indicate what information in ast_party_redirecting should be set.
464  */
466  /*! What redirecting-from id information to set. */
468  /*! What redirecting-to id information to set. */
470 };
471 
472 /*! \brief Typedef for a custom read function */
473 typedef int (*ast_acf_read_fn_t)(struct ast_channel *, const char *, char *, char *, size_t);
474 
475 /*! \brief Typedef for a custom read2 function */
476 typedef int (*ast_acf_read2_fn_t)(struct ast_channel *, const char *, char *, struct ast_str **, ssize_t);
477 
478 /*! \brief Typedef for a custom write function */
479 typedef int (*ast_acf_write_fn_t)(struct ast_channel *, const char *, char *, const char *);
480 
481 /*! \brief Structure to handle passing func_channel_write info to channels via setoption */
482 typedef struct {
483  /*! \brief ast_chan_write_info_t version. Must be incremented if structure is changed */
484  #define AST_CHAN_WRITE_INFO_T_VERSION 1
485  uint32_t version;
487  struct ast_channel *chan;
488  const char *function;
489  char *data;
490  const char *value;
492 
493 /*!
494  * \brief
495  * Structure to describe a channel "technology", ie a channel driver
496  * See for examples:
497  * \arg chan_iax2.c - The Inter-Asterisk exchange protocol
498  * \arg chan_sip.c - The SIP channel driver
499  * \arg chan_dahdi.c - PSTN connectivity (TDM, PRI, T1/E1, FXO, FXS)
500  *
501  * \details
502  * If you develop your own channel driver, this is where you
503  * tell the PBX at registration of your driver what properties
504  * this driver supports and where different callbacks are
505  * implemented.
506  */
508  const char * const type;
509  const char * const description;
510 
511  format_t capabilities; /*!< Bitmap of formats this channel can handle */
512 
513  int properties; /*!< Technology Properties */
514 
515  /*!
516  * \brief Requester - to set up call data structures (pvt's)
517  * \note data should be treated as const char *.
518  */
519  struct ast_channel *(* const requester)(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
520 
521  int (* const devicestate)(void *data); /*!< Devicestate call back */
522 
523  /*!
524  * \brief Start sending a literal DTMF digit
525  *
526  * \note The channel is not locked when this function gets called.
527  */
528  int (* const send_digit_begin)(struct ast_channel *chan, char digit);
529 
530  /*!
531  * \brief Stop sending a literal DTMF digit
532  *
533  * \note The channel is not locked when this function gets called.
534  */
535  int (* const send_digit_end)(struct ast_channel *chan, char digit, unsigned int duration);
536 
537  /*!
538  * \brief Call a given phone number (address, etc), but don't
539  * take longer than timeout seconds to do so.
540  * \note addr should be treated as const char *.
541  */
542  int (* const call)(struct ast_channel *chan, char *addr, int timeout);
543 
544  /*! \brief Hangup (and possibly destroy) the channel */
545  int (* const hangup)(struct ast_channel *chan);
546 
547  /*! \brief Answer the channel */
548  int (* const answer)(struct ast_channel *chan);
549 
550  /*! \brief Read a frame, in standard format (see frame.h) */
551  struct ast_frame * (* const read)(struct ast_channel *chan);
552 
553  /*! \brief Write a frame, in standard format (see frame.h) */
554  int (* const write)(struct ast_channel *chan, struct ast_frame *frame);
555 
556  /*! \brief Display or transmit text */
557  int (* const send_text)(struct ast_channel *chan, const char *text);
558 
559  /*! \brief Display or send an image */
560  int (* const send_image)(struct ast_channel *chan, struct ast_frame *frame);
561 
562  /*! \brief Send HTML data */
563  int (* const send_html)(struct ast_channel *chan, int subclass, const char *data, int len);
564 
565  /*! \brief Handle an exception, reading a frame */
566  struct ast_frame * (* const exception)(struct ast_channel *chan);
567 
568  /*! \brief Bridge two channels of the same type together */
569  enum ast_bridge_result (* const bridge)(struct ast_channel *c0, struct ast_channel *c1, int flags,
570  struct ast_frame **fo, struct ast_channel **rc, int timeoutms);
571 
572  /*! \brief Bridge two channels of the same type together (early) */
573  enum ast_bridge_result (* const early_bridge)(struct ast_channel *c0, struct ast_channel *c1);
574 
575  /*! \brief Indicate a particular condition (e.g. AST_CONTROL_BUSY or AST_CONTROL_RINGING or AST_CONTROL_CONGESTION */
576  int (* const indicate)(struct ast_channel *c, int condition, const void *data, size_t datalen);
577 
578  /*! \brief Fix up a channel: If a channel is consumed, this is called. Basically update any ->owner links */
579  int (* const fixup)(struct ast_channel *oldchan, struct ast_channel *newchan);
580 
581  /*! \brief Set a given option. Called with chan locked */
582  int (* const setoption)(struct ast_channel *chan, int option, void *data, int datalen);
583 
584  /*! \brief Query a given option. Called with chan locked */
585  int (* const queryoption)(struct ast_channel *chan, int option, void *data, int *datalen);
586 
587  /*! \brief Blind transfer other side (see app_transfer.c and ast_transfer() */
588  int (* const transfer)(struct ast_channel *chan, const char *newdest);
589 
590  /*! \brief Write a frame, in standard format */
591  int (* const write_video)(struct ast_channel *chan, struct ast_frame *frame);
592 
593  /*! \brief Write a text frame, in standard format */
594  int (* const write_text)(struct ast_channel *chan, struct ast_frame *frame);
595 
596  /*! \brief Find bridged channel */
597  struct ast_channel *(* const bridged_channel)(struct ast_channel *chan, struct ast_channel *bridge);
598 
599  /*! \brief Provide additional read items for CHANNEL() dialplan function */
600  int (* func_channel_read)(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len);
601 
602  /*! \brief Provide additional write items for CHANNEL() dialplan function */
603  int (* func_channel_write)(struct ast_channel *chan, const char *function, char *data, const char *value);
604 
605  /*! \brief Retrieve base channel (agent and local) */
606  struct ast_channel* (* get_base_channel)(struct ast_channel *chan);
607 
608  /*! \brief Set base channel (agent and local) */
609  int (* set_base_channel)(struct ast_channel *chan, struct ast_channel *base);
610 
611  /*! \brief Get the unique identifier for the PVT, i.e. SIP call-ID for SIP */
612  const char * (* get_pvt_uniqueid)(struct ast_channel *chan);
613 
614  /*! \brief Call a function with cc parameters as a function parameter
615  *
616  * \details
617  * This is a highly specialized callback that is not likely to be needed in many
618  * channel drivers. When dealing with a busy channel, for instance, most channel
619  * drivers will successfully return a channel to the requester. Once called, the channel
620  * can then queue a busy frame when it receives an appropriate message from the far end.
621  * In such a case, the channel driver has the opportunity to also queue a CC frame.
622  * The parameters for the CC channel can be retrieved from the channel structure.
623  *
624  * For other channel drivers, notably those that deal with "dumb" phones, the channel
625  * driver will not return a channel when one is requested. In such a scenario, there is never
626  * an opportunity for the channel driver to queue a CC frame since the channel is never
627  * called. Furthermore, it is not possible to retrieve the CC configuration parameters
628  * for the desired channel because no channel is ever allocated or returned to the
629  * requester. In such a case, call completion may still be a viable option. What we do is
630  * pass the same string that the requester used originally to request the channel to the
631  * channel driver. The channel driver can then find any potential channels/devices that
632  * match the input and return call the designated callback with the device's call completion
633  * parameters as a parameter.
634  */
635  int (* cc_callback)(struct ast_channel *inbound, const char *dest, ast_cc_callback_fn callback);
636 };
637 
638 /*! Kill the channel channel driver technology descriptor. */
639 extern const struct ast_channel_tech ast_kill_tech;
640 
641 struct ast_epoll_data;
642 
643 /*!
644  * The high bit of the frame count is used as a debug marker, so
645  * increments of the counters must be done with care.
646  * Please use c->fin = FRAMECOUNT_INC(c->fin) and the same for c->fout.
647  */
648 #define DEBUGCHAN_FLAG 0x80000000
649 
650 /* XXX not ideal to evaluate x twice... */
651 #define FRAMECOUNT_INC(x) ( ((x) & DEBUGCHAN_FLAG) | (((x)+1) & ~DEBUGCHAN_FLAG) )
652 
653 /*!
654  * The current value of the debug flags is stored in the two
655  * variables global_fin and global_fout (declared in main/channel.c)
656  */
657 extern unsigned long global_fin, global_fout;
658 
664 };
665 
666 /*!
667  * \brief Possible T38 states on channels
668  */
670  T38_STATE_UNAVAILABLE, /*!< T38 is unavailable on this channel or disabled by configuration */
671  T38_STATE_UNKNOWN, /*!< The channel supports T38 but the current status is unknown */
672  T38_STATE_NEGOTIATING, /*!< T38 is being negotiated */
673  T38_STATE_REJECTED, /*!< Remote side has rejected our offer */
674  T38_STATE_NEGOTIATED, /*!< T38 established */
675 };
676 
677 /*!
678  * \page AstChannel ast_channel locking and reference tracking
679  *
680  * \par Creating Channels
681  * A channel is allocated using the ast_channel_alloc() function. When created, it is
682  * automatically inserted into the main channels hash table that keeps track of all
683  * active channels in the system. The hash key is based on the channel name. Because
684  * of this, if you want to change the name, you _must_ use ast_change_name(), not change
685  * the name field directly. When ast_channel_alloc() returns a channel pointer, you now
686  * hold a reference to that channel. In most cases this reference is given to ast_pbx_run().
687  *
688  * \par Channel Locking
689  * There is a lock associated with every ast_channel. It is allocated internally via astobj2.
690  * To lock or unlock a channel, you must use the ast_channel_lock() wrappers.
691  *
692  * Previously, before ast_channel was converted to astobj2, the channel lock was used in some
693  * additional ways that are no longer necessary. Before, the only way to ensure that a channel
694  * did not disappear out from under you if you were working with a channel outside of the channel
695  * thread that owns it, was to hold the channel lock. Now, that is no longer necessary.
696  * You simply must hold a reference to the channel to ensure it does not go away.
697  *
698  * The channel must be locked if you need to ensure that data that you reading from the channel
699  * does not change while you access it. Further, you must hold the channel lock if you are
700  * making a non-atomic change to channel data.
701  *
702  * \par Channel References
703  * There are multiple ways to get a reference to a channel. The first is that you hold a reference
704  * to a channel after creating it. The other ways involve using the channel search or the channel
705  * traversal APIs. These functions are the ast_channel_get_*() functions or ast_channel_iterator_*()
706  * functions. Once a reference is retrieved by one of these methods, you know that the channel will
707  * not go away. So, the channel should only get locked as needed for data access or modification.
708  * But, make sure that the reference gets released when you are done with it!
709  *
710  * There are different things you can do when you are done with a reference to a channel. The first
711  * is to simply release the reference using ast_channel_unref(). The other option is to call
712  * ast_channel_release(). This function is generally used where ast_channel_free() was used in
713  * the past. The release function releases a reference as well as ensures that the channel is no
714  * longer in the global channels container. That way, the channel will get destroyed as soon as any
715  * other pending references get released.
716  *
717  * \par Exceptions to the rules
718  * Even though ast_channel is reference counted, there are some places where pointers to an ast_channel
719  * get stored, but the reference count does not reflect it. The reason is mostly historical.
720  * The only places where this happens should be places where because of how the code works, we
721  * _know_ that the pointer to the channel will get removed before the channel goes away. The main
722  * example of this is in channel drivers. Channel drivers generally store a pointer to their owner
723  * ast_channel in their technology specific pvt struct. In this case, the channel drivers _know_
724  * that this pointer to the channel will be removed in time, because the channel's hangup callback
725  * gets called before the channel goes away.
726  */
727 
728 /*!
729  * \brief Main Channel structure associated with a channel.
730  *
731  * \note XXX It is important to remember to increment .cleancount each time
732  * this structure is changed. XXX
733  *
734  * \note When adding fields to this structure, it is important to add the field
735  * 'in position' with like-aligned fields, so as to keep the compiler from
736  * having to add padding to align fields. The structure's fields are sorted
737  * in this order: pointers, structures, long, int/enum, short, char. This
738  * is especially important on 64-bit architectures, where mixing 4-byte
739  * and 8-byte fields causes 4 bytes of padding to be added before many
740  * 8-byte fields.
741  */
742 struct ast_channel {
743  const struct ast_channel_tech *tech; /*!< Technology (point to channel driver) */
744  void *tech_pvt; /*!< Private data used by the technology driver */
745  void *music_state; /*!< Music State*/
746  void *generatordata; /*!< Current generator data if there is any */
747  struct ast_generator *generator; /*!< Current active data generator */
748  struct ast_channel *_bridge; /*!< Who are we bridged to, if we're bridged.
749  * Who is proxying for us, if we are proxied (i.e. chan_agent).
750  * Do not access directly, use ast_bridged_channel(chan) */
751  struct ast_channel *masq; /*!< Channel that will masquerade as us */
752  struct ast_channel *masqr; /*!< Who we are masquerading as */
753  const char *blockproc; /*!< Procedure causing blocking */
754  const char *appl; /*!< Current application */
755  const char *data; /*!< Data passed to current application */
756  struct sched_context *sched; /*!< Schedule context */
757  struct ast_filestream *stream; /*!< Stream itself. */
758  struct ast_filestream *vstream; /*!< Video Stream itself. */
759  int (*timingfunc)(const void *data);
760  void *timingdata;
761  struct ast_pbx *pbx; /*!< PBX private structure for this channel */
762  struct ast_trans_pvt *writetrans; /*!< Write translation path */
763  struct ast_trans_pvt *readtrans; /*!< Read translation path */
766  struct ast_cdr *cdr; /*!< Call Detail Record */
767  struct ast_tone_zone *zone; /*!< Tone zone as set in indications.conf or
768  * in the CHANNEL dialplan function */
769  struct ast_channel_monitor *monitor; /*!< Channel monitoring */
770 #ifdef HAVE_EPOLL
771  struct ast_epoll_data *epfd_data[AST_MAX_FDS];
772 #endif
773 
775  AST_STRING_FIELD(name); /*!< ASCII unique channel name */
776  AST_STRING_FIELD(language); /*!< Language requested for voice prompts */
777  AST_STRING_FIELD(musicclass); /*!< Default music class */
778  AST_STRING_FIELD(accountcode); /*!< Account code for billing */
779  AST_STRING_FIELD(peeraccount); /*!< Peer account code for billing */
780  AST_STRING_FIELD(userfield); /*!< Userfield for CEL billing */
781  AST_STRING_FIELD(call_forward); /*!< Where to forward to if asked to dial on this interface */
782  AST_STRING_FIELD(uniqueid); /*!< Unique Channel Identifier */
783  AST_STRING_FIELD(linkedid); /*!< Linked Channel Identifier -- gets propagated by linkage */
784  AST_STRING_FIELD(parkinglot); /*! Default parking lot, if empty, default parking lot */
785  AST_STRING_FIELD(hangupsource); /*! Who is responsible for hanging up this channel */
786  AST_STRING_FIELD(dialcontext); /*!< Dial: Extension context that we were called from */
787  );
788 
789  struct timeval whentohangup; /*!< Non-zero, set to actual time when channel is to be hung up */
790  pthread_t blocker; /*!< If anyone is blocking, this is them */
791 
792  /*!
793  * \brief Dialed/Called information.
794  * \note Set on incoming channels to indicate the originally dialed party.
795  * \note Dialed Number Identifier (DNID)
796  */
798 
799  /*!
800  * \brief Channel Caller ID information.
801  * \note The caller id information is the caller id of this
802  * channel when it is used to initiate a call.
803  */
805 
806  /*!
807  * \brief Channel Connected Line ID information.
808  * \note The connected line information identifies the channel
809  * connected/bridged to this channel.
810  */
812 
813  /*! \brief Redirecting/Diversion information */
815 
816  struct ast_frame dtmff; /*!< DTMF frame */
817  struct varshead varshead; /*!< A linked list for channel variables. See \ref AstChanVar */
818  ast_group_t callgroup; /*!< Call group for call pickups */
819  ast_group_t pickupgroup; /*!< Pickup group - which calls groups can be picked up? */
821  struct ast_jb jb; /*!< The jitterbuffer state */
822  struct timeval dtmf_tv; /*!< The time that an in process digit began, or the last digit ended */
823  AST_LIST_HEAD_NOLOCK(datastores, ast_datastore) datastores; /*!< Data stores on the channel */
824  AST_LIST_HEAD_NOLOCK(autochans, ast_autochan) autochans; /*!< Autochans on the channel */
825 
826  unsigned long insmpl; /*!< Track the read/written samples for monitor use */
827  unsigned long outsmpl; /*!< Track the read/written samples for monitor use */
828 
829  int fds[AST_MAX_FDS]; /*!< File descriptors for channel -- Drivers will poll on
830  * these file descriptors, so at least one must be non -1.
831  * See \arg \ref AstFileDesc */
832  int _softhangup; /*!< Whether or not we have been hung up... Do not set this value
833  * directly, use ast_softhangup() */
834  int fdno; /*!< Which fd had an event detected on */
835  int streamid; /*!< For streaming playback, the schedule ID */
836  int vstreamid; /*!< For streaming video playback, the schedule ID */
837  format_t oldwriteformat; /*!< Original writer format */
838  int timingfd; /*!< Timing fd */
839  enum ast_channel_state _state; /*!< State of line -- Don't write directly, use ast_setstate() */
840  int rings; /*!< Number of rings so far */
841  int priority; /*!< Dialplan: Current extension priority */
842  int macropriority; /*!< Macro: Current non-macro priority. See app_macro.c */
843  int amaflags; /*!< Set BEFORE PBX is started to determine AMA flags */
844  enum ast_channel_adsicpe adsicpe; /*!< Whether or not ADSI is detected on CPE */
845  unsigned int fin; /*!< Frames in counters. The high bit is a debug mask, so
846  * the counter is only in the remaining bits */
847  unsigned int fout; /*!< Frames out counters. The high bit is a debug mask, so
848  * the counter is only in the remaining bits */
849  int hangupcause; /*!< Why is the channel hanged up. See causes.h */
850  unsigned int flags; /*!< channel flags of AST_FLAG_ type */
851  int alertpipe[2];
852  format_t nativeformats; /*!< Kinds of data this channel can natively handle */
853  format_t readformat; /*!< Requested read format (after translation) */
854  format_t writeformat; /*!< Requested write format (after translation) */
855  format_t rawreadformat; /*!< Raw read format (before translation) */
856  format_t rawwriteformat; /*!< Raw write format (before translation) */
857  unsigned int emulate_dtmf_duration; /*!< Number of ms left to emulate DTMF for */
858 #ifdef HAVE_EPOLL
859  int epfd;
860 #endif
861  int visible_indication; /*!< Indication currently playing on the channel */
862 
863  unsigned short transfercapability; /*!< ISDN Transfer Capability - AST_FLAG_DIGITAL is not enough */
864 
865  struct ast_bridge *bridge; /*!< Bridge this channel is participating in */
866  struct ast_timer *timer; /*!< timer object that provided timingfd */
867 
868  char context[AST_MAX_CONTEXT]; /*!< Dialplan: Current extension context */
869  char exten[AST_MAX_EXTENSION]; /*!< Dialplan: Current extension number */
870  char macrocontext[AST_MAX_CONTEXT]; /*!< Macro: Current non-macro context. See app_macro.c */
871  char macroexten[AST_MAX_EXTENSION]; /*!< Macro: Current non-macro extension. See app_macro.c */
872  char emulate_dtmf_digit; /*!< Digit being emulated */
873  char sending_dtmf_digit; /*!< Digit this channel is currently sending out. (zero if not sending) */
874  struct timeval sending_dtmf_tv; /*!< The time this channel started sending the current digit. (Invalid if sending_dtmf_digit is zero.) */
875 };
876 
877 /*! \brief ast_channel_tech Properties */
878 enum {
879  /*!
880  * \brief Channels have this property if they can accept input with jitter;
881  * i.e. most VoIP channels
882  */
884  /*!
885  * \brief Channels have this property if they can create jitter;
886  * i.e. most VoIP channels
887  */
889 };
890 
891 /*! \brief ast_channel flags */
892 enum {
893  /*! Queue incoming DTMF, to be released when this flag is turned off */
895  /*! write should be interrupt generator */
896  AST_FLAG_WRITE_INT = (1 << 2),
897  /*! a thread is blocking on this channel */
898  AST_FLAG_BLOCKING = (1 << 3),
899  /*! This is a zombie channel */
900  AST_FLAG_ZOMBIE = (1 << 4),
901  /*! There is an exception pending */
902  AST_FLAG_EXCEPTION = (1 << 5),
903  /*! Listening to moh XXX anthm promises me this will disappear XXX */
904  AST_FLAG_MOH = (1 << 6),
905  /*! This channel is spying on another channel */
906  AST_FLAG_SPYING = (1 << 7),
907  /*! This channel is in a native bridge */
908  AST_FLAG_NBRIDGE = (1 << 8),
909  /*! the channel is in an auto-incrementing dialplan processor,
910  * so when ->priority is set, it will get incremented before
911  * finding the next priority to run */
913  /*! This is an outgoing call */
914  AST_FLAG_OUTGOING = (1 << 10),
915  /*! A DTMF_BEGIN frame has been read from this channel, but not yet an END */
916  AST_FLAG_IN_DTMF = (1 << 12),
917  /*! A DTMF_END was received when not IN_DTMF, so the length of the digit is
918  * currently being emulated */
920  /*! This is set to tell the channel not to generate DTMF begin frames, and
921  * to instead only generate END frames. */
923  /*! Flag to show channels that this call is hangup due to the fact that the call
924  was indeed answered, but in another channel */
926  /*! This flag indicates that on a masquerade, an active stream should not
927  * be carried over */
929  /*! This flag indicates that the hangup exten was run when the bridge terminated,
930  * a message aimed at preventing a subsequent hangup exten being run at the pbx_run
931  * level */
933  /*! This flag indicates that the hangup exten should NOT be run when the
934  * bridge terminates, this will allow the hangup in the pbx loop to be run instead.
935  * */
937  /*! Disable certain workarounds. This reintroduces certain bugs, but allows
938  * some non-traditional dialplans (like AGI) to continue to function.
939  */
941  /*!
942  * Disable device state event caching. This allows channel
943  * drivers to selectively prevent device state events from being
944  * cached by certain channels such as anonymous calls which have
945  * no persistent represenatation that can be tracked.
946  */
948  /*!
949  * This flag indicates that a dual channel redirect is in
950  * progress. The bridge needs to wait until the flag is cleared
951  * to continue.
952  */
954  /*!
955  * The data on chan->timingdata is an astobj2 object.
956  */
958 };
959 
960 /*! \brief ast_bridge_config flags */
961 enum {
965  AST_FEATURE_ATXFER = (1 << 3),
971 };
972 
973 /*! \brief bridge configuration */
977  struct timeval start_time;
978  struct timeval nexteventts;
979  struct timeval feature_start_time;
981  long timelimit;
984  const char *warning_sound;
985  const char *end_sound;
986  const char *start_sound;
987  unsigned int flags;
988  void (* end_bridge_callback)(void *); /*!< A callback that is called after a bridge attempt */
989  void *end_bridge_callback_data; /*!< Data passed to the callback */
990  /*! If the end_bridge_callback_data refers to a channel which no longer is going to
991  * exist when the end_bridge_callback is called, then it needs to be fixed up properly
992  */
993  void (*end_bridge_callback_data_fixup)(struct ast_bridge_config *bconfig, struct ast_channel *originator, struct ast_channel *terminator);
994 };
995 
996 struct chanmon;
997 
999  const char *context;
1000  const char *exten;
1002  const char *cid_num;
1003  const char *cid_name;
1004  const char *account;
1007 };
1008 
1009 enum {
1010  /*!
1011  * Soft hangup requested by device or other internal reason.
1012  * Actual hangup needed.
1013  */
1015  /*!
1016  * Used to break the normal frame flow so an async goto can be
1017  * done instead of actually hanging up.
1018  */
1020  /*!
1021  * Soft hangup requested by system shutdown. Actual hangup
1022  * needed.
1023  */
1025  /*!
1026  * Used to break the normal frame flow after a timeout so an
1027  * implicit async goto can be done to the 'T' exten if it exists
1028  * instead of actually hanging up. If the exten does not exist
1029  * then actually hangup.
1030  */
1032  /*!
1033  * Soft hangup requested by application/channel-driver being
1034  * unloaded. Actual hangup needed.
1035  */
1037  /*!
1038  * Soft hangup requested by non-associated party. Actual hangup
1039  * needed.
1040  */
1042  /*!
1043  * Used to break a bridge so the channel can be spied upon
1044  * instead of actually hanging up.
1045  */
1047 
1048 
1049  /*!
1050  * \brief All softhangup flags.
1051  *
1052  * This can be used as an argument to ast_channel_softhangup_clear
1053  * to clear all softhangup flags from a channel.
1054  */
1055  AST_SOFTHANGUP_ALL = (0xFFFFFFFF)
1056 };
1057 
1058 
1059 /*! \brief Channel reload reasons for manager events at load or reload of configuration */
1065 };
1066 
1067 /*!
1068  * \note None of the datastore API calls lock the ast_channel they are using.
1069  * So, the channel should be locked before calling the functions that
1070  * take a channel argument.
1071  */
1072 
1073 /*!
1074  * \brief Create a channel data store object
1075  * \deprecated You should use the ast_datastore_alloc() generic function instead.
1076  * \version 1.6.1 deprecated
1077  */
1079  __attribute__((deprecated));
1080 
1081 /*!
1082  * \brief Free a channel data store object
1083  * \deprecated You should use the ast_datastore_free() generic function instead.
1084  * \version 1.6.1 deprecated
1085  */
1086 int ast_channel_datastore_free(struct ast_datastore *datastore)
1087  __attribute__((deprecated));
1088 
1089 /*! \brief Inherit datastores from a parent to a child. */
1090 int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to);
1091 
1092 /*!
1093  * \brief Add a datastore to a channel
1094  *
1095  * \note The channel should be locked before calling this function.
1096  *
1097  * \retval 0 success
1098  * \retval non-zero failure
1099  */
1100 int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore);
1101 
1102 /*!
1103  * \brief Remove a datastore from a channel
1104  *
1105  * \note The channel should be locked before calling this function.
1106  *
1107  * \retval 0 success
1108  * \retval non-zero failure
1109  */
1110 int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore);
1111 
1112 /*!
1113  * \brief Find a datastore on a channel
1114  *
1115  * \note The channel should be locked before calling this function.
1116  *
1117  * \note The datastore returned from this function must not be used if the
1118  * reference to the channel is released.
1119  *
1120  * \retval pointer to the datastore if found
1121  * \retval NULL if not found
1122  */
1123 struct ast_datastore *ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid);
1124 
1125 /*!
1126  * \brief Create a channel structure
1127  * \since 1.8
1128  *
1129  * \retval NULL failure
1130  * \retval non-NULL successfully allocated channel
1131  *
1132  * \note Absolutely _NO_ channel locks should be held before calling this function.
1133  * \note By default, new channels are set to the "s" extension
1134  * and "default" context.
1135  */
1136 struct ast_channel * attribute_malloc __attribute__((format(printf, 13, 14)))
1137  __ast_channel_alloc(int needqueue, int state, const char *cid_num,
1138  const char *cid_name, const char *acctcode,
1139  const char *exten, const char *context,
1140  const char *linkedid, const int amaflag,
1141  const char *file, int line, const char *function,
1142  const char *name_fmt, ...);
1143 
1144 /*!
1145  * \brief Create a channel structure
1146  *
1147  * \retval NULL failure
1148  * \retval non-NULL successfully allocated channel
1149  *
1150  * \note Absolutely _NO_ channel locks should be held before calling this function.
1151  * \note By default, new channels are set to the "s" extension
1152  * and "default" context.
1153  */
1154 #define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, linkedid, amaflag, ...) \
1155  __ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, linkedid, amaflag, \
1156  __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__)
1157 
1158 #if defined(REF_DEBUG) || defined(__AST_DEBUG_MALLOC)
1159 /*!
1160  * \brief Create a fake channel structure
1161  *
1162  * \retval NULL failure
1163  * \retval non-NULL successfully allocated channel
1164  *
1165  * \note This function should ONLY be used to create a fake channel
1166  * that can then be populated with data for use in variable
1167  * substitution when a real channel does not exist.
1168  *
1169  * \note The created dummy channel should be destroyed by
1170  * ast_channel_unref(). Using ast_channel_release() needlessly
1171  * grabs the channel container lock and can cause a deadlock as
1172  * a result. Also grabbing the channel container lock reduces
1173  * system performance.
1174  */
1175 #define ast_dummy_channel_alloc() __ast_dummy_channel_alloc(__FILE__, __LINE__, __PRETTY_FUNCTION__)
1176 struct ast_channel *__ast_dummy_channel_alloc(const char *file, int line, const char *function);
1177 #else
1178 /*!
1179  * \brief Create a fake channel structure
1180  *
1181  * \retval NULL failure
1182  * \retval non-NULL successfully allocated channel
1183  *
1184  * \note This function should ONLY be used to create a fake channel
1185  * that can then be populated with data for use in variable
1186  * substitution when a real channel does not exist.
1187  *
1188  * \note The created dummy channel should be destroyed by
1189  * ast_channel_unref(). Using ast_channel_release() needlessly
1190  * grabs the channel container lock and can cause a deadlock as
1191  * a result. Also grabbing the channel container lock reduces
1192  * system performance.
1193  */
1194 struct ast_channel *ast_dummy_channel_alloc(void);
1195 #endif
1196 
1197 /*!
1198  * \brief Queue one or more frames to a channel's frame queue
1199  *
1200  * \param chan the channel to queue the frame(s) on
1201  * \param f the frame(s) to queue. Note that the frame(s) will be duplicated
1202  * by this function. It is the responsibility of the caller to handle
1203  * freeing the memory associated with the frame(s) being passed if
1204  * necessary.
1205  *
1206  * \retval 0 success
1207  * \retval non-zero failure
1208  */
1209 int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f);
1210 
1211 /*!
1212  * \brief Queue one or more frames to the head of a channel's frame queue
1213  *
1214  * \param chan the channel to queue the frame(s) on
1215  * \param f the frame(s) to queue. Note that the frame(s) will be duplicated
1216  * by this function. It is the responsibility of the caller to handle
1217  * freeing the memory associated with the frame(s) being passed if
1218  * necessary.
1219  *
1220  * \retval 0 success
1221  * \retval non-zero failure
1222  */
1223 int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *f);
1224 
1225 /*!
1226  * \brief Queue a hangup frame
1227  *
1228  * \note The channel does not need to be locked before calling this function.
1229  */
1230 int ast_queue_hangup(struct ast_channel *chan);
1231 
1232 /*!
1233  * \brief Queue a hangup frame with hangupcause set
1234  *
1235  * \note The channel does not need to be locked before calling this function.
1236  * \param[in] chan channel to queue frame onto
1237  * \param[in] cause the hangup cause
1238  * \return 0 on success, -1 on error
1239  * \since 1.6.1
1240  */
1241 int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause);
1242 
1243 /*!
1244  * \brief Queue a control frame with payload
1245  *
1246  * \param chan channel to queue frame onto
1247  * \param control type of control frame
1248  *
1249  * \note The channel does not need to be locked before calling this function.
1250  *
1251  * \retval zero on success
1252  * \retval non-zero on failure
1253  */
1254 int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control);
1255 
1256 /*!
1257  * \brief Queue a control frame with payload
1258  *
1259  * \param chan channel to queue frame onto
1260  * \param control type of control frame
1261  * \param data pointer to payload data to be included in frame
1262  * \param datalen number of bytes of payload data
1263  *
1264  * \retval 0 success
1265  * \retval non-zero failure
1266  *
1267  * \details
1268  * The supplied payload data is copied into the frame, so the caller's copy
1269  * is not modified nor freed, and the resulting frame will retain a copy of
1270  * the data even if the caller frees their local copy.
1271  *
1272  * \note This method should be treated as a 'network transport'; in other
1273  * words, your frames may be transferred across an IAX2 channel to another
1274  * system, which may be a different endianness than yours. Because of this,
1275  * you should ensure that either your frames will never be expected to work
1276  * across systems, or that you always put your payload data into 'network byte
1277  * order' before calling this function.
1278  *
1279  * \note The channel does not need to be locked before calling this function.
1280  */
1281 int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control,
1282  const void *data, size_t datalen);
1283 
1284 /*!
1285  * \brief Change channel name
1286  *
1287  * \pre Absolutely all channels _MUST_ be unlocked before calling this function.
1288  *
1289  * \param chan the channel to change the name of
1290  * \param newname the name to change to
1291  *
1292  * \return nothing
1293  *
1294  * \note this function must _NEVER_ be used when any channels are locked
1295  * regardless if it is the channel who's name is being changed or not because
1296  * it invalidates our channel container locking order... lock container first,
1297  * then the individual channels, never the other way around.
1298  */
1299 void ast_change_name(struct ast_channel *chan, const char *newname);
1300 
1301 /*!
1302  * \brief Unlink and release reference to a channel
1303  *
1304  * This function will unlink the channel from the global channels container
1305  * if it is still there and also release the current reference to the channel.
1306  *
1307  * \return NULL, convenient for clearing invalid pointers
1308  * \note Absolutely _NO_ channel locks should be held before calling this function.
1309  *
1310  * \since 1.8
1311  */
1312 struct ast_channel *ast_channel_release(struct ast_channel *chan);
1313 
1314 /*!
1315  * \brief Requests a channel
1316  *
1317  * \param type type of channel to request
1318  * \param format requested channel format (codec)
1319  * \param requestor channel asking for data
1320  * \param data data to pass to the channel requester (Should be treated as const char *)
1321  * \param status status
1322  *
1323  * \details
1324  * Request a channel of a given type, with data as optional information used
1325  * by the low level module
1326  *
1327  * \retval NULL failure
1328  * \retval non-NULL channel on success
1329  */
1330 struct ast_channel *ast_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *status);
1331 
1332 /*!
1333  * \brief Request a channel of a given type, with data as optional information used
1334  * by the low level module and attempt to place a call on it
1335  *
1336  * \param type type of channel to request
1337  * \param format requested channel format
1338  * \param requestor channel asking for data
1339  * \param data data to pass to the channel requester
1340  * \param timeout maximum amount of time to wait for an answer
1341  * \param reason why unsuccessful (if unsuccessful)
1342  * \param cid_num Caller-ID Number
1343  * \param cid_name Caller-ID Name (ascii)
1344  *
1345  * \return Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state
1346  * to know if the call was answered or not.
1347  */
1348 struct ast_channel *ast_request_and_dial(const char *type, format_t format, const struct ast_channel *requestor, void *data,
1349  int timeout, int *reason, const char *cid_num, const char *cid_name);
1350 
1351 /*!
1352  * \brief Request a channel of a given type, with data as optional information used
1353  * by the low level module and attempt to place a call on it
1354  * \param type type of channel to request
1355  * \param format requested channel format
1356  * \param requestor channel requesting data
1357  * \param data data to pass to the channel requester
1358  * \param timeout maximum amount of time to wait for an answer
1359  * \param reason why unsuccessful (if unsuccessful)
1360  * \param cid_num Caller-ID Number
1361  * \param cid_name Caller-ID Name (ascii)
1362  * \param oh Outgoing helper
1363  * \return Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state
1364  * to know if the call was answered or not.
1365  */
1366 struct ast_channel *__ast_request_and_dial(const char *type, format_t format, const struct ast_channel *requestor, void *data,
1367  int timeout, int *reason, const char *cid_num, const char *cid_name, struct outgoing_helper *oh);
1368 
1369 /*!
1370  * \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.
1371  * \param caller in channel that requested orig
1372  * \param orig channel being replaced by the call forward channel
1373  * \param timeout maximum amount of time to wait for setup of new forward channel
1374  * \param format requested channel format
1375  * \param oh outgoing helper used with original channel
1376  * \param outstate reason why unsuccessful (if uncuccessful)
1377  * \return Returns the forwarded call's ast_channel on success or NULL on failure
1378  */
1379 struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, format_t format, struct outgoing_helper *oh, int *outstate);
1380 
1381 /*!
1382  * \brief Register a channel technology (a new channel driver)
1383  * Called by a channel module to register the kind of channels it supports.
1384  * \param tech Structure defining channel technology or "type"
1385  * \return Returns 0 on success, -1 on failure.
1386  */
1387 int ast_channel_register(const struct ast_channel_tech *tech);
1388 
1389 /*!
1390  * \brief Unregister a channel technology
1391  * \param tech Structure defining channel technology or "type" that was previously registered
1392  * \return No return value.
1393  */
1394 void ast_channel_unregister(const struct ast_channel_tech *tech);
1395 
1396 /*!
1397  * \brief Get a channel technology structure by name
1398  * \param name name of technology to find
1399  * \return a pointer to the structure, or NULL if no matching technology found
1400  */
1401 const struct ast_channel_tech *ast_get_channel_tech(const char *name);
1402 
1403 #ifdef CHANNEL_TRACE
1404 /*!
1405  * \brief Update the context backtrace if tracing is enabled
1406  * \return Returns 0 on success, -1 on failure
1407  */
1408 int ast_channel_trace_update(struct ast_channel *chan);
1409 
1410 /*!
1411  * \brief Enable context tracing in the channel
1412  * \return Returns 0 on success, -1 on failure
1413  */
1414 int ast_channel_trace_enable(struct ast_channel *chan);
1415 
1416 /*!
1417  * \brief Disable context tracing in the channel.
1418  * \note Does not remove current trace entries
1419  * \return Returns 0 on success, -1 on failure
1420  */
1421 int ast_channel_trace_disable(struct ast_channel *chan);
1422 
1423 /*!
1424  * \brief Whether or not context tracing is enabled
1425  * \return Returns -1 when the trace is enabled. 0 if not.
1426  */
1427 int ast_channel_trace_is_enabled(struct ast_channel *chan);
1428 
1429 /*!
1430  * \brief Put the channel backtrace in a string
1431  * \return Returns the amount of lines in the backtrace. -1 on error.
1432  */
1433 int ast_channel_trace_serialize(struct ast_channel *chan, struct ast_str **out);
1434 #endif
1435 
1436 /*!
1437  * \brief Hang up a channel
1438  * \note Absolutely _NO_ channel locks should be held before calling this function.
1439  * \note This function performs a hard hangup on a channel. Unlike the soft-hangup, this function
1440  * performs all stream stopping, etc, on the channel that needs to end.
1441  * chan is no longer valid after this call.
1442  * \param chan channel to hang up
1443  * \return Returns 0 on success, -1 on failure.
1444  */
1445 int ast_hangup(struct ast_channel *chan);
1446 
1447 /*!
1448  * \brief Softly hangup up a channel
1449  *
1450  * \param chan channel to be soft-hung-up
1451  * \param reason an AST_SOFTHANGUP_* reason code
1452  *
1453  * \details
1454  * Call the protocol layer, but don't destroy the channel structure
1455  * (use this if you are trying to
1456  * safely hangup a channel managed by another thread.
1457  *
1458  * \note The channel passed to this function does not need to be locked.
1459  *
1460  * \return Returns 0 regardless
1461  */
1462 int ast_softhangup(struct ast_channel *chan, int reason);
1463 
1464 /*!
1465  * \brief Softly hangup up a channel (no channel lock)
1466  * \param chan channel to be soft-hung-up
1467  * \param reason an AST_SOFTHANGUP_* reason code
1468  */
1469 int ast_softhangup_nolock(struct ast_channel *chan, int reason);
1470 
1471 /*!
1472  * \brief Clear a set of softhangup flags from a channel
1473  *
1474  * Never clear a softhangup flag from a channel directly. Instead,
1475  * use this function. This ensures that all aspects of the softhangup
1476  * process are aborted.
1477  *
1478  * \param chan the channel to clear the flag on
1479  * \param flag the flag or flags to clear
1480  *
1481  * \return Nothing.
1482  */
1483 void ast_channel_clear_softhangup(struct ast_channel *chan, int flag);
1484 
1485 /*!
1486  * \brief Set the source of the hangup in this channel and it's bridge
1487  *
1488  * \param chan channel to set the field on
1489  * \param source a string describing the source of the hangup for this channel
1490  * \param force
1491  *
1492  * \note Absolutely _NO_ channel locks should be held before calling this function.
1493  *
1494  * \since 1.8
1495  *
1496  * Hangupsource is generally the channel name that caused the bridge to be
1497  * hung up, but it can also be other things such as "dialplan/agi"
1498  * This can then be logged in the CDR or CEL
1499  */
1500 void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force);
1501 
1502 /*! \brief Check to see if a channel is needing hang up
1503  * \param chan channel on which to check for hang up
1504  * This function determines if the channel is being requested to be hung up.
1505  * \return Returns 0 if not, or 1 if hang up is requested (including time-out).
1506  */
1507 int ast_check_hangup(struct ast_channel *chan);
1508 
1509 int ast_check_hangup_locked(struct ast_channel *chan);
1510 
1511 /*!
1512  * \brief Compare a offset with the settings of when to hang a channel up
1513  * \param chan channel on which to check for hang up
1514  * \param offset offset in seconds from current time
1515  * \return 1, 0, or -1
1516  * \details
1517  * This function compares a offset from current time with the absolute time
1518  * out on a channel (when to hang up). If the absolute time out on a channel
1519  * is earlier than current time plus the offset, it returns 1, if the two
1520  * time values are equal, it return 0, otherwise, it return -1.
1521  * \sa ast_channel_cmpwhentohangup_tv()
1522  * \version 1.6.1 deprecated function (only had seconds precision)
1523  */
1524 int ast_channel_cmpwhentohangup(struct ast_channel *chan, time_t offset) __attribute__((deprecated));
1525 
1526 /*!
1527  * \brief Compare a offset with the settings of when to hang a channel up
1528  * \param chan channel on which to check for hangup
1529  * \param offset offset in seconds and microseconds from current time
1530  * \return 1, 0, or -1
1531  * This function compares a offset from current time with the absolute time
1532  * out on a channel (when to hang up). If the absolute time out on a channel
1533  * is earlier than current time plus the offset, it returns 1, if the two
1534  * time values are equal, it return 0, otherwise, it return -1.
1535  * \since 1.6.1
1536  */
1537 int ast_channel_cmpwhentohangup_tv(struct ast_channel *chan, struct timeval offset);
1538 
1539 /*!
1540  * \brief Set when to hang a channel up
1541  *
1542  * \param chan channel on which to check for hang up
1543  * \param offset offset in seconds relative to the current time of when to hang up
1544  *
1545  * \details
1546  * This function sets the absolute time out on a channel (when to hang up).
1547  *
1548  * \note This function does not require that the channel is locked before
1549  * calling it.
1550  *
1551  * \return Nothing
1552  * \sa ast_channel_setwhentohangup_tv()
1553  * \version 1.6.1 deprecated function (only had seconds precision)
1554  */
1555 void ast_channel_setwhentohangup(struct ast_channel *chan, time_t offset) __attribute__((deprecated));
1556 
1557 /*!
1558  * \brief Set when to hang a channel up
1559  *
1560  * \param chan channel on which to check for hang up
1561  * \param offset offset in seconds and useconds relative to the current time of when to hang up
1562  *
1563  * This function sets the absolute time out on a channel (when to hang up).
1564  *
1565  * \note This function does not require that the channel is locked before
1566  * calling it.
1567  *
1568  * \return Nothing
1569  * \since 1.6.1
1570  */
1571 void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset);
1572 
1573 /*!
1574  * \brief Answer a channel
1575  *
1576  * \param chan channel to answer
1577  *
1578  * \details
1579  * This function answers a channel and handles all necessary call
1580  * setup functions.
1581  *
1582  * \note The channel passed does not need to be locked, but is locked
1583  * by the function when needed.
1584  *
1585  * \note This function will wait up to 500 milliseconds for media to
1586  * arrive on the channel before returning to the caller, so that the
1587  * caller can properly assume the channel is 'ready' for media flow.
1588  *
1589  * \retval 0 on success
1590  * \retval non-zero on failure
1591  */
1592 int ast_answer(struct ast_channel *chan);
1593 
1594 /*!
1595  * \brief Answer a channel
1596  *
1597  * \param chan channel to answer
1598  * \param cdr_answer flag to control whether any associated CDR should be marked as 'answered'
1599  *
1600  * This function answers a channel and handles all necessary call
1601  * setup functions.
1602  *
1603  * \note The channel passed does not need to be locked, but is locked
1604  * by the function when needed.
1605  *
1606  * \note Unlike ast_answer(), this function will not wait for media
1607  * flow to begin. The caller should be careful before sending media
1608  * to the channel before incoming media arrives, as the outgoing
1609  * media may be lost.
1610  *
1611  * \retval 0 on success
1612  * \retval non-zero on failure
1613  */
1614 int ast_raw_answer(struct ast_channel *chan, int cdr_answer);
1615 
1616 /*!
1617  * \brief Answer a channel, with a selectable delay before returning
1618  *
1619  * \param chan channel to answer
1620  * \param delay maximum amount of time to wait for incoming media
1621  * \param cdr_answer flag to control whether any associated CDR should be marked as 'answered'
1622  *
1623  * This function answers a channel and handles all necessary call
1624  * setup functions.
1625  *
1626  * \note The channel passed does not need to be locked, but is locked
1627  * by the function when needed.
1628  *
1629  * \note This function will wait up to 'delay' milliseconds for media to
1630  * arrive on the channel before returning to the caller, so that the
1631  * caller can properly assume the channel is 'ready' for media flow. If
1632  * 'delay' is less than 500, the function will wait up to 500 milliseconds.
1633  *
1634  * \retval 0 on success
1635  * \retval non-zero on failure
1636  */
1637 int __ast_answer(struct ast_channel *chan, unsigned int delay, int cdr_answer);
1638 
1639 /*!
1640  * \brief Make a call
1641  * \note Absolutely _NO_ channel locks should be held before calling this function.
1642  * \param chan which channel to make the call on
1643  * \param addr destination of the call (Should be treated as const char *)
1644  * \param timeout time to wait on for connect
1645  * \details
1646  * Place a call, take no longer than timeout ms.
1647  * \return -1 on failure, 0 on not enough time
1648  * (does not automatically stop ringing), and
1649  * the number of seconds the connect took otherwise.
1650  */
1651 int ast_call(struct ast_channel *chan, char *addr, int timeout);
1652 
1653 /*!
1654  * \brief Indicates condition of channel
1655  * \note Absolutely _NO_ channel locks should be held before calling this function.
1656  * \note Indicate a condition such as AST_CONTROL_BUSY, AST_CONTROL_RINGING, or AST_CONTROL_CONGESTION on a channel
1657  * \param chan channel to change the indication
1658  * \param condition which condition to indicate on the channel
1659  * \return Returns 0 on success, -1 on failure
1660  */
1661 int ast_indicate(struct ast_channel *chan, int condition);
1662 
1663 /*!
1664  * \brief Indicates condition of channel, with payload
1665  * \note Absolutely _NO_ channel locks should be held before calling this function.
1666  * \note Indicate a condition such as AST_CONTROL_HOLD with payload being music on hold class
1667  * \param chan channel to change the indication
1668  * \param condition which condition to indicate on the channel
1669  * \param data pointer to payload data
1670  * \param datalen size of payload data
1671  * \return Returns 0 on success, -1 on failure
1672  */
1673 int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen);
1674 
1675 /* Misc stuff ------------------------------------------------ */
1676 
1677 /*!
1678  * \brief Wait for input on a channel
1679  * \param chan channel to wait on
1680  * \param ms length of time to wait on the channel
1681  * \details
1682  * Wait for input on a channel for a given # of milliseconds (<0 for indefinite).
1683  * \retval < 0 on failure
1684  * \retval 0 if nothing ever arrived
1685  * \retval the # of ms remaining otherwise
1686  */
1687 int ast_waitfor(struct ast_channel *chan, int ms);
1688 
1689 /*!
1690  * \brief Should we keep this frame for later?
1691  *
1692  * There are functions such as ast_safe_sleep which will
1693  * service a channel to ensure that it does not have a
1694  * large backlog of queued frames. When this happens,
1695  * we want to hold on to specific frame types and just drop
1696  * others. This function will tell if the frame we just
1697  * read should be held onto.
1698  *
1699  * \param frame The frame we just read
1700  * \retval 1 frame should be kept
1701  * \retval 0 frame should be dropped
1702  */
1703 int ast_is_deferrable_frame(const struct ast_frame *frame);
1704 
1705 /*!
1706  * \brief Wait for a specified amount of time, looking for hangups
1707  * \param chan channel to wait for
1708  * \param ms length of time in milliseconds to sleep. This should never be less than zero.
1709  * \details
1710  * Waits for a specified amount of time, servicing the channel as required.
1711  * \return returns -1 on hangup, otherwise 0.
1712  */
1713 int ast_safe_sleep(struct ast_channel *chan, int ms);
1714 
1715 /*!
1716  * \brief Wait for a specified amount of time, looking for hangups and a condition argument
1717  * \param chan channel to wait for
1718  * \param ms length of time in milliseconds to sleep.
1719  * \param cond a function pointer for testing continue condition
1720  * \param data argument to be passed to the condition test function
1721  * \return returns -1 on hangup, otherwise 0.
1722  * \details
1723  * Waits for a specified amount of time, servicing the channel as required. If cond
1724  * returns 0, this function returns.
1725  */
1726 int ast_safe_sleep_conditional(struct ast_channel *chan, int ms, int (*cond)(void*), void *data );
1727 
1728 /*!
1729  * \brief Waits for activity on a group of channels
1730  * \param chan an array of pointers to channels
1731  * \param n number of channels that are to be waited upon
1732  * \param fds an array of fds to wait upon
1733  * \param nfds the number of fds to wait upon
1734  * \param exception exception flag
1735  * \param outfd fd that had activity on it
1736  * \param ms how long the wait was
1737  * \details
1738  * Big momma function here. Wait for activity on any of the n channels, or any of the nfds
1739  * file descriptors.
1740  * \return Returns the channel with activity, or NULL on error or if an FD
1741  * came first. If the FD came first, it will be returned in outfd, otherwise, outfd
1742  * will be -1
1743  */
1744 struct ast_channel *ast_waitfor_nandfds(struct ast_channel **chan, int n,
1745  int *fds, int nfds, int *exception, int *outfd, int *ms);
1746 
1747 /*!
1748  * \brief Waits for input on a group of channels
1749  * Wait for input on an array of channels for a given # of milliseconds.
1750  * \return Return channel with activity, or NULL if none has activity.
1751  * \param chan an array of pointers to channels
1752  * \param n number of channels that are to be waited upon
1753  * \param ms time "ms" is modified in-place, if applicable
1754  */
1755 struct ast_channel *ast_waitfor_n(struct ast_channel **chan, int n, int *ms);
1756 
1757 /*!
1758  * \brief Waits for input on an fd
1759  * \note This version works on fd's only. Be careful with it.
1760  */
1761 int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception);
1762 
1763 
1764 /*!
1765  * \brief Reads a frame
1766  * \param chan channel to read a frame from
1767  * \return Returns a frame, or NULL on error. If it returns NULL, you
1768  * best just stop reading frames and assume the channel has been
1769  * disconnected.
1770  */
1771 struct ast_frame *ast_read(struct ast_channel *chan);
1772 
1773 /*!
1774  * \brief Reads a frame, returning AST_FRAME_NULL frame if audio.
1775  * \param chan channel to read a frame from
1776  * \return Returns a frame, or NULL on error. If it returns NULL, you
1777  * best just stop reading frames and assume the channel has been
1778  * disconnected.
1779  * \note Audio is replaced with AST_FRAME_NULL to avoid
1780  * transcode when the resulting audio is not necessary.
1781  */
1782 struct ast_frame *ast_read_noaudio(struct ast_channel *chan);
1783 
1784 /*!
1785  * \brief Write a frame to a channel
1786  * This function writes the given frame to the indicated channel.
1787  * \param chan destination channel of the frame
1788  * \param frame frame that will be written
1789  * \return It returns 0 on success, -1 on failure.
1790  */
1791 int ast_write(struct ast_channel *chan, struct ast_frame *frame);
1792 
1793 /*!
1794  * \brief Write video frame to a channel
1795  * This function writes the given frame to the indicated channel.
1796  * \param chan destination channel of the frame
1797  * \param frame frame that will be written
1798  * \return It returns 1 on success, 0 if not implemented, and -1 on failure.
1799  */
1800 int ast_write_video(struct ast_channel *chan, struct ast_frame *frame);
1801 
1802 /*!
1803  * \brief Write text frame to a channel
1804  * This function writes the given frame to the indicated channel.
1805  * \param chan destination channel of the frame
1806  * \param frame frame that will be written
1807  * \return It returns 1 on success, 0 if not implemented, and -1 on failure.
1808  */
1809 int ast_write_text(struct ast_channel *chan, struct ast_frame *frame);
1810 
1811 /*! \brief Send empty audio to prime a channel driver */
1812 int ast_prod(struct ast_channel *chan);
1813 
1814 /*!
1815  * \brief Sets read format on channel chan
1816  * Set read format for channel to whichever component of "format" is best.
1817  * \param chan channel to change
1818  * \param format format to change to
1819  * \return Returns 0 on success, -1 on failure
1820  */
1821 int ast_set_read_format(struct ast_channel *chan, format_t format);
1822 
1823 /*!
1824  * \brief Sets write format on channel chan
1825  * Set write format for channel to whichever component of "format" is best.
1826  * \param chan channel to change
1827  * \param format new format for writing
1828  * \return Returns 0 on success, -1 on failure
1829  */
1830 int ast_set_write_format(struct ast_channel *chan, format_t format);
1831 
1832 /*!
1833  * \brief Sends text to a channel
1834  *
1835  * \param chan channel to act upon
1836  * \param text string of text to send on the channel
1837  *
1838  * \details
1839  * Write text to a display on a channel
1840  *
1841  * \note The channel does not need to be locked before calling this function.
1842  *
1843  * \retval 0 on success
1844  * \retval -1 on failure
1845  */
1846 int ast_sendtext(struct ast_channel *chan, const char *text);
1847 
1848 /*!
1849  * \brief Receives a text character from a channel
1850  * \param chan channel to act upon
1851  * \param timeout timeout in milliseconds (0 for infinite wait)
1852  * \details
1853  * Read a char of text from a channel
1854  * \return 0 on success, -1 on failure
1855  */
1856 int ast_recvchar(struct ast_channel *chan, int timeout);
1857 
1858 /*!
1859  * \brief Send a DTMF digit to a channel.
1860  * \param chan channel to act upon
1861  * \param digit the DTMF digit to send, encoded in ASCII
1862  * \param duration the duration of the digit ending in ms
1863  * \return 0 on success, -1 on failure
1864  */
1865 int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration);
1866 
1867 /*!
1868  * \brief Send a DTMF digit to a channel.
1869  * \param chan channel to act upon
1870  * \param digit the DTMF digit to send, encoded in ASCII
1871  * \return 0 on success, -1 on failure
1872  */
1873 int ast_senddigit_begin(struct ast_channel *chan, char digit);
1874 
1875 /*!
1876  * \brief Send a DTMF digit to a channel.
1877  * \param chan channel to act upon
1878  * \param digit the DTMF digit to send, encoded in ASCII
1879  * \param duration the duration of the digit ending in ms
1880  * \return Returns 0 on success, -1 on failure
1881  */
1882 int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration);
1883 
1884 /*!
1885  * \brief Receives a text string from a channel
1886  * Read a string of text from a channel
1887  * \param chan channel to act upon
1888  * \param timeout timeout in milliseconds (0 for infinite wait)
1889  * \return the received text, or NULL to signify failure.
1890  */
1891 char *ast_recvtext(struct ast_channel *chan, int timeout);
1892 
1893 /*!
1894  * \brief Waits for a digit
1895  * \param c channel to wait for a digit on
1896  * \param ms how many milliseconds to wait (<0 for indefinite).
1897  * \return Returns <0 on error, 0 on no entry, and the digit on success.
1898  */
1899 int ast_waitfordigit(struct ast_channel *c, int ms);
1900 
1901 /*!
1902  * \brief Wait for a digit
1903  * Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to monitor for reading.
1904  * \param c channel to wait for a digit on
1905  * \param ms how many milliseconds to wait (<0 for indefinite).
1906  * \param audiofd audio file descriptor to write to if audio frames are received
1907  * \param ctrlfd control file descriptor to monitor for reading
1908  * \return Returns 1 if ctrlfd becomes available
1909  */
1910 int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int ctrlfd);
1911 
1912 /*!
1913  * \brief Reads multiple digits
1914  * \param c channel to read from
1915  * \param s string to read in to. Must be at least the size of your length
1916  * \param len how many digits to read (maximum)
1917  * \param timeout how long to timeout between digits
1918  * \param rtimeout timeout to wait on the first digit
1919  * \param enders digits to end the string
1920  * \details
1921  * Read in a digit string "s", max length "len", maximum timeout between
1922  * digits "timeout" (-1 for none), terminated by anything in "enders". Give them rtimeout
1923  * for the first digit.
1924  * \return Returns 0 on normal return, or 1 on a timeout. In the case of
1925  * a timeout, any digits that were read before the timeout will still be available in s.
1926  * RETURNS 2 in full version when ctrlfd is available, NOT 1
1927  */
1928 int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders);
1929 int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders, int audiofd, int ctrlfd);
1930 
1931 /*! \brief Report DTMF on channel 0 */
1932 #define AST_BRIDGE_DTMF_CHANNEL_0 (1 << 0)
1933 /*! \brief Report DTMF on channel 1 */
1934 #define AST_BRIDGE_DTMF_CHANNEL_1 (1 << 1)
1935 /*! \brief Return all voice frames on channel 0 */
1936 #define AST_BRIDGE_REC_CHANNEL_0 (1 << 2)
1937 /*! \brief Return all voice frames on channel 1 */
1938 #define AST_BRIDGE_REC_CHANNEL_1 (1 << 3)
1939 /*! \brief Ignore all signal frames except NULL */
1940 #define AST_BRIDGE_IGNORE_SIGS (1 << 4)
1941 
1942 
1943 /*!
1944  * \brief Makes two channel formats compatible
1945  * \param c0 first channel to make compatible
1946  * \param c1 other channel to make compatible
1947  * \details
1948  * Set two channels to compatible formats -- call before ast_channel_bridge in general.
1949  * \return Returns 0 on success and -1 if it could not be done
1950  */
1951 int ast_channel_make_compatible(struct ast_channel *c0, struct ast_channel *c1);
1952 
1953 /*!
1954  * \brief Bridge two channels together (early)
1955  * \param c0 first channel to bridge
1956  * \param c1 second channel to bridge
1957  * \details
1958  * Bridge two channels (c0 and c1) together early. This implies either side may not be answered yet.
1959  * \return Returns 0 on success and -1 if it could not be done
1960  */
1961 int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1);
1962 
1963 /*!
1964  * \brief Bridge two channels together
1965  * \param c0 first channel to bridge
1966  * \param c1 second channel to bridge
1967  * \param config config for the channels
1968  * \param fo destination frame(?)
1969  * \param rc destination channel(?)
1970  * \details
1971  * Bridge two channels (c0 and c1) together. If an important frame occurs, we return that frame in
1972  * *rf (remember, it could be NULL) and which channel (0 or 1) in rc
1973  */
1974 /* int ast_channel_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc); */
1975 int ast_channel_bridge(struct ast_channel *c0,struct ast_channel *c1,
1976  struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc);
1977 
1978 /*!
1979  * \brief Weird function made for call transfers
1980  *
1981  * \param original channel to make a copy of
1982  * \param clone copy of the original channel
1983  *
1984  * \details
1985  * This is a very strange and freaky function used primarily for transfer. Suppose that
1986  * "original" and "clone" are two channels in random situations. This function takes
1987  * the guts out of "clone" and puts them into the "original" channel, then alerts the
1988  * channel driver of the change, asking it to fixup any private information (like the
1989  * p->owner pointer) that is affected by the change. The physical layer of the original
1990  * channel is hung up.
1991  *
1992  * \note Neither channel passed here should be locked before
1993  * calling this function. This function performs deadlock
1994  * avoidance involving these two channels.
1995  */
1996 int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone);
1997 
1998 /*!
1999  * \brief Setup a masquerade to transfer a call.
2000  * \since 1.8
2001  *
2002  * \param target_chan Target of the call transfer. (Masquerade original channel)
2003  * \param target_id New connected line information for the target channel.
2004  * \param target_held TRUE if the target call is on hold.
2005  * \param transferee_chan Transferee of the call transfer. (Masquerade clone channel)
2006  * \param transferee_id New connected line information for the transferee channel.
2007  * \param transferee_held TRUE if the transferee call is on hold.
2008  *
2009  * \details
2010  * Party A - Transferee
2011  * Party B - Transferer
2012  * Party C - Target of transfer
2013  *
2014  * Party B transfers A to C.
2015  *
2016  * Party A is connected to bridged channel B1.
2017  * Party B is connected to channels C1 and C2.
2018  * Party C is connected to bridged channel B2.
2019  *
2020  * Party B -- C1 == B1 -- Party A
2021  * __/
2022  * /
2023  * Party B -- C2 == B2 -- Party C
2024  *
2025  * Bridged channel B1 is masqueraded into channel C2. Where B1
2026  * is the masquerade clone channel and C2 is the masquerade
2027  * original channel.
2028  *
2029  * \see ast_channel_masquerade()
2030  *
2031  * \note Has the same locking requirements as ast_channel_masquerade().
2032  *
2033  * \retval 0 on success.
2034  * \retval -1 on error.
2035  */
2037  struct ast_channel *target_chan,
2038  const struct ast_party_connected_line *target_id,
2039  int target_held,
2040  struct ast_channel *transferee_chan,
2041  const struct ast_party_connected_line *transferee_id,
2042  int transferee_held);
2043 
2044 /*!
2045  * \brief Gives the string form of a given cause code.
2046  *
2047  * \param state cause to get the description of
2048  * \return the text form of the binary cause code given
2049  */
2050 const char *ast_cause2str(int state) attribute_pure;
2051 
2052 /*!
2053  * \brief Convert the string form of a cause code to a number
2054  *
2055  * \param name string form of the cause
2056  * \return the cause code
2057  */
2058 int ast_str2cause(const char *name) attribute_pure;
2059 
2060 /*!
2061  * \brief Gives the string form of a given channel state
2062  *
2063  * \param ast_channel_state state to get the name of
2064  * \return the text form of the binary state given
2065  */
2066 const char *ast_state2str(enum ast_channel_state);
2067 
2068 /*!
2069  * \brief Gives the string form of a given transfer capability
2070  *
2071  * \param transfercapability transfer capability to get the name of
2072  * \return the text form of the binary transfer capability
2073  */
2074 char *ast_transfercapability2str(int transfercapability) attribute_const;
2075 
2076 /*
2077  * Options: Some low-level drivers may implement "options" allowing fine tuning of the
2078  * low level channel. See frame.h for options. Note that many channel drivers may support
2079  * none or a subset of those features, and you should not count on this if you want your
2080  * asterisk application to be portable. They're mainly useful for tweaking performance
2081  */
2082 
2083 /*!
2084  * \brief Sets an option on a channel
2085  *
2086  * \param channel channel to set options on
2087  * \param option option to change
2088  * \param data data specific to option
2089  * \param datalen length of the data
2090  * \param block blocking or not
2091  * \details
2092  * Set an option on a channel (see frame.h), optionally blocking awaiting the reply
2093  * \return 0 on success and -1 on failure
2094  */
2095 int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block);
2096 
2097 /*! Pick the best codec
2098  * Choose the best codec... Uhhh... Yah. */
2100 
2101 
2102 /*!
2103  * \brief Checks the value of an option
2104  *
2105  * Query the value of an option
2106  * Works similarly to setoption except only reads the options.
2107  */
2108 int ast_channel_queryoption(struct ast_channel *channel, int option, void *data, int *datalen, int block);
2109 
2110 /*!
2111  * \brief Checks for HTML support on a channel
2112  * \return 0 if channel does not support HTML or non-zero if it does
2113  */
2114 int ast_channel_supports_html(struct ast_channel *channel);
2115 
2116 /*!
2117  * \brief Sends HTML on given channel
2118  * Send HTML or URL on link.
2119  * \return 0 on success or -1 on failure
2120  */
2121 int ast_channel_sendhtml(struct ast_channel *channel, int subclass, const char *data, int datalen);
2122 
2123 /*!
2124  * \brief Sends a URL on a given link
2125  * Send URL on link.
2126  * \return 0 on success or -1 on failure
2127  */
2128 int ast_channel_sendurl(struct ast_channel *channel, const char *url);
2129 
2130 /*!
2131  * \brief Defers DTMF so that you only read things like hangups and audio.
2132  * \return non-zero if channel was already DTMF-deferred or
2133  * 0 if channel is just now being DTMF-deferred
2134  */
2135 int ast_channel_defer_dtmf(struct ast_channel *chan);
2136 
2137 /*! Undo defer. ast_read will return any DTMF characters that were queued */
2138 void ast_channel_undefer_dtmf(struct ast_channel *chan);
2139 
2140 /*! Initiate system shutdown -- prevents new channels from being allocated.
2141  * \param hangup If "hangup" is non-zero, all existing channels will receive soft
2142  * hangups */
2143 void ast_begin_shutdown(int hangup);
2144 
2145 /*! Cancels an existing shutdown and returns to normal operation */
2146 void ast_cancel_shutdown(void);
2147 
2148 /*! \return number of channels available for lookup */
2149 int ast_active_channels(void);
2150 
2151 /*! \return the number of channels not yet destroyed */
2152 int ast_undestroyed_channels(void);
2153 
2154 /*! \return non-zero if Asterisk is being shut down */
2155 int ast_shutting_down(void);
2156 
2157 /*! Activate a given generator */
2158 int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params);
2159 
2160 /*! Deactivate an active generator */
2161 void ast_deactivate_generator(struct ast_channel *chan);
2162 
2163 /*!
2164  * \brief Set caller ID number, name and ANI and generate AMI event.
2165  *
2166  * \note Use ast_channel_set_caller() and ast_channel_set_caller_event() instead.
2167  * \note The channel does not need to be locked before calling this function.
2168  */
2169 void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani);
2170 
2171 /*!
2172  * \brief Set the caller id information in the Asterisk channel
2173  * \since 1.8
2174  *
2175  * \param chan Asterisk channel to set caller id information
2176  * \param caller Caller id information
2177  * \param update What caller information to update. NULL if all.
2178  *
2179  * \return Nothing
2180  *
2181  * \note The channel does not need to be locked before calling this function.
2182  */
2183 void ast_channel_set_caller(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update);
2184 
2185 /*!
2186  * \brief Set the caller id information in the Asterisk channel and generate an AMI event
2187  * if the caller id name or number changed.
2188  * \since 1.8
2189  *
2190  * \param chan Asterisk channel to set caller id information
2191  * \param caller Caller id information
2192  * \param update What caller information to update. NULL if all.
2193  *
2194  * \return Nothing
2195  *
2196  * \note The channel does not need to be locked before calling this function.
2197  */
2198 void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update);
2199 
2200 /*! Set the file descriptor on the channel */
2201 void ast_channel_set_fd(struct ast_channel *chan, int which, int fd);
2202 
2203 /*! Add a channel to an optimized waitfor */
2204 void ast_poll_channel_add(struct ast_channel *chan0, struct ast_channel *chan1);
2205 
2206 /*! Delete a channel from an optimized waitfor */
2207 void ast_poll_channel_del(struct ast_channel *chan0, struct ast_channel *chan1);
2208 
2209 /*! Start a tone going */
2210 int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);
2211 /*! Stop a tone from playing */
2212 void ast_tonepair_stop(struct ast_channel *chan);
2213 /*! Play a tone pair for a given amount of time */
2214 int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);
2215 
2216 /*!
2217  * \brief Automatically service a channel for us...
2218  *
2219  * \retval 0 success
2220  * \retval -1 failure, or the channel is already being autoserviced
2221  */
2222 int ast_autoservice_start(struct ast_channel *chan);
2223 
2224 /*!
2225  * \brief Stop servicing a channel for us...
2226  *
2227  * \note if chan is locked prior to calling ast_autoservice_stop, it
2228  * is likely that there will be a deadlock between the thread that calls
2229  * ast_autoservice_stop and the autoservice thread. It is important
2230  * that chan is not locked prior to this call
2231  *
2232  * \param chan
2233  * \retval 0 success
2234  * \retval -1 error, or the channel has been hungup
2235  */
2236 int ast_autoservice_stop(struct ast_channel *chan);
2237 
2238 /*!
2239  * \brief Ignore certain frame types
2240  * \note Normally, we cache DTMF, IMAGE, HTML, TEXT, and CONTROL frames
2241  * while a channel is in autoservice and queue them up when taken out of
2242  * autoservice. When this is not desireable, this API may be used to
2243  * cause the channel to ignore those frametypes after the channel is put
2244  * into autoservice, but before autoservice is stopped.
2245  * \retval 0 success
2246  * \retval -1 channel is not in autoservice
2247  */
2248 int ast_autoservice_ignore(struct ast_channel *chan, enum ast_frame_type ftype);
2249 
2250 /*!
2251  * \brief Enable or disable timer ticks for a channel
2252  *
2253  * \param c channel
2254  * \param rate number of timer ticks per second
2255  * \param func callback function
2256  * \param data
2257  *
2258  * \details
2259  * If timers are supported, force a scheduled expiration on the
2260  * timer fd, at which point we call the callback function / data
2261  *
2262  * \note Call this function with a rate of 0 to turn off the timer ticks
2263  *
2264  * \version 1.6.1 changed samples parameter to rate, accomodates new timing methods
2265  */
2266 int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const void *data), void *data);
2267 int ast_settimeout_full(struct ast_channel *c, unsigned int rate, int (*func)(const void *data), void *data, unsigned int is_ao2_obj);
2268 
2269 /*!
2270  * \brief Transfer a channel (if supported).
2271  * \retval -1 on error
2272  * \retval 0 if not supported
2273  * \retval 1 if supported and requested
2274  * \param chan current channel
2275  * \param dest destination extension for transfer
2276  */
2277 int ast_transfer(struct ast_channel *chan, char *dest);
2278 
2279 /*!
2280  * \brief Start masquerading a channel
2281  * \note absolutely _NO_ channel locks should be held before calling this function.
2282  * \details
2283  * XXX This is a seriously whacked out operation. We're essentially putting the guts of
2284  * the clone channel into the original channel. Start by killing off the original
2285  * channel's backend. I'm not sure we're going to keep this function, because
2286  * while the features are nice, the cost is very high in terms of pure nastiness. XXX
2287  * \param chan Channel to masquerade
2288  */
2289 int ast_do_masquerade(struct ast_channel *chan);
2290 
2291 /*!
2292  * \brief Find bridged channel
2293  *
2294  * \note This function does _not_ return a reference to the bridged channel.
2295  * The reason for this is mostly historical. It _should_ return a reference,
2296  * but it will take a lot of work to make the code base account for that.
2297  * So, for now, the old rules still apply for how to handle this function.
2298  * If this function is being used from the channel thread that owns the channel,
2299  * then a reference is already held, and channel locking is not required to
2300  * guarantee that the channel will stay around. If this function is used
2301  * outside of the associated channel thread, the channel parameter 'chan'
2302  * MUST be locked before calling this function. Also, 'chan' must remain locked
2303  * for the entire time that the result of this function is being used.
2304  *
2305  * \param chan Current channel
2306  *
2307  * \return A pointer to the bridged channel
2308 */
2309 struct ast_channel *ast_bridged_channel(struct ast_channel *chan);
2310 
2311 /*!
2312  * \brief Inherits channel variable from parent to child channel
2313  * \param parent Parent channel
2314  * \param child Child channel
2315  *
2316  * \details
2317  * Scans all channel variables in the parent channel, looking for those
2318  * that should be copied into the child channel.
2319  * Variables whose names begin with a single '_' are copied into the
2320  * child channel with the prefix removed.
2321  * Variables whose names begin with '__' are copied into the child
2322  * channel with their names unchanged.
2323  */
2324 void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child);
2325 
2326 /*!
2327  * \brief adds a list of channel variables to a channel
2328  * \param chan the channel
2329  * \param vars a linked list of variables
2330  *
2331  * \details
2332  * Variable names can be for a regular channel variable or a dialplan function
2333  * that has the ability to be written to.
2334  */
2335 void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars);
2336 
2337 /*!
2338  * \brief An opaque 'object' structure use by silence generators on channels.
2339  */
2340 struct ast_silence_generator;
2341 
2342 /*!
2343  * \brief Starts a silence generator on the given channel.
2344  * \param chan The channel to generate silence on
2345  * \return An ast_silence_generator pointer, or NULL if an error occurs
2346  *
2347  * \details
2348  * This function will cause SLINEAR silence to be generated on the supplied
2349  * channel until it is disabled; if the channel cannot be put into SLINEAR
2350  * mode then the function will fail.
2351  *
2352  * \note
2353  * The pointer returned by this function must be preserved and passed to
2354  * ast_channel_stop_silence_generator when you wish to stop the silence
2355  * generation.
2356  */
2358 
2359 /*!
2360  * \brief Stops a previously-started silence generator on the given channel.
2361  * \param chan The channel to operate on
2362  * \param state The ast_silence_generator pointer return by a previous call to
2363  * ast_channel_start_silence_generator.
2364  * \return nothing
2365  *
2366  * \details
2367  * This function will stop the operating silence generator and return the channel
2368  * to its previous write format.
2369  */
2370 void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state);
2371 
2372 /*!
2373  * \brief Check if the channel can run in internal timing mode.
2374  * \param chan The channel to check
2375  * \return boolean
2376  *
2377  * \details
2378  * This function will return 1 if internal timing is enabled and the timing
2379  * device is available.
2380  */
2381 int ast_internal_timing_enabled(struct ast_channel *chan);
2382 
2383 /* Misc. functions below */
2384 
2385 /*!
2386  * \brief if fd is a valid descriptor, set *pfd with the descriptor
2387  * \return Return 1 (not -1!) if added, 0 otherwise (so we can add the
2388  * return value to the index into the array)
2389  */
2390 static inline int ast_add_fd(struct pollfd *pfd, int fd)
2391 {
2392  pfd->fd = fd;
2393  pfd->events = POLLIN | POLLPRI;
2394  return fd >= 0;
2395 }
2396 
2397 /*! \brief Helper function for migrating select to poll */
2398 static inline int ast_fdisset(struct pollfd *pfds, int fd, int maximum, int *start)
2399 {
2400  int x;
2401  int dummy = 0;
2402 
2403  if (fd < 0)
2404  return 0;
2405  if (!start)
2406  start = &dummy;
2407  for (x = *start; x < maximum; x++)
2408  if (pfds[x].fd == fd) {
2409  if (x == *start)
2410  (*start)++;
2411  return pfds[x].revents;
2412  }
2413  return 0;
2414 }
2415 
2416 /*! \brief Retrieves the current T38 state of a channel */
2417 static inline enum ast_t38_state ast_channel_get_t38_state(struct ast_channel *chan)
2418 {
2419  enum ast_t38_state state = T38_STATE_UNAVAILABLE;
2420  int datalen = sizeof(state);
2421 
2422  ast_channel_queryoption(chan, AST_OPTION_T38_STATE, &state, &datalen, 0);
2423 
2424  return state;
2425 }
2426 
2427 #define CHECK_BLOCKING(c) do { \
2428  if (ast_test_flag(c, AST_FLAG_BLOCKING)) {\
2429  ast_debug(1, "Thread %p is blocking '%s', already blocked by thread %p in procedure %s\n", \
2430  (void *) pthread_self(), (c)->name, (void *) (c)->blocker, (c)->blockproc); \
2431  } else { \
2432  (c)->blocker = pthread_self(); \
2433  (c)->blockproc = __PRETTY_FUNCTION__; \
2434  ast_set_flag(c, AST_FLAG_BLOCKING); \
2435  } } while (0)
2436 
2437 ast_group_t ast_get_group(const char *s);
2438 
2439 /*! \brief print call- and pickup groups into buffer */
2440 char *ast_print_group(char *buf, int buflen, ast_group_t group);
2441 
2442 /*!
2443  * \brief Convert enum channelreloadreason to text string for manager event
2444  * \param reason The reason for reload (manager, cli, start etc)
2445  */
2446 const char *channelreloadreason2txt(enum channelreloadreason reason);
2447 
2448 /*! \brief return an ast_variable list of channeltypes */
2449 struct ast_variable *ast_channeltype_list(void);
2450 
2451 /*!
2452  * \brief return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument
2453  * \param reason The integer argument, usually taken from AST_CONTROL_ macros
2454  * \return char pointer explaining the code
2455  */
2456 const char *ast_channel_reason2str(int reason);
2457 
2458 /*! \brief channel group info */
2461  char *category;
2462  char *group;
2464 };
2465 
2466 #define ast_channel_lock(chan) ao2_lock(chan)
2467 #define ast_channel_unlock(chan) ao2_unlock(chan)
2468 #define ast_channel_trylock(chan) ao2_trylock(chan)
2469 
2470 /*!
2471  * \brief Lock two channels.
2472  */
2473 #define ast_channel_lock_both(chan1, chan2) do { \
2474  ast_channel_lock(chan1); \
2475  while (ast_channel_trylock(chan2)) { \
2476  ast_channel_unlock(chan1); \
2477  sched_yield(); \
2478  ast_channel_lock(chan1); \
2479  } \
2480  } while (0)
2481 
2482 /*!
2483  * \brief Increase channel reference count
2484  *
2485  * \param c the channel
2486  *
2487  * \retval c always
2488  *
2489  * \since 1.8
2490  */
2491 #define ast_channel_ref(c) ({ ao2_ref(c, +1); (c); })
2492 
2493 /*!
2494  * \brief Decrease channel reference count
2495  *
2496  * \param c the channel
2497  *
2498  * \retval NULL always
2499  *
2500  * \since 1.8
2501  */
2502 #define ast_channel_unref(c) ({ ao2_ref(c, -1); (struct ast_channel *) (NULL); })
2503 
2504 /*! Channel Iterating @{ */
2505 
2506 /*!
2507  * \brief A channel iterator
2508  *
2509  * This is an opaque type.
2510  */
2511 struct ast_channel_iterator;
2512 
2513 /*!
2514  * \brief Destroy a channel iterator
2515  *
2516  * \arg i the itereator to destroy
2517  *
2518  * This function is used to destroy a channel iterator that was retrieved by
2519  * using one of the channel_iterator_new() functions.
2520  *
2521  * \return NULL, for convenience to clear out the pointer to the iterator that
2522  * was just destroyed.
2523  *
2524  * \since 1.8
2525  */
2527 
2528 /*!
2529  * \brief Create a new channel iterator based on extension
2530  *
2531  * \arg exten The extension that channels must be in
2532  * \arg context The context that channels must be in (optional)
2533  *
2534  * After creating an iterator using this function, the ast_channel_iterator_next()
2535  * function can be used to iterate through all channels that are currently
2536  * in the specified context and extension.
2537  *
2538  * \retval NULL on failure
2539  * \retval a new channel iterator based on the specified parameters
2540  *
2541  * \since 1.8
2542  */
2543 struct ast_channel_iterator *ast_channel_iterator_by_exten_new(const char *exten, const char *context);
2544 
2545 /*!
2546  * \brief Create a new channel iterator based on name
2547  *
2548  * \arg name channel name or channel uniqueid to match
2549  * \arg name_len number of characters in the channel name to match on. This
2550  * would be used to match based on name prefix. If matching on the full
2551  * channel name is desired, then this parameter should be 0.
2552  *
2553  * After creating an iterator using this function, the ast_channel_iterator_next()
2554  * function can be used to iterate through all channels that exist that have
2555  * the specified name or name prefix.
2556  *
2557  * \retval NULL on failure
2558  * \retval a new channel iterator based on the specified parameters
2559  *
2560  * \since 1.8
2561  */
2562 struct ast_channel_iterator *ast_channel_iterator_by_name_new(const char *name, size_t name_len);
2563 
2564 /*!
2565  * \brief Create a new channel iterator
2566  *
2567  * After creating an iterator using this function, the ast_channel_iterator_next()
2568  * function can be used to iterate through all channels that exist.
2569  *
2570  * \retval NULL on failure
2571  * \retval a new channel iterator
2572  *
2573  * \since 1.8
2574  */
2576 
2577 /*!
2578  * \brief Get the next channel for a channel iterator
2579  *
2580  * \arg i the channel iterator that was created using one of the
2581  * channel_iterator_new() functions.
2582  *
2583  * This function should be used to iterate through all channels that match a
2584  * specified set of parameters that were provided when the iterator was created.
2585  *
2586  * \retval the next channel that matches the parameters used when the iterator
2587  * was created.
2588  * \retval NULL, if no more channels match the iterator parameters.
2589  *
2590  * \since 1.8
2591  */
2593 
2594 /*! @} End channel iterator definitions. */
2595 
2596 /*!
2597  * \brief Call a function with every active channel
2598  *
2599  * This function executes a callback one time for each active channel on the
2600  * system. The channel is provided as an argument to the function.
2601  *
2602  * \note Absolutely _NO_ channel locks should be held before calling this function.
2603  * \since 1.8
2604  */
2605 struct ast_channel *ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg,
2606  void *data, int ao2_flags);
2607 
2608 /*! @{ Channel search functions */
2609 
2610 /*!
2611  * \brief Find a channel by name
2612  *
2613  * \arg name the name or uniqueid of the channel to search for
2614  *
2615  * Find a channel that has the same name as the provided argument.
2616  *
2617  * \retval a channel with the name specified by the argument
2618  * \retval NULL if no channel was found
2619  *
2620  * \since 1.8
2621  */
2622 struct ast_channel *ast_channel_get_by_name(const char *name);
2623 
2624 /*!
2625  * \brief Find a channel by a name prefix
2626  *
2627  * \arg name The channel name or uniqueid prefix to search for
2628  * \arg name_len Only search for up to this many characters from the name
2629  *
2630  * Find a channel that has the same name prefix as specified by the arguments.
2631  *
2632  * \retval a channel with the name prefix specified by the arguments
2633  * \retval NULL if no channel was found
2634  *
2635  * \since 1.8
2636  */
2637 struct ast_channel *ast_channel_get_by_name_prefix(const char *name, size_t name_len);
2638 
2639 /*!
2640  * \brief Find a channel by extension and context
2641  *
2642  * \arg exten the extension to search for
2643  * \arg context the context to search for (optional)
2644  *
2645  * Return a channel that is currently at the specified extension and context.
2646  *
2647  * \retval a channel that is at the specified extension and context
2648  * \retval NULL if no channel was found
2649  *
2650  * \since 1.8
2651  */
2652 struct ast_channel *ast_channel_get_by_exten(const char *exten, const char *context);
2653 
2654 /*! @} End channel search functions. */
2655 
2656 /*!
2657  \brief propagate the linked id between chan and peer
2658  */
2659 void ast_channel_set_linkgroup(struct ast_channel *chan, struct ast_channel *peer);
2660 
2661 
2662 /*!
2663  * \brief Initialize the given name structure.
2664  * \since 1.8
2665  *
2666  * \param init Name structure to initialize.
2667  *
2668  * \return Nothing
2669  */
2670 void ast_party_name_init(struct ast_party_name *init);
2671 
2672 /*!
2673  * \brief Copy the source party name information to the destination party name.
2674  * \since 1.8
2675  *
2676  * \param dest Destination party name
2677  * \param src Source party name
2678  *
2679  * \return Nothing
2680  */
2681 void ast_party_name_copy(struct ast_party_name *dest, const struct ast_party_name *src);
2682 
2683 /*!
2684  * \brief Initialize the given party name structure using the given guide
2685  * for a set update operation.
2686  * \since 1.8
2687  *
2688  * \details
2689  * The initialization is needed to allow a set operation to know if a
2690  * value needs to be updated. Simple integers need the guide's original
2691  * value in case the set operation is not trying to set a new value.
2692  * String values are simply set to NULL pointers if they are not going
2693  * to be updated.
2694  *
2695  * \param init Party name structure to initialize.
2696  * \param guide Source party name to use as a guide in initializing.
2697  *
2698  * \return Nothing
2699  */
2700 void ast_party_name_set_init(struct ast_party_name *init, const struct ast_party_name *guide);
2701 
2702 /*!
2703  * \brief Set the source party name information into the destination party name.
2704  * \since 1.8
2705  *
2706  * \param dest The name one wishes to update
2707  * \param src The new name values to update the dest
2708  *
2709  * \return Nothing
2710  */
2711 void ast_party_name_set(struct ast_party_name *dest, const struct ast_party_name *src);
2712 
2713 /*!
2714  * \brief Destroy the party name contents
2715  * \since 1.8
2716  *
2717  * \param doomed The party name to destroy.
2718  *
2719  * \return Nothing
2720  */
2721 void ast_party_name_free(struct ast_party_name *doomed);
2722 
2723 /*!
2724  * \brief Initialize the given number structure.
2725  * \since 1.8
2726  *
2727  * \param init Number structure to initialize.
2728  *
2729  * \return Nothing
2730  */
2731 void ast_party_number_init(struct ast_party_number *init);
2732 
2733 /*!
2734  * \brief Copy the source party number information to the destination party number.
2735  * \since 1.8
2736  *
2737  * \param dest Destination party number
2738  * \param src Source party number
2739  *
2740  * \return Nothing
2741  */
2742 void ast_party_number_copy(struct ast_party_number *dest, const struct ast_party_number *src);
2743 
2744 /*!
2745  * \brief Initialize the given party number structure using the given guide
2746  * for a set update operation.
2747  * \since 1.8
2748  *
2749  * \details
2750  * The initialization is needed to allow a set operation to know if a
2751  * value needs to be updated. Simple integers need the guide's original
2752  * value in case the set operation is not trying to set a new value.
2753  * String values are simply set to NULL pointers if they are not going
2754  * to be updated.
2755  *
2756  * \param init Party number structure to initialize.
2757  * \param guide Source party number to use as a guide in initializing.
2758  *
2759  * \return Nothing
2760  */
2761 void ast_party_number_set_init(struct ast_party_number *init, const struct ast_party_number *guide);
2762 
2763 /*!
2764  * \brief Set the source party number information into the destination party number.
2765  * \since 1.8
2766  *
2767  * \param dest The number one wishes to update
2768  * \param src The new number values to update the dest
2769  *
2770  * \return Nothing
2771  */
2772 void ast_party_number_set(struct ast_party_number *dest, const struct ast_party_number *src);
2773 
2774 /*!
2775  * \brief Destroy the party number contents
2776  * \since 1.8
2777  *
2778  * \param doomed The party number to destroy.
2779  *
2780  * \return Nothing
2781  */
2782 void ast_party_number_free(struct ast_party_number *doomed);
2783 
2784 /*!
2785  * \since 1.8
2786  * \brief Initialize the given subaddress structure.
2787  *
2788  * \param init Subaddress structure to initialize.
2789  *
2790  * \return Nothing
2791  */
2793 
2794 /*!
2795  * \since 1.8
2796  * \brief Copy the source party subaddress information to the destination party subaddress.
2797  *
2798  * \param dest Destination party subaddress
2799  * \param src Source party subaddress
2800  *
2801  * \return Nothing
2802  */
2803 void ast_party_subaddress_copy(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src);
2804 
2805 /*!
2806  * \since 1.8
2807  * \brief Initialize the given party subaddress structure using the given guide
2808  * for a set update operation.
2809  *
2810  * \details
2811  * The initialization is needed to allow a set operation to know if a
2812  * value needs to be updated. Simple integers need the guide's original
2813  * value in case the set operation is not trying to set a new value.
2814  * String values are simply set to NULL pointers if they are not going
2815  * to be updated.
2816  *
2817  * \param init Party subaddress structure to initialize.
2818  * \param guide Source party subaddress to use as a guide in initializing.
2819  *
2820  * \return Nothing
2821  */
2822 void ast_party_subaddress_set_init(struct ast_party_subaddress *init, const struct ast_party_subaddress *guide);
2823 
2824 /*!
2825  * \since 1.8
2826  * \brief Set the source party subaddress information into the destination party subaddress.
2827  *
2828  * \param dest The subaddress one wishes to update
2829  * \param src The new subaddress values to update the dest
2830  *
2831  * \return Nothing
2832  */
2833 void ast_party_subaddress_set(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src);
2834 
2835 /*!
2836  * \since 1.8
2837  * \brief Destroy the party subaddress contents
2838  *
2839  * \param doomed The party subaddress to destroy.
2840  *
2841  * \return Nothing
2842  */
2843 void ast_party_subaddress_free(struct ast_party_subaddress *doomed);
2844 
2845 /*!
2846  * \brief Initialize the given party id structure.
2847  * \since 1.8
2848  *
2849  * \param init Party id structure to initialize.
2850  *
2851  * \return Nothing
2852  */
2853 void ast_party_id_init(struct ast_party_id *init);
2854 
2855 /*!
2856  * \brief Copy the source party id information to the destination party id.
2857  * \since 1.8
2858  *
2859  * \param dest Destination party id
2860  * \param src Source party id
2861  *
2862  * \return Nothing
2863  */
2864 void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src);
2865 
2866 /*!
2867  * \brief Initialize the given party id structure using the given guide
2868  * for a set update operation.
2869  * \since 1.8
2870  *
2871  * \details
2872  * The initialization is needed to allow a set operation to know if a
2873  * value needs to be updated. Simple integers need the guide's original
2874  * value in case the set operation is not trying to set a new value.
2875  * String values are simply set to NULL pointers if they are not going
2876  * to be updated.
2877  *
2878  * \param init Party id structure to initialize.
2879  * \param guide Source party id to use as a guide in initializing.
2880  *
2881  * \return Nothing
2882  */
2883 void ast_party_id_set_init(struct ast_party_id *init, const struct ast_party_id *guide);
2884 
2885 /*!
2886  * \brief Set the source party id information into the destination party id.
2887  * \since 1.8
2888  *
2889  * \param dest The id one wishes to update
2890  * \param src The new id values to update the dest
2891  * \param update What id information to update. NULL if all.
2892  *
2893  * \return Nothing
2894  */
2895 void ast_party_id_set(struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update);
2896 
2897 /*!
2898  * \brief Destroy the party id contents
2899  * \since 1.8
2900  *
2901  * \param doomed The party id to destroy.
2902  *
2903  * \return Nothing
2904  */
2905 void ast_party_id_free(struct ast_party_id *doomed);
2906 
2907 /*!
2908  * \brief Determine the overall presentation value for the given party.
2909  * \since 1.8
2910  *
2911  * \param id Party to determine the overall presentation value.
2912  *
2913  * \return Overall presentation value for the given party.
2914  */
2915 int ast_party_id_presentation(const struct ast_party_id *id);
2916 
2917 /*!
2918  * \brief Initialize the given dialed structure.
2919  * \since 1.8
2920  *
2921  * \param init Dialed structure to initialize.
2922  *
2923  * \return Nothing
2924  */
2925 void ast_party_dialed_init(struct ast_party_dialed *init);
2926 
2927 /*!
2928  * \brief Copy the source dialed party information to the destination dialed party.
2929  * \since 1.8
2930  *
2931  * \param dest Destination dialed party
2932  * \param src Source dialed party
2933  *
2934  * \return Nothing
2935  */
2936 void ast_party_dialed_copy(struct ast_party_dialed *dest, const struct ast_party_dialed *src);
2937 
2938 /*!
2939  * \brief Initialize the given dialed structure using the given
2940  * guide for a set update operation.
2941  * \since 1.8
2942  *
2943  * \details
2944  * The initialization is needed to allow a set operation to know if a
2945  * value needs to be updated. Simple integers need the guide's original
2946  * value in case the set operation is not trying to set a new value.
2947  * String values are simply set to NULL pointers if they are not going
2948  * to be updated.
2949  *
2950  * \param init Caller structure to initialize.
2951  * \param guide Source dialed to use as a guide in initializing.
2952  *
2953  * \return Nothing
2954  */
2955 void ast_party_dialed_set_init(struct ast_party_dialed *init, const struct ast_party_dialed *guide);
2956 
2957 /*!
2958  * \brief Set the dialed information based on another dialed source
2959  * \since 1.8
2960  *
2961  * This is similar to ast_party_dialed_copy, except that NULL values for
2962  * strings in the src parameter indicate not to update the corresponding dest values.
2963  *
2964  * \param dest The dialed one wishes to update
2965  * \param src The new dialed values to update the dest
2966  *
2967  * \return Nada
2968  */
2969 void ast_party_dialed_set(struct ast_party_dialed *dest, const struct ast_party_dialed *src);
2970 
2971 /*!
2972  * \brief Destroy the dialed party contents
2973  * \since 1.8
2974  *
2975  * \param doomed The dialed party to destroy.
2976  *
2977  * \return Nothing
2978  */
2979 void ast_party_dialed_free(struct ast_party_dialed *doomed);
2980 
2981 /*!
2982  * \since 1.8
2983  * \brief Initialize the given caller structure.
2984  *
2985  * \param init Caller structure to initialize.
2986  *
2987  * \return Nothing
2988  */
2989 void ast_party_caller_init(struct ast_party_caller *init);
2990 
2991 /*!
2992  * \since 1.8
2993  * \brief Copy the source caller information to the destination caller.
2994  *
2995  * \param dest Destination caller
2996  * \param src Source caller
2997  *
2998  * \return Nothing
2999  */
3000 void ast_party_caller_copy(struct ast_party_caller *dest, const struct ast_party_caller *src);
3001 
3002 /*!
3003  * \brief Initialize the given caller structure using the given
3004  * guide for a set update operation.
3005  * \since 1.8
3006  *
3007  * \details
3008  * The initialization is needed to allow a set operation to know if a
3009  * value needs to be updated. Simple integers need the guide's original
3010  * value in case the set operation is not trying to set a new value.
3011  * String values are simply set to NULL pointers if they are not going
3012  * to be updated.
3013  *
3014  * \param init Caller structure to initialize.
3015  * \param guide Source caller to use as a guide in initializing.
3016  *
3017  * \return Nothing
3018  */
3019 void ast_party_caller_set_init(struct ast_party_caller *init, const struct ast_party_caller *guide);
3020 
3021 /*!
3022  * \brief Set the caller information based on another caller source
3023  * \since 1.8
3024  *
3025  * This is similar to ast_party_caller_copy, except that NULL values for
3026  * strings in the src parameter indicate not to update the corresponding dest values.
3027  *
3028  * \param dest The caller one wishes to update
3029  * \param src The new caller values to update the dest
3030  * \param update What caller information to update. NULL if all.
3031  *
3032  * \return Nada
3033  */
3034 void ast_party_caller_set(struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update);
3035 
3036 /*!
3037  * \brief Destroy the caller party contents
3038  * \since 1.8
3039  *
3040  * \param doomed The caller party to destroy.
3041  *
3042  * \return Nothing
3043  */
3044 void ast_party_caller_free(struct ast_party_caller *doomed);
3045 
3046 /*!
3047  * \since 1.8
3048  * \brief Initialize the given connected line structure.
3049  *
3050  * \param init Connected line structure to initialize.
3051  *
3052  * \return Nothing
3053  */
3055 
3056 /*!
3057  * \since 1.8
3058  * \brief Copy the source connected line information to the destination connected line.
3059  *
3060  * \param dest Destination connected line
3061  * \param src Source connected line
3062  *
3063  * \return Nothing
3064  */
3066 
3067 /*!
3068  * \since 1.8
3069  * \brief Initialize the given connected line structure using the given
3070  * guide for a set update operation.
3071  *
3072  * \details
3073  * The initialization is needed to allow a set operation to know if a
3074  * value needs to be updated. Simple integers need the guide's original
3075  * value in case the set operation is not trying to set a new value.
3076  * String values are simply set to NULL pointers if they are not going
3077  * to be updated.
3078  *
3079  * \param init Connected line structure to initialize.
3080  * \param guide Source connected line to use as a guide in initializing.
3081  *
3082  * \return Nothing
3083  */
3085 
3086 /*!
3087  * \since 1.8
3088  * \brief Set the connected line information based on another connected line source
3089  *
3090  * This is similar to ast_party_connected_line_copy, except that NULL values for
3091  * strings in the src parameter indicate not to update the corresponding dest values.
3092  *
3093  * \param dest The connected line one wishes to update
3094  * \param src The new connected line values to update the dest
3095  * \param update What connected line information to update. NULL if all.
3096  *
3097  * \return Nothing
3098  */
3100 
3101 /*!
3102  * \since 1.8
3103  * \brief Collect the caller party information into a connected line structure.
3104  *
3105  * \param connected Collected caller information for the connected line
3106  * \param caller Caller information.
3107  *
3108  * \return Nothing
3109  *
3110  * \warning This is a shallow copy.
3111  * \warning DO NOT call ast_party_connected_line_free() on the filled in
3112  * connected line structure!
3113  */
3115 
3116 /*!
3117  * \since 1.8
3118  * \brief Destroy the connected line information contents
3119  *
3120  * \param doomed The connected line information to destroy.
3121  *
3122  * \return Nothing
3123  */
3125 
3126 /*!
3127  * \brief Initialize the given redirecting structure.
3128  * \since 1.8
3129  *
3130  * \param init Redirecting structure to initialize.
3131  *
3132  * \return Nothing
3133  */
3135 
3136 /*!
3137  * \since 1.8
3138  * \brief Copy the source redirecting information to the destination redirecting.
3139  *
3140  * \param dest Destination redirecting
3141  * \param src Source redirecting
3142  *
3143  * \return Nothing
3144  */
3145 void ast_party_redirecting_copy(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src);
3146 
3147 /*!
3148  * \since 1.8
3149  * \brief Initialize the given redirecting id structure using the given guide
3150  * for a set update operation.
3151  *
3152  * \details
3153  * The initialization is needed to allow a set operation to know if a
3154  * value needs to be updated. Simple integers need the guide's original
3155  * value in case the set operation is not trying to set a new value.
3156  * String values are simply set to NULL pointers if they are not going
3157  * to be updated.
3158  *
3159  * \param init Redirecting id structure to initialize.
3160  * \param guide Source redirecting id to use as a guide in initializing.
3161  *
3162  * \return Nothing
3163  */
3164 void ast_party_redirecting_set_init(struct ast_party_redirecting *init, const struct ast_party_redirecting *guide);
3165 
3166 /*!
3167  * \brief Set the redirecting information based on another redirecting source
3168  * \since 1.8
3169  *
3170  * This is similar to ast_party_redirecting_copy, except that NULL values for
3171  * strings in the src parameter indicate not to update the corresponding dest values.
3172  *
3173  * \param dest The redirecting one wishes to update
3174  * \param src The new redirecting values to update the dest
3175  * \param update What redirecting information to update. NULL if all.
3176  *
3177  * \return Nothing
3178  */
3180 
3181 /*!
3182  * \since 1.8
3183  * \brief Destroy the redirecting information contents
3184  *
3185  * \param doomed The redirecting information to destroy.
3186  *
3187  * \return Nothing
3188  */
3190 
3191 /*!
3192  * \since 1.8
3193  * \brief Copy the caller information to the connected line information.
3194  *
3195  * \param dest Destination connected line information
3196  * \param src Source caller information
3197  *
3198  * \return Nothing
3199  *
3200  * \note Assumes locks are already acquired
3201  */
3203 
3204 /*!
3205  * \since 1.8
3206  * \brief Copy the connected line information to the caller information.
3207  *
3208  * \param dest Destination caller information
3209  * \param src Source connected line information
3210  *
3211  * \return Nothing
3212  *
3213  * \note Assumes locks are already acquired
3214  */
3216 
3217 /*!
3218  * \since 1.8
3219  * \brief Set the connected line information in the Asterisk channel
3220  *
3221  * \param chan Asterisk channel to set connected line information
3222  * \param connected Connected line information
3223  * \param update What connected line information to update. NULL if all.
3224  *
3225  * \return Nothing
3226  *
3227  * \note The channel does not need to be locked before calling this function.
3228  */
3230 
3231 /*!
3232  * \since 1.8
3233  * \brief Build the connected line information data frame.
3234  *
3235  * \param data Buffer to fill with the frame data
3236  * \param datalen Size of the buffer to fill
3237  * \param connected Connected line information
3238  * \param update What connected line information to build. NULL if all.
3239  *
3240  * \retval -1 if error
3241  * \retval Amount of data buffer used
3242  */
3243 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);
3244 
3245 /*!
3246  * \since 1.8
3247  * \brief Parse connected line indication frame data
3248  *
3249  * \param data Buffer with the frame data to parse
3250  * \param datalen Size of the buffer
3251  * \param connected Extracted connected line information
3252  *
3253  * \retval 0 on success.
3254  * \retval -1 on error.
3255  *
3256  * \note The filled in connected line structure needs to be initialized by
3257  * ast_party_connected_line_set_init() before calling. If defaults are not
3258  * required use ast_party_connected_line_init().
3259  * \note The filled in connected line structure needs to be destroyed by
3260  * ast_party_connected_line_free() when it is no longer needed.
3261  */
3262 int ast_connected_line_parse_data(const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected);
3263 
3264 /*!
3265  * \since 1.8
3266  * \brief Indicate that the connected line information has changed
3267  *
3268  * \param chan Asterisk channel to indicate connected line information
3269  * \param connected Connected line information
3270  * \param update What connected line information to update. NULL if all.
3271  *
3272  * \return Nothing
3273  */
3275 
3276 /*!
3277  * \since 1.8
3278  * \brief Queue a connected line update frame on a channel
3279  *
3280  * \param chan Asterisk channel to indicate connected line information
3281  * \param connected Connected line information
3282  * \param update What connected line information to update. NULL if all.
3283  *
3284  * \return Nothing
3285  */
3287 
3288 /*!
3289  * \since 1.8
3290  * \brief Set the redirecting id information in the Asterisk channel
3291  *
3292  * \param chan Asterisk channel to set redirecting id information
3293  * \param redirecting Redirecting id information
3294  * \param update What redirecting information to update. NULL if all.
3295  *
3296  * \return Nothing
3297  *
3298  * \note The channel does not need to be locked before calling this function.
3299  */
3301 
3302 /*!
3303  * \since 1.8
3304  * \brief Build the redirecting id data frame.
3305  *
3306  * \param data Buffer to fill with the frame data
3307  * \param datalen Size of the buffer to fill
3308  * \param redirecting Redirecting id information
3309  * \param update What redirecting information to build. NULL if all.
3310  *
3311  * \retval -1 if error
3312  * \retval Amount of data buffer used
3313  */
3314 int ast_redirecting_build_data(unsigned char *data, size_t datalen, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3315 
3316 /*!
3317  * \since 1.8
3318  * \brief Parse redirecting indication frame data
3319  *
3320  * \param data Buffer with the frame data to parse
3321  * \param datalen Size of the buffer
3322  * \param redirecting Extracted redirecting id information
3323  *
3324  * \retval 0 on success.
3325  * \retval -1 on error.
3326  *
3327  * \note The filled in id structure needs to be initialized by
3328  * ast_party_redirecting_set_init() before calling.
3329  * \note The filled in id structure needs to be destroyed by
3330  * ast_party_redirecting_free() when it is no longer needed.
3331  */
3332 int ast_redirecting_parse_data(const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting);
3333 
3334 /*!
3335  * \since 1.8
3336  * \brief Indicate that the redirecting id has changed
3337  *
3338  * \param chan Asterisk channel to indicate redirecting id information
3339  * \param redirecting Redirecting id information
3340  * \param update What redirecting information to update. NULL if all.
3341  *
3342  * \return Nothing
3343  */
3345 
3346 /*!
3347  * \since 1.8
3348  * \brief Queue a redirecting update frame on a channel
3349  *
3350  * \param chan Asterisk channel to indicate redirecting id information
3351  * \param redirecting Redirecting id information
3352  * \param update What redirecting information to update. NULL if all.
3353  *
3354  * \return Nothing
3355  */
3357 
3358 /*!
3359  * \since 1.8
3360  * \brief Run a connected line interception macro and update a channel's connected line
3361  * information
3362  *
3363  * Whenever we want to update a channel's connected line information, we may need to run
3364  * a macro so that an administrator can manipulate the information before sending it
3365  * out. This function both runs the macro and sends the update to the channel.
3366  *
3367  * \param autoservice_chan Channel to place into autoservice while the macro is running.
3368  * It is perfectly safe for this to be NULL
3369  * \param macro_chan The channel to run the macro on. Also the channel from which we
3370  * determine which macro we need to run.
3371  * \param connected_info Either an ast_party_connected_line or ast_frame pointer of type
3372  * AST_CONTROL_CONNECTED_LINE
3373  * \param caller If true, then run CONNECTED_LINE_CALLER_SEND_MACRO, otherwise run
3374  * CONNECTED_LINE_CALLEE_SEND_MACRO
3375  * \param frame If true, then connected_info is an ast_frame pointer, otherwise it is an
3376  * ast_party_connected_line pointer.
3377  * \retval 0 Success
3378  * \retval -1 Either the macro does not exist, or there was an error while attempting to
3379  * run the macro
3380  *
3381  * \todo Have multiple return codes based on the MACRO_RESULT
3382  * \todo Make constants so that caller and frame can be more expressive than just '1' and
3383  * '0'
3384  */
3385 int ast_channel_connected_line_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *connected_info, int caller, int frame);
3386 
3387 /*!
3388  * \brief Insert into an astdata tree, the channel structure.
3389  * \param[in] tree The ast data tree.
3390  * \param[in] chan The channel structure to add to tree.
3391  * \param[in] add_bridged Add the bridged channel to the structure.
3392  * \retval <0 on error.
3393  * \retval 0 on success.
3394  */
3395 int ast_channel_data_add_structure(struct ast_data *tree, struct ast_channel *chan, int add_bridged);
3396 
3397 /*!
3398  * \brief Compare to channel structures using the data api.
3399  * \param[in] tree The search tree generated by the data api.
3400  * \param[in] chan The channel to compare.
3401  * \param[in] structure_name The name of the node of the channel structure.
3402  * \retval 0 The structure matches.
3403  * \retval 1 The structure doesn't matches.
3404  */
3405 int ast_channel_data_cmp_structure(const struct ast_data_search *tree, struct ast_channel *chan,
3406  const char *structure_name);
3407 
3408 /*!
3409  * \since 1.8
3410  * \brief Run a redirecting interception macro and update a channel's redirecting information
3411  *
3412  * \details
3413  * Whenever we want to update a channel's redirecting information, we may need to run
3414  * a macro so that an administrator can manipulate the information before sending it
3415  * out. This function both runs the macro and sends the update to the channel.
3416  *
3417  * \param autoservice_chan Channel to place into autoservice while the macro is running.
3418  * It is perfectly safe for this to be NULL
3419  * \param macro_chan The channel to run the macro on. Also the channel from which we
3420  * determine which macro we need to run.
3421  * \param redirecting_info Either an ast_party_redirecting or ast_frame pointer of type
3422  * AST_CONTROL_REDIRECTING
3423  * \param is_caller If true, then run REDIRECTING_CALLER_SEND_MACRO, otherwise run
3424  * REDIRECTING_CALLEE_SEND_MACRO
3425  * \param is_frame If true, then redirecting_info is an ast_frame pointer, otherwise it is an
3426  * ast_party_redirecting pointer.
3427  *
3428  * \retval 0 Success
3429  * \retval -1 Either the macro does not exist, or there was an error while attempting to
3430  * run the macro
3431  *
3432  * \todo Have multiple return codes based on the MACRO_RESULT
3433  * \todo Make constants so that caller and frame can be more expressive than just '1' and
3434  * '0'
3435  */
3436 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);
3437 
3438 #include "asterisk/ccss.h"
3439 
3440 /*!
3441  * \since 1.8
3442  * \brief Set up datastore with CCSS parameters for a channel
3443  *
3444  * \note
3445  * If base_params is NULL, the channel will get the default
3446  * values for all CCSS parameters.
3447  *
3448  * \details
3449  * This function makes use of datastore operations on the channel, so
3450  * it is important to lock the channel before calling this function.
3451  *
3452  * \param chan The channel to create the datastore on
3453  * \param base_params CCSS parameters we wish to copy into the channel
3454  * \retval 0 Success
3455  * \retval -1 Failure
3456  */
3457 int ast_channel_cc_params_init(struct ast_channel *chan,
3458  const struct ast_cc_config_params *base_params);
3459 
3460 /*!
3461  * \since 1.8
3462  * \brief Get the CCSS parameters from a channel
3463  *
3464  * \details
3465  * This function makes use of datastore operations on the channel, so
3466  * it is important to lock the channel before calling this function.
3467  *
3468  * \param chan Channel to retrieve parameters from
3469  * \retval NULL Failure
3470  * \retval non-NULL The parameters desired
3471  */
3473 
3474 
3475 /*!
3476  * \since 1.8
3477  * \brief Get a device name given its channel structure
3478  *
3479  * \details
3480  * A common practice in Asterisk is to determine the device being talked
3481  * to by dissecting the channel name. For certain channel types, this is not
3482  * accurate. For instance, an ISDN channel is named based on what B channel is
3483  * used, not the device being communicated with.
3484  *
3485  * This function interfaces with a channel tech's queryoption callback to
3486  * retrieve the name of the device being communicated with. If the channel does not
3487  * implement this specific option, then the traditional method of using the channel
3488  * name is used instead.
3489  *
3490  * \param chan The channel to retrieve the information from
3491  * \param[out] device_name The buffer to place the device's name into
3492  * \param name_buffer_length The allocated space for the device_name
3493  * \return 0 always
3494  */
3495 int ast_channel_get_device_name(struct ast_channel *chan, char *device_name, size_t name_buffer_length);
3496 
3497 /*!
3498  * \since 1.8
3499  * \brief Find the appropriate CC agent type to use given a channel
3500  *
3501  * \details
3502  * During call completion, we will need to create a call completion agent structure. To
3503  * figure out the type of agent to construct, we need to ask the channel driver for the
3504  * appropriate type.
3505  *
3506  * Prior to adding this function, the call completion core attempted to figure this
3507  * out for itself by stripping the technology off the channel's name. However, in the
3508  * case of chan_dahdi, there are multiple agent types registered, and so simply searching
3509  * for an agent type called "DAHDI" is not possible. In a case where multiple agent types
3510  * are defined, the channel driver must have a queryoption callback defined in its
3511  * channel_tech, and the queryoption callback must handle AST_OPTION_CC_AGENT_TYPE
3512  *
3513  * If a channel driver does not have a queryoption callback or if the queryoption callback
3514  * does not handle AST_OPTION_CC_AGENT_TYPE, then the old behavior of using the technology
3515  * portion of the channel name is used instead. This is perfectly suitable for channel drivers
3516  * whose channel technologies are a one-to-one match with the agent types defined within.
3517  *
3518  * Note that this function is only called when the agent policy on a given channel is set
3519  * to "native." Generic agents' type can be determined automatically by the core.
3520  *
3521  * \param chan The channel for which we wish to retrieve the agent type
3522  * \param[out] agent_type The type of agent the channel driver wants us to use
3523  * \param size The size of the buffer to write to
3524  */
3525 int ast_channel_get_cc_agent_type(struct ast_channel *chan, char *agent_type, size_t size);
3526 #if defined(__cplusplus) || defined(c_plusplus)
3527 }
3528 #endif
3529 
3530 #endif /* _ASTERISK_CHANNEL_H */
int(* func_channel_read)(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len)
Provide additional read items for CHANNEL() dialplan function.
Definition: channel.h:600
const ast_string_field peeraccount
Definition: channel.h:787
void ast_party_connected_line_collect_caller(struct ast_party_connected_line *connected, struct ast_party_caller *caller)
Collect the caller party information into a connected line structure.
Definition: channel.c:2345
void * music_state
Definition: channel.h:745
static enum ast_t38_state ast_channel_get_t38_state(struct ast_channel *chan)
Retrieves the current T38 state of a channel.
Definition: channel.h:2417
struct ast_channel * ast_waitfor_n(struct ast_channel **chan, int n, int *ms)
Waits for input on a group of channels Wait for input on an array of channels for a given # of millis...
Definition: channel.c:3534
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
Definition: channel.c:1916
void ast_party_name_copy(struct ast_party_name *dest, const struct ast_party_name *src)
Copy the source party name information to the destination party name.
Definition: channel.c:1936
int ast_queue_hangup(struct ast_channel *chan)
Queue a hangup frame.
Definition: channel.c:1569
unsigned long long ast_group_t
Definition: channel.h:175
union ast_frame_subclass subclass
Definition: frame.h:146
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2804
int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1)
Bridge two channels together (early)
Definition: channel.c:7406
Information needed to identify an endpoint in a call.
Definition: channel.h:288
enum sip_cc_notify_state state
Definition: chan_sip.c:842
int ast_recvchar(struct ast_channel *chan, int timeout)
Receives a text character from a channel.
Definition: channel.c:4642
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
Definition: channel.c:2308
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:227
struct ast_channel * masqr
Definition: channel.h:752
void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani)
Set caller ID number, name and ANI and generate AMI event.
Definition: channel.c:7051
#define attribute_pure
Definition: compiler.h:35
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:109
Main Channel structure associated with a channel.
Definition: channel.h:742
void ast_party_redirecting_set(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src, const struct ast_set_party_redirecting *update)
Set the redirecting information based on another redirecting source.
Definition: channel.c:2388
channel group info
Definition: channel.h:2459
const char * cid_num
Definition: channel.h:1002
struct ast_channel * ast_channel_get_by_exten(const char *exten, const char *context)
Find a channel by extension and context.
Definition: channel.c:1813
int ast_connected_line_build_data(unsigned char *data, size_t datalen, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Build the connected line information data frame.
Definition: channel.c:8825
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:338
long feature_timer
Definition: channel.h:980
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
struct ast_channel * masq
Definition: channel.h:751
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
const char *const type
Definition: channel.h:508
Asterisk locking-related definitions:
struct ast_channel * ast_channel_iterator_next(struct ast_channel_iterator *i)
Get the next channel for a channel iterator.
Definition: channel.c:1715
int rings
Definition: channel.h:840
void ast_poll_channel_add(struct ast_channel *chan0, struct ast_channel *chan1)
Definition: channel.c:2665
struct ast_channel *(*const requester)(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
Requester - to set up call data structures (pvt&#39;s)
Definition: channel.h:519
int ast_channel_cmpwhentohangup(struct ast_channel *chan, time_t offset)
Compare a offset with the settings of when to hang a channel up.
Definition: channel.c:900
void(* end_bridge_callback_data_fixup)(struct ast_bridge_config *bconfig, struct ast_channel *originator, struct ast_channel *terminator)
Definition: channel.h:993
int(*const send_image)(struct ast_channel *chan, struct ast_frame *frame)
Display or send an image.
Definition: channel.h:560
static const char config[]
Definition: cdr_csv.c:57
The data tree to be returned by the callbacks and managed by functions local to this file...
Definition: data.c:85
char * str
Subscriber phone number (Malloced)
Definition: channel.h:336
void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update)
Set the caller id information in the Asterisk channel and generate an AMI event if the caller id name...
Definition: channel.c:7091
int(*const write_video)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format.
Definition: channel.h:591
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame with payload.
Definition: channel.c:1601
int ast_redirecting_parse_data(const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting)
Parse redirecting indication frame data.
Definition: channel.c:9254
struct timeval feature_start_time
Definition: channel.h:979
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
int ast_write_text(struct ast_channel *chan, struct ast_frame *frame)
Write text frame to a channel This function writes the given frame to the indicated channel...
struct ast_tone_zone * zone
Definition: channel.h:767
struct ast_set_party_id ani
Definition: channel.h:391
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
Definition: autoservice.c:179
void ast_party_number_set_init(struct ast_party_number *init, const struct ast_party_number *guide)
Initialize the given party number structure using the given guide for a set update operation...
Definition: channel.c:2003
format_t capabilities
Definition: channel.h:511
int priority
Definition: channel.h:841
int timingfd
Definition: channel.h:838
struct ast_channel_tech * ast_get_channel_tech(const char *name)
Get a channel technology structure by name.
Definition: channel.c:960
const ast_string_field uniqueid
Definition: channel.h:787
struct ast_flags features_callee
Definition: channel.h:976
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:245
channelreloadreason
Channel reload reasons for manager events at load or reload of configuration.
Definition: channel.h:1060
int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone)
Weird function made for call transfers.
Definition: channel.c:6110
format_t writeformat
Definition: channel.h:854
int visible_indication
Definition: channel.h:861
struct ast_channel * parent_channel
Definition: channel.h:1006
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
void ast_party_connected_line_set_init(struct ast_party_connected_line *init, const struct ast_party_connected_line *guide)
Initialize the given connected line structure using the given guide for a set update operation...
Definition: channel.c:2329
void ast_party_subaddress_copy(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src)
Copy the source party subaddress information to the destination party subaddress. ...
Definition: channel.c:2042
int __ast_answer(struct ast_channel *chan, unsigned int delay, int cdr_answer)
Answer a channel, with a selectable delay before returning.
Definition: channel.c:2982
void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset)
Set when to hang a channel up.
Definition: channel.c:871
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
Definition: channel.c:3148
static void update(int code_size, int y, int wi, int fi, int dq, int sr, int dqsez, struct g726_state *state_ptr)
Definition: codec_g726.c:367
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4393
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
char emulate_dtmf_digit
Definition: channel.h:872
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
Definition: channel.c:938
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:449
void * tech_pvt
Definition: channel.h:744
int ast_channel_queryoption(struct ast_channel *channel, int option, void *data, int *datalen, int block)
Checks the value of an option.
Definition: channel.c:7815
void ast_channel_update_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Indicate that the redirecting id has changed.
Definition: channel.c:9592
Channel Variables.
char context[AST_MAX_CONTEXT]
Definition: channel.h:868
int(*const send_digit_begin)(struct ast_channel *chan, char digit)
Start sending a literal DTMF digit.
Definition: channel.h:528
struct ast_variable * ast_channeltype_list(void)
return an ast_variable list of channeltypes
Definition: channel.c:261
struct ast_channel * ast_channel_release(struct ast_channel *chan)
Unlink and release reference to a channel.
Definition: channel.c:1921
int ast_channel_supports_html(struct ast_channel *channel)
Checks for HTML support on a channel.
Definition: channel.c:5902
int ast_check_hangup_locked(struct ast_channel *chan)
Definition: channel.c:820
struct ast_channel * __ast_request_and_dial(const char *type, format_t format, const struct ast_channel *requestor, void *data, int timeout, int *reason, const char *cid_num, const char *cid_name, struct outgoing_helper *oh)
Request a channel of a given type, with data as optional information used by the low level module and...
Definition: channel.c:5456
unsigned int fout
Definition: channel.h:847
static int ast_fdisset(struct pollfd *pfds, int fd, int maximum, int *start)
Helper function for migrating select to poll.
Definition: channel.h:2398
const char * blockproc
Definition: channel.h:753
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
Definition: channel.c:2151
static void dummy(char *unused,...)
Definition: chan_unistim.c:188
void ast_channel_update_connected_line(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Indicate that the connected line information has changed.
Definition: channel.c:9085
struct ast_timer * timer
Definition: channel.h:866
void ast_party_caller_set(struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update)
Set the caller information based on another caller source.
Definition: channel.c:2295
void ast_begin_shutdown(int hangup)
Definition: channel.c:838
static int ast_add_fd(struct pollfd *pfd, int fd)
if fd is a valid descriptor, set *pfd with the descriptor
Definition: channel.h:2390
int ast_settimeout_full(struct ast_channel *c, unsigned int rate, int(*func)(const void *data), void *data, unsigned int is_ao2_obj)
Definition: channel.c:3562
struct ast_datastore_info * info
Definition: datastore.h:57
Data retrieval API.
void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src)
Copy the source party id information to the destination party id.
Definition: channel.c:2095
Structure for variables, used for configurations and for channel variables.
Definition: config.h:75
int ast_channel_datastore_free(struct ast_datastore *datastore)
Free a channel data store object.
Definition: channel.c:2568
struct ast_generator * generator
Definition: channel.h:747
unsigned int emulate_dtmf_duration
Definition: channel.h:857
unsigned long global_fin
Definition: channel.c:104
void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars)
adds a list of channel variables to a channel
Definition: channel.c:8261
int(* cc_callback)(struct ast_channel *inbound, const char *dest, ast_cc_callback_fn callback)
Call a function with cc parameters as a function parameter.
Definition: channel.h:635
format_t rawwriteformat
Definition: channel.h:856
void ast_channel_set_caller(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update)
Set the caller id information in the Asterisk channel.
Definition: channel.c:7079
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4383
struct ast_frame *(*const read)(struct ast_channel *chan)
Read a frame, in standard format (see frame.h)
Definition: channel.h:551
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Definition: channel.h:814
int char_set
Character set the name is using.
Definition: channel.h:222
unsigned long outsmpl
Definition: channel.h:827
Structure for a data store type.
Definition: datastore.h:31
Configuration File Parser.
ast_channel_state
ast_channel states
Definition: channelstate.h:35
char * str
Subscriber name (Malloced)
Definition: channel.h:214
int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen)
Indicates condition of channel, with payload.
Definition: channel.c:4447
unsigned long global_fout
Definition: channel.c:104
struct timeval nexteventts
Definition: channel.h:978
ast_t38_state
Possible T38 states on channels.
Definition: channel.h:669
void ast_party_caller_free(struct ast_party_caller *doomed)
Destroy the caller party contents.
Definition: channel.c:2302
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:278
int(*const send_digit_end)(struct ast_channel *chan, char digit, unsigned int duration)
Stop sending a literal DTMF digit.
Definition: channel.h:535
Channel states.
format_t ast_best_codec(format_t fmts)
Pick the best audio codec.
Definition: channel.c:1062
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
Definition: stringfields.h:235
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:417
struct ast_cdr * cdr
Definition: channel.h:766
unsigned short transfercapability
Definition: channel.h:863
int ast_channel_register(const struct ast_channel_tech *tech)
Register a channel technology (a new channel driver) Called by a channel module to register the kind ...
Definition: channel.c:907
char * text
Definition: app_queue.c:1091
format_t nativeformats
Definition: channel.h:852
void ast_party_id_free(struct ast_party_id *doomed)
Destroy the party id contents.
Definition: channel.c:2141
Structure for a data store object.
Definition: datastore.h:54
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition: channel.c:2353
int alertpipe[2]
Definition: channel.h:851
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
Definition: channel.c:2604
int(*const queryoption)(struct ast_channel *chan, int option, void *data, int *datalen)
Query a given option. Called with chan locked.
Definition: channel.h:585
int ast_channel_connected_line_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *connected_info, int caller, int frame)
Run a connected line interception macro and update a channel&#39;s connected line information.
Definition: channel.c:9618
int ast_prod(struct ast_channel *chan)
Send empty audio to prime a channel driver.
Definition: channel.c:4784
const char * ast_state2str(enum ast_channel_state)
Gives the string form of a given channel state.
Definition: channel.c:1007
struct ast_datastore *attribute_malloc ast_channel_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
Create a channel data store object.
Definition: channel.c:2563
int ast_senddigit_begin(struct ast_channel *chan, char digit)
Send a DTMF digit to a channel.
Definition: channel.c:4705
char * str
Malloced subaddress string.
Definition: channel.h:263
const char * data
Definition: channel.h:755
int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition: channel.c:4774
Common implementation-independent jitterbuffer stuff.
int value
Definition: syslog.c:39
int(* ast_acf_read2_fn_t)(struct ast_channel *, const char *, char *, struct ast_str **, ssize_t)
Typedef for a custom read2 function.
Definition: channel.h:476
const ast_string_field linkedid
Definition: channel.h:787
int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block)
Sets an option on a channel.
Definition: channel.c:7795
int(*const fixup)(struct ast_channel *oldchan, struct ast_channel *newchan)
Fix up a channel: If a channel is consumed, this is called. Basically update any -&gt;owner links...
Definition: channel.h:579
enum ast_channel_adsicpe adsicpe
Definition: channel.h:844
format_t rawreadformat
Definition: channel.h:855
static char cid_num[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:157
struct ast_channel * ast_waitfor_nandfds(struct ast_channel **chan, int n, int *fds, int nfds, int *exception, int *outfd, int *ms)
Waits for activity on a group of channels.
Definition: channel.c:3188
ast_group_t pickupgroup
Definition: channel.h:819
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:276
Indicate what information in ast_party_caller should be set.
Definition: channel.h:387
const char * appl
Definition: channel.h:754
ast_group_t callgroup
Definition: channel.h:818
struct ast_variable * vars
Definition: channel.h:1005
struct ast_cc_config_params * ast_channel_get_cc_config_params(struct ast_channel *chan)
Get the CCSS parameters from a channel.
Definition: channel.c:9754
int(*const answer)(struct ast_channel *chan)
Answer the channel.
Definition: channel.h:548
struct ast_frame dtmff
Definition: channel.h:816
const char * uid
Definition: datastore.h:55
String fields in structures.
Utility functions.
char * ast_print_group(char *buf, int buflen, ast_group_t group)
print call- and pickup groups into buffer
Definition: channel.c:8236
void ast_party_caller_copy(struct ast_party_caller *dest, const struct ast_party_caller *src)
Copy the source caller information to the destination caller.
Definition: channel.c:2276
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
Definition: channel.c:1581
struct ast_channel * ast_channel_get_by_name_prefix(const char *name, size_t name_len)
Find a channel by a name prefix.
Definition: channel.c:1808
const char * start_sound
Definition: channel.h:986
void ast_party_dialed_set(struct ast_party_dialed *dest, const struct ast_party_dialed *src)
Set the dialed information based on another dialed source.
Definition: channel.c:2249
const char * value
Definition: channel.h:490
struct ast_set_party_id from
Definition: channel.h:467
int ast_channel_defer_dtmf(struct ast_channel *chan)
Defers DTMF so that you only read things like hangups and audio.
Definition: channel.c:1616
Number structure.
Definition: app_followme.c:109
#define attribute_const
Definition: compiler.h:41
Asterisk datastore objects.
void ast_party_id_set(struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update)
Set the source party id information into the destination party id.
Definition: channel.c:2118
unsigned int flags
Definition: channel.h:850
AST_PARTY_CHAR_SET
Definition: channel.h:192
Call Detail Record API.
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
int ast_channel_bridge(struct ast_channel *c0, struct ast_channel *c1, struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc)
Bridge two channels together.
Definition: channel.c:7506
int ast_set_write_format(struct ast_channel *chan, format_t format)
Sets write format on channel chan Set write format for channel to whichever component of &quot;format&quot; is ...
Definition: channel.c:5307
void ast_change_name(struct ast_channel *chan, const char *newname)
Change channel name.
Definition: channel.c:6229
int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to)
Inherit datastores from a parent to a child.
Definition: channel.c:2573
Definition: pbx.h:179
int ast_set_read_format(struct ast_channel *chan, format_t format)
Sets read format on channel chan Set read format for channel to whichever component of &quot;format&quot; is be...
Definition: channel.c:5301
int(*const setoption)(struct ast_channel *chan, int option, void *data, int datalen)
Set a given option. Called with chan locked.
Definition: channel.h:582
const char * exten
Definition: channel.h:1000
format_t oldwriteformat
Definition: channel.h:837
int ast_channel_data_add_structure(struct ast_data *tree, struct ast_channel *chan, int add_bridged)
Insert into an astdata tree, the channel structure.
Definition: channel.c:357
const char * cid_name
Definition: channel.h:1003
unsigned int flags
Definition: channel.h:987
int macropriority
Definition: channel.h:842
int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception)
Waits for input on an fd.
Definition: channel.c:3176
void ast_channel_queue_connected_line_update(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Queue a connected line update frame on a channel.
Definition: channel.c:9098
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:377
struct ast_channel * ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, format_t format, struct outgoing_helper *oh, int *outstate)
Forwards a call to a new channel specified by the original channel&#39;s call_forward str...
Definition: channel.c:5386
struct ast_channel * chan
Definition: channel.h:487
int(* set_base_channel)(struct ast_channel *chan, struct ast_channel *base)
Set base channel (agent and local)
Definition: channel.h:609
struct ast_party_dialed::@155 number
Dialed/Called number.
int ast_raw_answer(struct ast_channel *chan, int cdr_answer)
Answer a channel.
Definition: channel.c:2930
void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force)
Set the source of the hangup in this channel and it&#39;s bridge.
Definition: channel.c:2769
int(*const hangup)(struct ast_channel *chan)
Hangup (and possibly destroy) the channel.
Definition: channel.h:545
void ast_channel_clear_softhangup(struct ast_channel *chan, int flag)
Clear a set of softhangup flags from a channel.
Definition: channel.c:2707
void ast_channel_undefer_dtmf(struct ast_channel *chan)
Unset defer DTMF flag on channel.
Definition: channel.c:1628
struct timeval start_time
Definition: channel.h:977
int ast_write_video(struct ast_channel *chan, struct ast_frame *frame)
Write video frame to a channel This function writes the given frame to the indicated channel...
Definition: channel.c:4801
A set of tones for a given locale.
Definition: indications.h:73
static struct ast_generator gen
void ast_party_subaddress_free(struct ast_party_subaddress *doomed)
Destroy the party subaddress contents.
Definition: channel.c:2081
const char * account
Definition: channel.h:1004
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition: channel.c:4755
unsigned char subaddress
Definition: channel.h:317
int ast_channel_data_cmp_structure(const struct ast_data_search *tree, struct ast_channel *chan, const char *structure_name)
Compare to channel structures using the data api.
Definition: channel.c:489
struct ast_audiohook_list * audiohooks
Definition: channel.h:764
Asterisk internal frame definitions.
ast_cond_t cond
Definition: app_meetme.c:963
#define AST_MAX_EXTENSION
Definition: channel.h:135
int datalen
Definition: frame.h:148
int ast_settimeout(struct ast_channel *c, unsigned int rate, int(*func)(const void *data), void *data)
Enable or disable timer ticks for a channel.
Definition: channel.c:3557
Scheduler Routines (derived from cheops)
#define AST_STRING_FIELD(name)
Declare a string field.
Definition: stringfields.h:220
void ast_party_number_init(struct ast_party_number *init)
Initialize the given number structure.
Definition: channel.c:1981
bridge configuration
Definition: channel.h:974
void * end_bridge_callback_data
Definition: channel.h:989
Caller Party information.
Definition: channel.h:368
All softhangup flags.
Definition: channel.h:1055
int(*const write_text)(struct ast_channel *chan, struct ast_frame *frame)
Write a text frame, in standard format.
Definition: channel.h:594
const char * end_sound
Definition: channel.h:985
int ast_shutting_down(void)
Returns non-zero if Asterisk is being shut down.
Definition: channel.c:865
int ast_softhangup(struct ast_channel *chan, int reason)
Softly hangup up a channel.
Definition: channel.c:2746
const ast_string_field parkinglot
Definition: channel.h:787
int ast_internal_timing_enabled(struct ast_channel *chan)
Check if the channel can run in internal timing mode.
Definition: channel.c:4378
int ast_channel_get_cc_agent_type(struct ast_channel *chan, char *agent_type, size_t size)
Find the appropriate CC agent type to use given a channel.
Definition: channel.c:9793
struct sched_context * sched
Definition: channel.h:756
struct ast_set_party_id id
Definition: channel.h:389
struct ast_frame *(*const exception)(struct ast_channel *chan)
Handle an exception, reading a frame.
Definition: channel.h:566
A set of macros to manage forward-linked lists.
void ast_channel_set_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Set the redirecting id information in the Asterisk channel.
Definition: channel.c:9111
int streamid
Definition: channel.h:835
int(* timingfunc)(const void *data)
Definition: channel.h:759
void ast_channel_set_linkgroup(struct ast_channel *chan, struct ast_channel *peer)
propagate the linked id between chan and peer
Definition: channel.c:6387
struct ast_channel * _bridge
Definition: channel.h:748
ast_group_t ast_get_group(const char *s)
Definition: channel.c:7987
int(* ast_acf_read_fn_t)(struct ast_channel *, const char *, char *, char *, size_t)
Typedef for a custom read function.
Definition: channel.h:473
char sending_dtmf_digit
Definition: channel.h:873
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:410
char * group
Definition: channel.h:2462
Structure to describe a channel &quot;technology&quot;, ie a channel driver See for examples: ...
Definition: channel.h:507
const ast_string_field dialcontext
Definition: channel.h:787
int ast_channel_cc_params_init(struct ast_channel *chan, const struct ast_cc_config_params *base_params)
Set up datastore with CCSS parameters for a channel.
Definition: channel.c:9731
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
void ast_party_number_free(struct ast_party_number *doomed)
Destroy the party number contents.
Definition: channel.c:2028
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:238
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:806
struct ast_flags features_caller
Definition: channel.h:975
void ast_party_subaddress_set_init(struct ast_party_subaddress *init, const struct ast_party_subaddress *guide)
Initialize the given party subaddress structure using the given guide for a set update operation...
Definition: channel.c:2056
struct ast_channel * ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg, void *data, int ao2_flags)
Call a function with every active channel.
Definition: channel.c:1634
struct ast_channel * chan
Definition: channel.h:2460
The list of nodes with their search requirement.
Definition: data.c:122
ast_acf_write_fn_t write_fn
Definition: channel.h:486
enum ast_bridge_result(*const bridge)(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms)
Bridge two channels of the same type together.
Definition: channel.h:569
int fds[AST_MAX_FDS]
Definition: channel.h:829
struct ast_party_dialed dialed
Dialed/Called information.
Definition: channel.h:797
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
Definition: channel.c:8309
struct ast_trans_pvt * writetrans
Definition: channel.h:762
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
Definition: linkedlists.h:224
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:294
Dialed/Called Party information.
Definition: channel.h:328
int ast_connected_line_parse_data(const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected)
Parse connected line indication frame data.
Definition: channel.c:8886
Responsible for call detail data.
Definition: cdr.h:82
Structure that contains information about a bridge.
Definition: bridging.h:149
Indicate what information in ast_party_id should be set.
Definition: channel.h:311
ast_control_frame_type
Internal control frame subtype field values.
Definition: frame.h:319
struct ast_channel_tech ast_kill_tech
Kill the channel channel driver technology descriptor.
Definition: channel.c:668
void ast_party_dialed_init(struct ast_party_dialed *init)
Initialize the given dialed structure.
Definition: channel.c:2219
int ast_channel_transfer_masquerade(struct ast_channel *target_chan, const struct ast_party_connected_line *target_id, int target_held, struct ast_channel *transferee_chan, const struct ast_party_connected_line *transferee_id, int transferee_held)
Setup a masquerade to transfer a call.
Definition: channel.c:6184
void ast_party_caller_set_init(struct ast_party_caller *init, const struct ast_party_caller *guide)
Initialize the given caller structure using the given guide for a set update operation.
Definition: channel.c:2288
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:364
Default structure for translators, with the basic fields and buffers, all allocated as part of the sa...
Definition: translate.h:135
int64_t format_t
Definition: frame_defs.h:32
unsigned int fin
Definition: channel.h:845
unsigned char number
Definition: channel.h:315
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:243
void ast_party_name_set(struct ast_party_name *dest, const struct ast_party_name *src)
Set the source party name information into the destination party name.
Definition: channel.c:1958
struct timeval sending_dtmf_tv
Definition: channel.h:874
unsigned long insmpl
Definition: channel.h:826
char * ast_recvtext(struct ast_channel *chan, int timeout)
Receives a text string from a channel Read a string of text from a channel.
Definition: channel.c:4653
void(* ast_cc_callback_fn)(struct ast_channel *chan, struct ast_cc_config_params *cc_params, const char *monitor_type, const char *const device_name, const char *const dialstring, void *private_data)
Callback made from ast_cc_callback for certain channel types.
Definition: ccss.h:1583
const ast_string_field call_forward
Definition: channel.h:787
void ast_party_name_init(struct ast_party_name *init)
Initialize the given name structure.
Definition: channel.c:1928
void ast_party_connected_line_set(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src, const struct ast_set_party_connected_line *update)
Set the connected line information based on another connected line source.
Definition: channel.c:2337
struct ast_framehook_list * framehooks
Definition: channel.h:765
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:380
ast_channel_adsicpe
Definition: channel.h:659
enum ast_channel_state _state
Definition: channel.h:839
#define AST_OPTION_T38_STATE
Definition: frame.h:490
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
Definition: channel.c:7160
struct ast_channel_iterator * ast_channel_iterator_by_exten_new(const char *exten, const char *context)
Create a new channel iterator based on extension.
Definition: channel.c:1691
void(* release)(struct ast_channel *chan, void *data)
Definition: channel.h:181
Connected Line/Party information.
Definition: channel.h:401
const ast_string_field name
Definition: channel.h:787
void ast_party_id_set_init(struct ast_party_id *init, const struct ast_party_id *guide)
Initialize the given party id structure using the given guide for a set update operation.
Definition: channel.c:2110
void ast_party_name_set_init(struct ast_party_name *init, const struct ast_party_name *guide)
Initialize the given party name structure using the given guide for a set update operation.
Definition: channel.c:1950
const ast_string_field hangupsource
Definition: channel.h:787
void ast_party_name_free(struct ast_party_name *doomed)
Destroy the party name contents.
Definition: channel.c:1975
void * timingdata
Definition: channel.h:760
int _softhangup
Definition: channel.h:832
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
Definition: channel.h:447
int ast_softhangup_nolock(struct ast_channel *chan, int reason)
Softly hangup up a channel (no channel lock)
Definition: channel.c:2733
int ast_channel_sendhtml(struct ast_channel *channel, int subclass, const char *data, int datalen)
Sends HTML on given channel Send HTML or URL on link.
Definition: channel.c:5907
struct ast_bridge * bridge
Definition: channel.h:865
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
Definition: linkedlists.h:409
General jitterbuffer state.
Definition: abstract_jb.h:87
int fdno
Definition: channel.h:834
int ast_channel_sendurl(struct ast_channel *channel, const char *url)
Sends a URL on a given link Send URL on link.
Definition: channel.c:5914
int(*const send_html)(struct ast_channel *chan, int subclass, const char *data, int len)
Send HTML data.
Definition: channel.h:563
int(*const transfer)(struct ast_channel *chan, const char *newdest)
Blind transfer other side (see app_transfer.c and ast_transfer()
Definition: channel.h:588
void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state)
Stops a previously-started silence generator on the given channel.
Definition: channel.c:8355
const char * ast_cause2str(int state) attribute_pure
Gives the string form of a given cause code.
Definition: channel.c:980
static const char name[]
#define AST_MAX_CONTEXT
Definition: channel.h:136
int(*const send_text)(struct ast_channel *chan, const char *text)
Display or transmit text.
Definition: channel.h:557
void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child)
Inherits channel variable from parent to child channel.
Definition: channel.c:6241
int source
Information about the source of an update.
Definition: channel.h:424
char macrocontext[AST_MAX_CONTEXT]
Definition: channel.h:870
void ast_cancel_shutdown(void)
Cancel a shutdown in progress.
Definition: channel.c:859
struct ast_filestream * vstream
Definition: channel.h:758
struct ast_jb jb
Definition: channel.h:821
Structure to handle passing func_channel_write info to channels via setoption.
Definition: channel.h:482
#define AST_MAX_FDS
Definition: channel.h:158
Call Completion Supplementary Services API.
struct ast_channel *attribute_malloc __ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const char *linkedid, const int amaflag, const char *file, int line, const char *function, const char *name_fmt,...)
Create a channel structure.
Definition: channel.c:1366
struct ast_channel *(*const bridged_channel)(struct ast_channel *chan, struct ast_channel *bridge)
Find bridged channel.
Definition: channel.h:597
static struct ast_format f[]
Definition: format_g726.c:181
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
Definition: channel.c:4916
void ast_party_number_copy(struct ast_party_number *dest, const struct ast_party_number *src)
Copy the source party number information to the destination party number.
Definition: channel.c:1989
char * category
Definition: channel.h:2461
int ast_call(struct ast_channel *chan, char *addr, int timeout)
Make a call.
Definition: channel.c:5761
const ast_string_field userfield
Definition: channel.h:787
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition: channel.h:341
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition: channel.c:2087
void ast_channel_setwhentohangup(struct ast_channel *chan, time_t offset)
Set when to hang a channel up.
Definition: channel.c:878
const char *const description
Definition: channel.h:509
int ast_autoservice_ignore(struct ast_channel *chan, enum ast_frame_type ftype)
Ignore certain frame types.
Definition: autoservice.c:307
Structure used to handle boolean flags.
Definition: utils.h:200
struct ast_channel_iterator * ast_channel_iterator_by_name_new(const char *name, size_t name_len)
Create a new channel iterator based on name.
Definition: channel.c:1696
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
Definition: channel.c:2631
static char cid_name[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:158
Indicate what information in ast_party_connected_line should be set.
Definition: channel.h:431
int(* generate)(struct ast_channel *chan, void *data, int len, int samples)
Definition: channel.h:186
ast_frame_type
Frame types.
Definition: frame.h:101
int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int ctrlfd)
Wait for a digit Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to mon...
Definition: channel.c:3616
int(*const write)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format (see frame.h)
Definition: channel.h:554
char macroexten[AST_MAX_EXTENSION]
Definition: channel.h:871
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
Definition: channel.c:3552
#define attribute_malloc
Definition: compiler.h:59
FrameHook Architecture.
char * tag
User-set &quot;tag&quot;.
Definition: channel.h:304
struct ast_set_party_id id
Definition: channel.h:433
void ast_deactivate_generator(struct ast_channel *chan)
Definition: channel.c:3107
int type
Q.931 subaddress type.
Definition: channel.h:270
void ast_poll_channel_del(struct ast_channel *chan0, struct ast_channel *chan1)
Definition: channel.c:2688
int transit_network_select
Transit Network Select.
Definition: channel.h:347
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition: channel.c:2396
int(*const call)(struct ast_channel *chan, char *addr, int timeout)
Call a given phone number (address, etc), but don&#39;t take longer than timeout seconds to do so...
Definition: channel.h:542
int(*const devicestate)(void *data)
Definition: channel.h:521
void ast_party_connected_line_copy(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src)
Copy the source connected line information to the destination connected line.
Definition: channel.c:2316
struct ast_set_party_id to
Definition: channel.h:469
unsigned char name
Definition: channel.h:313
This structure is allocated by file.c in one chunk, together with buf_size and desc_size bytes of mem...
Definition: mod_format.h:100
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3539
int ast_channel_make_compatible(struct ast_channel *c0, struct ast_channel *c1)
Makes two channel formats compatible.
Definition: channel.c:5970
Channels have this property if they can create jitter; i.e. most VoIP channels.
Definition: channel.h:888
Indicate what information in ast_party_redirecting should be set.
Definition: channel.h:465
struct ast_channel * ast_request_and_dial(const char *type, format_t format, const struct ast_channel *requestor, void *data, int timeout, int *reason, const char *cid_num, const char *cid_name)
Request a channel of a given type, with data as optional information used by the low level module and...
Definition: channel.c:5650
void ast_tonepair_stop(struct ast_channel *chan)
Definition: channel.c:7964
int count
Number of times the call was redirected.
Definition: channel.h:455
format_t readformat
Definition: channel.h:853
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:452
void ast_connected_line_copy_from_caller(struct ast_party_connected_line *dest, const struct ast_party_caller *src)
Copy the caller information to the connected line information.
Definition: channel.c:8443
void ast_party_subaddress_init(struct ast_party_subaddress *init)
Initialize the given subaddress structure.
Definition: channel.c:2034
enum ast_bridge_result(*const early_bridge)(struct ast_channel *c0, struct ast_channel *c1)
Bridge two channels of the same type together (early)
Definition: channel.h:573
struct ast_set_party_id ani
Definition: channel.h:435
struct ast_group_info::@157 group_list
void ast_party_redirecting_init(struct ast_party_redirecting *init)
Initialize the given redirecting structure.
Definition: channel.c:2359
const char * context
Definition: channel.h:999
int vstreamid
Definition: channel.h:836
pthread_t blocker
Definition: channel.h:790
int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders, int audiofd, int ctrlfd)
Definition: channel.c:5842
struct ast_channel_iterator * ast_channel_iterator_destroy(struct ast_channel_iterator *i)
Destroy a channel iterator.
Definition: channel.c:1649
Information needed to specify a number in a call.
Definition: channel.h:239
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition: channel.c:3086
char * ast_transfercapability2str(int transfercapability) attribute_const
Gives the string form of a given transfer capability.
Definition: channel.c:1041
int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen)
Queue a control frame with payload.
Definition: channel.c:1608
int ast_transfer(struct ast_channel *chan, char *dest)
Transfer a channel (if supported).
Definition: channel.c:5788
const ast_string_field musicclass
Definition: channel.h:787
int ast_is_deferrable_frame(const struct ast_frame *frame)
Should we keep this frame for later?
Definition: channel.c:1818
int ast_channel_get_device_name(struct ast_channel *chan, char *device_name, size_t name_buffer_length)
Get a device name given its channel structure.
Definition: channel.c:9776
const ast_string_field accountcode
Definition: channel.h:787
Data structure associated with a single frame of data.
Definition: frame.h:142
int hangupcause
Definition: channel.h:849
void ast_party_redirecting_set_init(struct ast_party_redirecting *init, const struct ast_party_redirecting *guide)
Initialize the given redirecting id structure using the given guide for a set update operation...
Definition: channel.c:2380
static int connected
Definition: cdr_pgsql.c:57
void ast_connected_line_copy_to_caller(struct ast_party_caller *dest, const struct ast_party_connected_line *src)
Copy the connected line information to the caller information.
Definition: channel.c:8450
int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
Definition: channel.c:7951
struct timeval dtmf_tv
Definition: channel.h:822
void ast_party_dialed_free(struct ast_party_dialed *doomed)
Destroy the dialed party contents.
Definition: channel.c:2262
Channels have this property if they can accept input with jitter; i.e. most VoIP channels.
Definition: channel.h:883
struct timeval whentohangup
Definition: channel.h:789
int ast_str2cause(const char *name) attribute_pure
Convert the string form of a cause code to a number.
Definition: channel.c:993
const char * warning_sound
Definition: channel.h:984
void ast_channel_queue_redirecting_update(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Queue a redirecting update frame on a channel.
Definition: channel.c:9605
int ast_safe_sleep_conditional(struct ast_channel *chan, int ms, int(*cond)(void *), void *data)
Wait for a specified amount of time, looking for hangups and a condition argument.
Definition: channel.c:1845
int ast_undestroyed_channels(void)
Definition: channel.c:853
struct ast_trans_pvt * readtrans
Definition: channel.h:763
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
const char * ast_channel_reason2str(int reason)
return an english explanation of the code returned thru __ast_request_and_dial&#39;s &#39;outstate&#39; argument ...
Definition: channel.c:5313
const char * channelreloadreason2txt(enum channelreloadreason reason)
Convert enum channelreloadreason to text string for manager event.
Definition: channel.c:8372
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:107
int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders)
Reads multiple digits.
Definition: channel.c:5837
Information needed to specify a subaddress in a call.
Definition: channel.h:257
int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
Definition: channel.c:7969
struct ast_channel_monitor * monitor
Definition: channel.h:769
void ast_party_number_set(struct ast_party_number *dest, const struct ast_party_number *src)
Set the source party number information into the destination party number.
Definition: channel.c:2011
struct ast_channel_iterator * ast_channel_iterator_all_new(void)
Create a new channel iterator.
Definition: channel.c:1701
void(* end_bridge_callback)(void *)
Definition: channel.h:988
int reason
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:458
struct ast_channel * ast_dummy_channel_alloc(void)
Create a fake channel structure.
Definition: channel.c:1391
struct ast_filestream * stream
Definition: channel.h:757
static char url[512]
int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to the head of a channel&#39;s frame queue.
Definition: channel.c:1563
void ast_party_caller_init(struct ast_party_caller *init)
Initialize the given caller structure.
Definition: channel.c:2269
int(* func_channel_write)(struct ast_channel *chan, const char *function, char *data, const char *value)
Provide additional write items for CHANNEL() dialplan function.
Definition: channel.h:603
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
Definition: channel.c:1803
int(* ast_acf_write_fn_t)(struct ast_channel *, const char *, char *, const char *)
Typedef for a custom write function.
Definition: channel.h:479
int amaflags
Definition: channel.h:843
struct ast_channel * ast_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *status)
Requests a channel.
Definition: channel.c:5695
static snd_pcm_format_t format
Definition: chan_alsa.c:93
int ast_active_channels(void)
returns number of active/allocated channels
Definition: channel.c:848
struct ast_channel_tech * tech
Definition: channel.h:743
struct ast_channel::@156 readq
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition: channel.c:2590
Information needed to specify a name in a call.
Definition: channel.h:212
struct ast_frame * ast_read_noaudio(struct ast_channel *chan)
Reads a frame, returning AST_FRAME_NULL frame if audio.
Definition: channel.c:4388
int(*const indicate)(struct ast_channel *c, int condition, const void *data, size_t datalen)
Indicate a particular condition (e.g. AST_CONTROL_BUSY or AST_CONTROL_RINGING or AST_CONTROL_CONGESTI...
Definition: channel.h:576
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
Definition: channel.c:2599
void * generatordata
Definition: channel.h:746
const ast_string_field language
Definition: channel.h:787
void ast_channel_set_connected_line(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Set the connected line information in the Asterisk channel.
Definition: channel.c:8458
int( ao2_callback_data_fn)(void *obj, void *arg, void *data, int flags)
Type of a generic callback function.
Definition: astobj2.h:643
int ast_do_masquerade(struct ast_channel *chan)
Start masquerading a channel.
Definition: channel.c:6546
char exten[AST_MAX_EXTENSION]
Definition: channel.h:869
int ast_redirecting_build_data(unsigned char *data, size_t datalen, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Build the redirecting id data frame.
Definition: channel.c:9161
void ast_party_redirecting_copy(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src)
Copy the source redirecting information to the destination redirecting.
Definition: channel.c:2367
int ast_channel_cmpwhentohangup_tv(struct ast_channel *chan, struct timeval offset)
Compare a offset with the settings of when to hang a channel up.
Definition: channel.c:885
jack_status_t status
Definition: app_jack.c:143
void ast_party_dialed_copy(struct ast_party_dialed *dest, const struct ast_party_dialed *src)
Copy the source dialed party information to the destination dialed party.
Definition: channel.c:2227
int ast_channel_redirecting_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *redirecting_info, int is_caller, int is_frame)
Run a redirecting interception macro and update a channel&#39;s redirecting information.
Definition: channel.c:9663
void ast_party_dialed_set_init(struct ast_party_dialed *init, const struct ast_party_dialed *guide)
Initialize the given dialed structure using the given guide for a set update operation.
Definition: channel.c:2241
void ast_party_subaddress_set(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src)
Set the source party subaddress information into the destination party subaddress.
Definition: channel.c:2064
struct ast_pbx * pbx
Definition: channel.h:761
int ast_sendtext(struct ast_channel *chan, const char *text)
Sends text to a channel.
Definition: channel.c:4687
ast_bridge_result
Definition: channel.h:168
void(* digit)(struct ast_channel *chan, char digit)
Definition: channel.h:188