Asterisk - The Open Source Telephony Project  GIT-master-b91fb3c
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/alertpipe.h"
127 #include "asterisk/abstract_jb.h"
128 #include "asterisk/astobj2.h"
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 
138 /*!
139  * Max length of a channel uniqueid reported to the outside world.
140  *
141  * \details
142  * 149 = 127 (max systemname) + "-" + 10 (epoch timestamp)
143  * + "." + 10 (monotonically incrementing integer).
144  *
145  * \note If this value is ever changed, MAX_CHANNEL_ID should
146  * be updated in rtp_engine.h.
147  */
148 #define AST_MAX_PUBLIC_UNIQUEID 149
149 
150 /*!
151  * The number of buckets to store channels or channel information
152  */
153 #ifdef LOW_MEMORY
154 #define AST_NUM_CHANNEL_BUCKETS 61
155 #else
156 #define AST_NUM_CHANNEL_BUCKETS 1567
157 #endif
158 
159 /*!
160  * Maximum size of an internal Asterisk channel unique ID.
161  *
162  * \details
163  * Add two for the Local;2 channel to append a ';2' if needed
164  * plus nul terminator.
165  *
166  * \note If this value is ever changed, MAX_CHANNEL_ID should
167  * be updated in rtp_engine.h.
168  */
169 #define AST_MAX_UNIQUEID (AST_MAX_PUBLIC_UNIQUEID + 2 + 1)
170 
171 #define AST_MAX_ACCOUNT_CODE 80 /*!< Max length of an account code */
172 #define AST_CHANNEL_NAME 80 /*!< Max length of an ast_channel name */
173 #define MAX_LANGUAGE 40 /*!< Max length of the language setting */
174 #define MAX_MUSICCLASS 80 /*!< Max length of the music class setting */
175 #define AST_MAX_USER_FIELD 256 /*!< Max length of the channel user field */
176 
177 #include "asterisk/frame.h"
178 #include "asterisk/chanvars.h"
179 #include "asterisk/config.h"
180 #include "asterisk/lock.h"
181 #include "asterisk/cdr.h"
182 #include "asterisk/utils.h"
183 #include "asterisk/linkedlists.h"
184 #include "asterisk/stringfields.h"
185 #include "asterisk/datastore.h"
186 #include "asterisk/format_cap.h"
187 #include "asterisk/channelstate.h"
188 #include "asterisk/ccss.h"
189 #include "asterisk/framehook.h"
190 #include "asterisk/stasis.h"
191 #include "asterisk/endpoints.h"
192 
193 #define DATASTORE_INHERIT_FOREVER INT_MAX
194 
195 #define AST_MAX_FDS 11 /*!< original maximum number of file descriptors */
196 #define AST_EXTENDED_FDS 12 /*!< the start of extended file descriptor positions */
197 /*
198  * We have AST_MAX_FDS file descriptors in a channel.
199  * Some of them have a fixed use:
200  */
201 #define AST_ALERT_FD (AST_MAX_FDS-1) /*!< used for alertpipe */
202 #define AST_TIMING_FD (AST_MAX_FDS-2) /*!< used for timingfd */
203 #define AST_AGENT_FD (AST_MAX_FDS-3) /*!< used by agents for pass through */
204 #define AST_GENERATOR_FD (AST_MAX_FDS-4) /*!< used by generator */
205 #define AST_JITTERBUFFER_FD (AST_MAX_FDS-5) /*!< used by generator */
206 
212 };
213 
214 typedef unsigned long long ast_group_t;
215 
216 struct ast_stream_topology;
217 
218 /*!
219  * \brief Set as the change source reason when a channel stream topology has
220  * been changed externally as a result of the remote side renegotiating.
221  */
222 static const char ast_stream_topology_changed_external[] = "external";
223 
224 /*! \todo Add an explanation of an Asterisk generator
225 */
227  void *(*alloc)(struct ast_channel *chan, void *params);
228  /*! Channel is locked during this function callback. */
229  void (*release)(struct ast_channel *chan, void *data);
230  /*! This function gets called with the channel unlocked, but is called in
231  * the context of the channel thread so we know the channel is not going
232  * to disappear. This callback is responsible for locking the channel as
233  * necessary. */
234  int (*generate)(struct ast_channel *chan, void *data, int len, int samples);
235  /*! This gets called when DTMF_END frames are read from the channel */
236  void (*digit)(struct ast_channel *chan, char digit);
237  /*! This gets called when the write format on a channel is changed while
238  * generating. The channel is locked during this callback. */
239  void (*write_format_change)(struct ast_channel *chan, void *data);
240 };
241 
242 /*! Party name character set enumeration values (values from Q.SIG) */
246  AST_PARTY_CHAR_SET_WITHDRAWN = 2,/* ITU withdrew this enum value. */
254 };
255 
256 /*!
257  * \since 1.8
258  * \brief Information needed to specify a name in a call.
259  * \note All string fields here are malloc'ed, so they need to be
260  * freed when the structure is deleted.
261  * \note NULL and "" must be considered equivalent.
262  */
264  /*! \brief Subscriber name (Malloced) */
265  char *str;
266  /*!
267  * \brief Character set the name is using.
268  * \see enum AST_PARTY_CHAR_SET
269  * \note
270  * Set to AST_PARTY_CHAR_SET_ISO8859_1 if unsure what to use.
271  * \todo Start using the party name character set value. Not currently used.
272  */
273  int char_set;
274  /*!
275  * \brief Q.931 encoded presentation-indicator encoded field
276  * \note Must tolerate the Q.931 screening-indicator field values being present.
277  */
279  /*! \brief TRUE if the name information is valid/present */
280  unsigned char valid;
281 };
282 
283 /*!
284  * \since 1.8
285  * \brief Information needed to specify a number in a call.
286  * \note All string fields here are malloc'ed, so they need to be
287  * freed when the structure is deleted.
288  * \note NULL and "" must be considered equivalent.
289  */
291  /*! \brief Subscriber phone number (Malloced) */
292  char *str;
293  /*! \brief Q.931 Type-Of-Number and Numbering-Plan encoded fields */
294  int plan;
295  /*! \brief Q.931 presentation-indicator and screening-indicator encoded fields */
297  /*! \brief TRUE if the number information is valid/present */
298  unsigned char valid;
299 };
300 
301 /*!
302  * \since 1.8
303  * \brief Information needed to specify a subaddress in a call.
304  * \note All string fields here are malloc'ed, so they need to be
305  * freed when the structure is deleted.
306  * \note NULL and "" must be considered equivalent.
307  */
309  /*!
310  * \brief Malloced subaddress string.
311  * \note If the subaddress type is user specified then the subaddress is
312  * a string of ASCII hex because the actual subaddress is likely BCD encoded.
313  */
314  char *str;
315  /*!
316  * \brief Q.931 subaddress type.
317  * \details
318  * nsap(0),
319  * user_specified(2)
320  */
321  int type;
322  /*!
323  * \brief TRUE if odd number of address signals
324  * \note The odd/even indicator is used when the type of subaddress is
325  * user_specified and the coding is BCD.
326  */
327  unsigned char odd_even_indicator;
328  /*! \brief TRUE if the subaddress information is valid/present */
329  unsigned char valid;
330 };
331 
332 /*!
333  * \since 1.8
334  * \brief Information needed to identify an endpoint in a call.
335  * \note All string fields here are malloc'ed, so they need to be
336  * freed when the structure is deleted.
337  * \note NULL and "" must be considered equivalent.
338  */
339 struct ast_party_id {
340  /*! \brief Subscriber name */
342  /*! \brief Subscriber phone number */
344  /*! \brief Subscriber subaddress. */
345  struct ast_party_subaddress subaddress;
346 
347  /*!
348  * \brief User-set "tag"
349  * \details
350  * A user-settable field used to help associate some extrinsic information
351  * about the channel or user of the channel to the party ID. This information
352  * is normally not transmitted over the wire and so is only useful within an
353  * Asterisk environment.
354  */
355  char *tag;
356 };
357 
358 /*!
359  * \since 1.8
360  * \brief Indicate what information in ast_party_id should be set.
361  */
363  /*! TRUE if the ast_party_name information should be set. */
364  unsigned char name;
365  /*! TRUE if the ast_party_number information should be set. */
366  unsigned char number;
367  /*! TRUE if the ast_party_subaddress information should be set. */
368  unsigned char subaddress;
369 };
370 
371 /*!
372  * \since 1.8
373  * \brief Dialed/Called Party information.
374  * \note Dialed Number Identifier (DNID)
375  * \note All string fields here are malloc'ed, so they need to be
376  * freed when the structure is deleted.
377  * \note NULL and "" must be considered equivalent.
378  */
380  /*!
381  * \brief Dialed/Called number
382  * \note Done this way in case we ever really need to use ast_party_number.
383  * We currently do not need all of the ast_party_number fields.
384  */
385  struct {
386  /*! \brief Subscriber phone number (Malloced) */
387  char *str;
388  /*! \brief Q.931 Type-Of-Number and Numbering-Plan encoded fields */
389  int plan;
390  } number;
391  /*! \brief Dialed/Called subaddress */
392  struct ast_party_subaddress subaddress;
393  /*!
394  * \brief Transit Network Select
395  * \note Currently this value is just passed around the system.
396  * You can read it and set it but it is never used for anything.
397  */
399 };
400 
401 /*!
402  * \since 1.8
403  * \brief Caller Party information.
404  * \note All string fields here are malloc'ed, so they need to be
405  * freed when the structure is deleted.
406  * \note NULL and "" must be considered equivalent.
407  *
408  * \note SIP and IAX2 has UTF8 encoded Unicode Caller ID names.
409  * In some cases, we also have an alternative (RPID) E.164 number that can
410  * be used as Caller ID on numeric E.164 phone networks (DAHDI or SIP/IAX2 to
411  * PSTN gateway).
412  *
413  * \todo Implement settings for transliteration between UTF8 Caller ID names in
414  * to ASCII Caller ID's (DAHDI). Östen Åsklund might be transliterated into
415  * Osten Asklund or Oesten Aasklund depending upon language and person...
416  * We need automatic routines for incoming calls and static settings for
417  * our own accounts.
418  */
420  /*! \brief Caller party ID */
421  struct ast_party_id id;
422 
423  /*!
424  * \brief Automatic Number Identification (ANI)
425  * \note The name subcomponent is only likely to be used by SIP.
426  * \note The subaddress subcomponent is not likely to be used.
427  */
428  struct ast_party_id ani;
429 
430  /*! \brief Private caller party ID */
431  struct ast_party_id priv;
432 
433  /*! \brief Automatic Number Identification 2 (Info Digits) */
434  int ani2;
435 };
436 
437 /*!
438  * \since 1.8
439  * \brief Indicate what information in ast_party_caller should be set.
440  */
442  /*! What caller id information to set. */
444  /*! What ANI id information to set. */
445  struct ast_set_party_id ani;
446  /*! What private caller id information to set. */
447  struct ast_set_party_id priv;
448 };
449 
450 /*!
451  * \since 1.8
452  * \brief Connected Line/Party information.
453  * \note All string fields here are malloc'ed, so they need to be
454  * freed when the structure is deleted.
455  * \note NULL and "" must be considered equivalent.
456  */
458  /*! \brief Connected party ID */
459  struct ast_party_id id;
460 
461  /*!
462  * \brief Automatic Number Identification (ANI)
463  * \note Not really part of connected line data but needed to
464  * save the corresponding caller id value.
465  */
466  struct ast_party_id ani;
467 
468  /*! \brief Private connected party ID */
469  struct ast_party_id priv;
470 
471  /*!
472  * \brief Automatic Number Identification 2 (Info Digits)
473  * \note Not really part of connected line data but needed to
474  * save the corresponding caller id value.
475  */
476  int ani2;
477 
478  /*!
479  * \brief Information about the source of an update.
480  * \note enum AST_CONNECTED_LINE_UPDATE_SOURCE values
481  * for Normal-Answer and Call-transfer.
482  */
483  int source;
484 };
485 
486 /*!
487  * \since 1.8
488  * \brief Indicate what information in ast_party_connected_line should be set.
489  */
491  /*! What connected line id information to set. */
493  /*! What ANI id information to set. */
494  struct ast_set_party_id ani;
495  /*! What private connected line id information to set. */
496  struct ast_set_party_id priv;
497 };
498 
499 /*!
500  * \brief Redirecting reason information
501  */
503  /*! \brief a string value for the redirecting reason
504  *
505  * Useful for cases where an endpoint has specified a redirecting reason
506  * that does not correspond to an enum AST_REDIRECTING_REASON
507  */
508  char *str;
509 
510  /*! \brief enum AST_REDIRECTING_REASON value for redirection */
511  int code;
512 };
513 
514 /*!
515  * \since 1.8
516  * \brief Redirecting Line information.
517  * RDNIS (Redirecting Directory Number Information Service)
518  * Where a call diversion or transfer was invoked.
519  * \note All string fields here are malloc'ed, so they need to be
520  * freed when the structure is deleted.
521  * \note NULL and "" must be considered equivalent.
522  */
524  /*! \brief Who originally redirected the call (Sent to the party the call is redirected toward) */
525  struct ast_party_id orig;
526 
527  /*! \brief Who is redirecting the call (Sent to the party the call is redirected toward) */
528  struct ast_party_id from;
529 
530  /*! \brief Call is redirecting to a new party (Sent to the caller) */
531  struct ast_party_id to;
532 
533  /*! \brief Who originally redirected the call (Sent to the party the call is redirected toward) - private representation */
534  struct ast_party_id priv_orig;
535 
536  /*! \brief Who is redirecting the call (Sent to the party the call is redirected toward) - private representation */
537  struct ast_party_id priv_from;
538 
539  /*! \brief Call is redirecting to a new party (Sent to the caller) - private representation */
540  struct ast_party_id priv_to;
541 
542  /*! \brief Reason for the redirection */
544 
545  /*! \brief Reason for the redirection by the original party */
546  struct ast_party_redirecting_reason orig_reason;
547 
548  /*! \brief Number of times the call was redirected */
549  int count;
550 };
551 
552 /*!
553  * \since 1.8
554  * \brief Indicate what information in ast_party_redirecting should be set.
555  */
557  /*! What redirecting-orig id information to set. */
558  struct ast_set_party_id orig;
559  /*! What redirecting-from id information to set. */
560  struct ast_set_party_id from;
561  /*! What redirecting-to id information to set. */
562  struct ast_set_party_id to;
563  /*! What private redirecting-orig id information to set. */
564  struct ast_set_party_id priv_orig;
565  /*! What private redirecting-from id information to set. */
566  struct ast_set_party_id priv_from;
567  /*! What private redirecting-to id information to set. */
568  struct ast_set_party_id priv_to;
569 };
570 
571 /*!
572  * \brief Typedef for a custom read function
573  * \note data should be treated as const char *.
574  */
575 typedef int (*ast_acf_read_fn_t)(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len);
576 
577 /*!
578  * \brief Typedef for a custom read2 function
579  * \note data should be treated as const char *.
580  */
581 typedef int (*ast_acf_read2_fn_t)(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **str, ssize_t len);
582 
583 /*!
584  * \brief Typedef for a custom write function
585  * \note data should be treated as const char *.
586  */
587 typedef int (*ast_acf_write_fn_t)(struct ast_channel *chan, const char *function, char *data, const char *value);
588 
589 /*! \brief Structure to handle passing func_channel_write info to channels via setoption */
590 typedef struct {
591  /*! \brief ast_chan_write_info_t version. Must be incremented if structure is changed */
592  #define AST_CHAN_WRITE_INFO_T_VERSION 1
593  uint32_t version;
595  struct ast_channel *chan;
596  const char *function;
597  char *data;
598  const char *value;
600 
601 /*!
602  * \brief Structure to pass both assignedid values to channel drivers
603  * \note The second value is used only by core_unreal (LOCAL)
604  */
606  const char *uniqueid;
607  const char *uniqueid2;
608 };
609 
610 /*!
611  * \brief Forward declaration
612  */
613 struct ast_msg_data;
614 
615 /*!
616  * \brief
617  * Structure to describe a channel "technology", ie a channel driver
618  * See for examples:
619  * \arg chan_iax2.c - The Inter-Asterisk exchange protocol
620  * \arg chan_sip.c - The SIP channel driver
621  * \arg chan_dahdi.c - PSTN connectivity (TDM, PRI, T1/E1, FXO, FXS)
622  *
623  * \details
624  * If you develop your own channel driver, this is where you
625  * tell the PBX at registration of your driver what properties
626  * this driver supports and where different callbacks are
627  * implemented.
628  */
630  const char * const type;
631  const char * const description;
632 
633  struct ast_format_cap *capabilities; /*!< format capabilities this channel can handle */
634 
635  int properties; /*!< Technology Properties */
636 
637  /*!
638  * \brief Requester - to set up call data structures (pvt's)
639  *
640  * \param type type of channel to request
641  * \param cap Format capabilities for requested channel
642  * \param assignedid Unique ID string to assign to channel
643  * \param requestor channel asking for data
644  * \param addr destination of the call
645  * \param cause Cause of failure
646  *
647  * \details
648  * Request a channel of a given type, with addr as optional information used
649  * by the low level module
650  *
651  * \retval NULL failure
652  * \retval non-NULL channel on success
653  */
654  struct ast_channel *(* const requester)(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause);
655 
656  /*!
657  * \brief Requester - to set up call data structures (pvt's) with stream topology
658  *
659  * \param type type of channel to request
660  * \param topology Stream topology for requested channel
661  * \param assignedid Unique ID string to assign to channel
662  * \param requestor channel asking for data
663  * \param addr destination of the call
664  * \param cause Cause of failure
665  *
666  * \details
667  * Request a channel of a given type, with addr as optional information used
668  * by the low level module
669  *
670  * \retval NULL failure
671  * \retval non-NULL channel on success
672  */
673  struct ast_channel *(* const requester_with_stream_topology)(const char *type, struct ast_stream_topology *topology, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause);
674 
675 
676  int (* const devicestate)(const char *device_number); /*!< Devicestate call back */
677  int (* const presencestate)(const char *presence_provider, char **subtype, char **message); /*!< Presencestate callback */
678 
679  /*!
680  * \brief Start sending a literal DTMF digit
681  *
682  * \note The channel is not locked when this function gets called.
683  */
684  int (* const send_digit_begin)(struct ast_channel *chan, char digit);
685 
686  /*!
687  * \brief Stop sending a literal DTMF digit
688  *
689  * \note The channel is not locked when this function gets called.
690  */
691  int (* const send_digit_end)(struct ast_channel *chan, char digit, unsigned int duration);
692 
693  /*!
694  * \brief Make a call
695  * \note The channel is locked when called.
696  * \param chan which channel to make the call on
697  * \param addr destination of the call
698  * \param timeout time to wait on for connect (Doesn't seem to be used.)
699  * \retval 0 on success
700  * \retval -1 on failure
701  */
702  int (* const call)(struct ast_channel *chan, const char *addr, int timeout);
703 
704  /*! \brief Hangup (and possibly destroy) the channel */
705  int (* const hangup)(struct ast_channel *chan);
706 
707  /*! \brief Answer the channel */
708  int (* const answer)(struct ast_channel *chan);
709 
710  /*!
711  * \brief Answer the channel with topology
712  * \since 18.0.0
713  *
714  * \param chan The channel to answer
715  * \param topology The topology to use, probably the peer's.
716  *
717  * \note The topology may be NULL when the peer doesn't support streams
718  * or, in the case where transcoding is in effect, when this channel should use
719  * its existing topology.
720  */
721  int (* const answer_with_stream_topology)(struct ast_channel *chan, struct ast_stream_topology *topology);
722 
723  /*!
724  * \brief Read a frame (or chain of frames from the same stream), in standard format (see frame.h)
725  *
726  * \param chan channel to read frames from
727  *
728  * \retval non-NULL on success
729  * \retval NULL on failure
730  *
731  * \note Each media frame from this callback will have the stream_num of it changed to the default
732  * stream num based on the type of media returned. As a result a multistream capable channel
733  * should not implement this callback.
734  */
735  struct ast_frame * (* const read)(struct ast_channel *chan);
736 
737  /*!
738  * \brief Read a frame (or chain of frames from the same stream), in standard format (see frame.h), with stream num
739  *
740  * \param chan channel to read frames from
741  *
742  * \retval non-NULL on success
743  * \retval NULL on failure
744  *
745  * \note Each media frame from this callback should contain a stream_num value which is set to the
746  * stream that the media frame originated from.
747  */
748  struct ast_frame * (* const read_stream)(struct ast_channel *chan);
749 
750  /*! \brief Write a frame, in standard format (see frame.h) */
751  int (* const write)(struct ast_channel *chan, struct ast_frame *frame);
752 
753  /*! \brief Write a frame on a specific stream, in standard format (see frame.h) */
754  int (* const write_stream)(struct ast_channel *chan, int stream_num, struct ast_frame *frame);
755 
756  /*! \brief Display or transmit text */
757  int (* const send_text)(struct ast_channel *chan, const char *text);
758 
759  /*! \brief Display or send an image */
760  int (* const send_image)(struct ast_channel *chan, struct ast_frame *frame);
761 
762  /*! \brief Send HTML data */
763  int (* const send_html)(struct ast_channel *chan, int subclass, const char *data, int len);
764 
765  /*! \brief Handle an exception, reading a frame */
766  struct ast_frame * (* const exception)(struct ast_channel *chan);
767 
768  /*! \brief Bridge two channels of the same type together (early) */
769  enum ast_bridge_result (* const early_bridge)(struct ast_channel *c0, struct ast_channel *c1);
770 
771  /*! \brief Indicate a particular condition (e.g. AST_CONTROL_BUSY or AST_CONTROL_RINGING or AST_CONTROL_CONGESTION */
772  int (* const indicate)(struct ast_channel *c, int condition, const void *data, size_t datalen);
773 
774  /*! \brief Fix up a channel: If a channel is consumed, this is called. Basically update any ->owner links */
775  int (* const fixup)(struct ast_channel *oldchan, struct ast_channel *newchan);
776 
777  /*! \brief Set a given option. Called with chan locked */
778  int (* const setoption)(struct ast_channel *chan, int option, void *data, int datalen);
779 
780  /*! \brief Query a given option. Called with chan locked */
781  int (* const queryoption)(struct ast_channel *chan, int option, void *data, int *datalen);
782 
783  /*! \brief Blind transfer other side (see app_transfer.c and ast_transfer() */
784  int (* const transfer)(struct ast_channel *chan, const char *newdest);
785 
786  /*! \brief Write a frame, in standard format */
787  int (* const write_video)(struct ast_channel *chan, struct ast_frame *frame);
788 
789  /*! \brief Write a text frame, in standard format */
790  int (* const write_text)(struct ast_channel *chan, struct ast_frame *frame);
791 
792  /*!
793  * \brief Provide additional read items for CHANNEL() dialplan function
794  * \note data should be treated as a const char *.
795  */
796  int (* func_channel_read)(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len);
797 
798  /*!
799  * \brief Provide additional write items for CHANNEL() dialplan function
800  * \note data should be treated as a const char *.
801  */
802  int (* func_channel_write)(struct ast_channel *chan, const char *function, char *data, const char *value);
803 
804  /*! \brief Get the unique identifier for the PVT, i.e. SIP call-ID for SIP */
805  const char * (* get_pvt_uniqueid)(struct ast_channel *chan);
806 
807  /*! \brief Call a function with cc parameters as a function parameter
808  *
809  * \details
810  * This is a highly specialized callback that is not likely to be needed in many
811  * channel drivers. When dealing with a busy channel, for instance, most channel
812  * drivers will successfully return a channel to the requester. Once called, the channel
813  * can then queue a busy frame when it receives an appropriate message from the far end.
814  * In such a case, the channel driver has the opportunity to also queue a CC frame.
815  * The parameters for the CC channel can be retrieved from the channel structure.
816  *
817  * For other channel drivers, notably those that deal with "dumb" phones, the channel
818  * driver will not return a channel when one is requested. In such a scenario, there is never
819  * an opportunity for the channel driver to queue a CC frame since the channel is never
820  * called. Furthermore, it is not possible to retrieve the CC configuration parameters
821  * for the desired channel because no channel is ever allocated or returned to the
822  * requester. In such a case, call completion may still be a viable option. What we do is
823  * pass the same string that the requester used originally to request the channel to the
824  * channel driver. The channel driver can then find any potential channels/devices that
825  * match the input and return call the designated callback with the device's call completion
826  * parameters as a parameter.
827  */
828  int (* cc_callback)(struct ast_channel *inbound, const char *dest, ast_cc_callback_fn callback);
829 
830  /*!
831  * \brief Execute a Gosub call on the channel in a technology specific way before a call is placed.
832  * \since 11.0
833  *
834  * \param chan Channel to execute Gosub in a tech specific way.
835  * \param sub_args Gosub application parameter string.
836  *
837  * \note The chan is locked before calling.
838  *
839  * \retval 0 on success.
840  * \retval -1 on error.
841  */
842  int (*pre_call)(struct ast_channel *chan, const char *sub_args);
843 
844  /*! \brief Display or transmit text with data*/
845  int (* const send_text_data)(struct ast_channel *chan, struct ast_msg_data *data);
846 };
847 
848 /*! Kill the channel channel driver technology descriptor. */
849 extern const struct ast_channel_tech ast_kill_tech;
850 
851 struct ast_epoll_data;
852 
853 /*!
854  * The high bit of the frame count is used as a debug marker, so
855  * increments of the counters must be done with care.
856  * Please use c->fin = FRAMECOUNT_INC(c->fin) and the same for c->fout.
857  */
858 #define DEBUGCHAN_FLAG 0x80000000
859 
860 /* XXX not ideal to evaluate x twice... */
861 #define FRAMECOUNT_INC(x) ( ((x) & DEBUGCHAN_FLAG) | (((x)+1) & ~DEBUGCHAN_FLAG) )
862 
863 /*!
864  * The current value of the debug flags is stored in the two
865  * variables global_fin and global_fout (declared in main/channel.c)
866  */
867 extern unsigned long global_fin, global_fout;
868 
874 };
875 
876 /*!
877  * \brief Possible T38 states on channels
878  */
880  T38_STATE_UNAVAILABLE, /*!< T38 is unavailable on this channel or disabled by configuration */
881  T38_STATE_UNKNOWN, /*!< The channel supports T38 but the current status is unknown */
882  T38_STATE_NEGOTIATING, /*!< T38 is being negotiated */
883  T38_STATE_REJECTED, /*!< Remote side has rejected our offer */
884  T38_STATE_NEGOTIATED, /*!< T38 established */
885 };
886 
887 /*! Hangup handler instance node. */
889  /*! Next hangup handler node. */
891  /*! Hangup handler arg string passed to the Gosub application */
892  char args[0];
893 };
894 
899 
900 typedef int(*ast_timing_func_t)(const void *data);
901 /*!
902  * \page AstChannel ast_channel locking and reference tracking
903  *
904  * \par Creating Channels
905  * A channel is allocated using the ast_channel_alloc() function. When created, it is
906  * automatically inserted into the main channels hash table that keeps track of all
907  * active channels in the system. The hash key is based on the channel name. Because
908  * of this, if you want to change the name, you _must_ use ast_change_name(), not change
909  * the name field directly. When ast_channel_alloc() returns a channel pointer, you now
910  * hold both a reference to that channel and a lock on the channel. Once the channel has
911  * been set up the lock can be released. In most cases the reference is given to ast_pbx_run().
912  *
913  * \par Channel Locking
914  * There is a lock associated with every ast_channel. It is allocated internally via astobj2.
915  * To lock or unlock a channel, you must use the ast_channel_lock() wrappers.
916  *
917  * Previously, before ast_channel was converted to astobj2, the channel lock was used in some
918  * additional ways that are no longer necessary. Before, the only way to ensure that a channel
919  * did not disappear out from under you if you were working with a channel outside of the channel
920  * thread that owns it, was to hold the channel lock. Now, that is no longer necessary.
921  * You simply must hold a reference to the channel to ensure it does not go away.
922  *
923  * The channel must be locked if you need to ensure that data that you reading from the channel
924  * does not change while you access it. Further, you must hold the channel lock if you are
925  * making a non-atomic change to channel data.
926  *
927  * \par Channel References
928  * There are multiple ways to get a reference to a channel. The first is that you hold a reference
929  * to a channel after creating it. The other ways involve using the channel search or the channel
930  * traversal APIs. These functions are the ast_channel_get_*() functions or ast_channel_iterator_*()
931  * functions. Once a reference is retrieved by one of these methods, you know that the channel will
932  * not go away. So, the channel should only get locked as needed for data access or modification.
933  * But, make sure that the reference gets released when you are done with it!
934  *
935  * There are different things you can do when you are done with a reference to a channel. The first
936  * is to simply release the reference using ast_channel_unref(). The other option is to call
937  * ast_channel_release(). This function is generally used where ast_channel_free() was used in
938  * the past. The release function releases a reference as well as ensures that the channel is no
939  * longer in the global channels container. That way, the channel will get destroyed as soon as any
940  * other pending references get released.
941  *
942  * \par Exceptions to the rules
943  * Even though ast_channel is reference counted, there are some places where pointers to an ast_channel
944  * get stored, but the reference count does not reflect it. The reason is mostly historical.
945  * The only places where this happens should be places where because of how the code works, we
946  * _know_ that the pointer to the channel will get removed before the channel goes away. The main
947  * example of this is in channel drivers. Channel drivers generally store a pointer to their owner
948  * ast_channel in their technology specific pvt struct. In this case, the channel drivers _know_
949  * that this pointer to the channel will be removed in time, because the channel's hangup callback
950  * gets called before the channel goes away.
951  */
952 
953 struct ast_channel;
954 
955 /*! \brief ast_channel_tech Properties */
956 enum {
957  /*!
958  * \brief Channels have this property if they can accept input with jitter;
959  * i.e. most VoIP channels
960  */
962  /*!
963  * \brief Channels have this property if they can create jitter;
964  * i.e. most VoIP channels
965  */
967  /*!
968  * \brief Channels with this particular technology are an implementation detail of
969  * Asterisk and should generally not be exposed or manipulated by the outside
970  * world
971  */
973  /*!
974  * \brief Channels have this property if they implement send_text_data
975  */
977 };
978 
979 /*! \brief ast_channel flags */
980 enum {
981  /*! Queue incoming DTMF, to be released when this flag is turned off */
983  /*! write should be interrupt generator */
984  AST_FLAG_WRITE_INT = (1 << 2),
985  /*! a thread is blocking on this channel */
986  AST_FLAG_BLOCKING = (1 << 3),
987  /*! This is a zombie channel */
988  AST_FLAG_ZOMBIE = (1 << 4),
989  /*! There is an exception pending */
990  AST_FLAG_EXCEPTION = (1 << 5),
991  /*! Listening to moh XXX anthm promises me this will disappear XXX */
992  AST_FLAG_MOH = (1 << 6),
993  /*! This channel is spying on another channel */
994  AST_FLAG_SPYING = (1 << 7),
995  /*! the channel is in an auto-incrementing dialplan processor,
996  * so when ->priority is set, it will get incremented before
997  * finding the next priority to run */
999  /*! This is an outgoing call */
1000  AST_FLAG_OUTGOING = (1 << 10),
1001  /*! A DTMF_BEGIN frame has been read from this channel, but not yet an END */
1002  AST_FLAG_IN_DTMF = (1 << 12),
1003  /*! A DTMF_END was received when not IN_DTMF, so the length of the digit is
1004  * currently being emulated */
1006  /*! This is set to tell the channel not to generate DTMF begin frames, and
1007  * to instead only generate END frames. */
1009  /* OBSOLETED in favor of AST_CAUSE_ANSWERED_ELSEWHERE
1010  * Flag to show channels that this call is hangup due to the fact that the call
1011  * was indeed answered, but in another channel */
1012  /* AST_FLAG_ANSWERED_ELSEWHERE = (1 << 15), */
1013  /*! This flag indicates that on a masquerade, an active stream should not
1014  * be carried over */
1016  /*! This flag indicates that the hangup exten was run when the bridge terminated,
1017  * a message aimed at preventing a subsequent hangup exten being run at the pbx_run
1018  * level */
1020  /*! Disable certain workarounds. This reintroduces certain bugs, but allows
1021  * some non-traditional dialplans (like AGI) to continue to function.
1022  */
1024  /*!
1025  * Disable device state event caching. This allows channel
1026  * drivers to selectively prevent device state events from being
1027  * cached by certain channels such as anonymous calls which have
1028  * no persistent represenatation that can be tracked.
1029  */
1031  /*!
1032  * This flag indicates that a dual channel redirect is in
1033  * progress. The bridge needs to wait until the flag is cleared
1034  * to continue.
1035  */
1037  /*!
1038  * This flag indicates that the channel was originated.
1039  */
1040  AST_FLAG_ORIGINATED = (1 << 23),
1041  /*!
1042  * The channel is well and truly dead. Once this is set and published, no further
1043  * actions should be taken upon the channel, and no further publications should
1044  * occur.
1045  */
1046  AST_FLAG_DEAD = (1 << 24),
1047  /*!
1048  * Channel snapshot should not be published, it is being staged for an explicit
1049  * publish.
1050  */
1052  /*!
1053  * The data on chan->timingdata is an astobj2 object.
1054  */
1056  /*!
1057  * The channel is executing a subroutine or macro
1058  */
1060 };
1061 
1062 /*! \brief ast_bridge_config flags */
1063 enum {
1071 };
1072 
1073 #define AST_FEATURE_DTMF_MASK (AST_FEATURE_REDIRECT | AST_FEATURE_DISCONNECT |\
1074  AST_FEATURE_ATXFER | AST_FEATURE_AUTOMON | AST_FEATURE_PARKCALL | AST_FEATURE_AUTOMIXMON)
1075 
1076 /*! \brief bridge configuration */
1078  struct ast_flags features_caller;
1079  struct ast_flags features_callee;
1080  struct timeval start_time;
1081  struct timeval nexteventts;
1082  struct timeval feature_start_time;
1087  const char *warning_sound;
1088  const char *end_sound;
1089  const char *start_sound;
1090  unsigned int flags;
1091  void (* end_bridge_callback)(void *); /*!< A callback that is called after a bridge attempt */
1092  void *end_bridge_callback_data; /*!< Data passed to the callback */
1093  /*! If the end_bridge_callback_data refers to a channel which no longer is going to
1094  * exist when the end_bridge_callback is called, then it needs to be fixed up properly
1095  */
1096  void (*end_bridge_callback_data_fixup)(struct ast_bridge_config *bconfig, struct ast_channel *originator, struct ast_channel *terminator);
1097  /*! If the bridge answers the channel this topology should be passed to the channel
1098  * and used if the channel supports the answer_with_stream_topology callback.
1099  */
1101 };
1102 
1103 struct chanmon;
1104 
1106  const char *context;
1107  const char *exten;
1109  int connect_on_early_media; /* If set, treat session progress as answer */
1110  const char *cid_num;
1111  const char *cid_name;
1112  const char *account;
1115 };
1116 
1117 enum {
1118  /*!
1119  * Soft hangup requested by device or other internal reason.
1120  * Actual hangup needed.
1121  */
1123  /*!
1124  * Used to break the normal frame flow so an async goto can be
1125  * done instead of actually hanging up.
1126  */
1128  /*!
1129  * Soft hangup requested by system shutdown. Actual hangup
1130  * needed.
1131  */
1133  /*!
1134  * Used to break the normal frame flow after a timeout so an
1135  * implicit async goto can be done to the 'T' exten if it exists
1136  * instead of actually hanging up. If the exten does not exist
1137  * then actually hangup.
1138  */
1140  /*!
1141  * Soft hangup requested by application/channel-driver being
1142  * unloaded. Actual hangup needed.
1143  */
1145  /*!
1146  * Soft hangup requested by non-associated party. Actual hangup
1147  * needed.
1148  */
1150  /*!
1151  * Used to indicate that the channel is currently executing hangup
1152  * logic in the dialplan. The channel has been hungup when this is
1153  * set.
1154  */
1156  /*!
1157  * \brief All softhangup flags.
1158  *
1159  * This can be used as an argument to ast_channel_clear_softhangup()
1160  * to clear all softhangup flags from a channel.
1161  */
1162  AST_SOFTHANGUP_ALL = (0xFFFFFFFF)
1163 };
1164 
1165 
1166 /*! \brief Channel reload reasons for manager events at load or reload of configuration */
1173 };
1174 
1175 /*!
1176  * \brief Channel AMA Flags
1177  */
1183 };
1184 
1185 /*!
1186  * \note None of the datastore API calls lock the ast_channel they are using.
1187  * So, the channel should be locked before calling the functions that
1188  * take a channel argument.
1189  */
1190 
1191 /*! \brief Inherit datastores from a parent to a child. */
1192 int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to);
1193 
1194 /*!
1195  * \brief Add a datastore to a channel
1196  *
1197  * \note The channel should be locked before calling this function.
1198  *
1199  * \retval 0 success
1200  * \retval non-zero failure
1201  */
1202 int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore);
1203 
1204 /*!
1205  * \brief Remove a datastore from a channel
1206  *
1207  * \note The channel should be locked before calling this function.
1208  *
1209  * \retval 0 success
1210  * \retval non-zero failure
1211  */
1212 int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore);
1213 
1214 /*!
1215  * \brief Find a datastore on a channel
1216  *
1217  * \note The channel should be locked before calling this function.
1218  *
1219  * \note The datastore returned from this function must not be used if the
1220  * reference to the channel is released.
1221  *
1222  * \retval pointer to the datastore if found
1223  * \retval NULL if not found
1224  */
1225 struct ast_datastore *ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid);
1226 
1227 /*!
1228  * \brief Create a channel structure
1229  * \since 1.8
1230  *
1231  * \retval NULL failure
1232  * \retval non-NULL successfully allocated channel
1233  *
1234  * \note Absolutely _NO_ channel locks should be held before calling this function.
1235  * \note By default, new channels are set to the "s" extension
1236  * and "default" context.
1237  * \note Since 12.0.0 this function returns with the newly created channel locked.
1238  */
1239 struct ast_channel * __attribute__((format(printf, 15, 16)))
1240  __ast_channel_alloc(int needqueue, int state, const char *cid_num,
1241  const char *cid_name, const char *acctcode,
1242  const char *exten, const char *context, const struct ast_assigned_ids *assignedids,
1243  const struct ast_channel *requestor, enum ama_flags amaflag,
1244  struct ast_endpoint *endpoint,
1245  const char *file, int line, const char *function,
1246  const char *name_fmt, ...);
1247 
1248 /*!
1249  * \brief Create a channel structure
1250  *
1251  * \retval NULL failure
1252  * \retval non-NULL successfully allocated channel
1253  *
1254  * \note Absolutely _NO_ channel locks should be held before calling this function.
1255  * \note By default, new channels are set to the "s" extension
1256  * and "default" context.
1257  * \note Since 12.0.0 this function returns with the newly created channel locked.
1258  */
1259 #define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag, ...) \
1260  __ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag, NULL, \
1261  __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__)
1262 
1263 #define ast_channel_alloc_with_endpoint(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag, endpoint, ...) \
1264  __ast_channel_alloc((needqueue), (state), (cid_num), (cid_name), (acctcode), (exten), (context), (assignedids), (requestor), (amaflag), (endpoint), \
1265  __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__)
1266 
1267 /*!
1268  * \brief Create a fake channel structure
1269  *
1270  * \retval NULL failure
1271  * \retval non-NULL successfully allocated channel
1272  *
1273  * \note This function should ONLY be used to create a fake channel
1274  * that can then be populated with data for use in variable
1275  * substitution when a real channel does not exist.
1276  *
1277  * \note The created dummy channel should be destroyed by
1278  * ast_channel_unref(). Using ast_channel_release() needlessly
1279  * grabs the channel container lock and can cause a deadlock as
1280  * a result. Also grabbing the channel container lock reduces
1281  * system performance.
1282  */
1283 #define ast_dummy_channel_alloc() __ast_dummy_channel_alloc(__FILE__, __LINE__, __PRETTY_FUNCTION__)
1284 struct ast_channel *__ast_dummy_channel_alloc(const char *file, int line, const char *function);
1285 
1286 /*!
1287  * \brief Queue one or more frames to a channel's frame queue
1288  *
1289  * \param chan the channel to queue the frame(s) on
1290  * \param f the frame(s) to queue. Note that the frame(s) will be duplicated
1291  * by this function. It is the responsibility of the caller to handle
1292  * freeing the memory associated with the frame(s) being passed if
1293  * necessary.
1294  *
1295  * \retval 0 success
1296  * \retval non-zero failure
1297  */
1298 int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f);
1299 
1300 /*!
1301  * \brief Queue one or more frames to the head of a channel's frame queue
1302  *
1303  * \param chan the channel to queue the frame(s) on
1304  * \param f the frame(s) to queue. Note that the frame(s) will be duplicated
1305  * by this function. It is the responsibility of the caller to handle
1306  * freeing the memory associated with the frame(s) being passed if
1307  * necessary.
1308  *
1309  * \retval 0 success
1310  * \retval non-zero failure
1311  */
1312 int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *f);
1313 
1314 /*!
1315  * \brief Queue a hangup frame
1316  *
1317  * \note The channel does not need to be locked before calling this function.
1318  */
1319 int ast_queue_hangup(struct ast_channel *chan);
1320 
1321 /*!
1322  * \brief Queue a hangup frame with hangupcause set
1323  *
1324  * \note The channel does not need to be locked before calling this function.
1325  * \param[in] chan channel to queue frame onto
1326  * \param[in] cause the hangup cause
1327  * \return 0 on success, -1 on error
1328  * \since 1.6.1
1329  */
1330 int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause);
1331 
1332 /*!
1333  * \brief Queue a hold frame
1334  *
1335  * \param chan channel to queue frame onto
1336  * \param musicclass The suggested musicclass for the other end to use
1337  *
1338  * \note The channel does not need to be locked before calling this function.
1339  *
1340  * \retval zero on success
1341  * \retval non-zero on failure
1342  */
1343 int ast_queue_hold(struct ast_channel *chan, const char *musicclass);
1344 
1345 /*!
1346  * \brief Queue an unhold frame
1347  *
1348  * \param chan channel to queue frame onto
1349  *
1350  * \note The channel does not need to be locked before calling this function.
1351  *
1352  * \retval zero on success
1353  * \retval non-zero on failure
1354  */
1355 int ast_queue_unhold(struct ast_channel *chan);
1356 
1357 /*!
1358  * \brief Queue a control frame without payload
1359  *
1360  * \param chan channel to queue frame onto
1361  * \param control type of control frame
1362  *
1363  * \note The channel does not need to be locked before calling this function.
1364  *
1365  * \retval zero on success
1366  * \retval non-zero on failure
1367  */
1368 int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control);
1369 
1370 /*!
1371  * \brief Queue a control frame with payload
1372  *
1373  * \param chan channel to queue frame onto
1374  * \param control type of control frame
1375  * \param data pointer to payload data to be included in frame
1376  * \param datalen number of bytes of payload data
1377  *
1378  * \retval 0 success
1379  * \retval non-zero failure
1380  *
1381  * \details
1382  * The supplied payload data is copied into the frame, so the caller's copy
1383  * is not modified nor freed, and the resulting frame will retain a copy of
1384  * the data even if the caller frees their local copy.
1385  *
1386  * \note This method should be treated as a 'network transport'; in other
1387  * words, your frames may be transferred across an IAX2 channel to another
1388  * system, which may be a different endianness than yours. Because of this,
1389  * you should ensure that either your frames will never be expected to work
1390  * across systems, or that you always put your payload data into 'network byte
1391  * order' before calling this function.
1392  *
1393  * \note The channel does not need to be locked before calling this function.
1394  */
1395 int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control,
1396  const void *data, size_t datalen);
1397 
1398 /*!
1399  * \brief Queue an ANSWER control frame with topology
1400  *
1401  * \param chan channel to queue frame onto
1402  * \param topology topology to be passed through the core to the peer channel
1403  *
1404  * \retval 0 success
1405  * \retval non-zero failure
1406  */
1407 int ast_queue_answer(struct ast_channel *chan, const struct ast_stream_topology *topology);
1408 
1409 /*!
1410  * \brief Change channel name
1411  *
1412  * \pre Absolutely all channels _MUST_ be unlocked before calling this function.
1413  *
1414  * \param chan the channel to change the name of
1415  * \param newname the name to change to
1416  *
1417  * \return nothing
1418  *
1419  * \note this function must _NEVER_ be used when any channels are locked
1420  * regardless if it is the channel who's name is being changed or not because
1421  * it invalidates our channel container locking order... lock container first,
1422  * then the individual channels, never the other way around.
1423  */
1424 void ast_change_name(struct ast_channel *chan, const char *newname);
1425 
1426 /*!
1427  * \brief Unlink and release reference to a channel
1428  *
1429  * This function will unlink the channel from the global channels container
1430  * if it is still there and also release the current reference to the channel.
1431  *
1432  * \return NULL, convenient for clearing invalid pointers
1433  * \note Absolutely _NO_ channel locks should be held before calling this function.
1434  *
1435  * \since 1.8
1436  */
1437 struct ast_channel *ast_channel_release(struct ast_channel *chan);
1438 
1439 /*!
1440  * \brief Requests a channel
1441  *
1442  * \param type type of channel to request
1443  * \param request_cap Format capabilities for requested channel
1444  * \param assignedids Unique ID to create channel with
1445  * \param requestor channel asking for data
1446  * \param addr destination of the call
1447  * \param cause Cause of failure
1448  *
1449  * \details
1450  * Request a channel of a given type, with addr as optional information used
1451  * by the low level module
1452  *
1453  * \retval NULL failure
1454  * \retval non-NULL channel on success
1455  */
1456 struct ast_channel *ast_request(const char *type, struct ast_format_cap *request_cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause);
1457 
1458 /*!
1459  * \brief Requests a channel (specifying stream topology)
1460  *
1461  * \param type type of channel to request
1462  * \param topology Stream topology for requested channel
1463  * \param assignedids Unique ID to create channel with
1464  * \param requestor channel asking for data
1465  * \param addr destination of the call
1466  * \param cause Cause of failure
1467  *
1468  * \details
1469  * Request a channel of a given type, with addr as optional information used
1470  * by the low level module
1471  *
1472  * \retval NULL failure
1473  * \retval non-NULL channel on success
1474  */
1475 struct ast_channel *ast_request_with_stream_topology(const char *type, struct ast_stream_topology *topology, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause);
1476 
1478  /*! The requestor is the future bridge peer of the channel. */
1480  /*! The requestor is to be replaced by the channel. */
1482 };
1483 
1484 /*!
1485  * \brief Setup new channel accountcodes from the requestor channel after ast_request().
1486  * \since 13.0.0
1487  *
1488  * \param chan New channel to get accountcodes setup.
1489  * \param requestor Requesting channel to get accountcodes from.
1490  * \param relationship What the new channel was created for.
1491  *
1492  * \pre The chan and requestor channels are already locked.
1493  *
1494  * \note Pre-existing accountcodes on chan will be overwritten.
1495  *
1496  * \return Nothing
1497  */
1498 void ast_channel_req_accountcodes(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship);
1499 
1500 /*!
1501  * \brief Setup new channel accountcodes from the requestor channel after ast_request().
1502  * \since 13.0.0
1503  *
1504  * \param chan New channel to get accountcodes setup.
1505  * \param requestor Requesting channel to get accountcodes from.
1506  * \param relationship What the new channel was created for.
1507  *
1508  * \pre The chan and requestor channels are already locked.
1509  *
1510  * \note Pre-existing accountcodes on chan will not be overwritten.
1511  *
1512  * \return Nothing
1513  */
1514 void ast_channel_req_accountcodes_precious(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship);
1515 
1516 /*!
1517  * \brief Request a channel of a given type, with data as optional information used
1518  * by the low level module and attempt to place a call on it
1519  *
1520  * \param type type of channel to request
1521  * \param cap format capabilities for requested channel
1522  * \param assignedids Unique Id to assign to channel
1523  * \param requestor channel asking for data
1524  * \param addr destination of the call
1525  * \param timeout maximum amount of time to wait for an answer
1526  * \param reason why unsuccessful (if unsuccessful)
1527  * \param cid_num Caller-ID Number
1528  * \param cid_name Caller-ID Name (ascii)
1529  *
1530  * \return Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state
1531  * to know if the call was answered or not.
1532  */
1533 struct ast_channel *ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr,
1534  int timeout, int *reason, const char *cid_num, const char *cid_name);
1535 
1536 /*!
1537  * \brief Request a channel of a given type, with data as optional information used
1538  * by the low level module and attempt to place a call on it
1539  * \param type type of channel to request
1540  * \param cap format capabilities for requested channel
1541  * \param assignedids Unique Id to assign to channel
1542  * \param requestor channel requesting data
1543  * \param addr destination of the call
1544  * \param timeout maximum amount of time to wait for an answer
1545  * \param reason why unsuccessful (if unsuccessful)
1546  * \param cid_num Caller-ID Number
1547  * \param cid_name Caller-ID Name (ascii)
1548  * \param oh Outgoing helper
1549  * \return Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state
1550  * to know if the call was answered or not.
1551  */
1552 struct ast_channel *__ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr,
1553  int timeout, int *reason, const char *cid_num, const char *cid_name, struct outgoing_helper *oh);
1554 
1555 /*!
1556  * \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.
1557  * \param caller in channel that requested orig
1558  * \param orig channel being replaced by the call forward channel
1559  * \param timeout maximum amount of time to wait for setup of new forward channel
1560  * \param cap format capabilities for requested channel
1561  * \param oh outgoing helper used with original channel
1562  * \param outstate reason why unsuccessful (if uncuccessful)
1563  * \return Returns the forwarded call's ast_channel on success or NULL on failure
1564  */
1565 struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, struct ast_format_cap *cap, struct outgoing_helper *oh, int *outstate);
1566 
1567 /*!
1568  * \brief Register a channel technology (a new channel driver)
1569  * Called by a channel module to register the kind of channels it supports.
1570  * \param tech Structure defining channel technology or "type"
1571  * \return Returns 0 on success, -1 on failure.
1572  */
1573 int ast_channel_register(const struct ast_channel_tech *tech);
1574 
1575 /*!
1576  * \brief Unregister a channel technology
1577  * \param tech Structure defining channel technology or "type" that was previously registered
1578  * \return No return value.
1579  */
1580 void ast_channel_unregister(const struct ast_channel_tech *tech);
1581 
1582 /*!
1583  * \brief Get a channel technology structure by name
1584  * \param name name of technology to find
1585  * \return a pointer to the structure, or NULL if no matching technology found
1586  */
1587 const struct ast_channel_tech *ast_get_channel_tech(const char *name);
1588 
1589 /*!
1590  * \brief Hang up a channel
1591  * \note Absolutely _NO_ channel locks should be held before calling this function.
1592  * \note This function performs a hard hangup on a channel. Unlike the soft-hangup, this function
1593  * performs all stream stopping, etc, on the channel that needs to end.
1594  * chan is no longer valid after this call.
1595  * \param chan channel to hang up (NULL tolerant)
1596  * \return Nothing
1597  */
1598 void ast_hangup(struct ast_channel *chan);
1599 
1600 /*!
1601  * \brief Soft hangup all active channels.
1602  * \since 13.3.0
1603  *
1604  * \return Nothing
1605  */
1606 void ast_softhangup_all(void);
1607 
1608 /*!
1609  * \brief Softly hangup up a channel
1610  *
1611  * \param chan channel to be soft-hung-up
1612  * \param reason an AST_SOFTHANGUP_* reason code
1613  *
1614  * \details
1615  * Call the protocol layer, but don't destroy the channel structure
1616  * (use this if you are trying to
1617  * safely hangup a channel managed by another thread.
1618  *
1619  * \note The channel passed to this function does not need to be locked.
1620  *
1621  * \return Returns 0 regardless
1622  */
1623 int ast_softhangup(struct ast_channel *chan, int reason);
1624 
1625 /*!
1626  * \brief Softly hangup up a channel (no channel lock)
1627  * \param chan channel to be soft-hung-up
1628  * \param reason an AST_SOFTHANGUP_* reason code
1629  */
1630 int ast_softhangup_nolock(struct ast_channel *chan, int reason);
1631 
1632 /*!
1633  * \brief Clear a set of softhangup flags from a channel
1634  *
1635  * Never clear a softhangup flag from a channel directly. Instead,
1636  * use this function. This ensures that all aspects of the softhangup
1637  * process are aborted.
1638  *
1639  * \param chan the channel to clear the flag on
1640  * \param flag the flag or flags to clear
1641  *
1642  * \return Nothing.
1643  */
1644 void ast_channel_clear_softhangup(struct ast_channel *chan, int flag);
1645 
1646 /*!
1647  * \brief Set the source of the hangup in this channel and it's bridge
1648  *
1649  * \param chan channel to set the field on
1650  * \param source a string describing the source of the hangup for this channel
1651  * \param force
1652  *
1653  * \note Absolutely _NO_ channel locks should be held before calling this function.
1654  *
1655  * \since 1.8
1656  *
1657  * Hangupsource is generally the channel name that caused the bridge to be
1658  * hung up, but it can also be other things such as "dialplan/agi"
1659  * This can then be logged in the CDR or CEL
1660  */
1661 void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force);
1662 
1663 /*! \brief Check to see if a channel is needing hang up
1664  * \param chan channel on which to check for hang up
1665  * This function determines if the channel is being requested to be hung up.
1666  * \return Returns 0 if not, or 1 if hang up is requested (including time-out).
1667  */
1668 int ast_check_hangup(struct ast_channel *chan);
1669 
1670 int ast_check_hangup_locked(struct ast_channel *chan);
1671 
1672 /*! \brief This function will check if the bridge needs to be re-evaluated due to
1673  * external changes.
1674  *
1675  * \param chan Channel on which to check the unbridge_eval flag
1676  *
1677  * \return Returns 0 if the flag is down or 1 if the flag is up.
1678  */
1679 int ast_channel_unbridged(struct ast_channel *chan);
1680 
1681 /*! \brief ast_channel_unbridged variant. Use this if the channel
1682  * is already locked prior to calling.
1683  *
1684  * \param chan Channel on which to check the unbridge flag
1685  *
1686  * \return Returns 0 if the flag is down or 1 if the flag is up.
1687  */
1688 int ast_channel_unbridged_nolock(struct ast_channel *chan);
1689 
1690 /*! \brief Sets the unbridged flag and queues a NULL frame on the channel to trigger
1691  * a check by bridge_channel_wait
1692  *
1693  * \param chan Which channel is having its unbridged value set
1694  * \param value What the unbridge value is being set to
1695  */
1696 void ast_channel_set_unbridged(struct ast_channel *chan, int value);
1697 
1698 /*! \brief Variant of ast_channel_set_unbridged. Use this if the channel
1699  * is already locked prior to calling.
1700  *
1701  * \param chan Which channel is having its unbridged value set
1702  * \param value What the unbridge value is being set to
1703  */
1704 void ast_channel_set_unbridged_nolock(struct ast_channel *chan, int value);
1705 
1706 /*!
1707  * \brief This function will check if T.38 is active on the channel.
1708  *
1709  * \param chan Channel on which to check the unbridge_eval flag
1710  *
1711  * \return Returns 0 if the flag is down or 1 if the flag is up.
1712  */
1713 int ast_channel_is_t38_active(struct ast_channel *chan);
1714 
1715 /*!
1716  * \brief ast_channel_is_t38_active variant. Use this if the channel
1717  * is already locked prior to calling.
1718  *
1719  * \param chan Channel on which to check the is_t38_active flag
1720  *
1721  * \return Returns 0 if the flag is down or 1 if the flag is up.
1722  */
1724 
1725 /*!
1726  * \brief Sets the is_t38_active flag
1727  *
1728  * \param chan Which channel is having its is_t38_active value set
1729  * \param is_t38_active Non-zero if T.38 is active
1730  */
1731 void ast_channel_set_is_t38_active(struct ast_channel *chan, int is_t38_active);
1732 
1733 /*!
1734  * \brief Variant of ast_channel_set_is_t38_active. Use this if the channel
1735  * is already locked prior to calling.
1736  *
1737  * \param chan Which channel is having its is_t38_active value set
1738  * \param is_t38_active Non-zero if T.38 is active
1739  */
1740 void ast_channel_set_is_t38_active_nolock(struct ast_channel *chan, int is_t38_active);
1741 
1742 /*!
1743  * \brief Lock the given channel, then request softhangup on the channel with the given causecode
1744  * \param chan channel on which to hang up
1745  * \param causecode cause code to use (Zero if don't use cause code)
1746  * \return Nothing
1747  */
1748 void ast_channel_softhangup_withcause_locked(struct ast_channel *chan, int causecode);
1749 
1750 /*!
1751  * \brief Compare a offset with the settings of when to hang a channel up
1752  * \param chan channel on which to check for hangup
1753  * \param offset offset in seconds and microseconds from current time
1754  * \return 1, 0, or -1
1755  * This function compares a offset from current time with the absolute time
1756  * out on a channel (when to hang up). If the absolute time out on a channel
1757  * is earlier than current time plus the offset, it returns 1, if the two
1758  * time values are equal, it return 0, otherwise, it return -1.
1759  * \since 1.6.1
1760  */
1761 int ast_channel_cmpwhentohangup_tv(struct ast_channel *chan, struct timeval offset);
1762 
1763 /*!
1764  * \brief Set when to hang a channel up
1765  *
1766  * \param chan channel on which to check for hang up
1767  * \param offset offset in seconds and useconds relative to the current time of when to hang up
1768  *
1769  * This function sets the absolute time out on a channel (when to hang up).
1770  *
1771  * \pre chan is locked
1772  *
1773  * \return Nothing
1774  * \since 1.6.1
1775  */
1776 void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset);
1777 
1778 /*!
1779  * \brief Answer a channel
1780  *
1781  * \param chan channel to answer
1782  *
1783  * \details
1784  * This function answers a channel and handles all necessary call
1785  * setup functions.
1786  *
1787  * \note The channel passed does not need to be locked, but is locked
1788  * by the function when needed.
1789  *
1790  * \note This function will wait up to 500 milliseconds for media to
1791  * arrive on the channel before returning to the caller, so that the
1792  * caller can properly assume the channel is 'ready' for media flow.
1793  *
1794  * \retval 0 on success
1795  * \retval non-zero on failure
1796  */
1797 int ast_answer(struct ast_channel *chan);
1798 
1799 /*!
1800  * \brief Answer a channel, if it's not already answered.
1801  *
1802  * \param chan channel to answer
1803  *
1804  * \details See ast_answer()
1805  *
1806  * \retval 0 on success
1807  * \retval non-zero on failure
1808  */
1809 int ast_auto_answer(struct ast_channel *chan);
1810 
1811 /*!
1812  * \brief Answer a channel
1813  *
1814  * \param chan channel to answer
1815  *
1816  * This function answers a channel and handles all necessary call
1817  * setup functions.
1818  *
1819  * \note The channel passed does not need to be locked, but is locked
1820  * by the function when needed.
1821  *
1822  * \note Unlike ast_answer(), this function will not wait for media
1823  * flow to begin. The caller should be careful before sending media
1824  * to the channel before incoming media arrives, as the outgoing
1825  * media may be lost.
1826  *
1827  * \retval 0 on success
1828  * \retval non-zero on failure
1829  */
1830 int ast_raw_answer(struct ast_channel *chan);
1831 
1832 /*!
1833  * \brief Answer a channel passing in a stream topology
1834  * \since 18.0.0
1835  *
1836  * \param chan channel to answer
1837  * \param topology the peer's stream topology
1838  *
1839  * This function answers a channel and handles all necessary call
1840  * setup functions.
1841  *
1842  * \note The channel passed does not need to be locked, but is locked
1843  * by the function when needed.
1844  *
1845  * \note Unlike ast_answer(), this function will not wait for media
1846  * flow to begin. The caller should be careful before sending media
1847  * to the channel before incoming media arrives, as the outgoing
1848  * media may be lost.
1849  *
1850  * \note The topology is usually that of the peer channel and may be NULL.
1851  *
1852  * \retval 0 on success
1853  * \retval non-zero on failure
1854  */
1855 int ast_raw_answer_with_stream_topology(struct ast_channel *chan, struct ast_stream_topology *topology);
1856 
1857 /*!
1858  * \brief Answer a channel, with a selectable delay before returning
1859  *
1860  * \param chan channel to answer
1861  * \param delay maximum amount of time to wait for incoming media
1862  *
1863  * This function answers a channel and handles all necessary call
1864  * setup functions.
1865  *
1866  * \note The channel passed does not need to be locked, but is locked
1867  * by the function when needed.
1868  *
1869  * \note This function will wait up to 'delay' milliseconds for media to
1870  * arrive on the channel before returning to the caller, so that the
1871  * caller can properly assume the channel is 'ready' for media flow. If
1872  * 'delay' is less than 500, the function will wait up to 500 milliseconds.
1873  *
1874  * \retval 0 on success
1875  * \retval non-zero on failure
1876  */
1877 int __ast_answer(struct ast_channel *chan, unsigned int delay);
1878 
1879 /*!
1880  * \brief Execute a Gosub call on the channel before a call is placed.
1881  * \since 11.0
1882  *
1883  * \details
1884  * This is called between ast_request() and ast_call() to
1885  * execute a predial routine on the newly created channel.
1886  *
1887  * \param chan Channel to execute Gosub.
1888  * \param sub_args Gosub application parameter string.
1889  *
1890  * \note Absolutely _NO_ channel locks should be held before calling this function.
1891  *
1892  * \retval 0 on success.
1893  * \retval -1 on error.
1894  */
1895 int ast_pre_call(struct ast_channel *chan, const char *sub_args);
1896 
1897 /*!
1898  * \brief Make a call
1899  * \note Absolutely _NO_ channel locks should be held before calling this function.
1900  * \param chan which channel to make the call on
1901  * \param addr destination of the call
1902  * \param timeout time to wait on for connect (Doesn't seem to be used.)
1903  * \details
1904  * Place a call, take no longer than timeout ms.
1905  * \retval 0 on success
1906  * \retval -1 on failure
1907  */
1908 int ast_call(struct ast_channel *chan, const char *addr, int timeout);
1909 
1910 /*!
1911  * \brief Indicates condition of channel
1912  * \note Absolutely _NO_ channel locks should be held before calling this function.
1913  * \note Indicate a condition such as AST_CONTROL_BUSY, AST_CONTROL_RINGING, or AST_CONTROL_CONGESTION on a channel
1914  * \param chan channel to change the indication
1915  * \param condition which condition to indicate on the channel
1916  * \return Returns 0 on success, -1 on failure
1917  */
1918 int ast_indicate(struct ast_channel *chan, int condition);
1919 
1920 /*!
1921  * \brief Indicates condition of channel, with payload
1922  * \note Absolutely _NO_ channel locks should be held before calling this function.
1923  * \note Indicate a condition such as AST_CONTROL_HOLD with payload being music on hold class
1924  * \param chan channel to change the indication
1925  * \param condition which condition to indicate on the channel
1926  * \param data pointer to payload data
1927  * \param datalen size of payload data
1928  * \return Returns 0 on success, -1 on failure
1929  */
1930 int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen);
1931 
1932 /* Misc stuff ------------------------------------------------ */
1933 
1934 /*!
1935  * \brief Wait for input on a channel
1936  * \param chan channel to wait on
1937  * \param ms length of time to wait on the channel
1938  * \details
1939  * Wait for input on a channel for a given # of milliseconds (<0 for indefinite).
1940  * \retval < 0 on failure
1941  * \retval 0 if nothing ever arrived
1942  * \retval the # of ms remaining otherwise
1943  */
1944 int ast_waitfor(struct ast_channel *chan, int ms);
1945 
1946 /*!
1947  * \brief Should we keep this frame for later?
1948  *
1949  * There are functions such as ast_safe_sleep which will
1950  * service a channel to ensure that it does not have a
1951  * large backlog of queued frames. When this happens,
1952  * we want to hold on to specific frame types and just drop
1953  * others. This function will tell if the frame we just
1954  * read should be held onto.
1955  *
1956  * \param frame The frame we just read
1957  * \retval 1 frame should be kept
1958  * \retval 0 frame should be dropped
1959  */
1960 int ast_is_deferrable_frame(const struct ast_frame *frame);
1961 
1962 /*!
1963  * \brief Wait for a specified amount of time, looking for hangups
1964  * \param chan channel to wait for
1965  * \param ms length of time in milliseconds to sleep. This should never be less than zero.
1966  * \details
1967  * Waits for a specified amount of time, servicing the channel as required.
1968  * \return returns -1 on hangup, otherwise 0.
1969  */
1970 int ast_safe_sleep(struct ast_channel *chan, int ms);
1971 
1972 /*!
1973  * \brief Wait for a specified amount of time, looking for hangups and a condition argument
1974  * \param chan channel to wait for
1975  * \param ms length of time in milliseconds to sleep.
1976  * \param cond a function pointer for testing continue condition
1977  * \param data argument to be passed to the condition test function
1978  * \return returns -1 on hangup, otherwise 0.
1979  * \details
1980  * Waits for a specified amount of time, servicing the channel as required. If cond
1981  * returns 0, this function returns.
1982  */
1983 int ast_safe_sleep_conditional(struct ast_channel *chan, int ms, int (*cond)(void*), void *data );
1984 
1985 /*!
1986  * \brief Waits for activity on a group of channels
1987  * \param chan an array of pointers to channels
1988  * \param n number of channels that are to be waited upon
1989  * \param fds an array of fds to wait upon
1990  * \param nfds the number of fds to wait upon
1991  * \param exception exception flag
1992  * \param outfd fd that had activity on it
1993  * \param ms how long the wait was
1994  * \details
1995  * Big momma function here. Wait for activity on any of the n channels, or any of the nfds
1996  * file descriptors.
1997  * \return Returns the channel with activity, or NULL on error or if an FD
1998  * came first. If the FD came first, it will be returned in outfd, otherwise, outfd
1999  * will be -1
2000  */
2001 struct ast_channel *ast_waitfor_nandfds(struct ast_channel **chan, int n,
2002  int *fds, int nfds, int *exception, int *outfd, int *ms);
2003 
2004 /*!
2005  * \brief Waits for input on a group of channels
2006  * Wait for input on an array of channels for a given # of milliseconds.
2007  * \return Return channel with activity, or NULL if none has activity.
2008  * \param chan an array of pointers to channels
2009  * \param n number of channels that are to be waited upon
2010  * \param ms time "ms" is modified in-place, if applicable
2011  */
2012 struct ast_channel *ast_waitfor_n(struct ast_channel **chan, int n, int *ms);
2013 
2014 /*!
2015  * \brief Waits for input on an fd
2016  * \note This version works on fd's only. Be careful with it.
2017  */
2018 int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception);
2019 
2020 
2021 /*!
2022  * \brief Reads a frame
2023  *
2024  * \param chan channel to read a frame from
2025  *
2026  * \return Returns a frame, or NULL on error. If it returns NULL, you
2027  * best just stop reading frames and assume the channel has been
2028  * disconnected.
2029  *
2030  * \note This function will filter frames received from the channel so
2031  * that only frames from the default stream for each media type
2032  * are returned. All other media frames from other streams will
2033  * be absorbed internally and a NULL frame returned instead.
2034  */
2035 struct ast_frame *ast_read(struct ast_channel *chan);
2036 
2037 /*!
2038  * \brief Reads a frame, but does not filter to just the default streams
2039  *
2040  * \param chan channel to read a frame from
2041  *
2042  * \return Returns a frame, or NULL on error. If it returns NULL, you
2043  * best just stop reading frames and assume the channel has been
2044  * disconnected.
2045  *
2046  * \note This function will not perform any filtering and will return
2047  * media frames from all streams on the channel. To determine which
2048  * stream a frame originated from the stream_num on it can be
2049  * examined.
2050  */
2051 struct ast_frame *ast_read_stream(struct ast_channel *chan);
2052 
2053 /*!
2054  * \brief Reads a frame, returning AST_FRAME_NULL frame if audio.
2055  * \param chan channel to read a frame from
2056  * \return Returns a frame, or NULL on error. If it returns NULL, you
2057  * best just stop reading frames and assume the channel has been
2058  * disconnected.
2059  * \note Audio is replaced with AST_FRAME_NULL to avoid
2060  * transcode when the resulting audio is not necessary.
2061  */
2062 struct ast_frame *ast_read_noaudio(struct ast_channel *chan);
2063 
2064 /*!
2065  * \brief Reads a frame, but does not filter to just the default streams,
2066  * returning AST_FRAME_NULL frame if audio.
2067  *
2068  * \param chan channel to read a frame from
2069  *
2070  * \return Returns a frame, or NULL on error. If it returns NULL, you
2071  * best just stop reading frames and assume the channel has been
2072  * disconnected.
2073  *
2074  * \note This function will not perform any filtering and will return
2075  * media frames from all streams on the channel. To determine which
2076  * stream a frame originated from the stream_num on it can be
2077  * examined.
2078  *
2079  * \note Audio is replaced with AST_FRAME_NULL to avoid
2080  * transcode when the resulting audio is not necessary.
2081  */
2082 struct ast_frame *ast_read_stream_noaudio(struct ast_channel *chan);
2083 
2084 /*!
2085  * \brief Write a frame to a channel
2086  * This function writes the given frame to the indicated channel.
2087  * \param chan destination channel of the frame
2088  * \param frame frame that will be written
2089  * \return It returns 0 on success, -1 on failure.
2090  */
2091 int ast_write(struct ast_channel *chan, struct ast_frame *frame);
2092 
2093 /*!
2094  * \brief Write video frame to a channel
2095  * This function writes the given frame to the indicated channel.
2096  * \param chan destination channel of the frame
2097  * \param frame frame that will be written
2098  * \return It returns 1 on success, 0 if not implemented, and -1 on failure.
2099  */
2100 int ast_write_video(struct ast_channel *chan, struct ast_frame *frame);
2101 
2102 /*!
2103  * \brief Write text frame to a channel
2104  * This function writes the given frame to the indicated channel.
2105  * \param chan destination channel of the frame
2106  * \param frame frame that will be written
2107  * \return It returns 1 on success, 0 if not implemented, and -1 on failure.
2108  */
2109 int ast_write_text(struct ast_channel *chan, struct ast_frame *frame);
2110 
2111 /*!
2112  * \brief Write a frame to a stream
2113  * This function writes the given frame to the indicated stream on the channel.
2114  * \param chan destination channel of the frame
2115  * \param stream_num destination stream on the channel
2116  * \param frame frame that will be written
2117  * \return It returns 0 on success, -1 on failure.
2118  * \note If -1 is provided as the stream number and a media frame is provided the
2119  * function will write to the default stream of the type of media.
2120  */
2121 int ast_write_stream(struct ast_channel *chan, int stream_num, struct ast_frame *frame);
2122 
2123 /*! \brief Send empty audio to prime a channel driver */
2124 int ast_prod(struct ast_channel *chan);
2125 
2126 /*!
2127  * \brief Set specific read path on channel.
2128  * \since 13.4.0
2129  *
2130  * \param chan Channel to setup read path.
2131  * \param raw_format Format to expect from the channel driver.
2132  * \param core_format What the core wants to read.
2133  *
2134  * \pre chan is locked
2135  *
2136  * \retval 0 on success.
2137  * \retval -1 on error.
2138  */
2139 int ast_set_read_format_path(struct ast_channel *chan, struct ast_format *raw_format, struct ast_format *core_format);
2140 
2141 /*!
2142  * \brief Set specific write path on channel.
2143  * \since 13.13.0
2144  *
2145  * \param chan Channel to setup write path.
2146  * \param core_format What the core wants to write.
2147  * \param raw_format Raw write format.
2148  *
2149  * \pre chan is locked
2150  *
2151  * \retval 0 on success.
2152  * \retval -1 on error.
2153  */
2154 int ast_set_write_format_path(struct ast_channel *chan, struct ast_format *core_format, struct ast_format *raw_format);
2155 
2156 /*!
2157  * \brief Sets read format on channel chan from capabilities
2158  * Set read format for channel to whichever component of "format" is best.
2159  * \param chan channel to change
2160  * \param formats new formats to pick from for reading
2161  * \return Returns 0 on success, -1 on failure
2162  */
2164 
2165 /*!
2166  * \brief Sets read format on channel chan
2167  * \param chan channel to change
2168  * \param format format to set for reading
2169  * \return Returns 0 on success, -1 on failure
2170  */
2171 int ast_set_read_format(struct ast_channel *chan, struct ast_format *format);
2172 
2173 /*!
2174  * \brief Sets write format on channel chan
2175  * Set write format for channel to whichever component of "format" is best.
2176  * \param chan channel to change
2177  * \param formats new formats to pick from for writing
2178  * \return Returns 0 on success, -1 on failure
2179  */
2181 
2182 /*!
2183  * \brief Sets write format on channel chan
2184  * \param chan channel to change
2185  * \param format format to set for writing
2186  * \return Returns 0 on success, -1 on failure
2187  */
2188 int ast_set_write_format(struct ast_channel *chan, struct ast_format *format);
2189 
2190 /*!
2191  * \brief Sets write format for a channel.
2192  * All internal data will than be handled in an interleaved format. (needed by binaural opus)
2193  *
2194  * \param chan channel to change
2195  * \param format format to set for writing
2196  * \return Returns 0 on success, -1 on failure
2197  */
2199 
2200 /*!
2201  * \brief Sends text to a channel
2202  *
2203  * \param chan channel to act upon
2204  * \param text string of text to send on the channel
2205  *
2206  * \details
2207  * Write text to a display on a channel
2208  *
2209  * \note The channel does not need to be locked before calling this function.
2210  *
2211  * \retval 0 on success
2212  * \retval -1 on failure
2213  */
2214 int ast_sendtext(struct ast_channel *chan, const char *text);
2215 
2216 /*!
2217  * \brief Sends text to a channel in an ast_msg_data structure wrapper with ast_sendtext as fallback
2218  * \since 13.22.0
2219  * \since 15.5.0
2220  *
2221  * \param chan channel to act upon
2222  * \param msg ast_msg_data structure
2223  *
2224  * \details
2225  * Write text to a display on a channel. If the channel driver doesn't support the
2226  * send_text_data callback. then the original send_text callback will be used if
2227  * available.
2228  *
2229  * \note The channel does not need to be locked before calling this function.
2230  *
2231  * \retval 0 on success
2232  * \retval -1 on failure
2233  */
2234 int ast_sendtext_data(struct ast_channel *chan, struct ast_msg_data *msg);
2235 
2236 /*!
2237  * \brief Receives a text character from a channel
2238  * \param chan channel to act upon
2239  * \param timeout timeout in milliseconds (0 for infinite wait)
2240  * \details
2241  * Read a char of text from a channel
2242  * \return 0 on success, -1 on failure
2243  */
2244 int ast_recvchar(struct ast_channel *chan, int timeout);
2245 
2246 /*!
2247  * \brief Send a DTMF digit to a channel.
2248  *
2249  * \param chan channel to act upon
2250  * \param digit the DTMF digit to send, encoded in ASCII
2251  * \param duration the duration of the digit ending in ms
2252  *
2253  * \pre This must only be called by the channel's media handler thread.
2254  *
2255  * \return 0 on success, -1 on failure
2256  */
2257 int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration);
2258 
2259 /*!
2260  * \brief Send a DTMF digit to a channel from an external thread.
2261  *
2262  * \param chan channel to act upon
2263  * \param digit the DTMF digit to send, encoded in ASCII
2264  * \param duration the duration of the digit ending in ms
2265  *
2266  * \pre This must only be called by threads that are not the channel's
2267  * media handler thread.
2268  *
2269  * \return 0 on success, -1 on failure
2270  */
2271 int ast_senddigit_external(struct ast_channel *chan, char digit, unsigned int duration);
2272 
2273 /*!
2274  * \brief Send a DTMF digit to a channel.
2275  * \param chan channel to act upon
2276  * \param digit the DTMF digit to send, encoded in ASCII
2277  * \return 0 on success, -1 on failure
2278  */
2279 int ast_senddigit_begin(struct ast_channel *chan, char digit);
2280 
2281 /*!
2282  * \brief Send a DTMF digit to a channel.
2283  * \param chan channel to act upon
2284  * \param digit the DTMF digit to send, encoded in ASCII
2285  * \param duration the duration of the digit ending in ms
2286  * \return Returns 0 on success, -1 on failure
2287  */
2288 int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration);
2289 
2290 /*!
2291  * \brief Receives a text string from a channel
2292  * Read a string of text from a channel
2293  * \param chan channel to act upon
2294  * \param timeout timeout in milliseconds (0 for infinite wait)
2295  * \return the received text, or NULL to signify failure.
2296  */
2297 char *ast_recvtext(struct ast_channel *chan, int timeout);
2298 
2299 /*!
2300  * \brief Waits for a digit
2301  * \param c channel to wait for a digit on
2302  * \param ms how many milliseconds to wait (<0 for indefinite).
2303  * \return Returns <0 on error, 0 on no entry, and the digit on success.
2304  */
2305 int ast_waitfordigit(struct ast_channel *c, int ms);
2306 
2307 /*!
2308  * \brief Wait for a digit
2309  * Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to monitor for reading.
2310  * \param c channel to wait for a digit on
2311  * \param ms how many milliseconds to wait (<0 for indefinite).
2312  * \param breakon string of DTMF digits to break upon or NULL for any.
2313  * \param audiofd audio file descriptor to write to if audio frames are received
2314  * \param ctrlfd control file descriptor to monitor for reading
2315  * \return Returns 1 if ctrlfd becomes available
2316  */
2317 int ast_waitfordigit_full(struct ast_channel *c, int ms, const char *breakon, int audiofd, int ctrlfd);
2318 
2319 /*!
2320  * \brief Reads multiple digits
2321  * \param c channel to read from
2322  * \param s string to read in to. Must be at least the size of your length
2323  * \param len how many digits to read (maximum)
2324  * \param timeout how long to timeout between digits
2325  * \param rtimeout timeout to wait on the first digit
2326  * \param enders digits to end the string
2327  * \details
2328  * Read in a digit string "s", max length "len", maximum timeout between
2329  * digits "timeout" (-1 for none), terminated by anything in "enders". Give them rtimeout
2330  * for the first digit.
2331  * \return Returns 0 on normal return, or 1 on a timeout. In the case of
2332  * a timeout, any digits that were read before the timeout will still be available in s.
2333  * RETURNS 2 in full version when ctrlfd is available, NOT 1
2334  */
2335 int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders);
2336 int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders, int audiofd, int ctrlfd);
2337 
2338 /*! \brief Report DTMF on channel 0 */
2339 #define AST_BRIDGE_DTMF_CHANNEL_0 (1 << 0)
2340 /*! \brief Report DTMF on channel 1 */
2341 #define AST_BRIDGE_DTMF_CHANNEL_1 (1 << 1)
2342 
2343 
2344 /*!
2345  * \brief Make the frame formats of two channels compatible.
2346  *
2347  * \param chan First channel to make compatible. Should be the calling party.
2348  * \param peer Other channel to make compatible. Should be the called party.
2349  *
2350  * \note Absolutely _NO_ channel locks should be held before calling this function.
2351  *
2352  * \details
2353  * Set two channels to compatible frame formats in both
2354  * directions. The path from peer to chan is made compatible
2355  * first to allow for in-band audio in case the other direction
2356  * cannot be made compatible.
2357  *
2358  * \retval 0 on success.
2359  * \retval -1 on error.
2360  */
2361 int ast_channel_make_compatible(struct ast_channel *chan, struct ast_channel *peer);
2362 
2363 /*!
2364  * \brief Bridge two channels together (early)
2365  * \param c0 first channel to bridge
2366  * \param c1 second channel to bridge
2367  * \details
2368  * Bridge two channels (c0 and c1) together early. This implies either side may not be answered yet.
2369  * \return Returns 0 on success and -1 if it could not be done
2370  */
2371 int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1);
2372 
2373 /*!
2374  * \brief Gives the string form of a given cause code.
2375  *
2376  * \param state cause to get the description of
2377  * \return the text form of the binary cause code given
2378  */
2379 const char *ast_cause2str(int state) attribute_pure;
2380 
2381 /*!
2382  * \brief Convert the string form of a cause code to a number
2383  *
2384  * \param name string form of the cause
2385  * \return the cause code
2386  */
2387 int ast_str2cause(const char *name) attribute_pure;
2388 
2389 /*!
2390  * \brief Gives the string form of a given channel state
2391  *
2392  * \param ast_channel_state state to get the name of
2393  * \return the text form of the binary state given
2394  */
2395 const char *ast_state2str(enum ast_channel_state);
2396 
2397 /*!
2398  * \brief Gives the string form of a given transfer capability
2399  *
2400  * \param transfercapability transfer capability to get the name of
2401  * \return the text form of the binary transfer capability
2402  */
2403 char *ast_transfercapability2str(int transfercapability) attribute_const;
2404 
2405 /*
2406  * Options: Some low-level drivers may implement "options" allowing fine tuning of the
2407  * low level channel. See frame.h for options. Note that many channel drivers may support
2408  * none or a subset of those features, and you should not count on this if you want your
2409  * asterisk application to be portable. They're mainly useful for tweaking performance
2410  */
2411 
2412 /*!
2413  * \brief Sets an option on a channel
2414  *
2415  * \param channel channel to set options on
2416  * \param option option to change
2417  * \param data data specific to option
2418  * \param datalen length of the data
2419  * \param block blocking or not
2420  * \details
2421  * Set an option on a channel (see frame.h), optionally blocking awaiting the reply
2422  * \return 0 on success and -1 on failure
2423  */
2424 int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block);
2425 
2426 /*!
2427  * \brief Checks the value of an option
2428  *
2429  * Query the value of an option
2430  * Works similarly to setoption except only reads the options.
2431  */
2432 int ast_channel_queryoption(struct ast_channel *channel, int option, void *data, int *datalen, int block);
2433 
2434 /*!
2435  * \brief Checks for HTML support on a channel
2436  * \return 0 if channel does not support HTML or non-zero if it does
2437  */
2439 
2440 /*!
2441  * \brief Sends HTML on given channel
2442  * Send HTML or URL on link.
2443  * \return 0 on success or -1 on failure
2444  */
2445 int ast_channel_sendhtml(struct ast_channel *channel, int subclass, const char *data, int datalen);
2446 
2447 /*!
2448  * \brief Sends a URL on a given link
2449  * Send URL on link.
2450  * \return 0 on success or -1 on failure
2451  */
2452 int ast_channel_sendurl(struct ast_channel *channel, const char *url);
2453 
2454 /*!
2455  * \brief Defers DTMF so that you only read things like hangups and audio.
2456  * \return non-zero if channel was already DTMF-deferred or
2457  * 0 if channel is just now being DTMF-deferred
2458  */
2459 int ast_channel_defer_dtmf(struct ast_channel *chan);
2460 
2461 /*! Undo defer. ast_read will return any DTMF characters that were queued */
2462 void ast_channel_undefer_dtmf(struct ast_channel *chan);
2463 
2464 /*! \return number of channels available for lookup */
2465 int ast_active_channels(void);
2466 
2467 /*! \return the number of channels not yet destroyed */
2468 int ast_undestroyed_channels(void);
2469 
2470 /*! Activate a given generator */
2471 int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params);
2472 
2473 /*! Deactivate an active generator */
2474 void ast_deactivate_generator(struct ast_channel *chan);
2475 
2476 /*!
2477  * \since 13.27.0
2478  * \since 16.4.0
2479  * \brief Obtain how long it's been, in milliseconds, since the channel was created
2480  *
2481  * \param chan The channel object
2482  *
2483  * \retval 0 if the time value cannot be computed (or you called this really fast)
2484  * \retval The number of milliseconds since channel creation
2485  */
2486 int64_t ast_channel_get_duration_ms(struct ast_channel *chan);
2487 
2488 /*!
2489  * \since 12
2490  * \brief Obtain how long the channel since the channel was created
2491  *
2492  * \param chan The channel object
2493  *
2494  * \retval 0 if the time value cannot be computed (or you called this really fast)
2495  * \retval The number of seconds the channel has been up
2496  */
2497 int ast_channel_get_duration(struct ast_channel *chan);
2498 
2499 /*!
2500  * \since 13.27.0
2501  * \since 16.4.0
2502  * \brief Obtain how long it has been since the channel was answered in ms
2503  *
2504  * \param chan The channel object
2505  *
2506  * \retval 0 if the channel isn't answered (or you called this really fast)
2507  * \retval The number of milliseconds the channel has been up
2508  */
2509 int64_t ast_channel_get_up_time_ms(struct ast_channel *chan);
2510 
2511 /*!
2512  * \since 12
2513  * \brief Obtain how long it has been since the channel was answered
2514  *
2515  * \param chan The channel object
2516  *
2517  * \retval 0 if the channel isn't answered (or you called this really fast)
2518  * \retval The number of seconds the channel has been up
2519  */
2520 int ast_channel_get_up_time(struct ast_channel *chan);
2521 
2522 /*!
2523  * \brief Set caller ID number, name and ANI and generate AMI event.
2524  *
2525  * \note Use ast_channel_set_caller() and ast_channel_set_caller_event() instead.
2526  * \note The channel does not need to be locked before calling this function.
2527  */
2528 void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani);
2529 
2530 /*!
2531  * \brief Set the caller id information in the Asterisk channel
2532  * \since 1.8
2533  *
2534  * \param chan Asterisk channel to set caller id information
2535  * \param caller Caller id information
2536  * \param update What caller information to update. NULL if all.
2537  *
2538  * \return Nothing
2539  *
2540  * \note The channel does not need to be locked before calling this function.
2541  */
2542 void ast_channel_set_caller(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update);
2543 
2544 /*!
2545  * \brief Set the caller id information in the Asterisk channel and generate an AMI event
2546  * if the caller id name or number changed.
2547  * \since 1.8
2548  *
2549  * \param chan Asterisk channel to set caller id information
2550  * \param caller Caller id information
2551  * \param update What caller information to update. NULL if all.
2552  *
2553  * \return Nothing
2554  *
2555  * \note The channel does not need to be locked before calling this function.
2556  */
2557 void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update);
2558 
2559 /*! Set the file descriptor on the channel */
2560 void ast_channel_set_fd(struct ast_channel *chan, int which, int fd);
2561 
2562 /*! Start a tone going */
2563 int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);
2564 /*! Stop a tone from playing */
2565 void ast_tonepair_stop(struct ast_channel *chan);
2566 /*! Play a tone pair for a given amount of time */
2567 int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);
2568 
2569 /*!
2570  * \brief Automatically service a channel for us...
2571  *
2572  * \retval 0 success
2573  * \retval -1 failure, or the channel is already being autoserviced
2574  */
2575 int ast_autoservice_start(struct ast_channel *chan);
2576 
2577 /*!
2578  * \brief Stop servicing a channel for us...
2579  *
2580  * \note if chan is locked prior to calling ast_autoservice_stop, it
2581  * is likely that there will be a deadlock between the thread that calls
2582  * ast_autoservice_stop and the autoservice thread. It is important
2583  * that chan is not locked prior to this call
2584  *
2585  * \param chan
2586  * \retval 0 success
2587  * \retval -1 error, or the channel has been hungup
2588  */
2589 int ast_autoservice_stop(struct ast_channel *chan);
2590 
2591 /*!
2592  * \brief Put chan into autoservice while hanging up peer.
2593  * \since 11.0
2594  *
2595  * \param chan Chan to put into autoservice.
2596  * \param peer Chan to run hangup handlers and hangup.
2597  *
2598  * \return Nothing
2599  */
2600 void ast_autoservice_chan_hangup_peer(struct ast_channel *chan, struct ast_channel *peer);
2601 
2602 /*!
2603  * \brief Ignore certain frame types
2604  * \note Normally, we cache DTMF, IMAGE, HTML, TEXT, and CONTROL frames
2605  * while a channel is in autoservice and queue them up when taken out of
2606  * autoservice. When this is not desireable, this API may be used to
2607  * cause the channel to ignore those frametypes after the channel is put
2608  * into autoservice, but before autoservice is stopped.
2609  * \retval 0 success
2610  * \retval -1 channel is not in autoservice
2611  */
2612 int ast_autoservice_ignore(struct ast_channel *chan, enum ast_frame_type ftype);
2613 
2614 /*!
2615  * \brief Enable or disable timer ticks for a channel
2616  *
2617  * \param c channel
2618  * \param rate number of timer ticks per second
2619  * \param func callback function
2620  * \param data
2621  *
2622  * \details
2623  * If timers are supported, force a scheduled expiration on the
2624  * timer fd, at which point we call the callback function / data
2625  *
2626  * \note Call this function with a rate of 0 to turn off the timer ticks
2627  *
2628  * \version 1.6.1 changed samples parameter to rate, accomodates new timing methods
2629  */
2630 int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const void *data), void *data);
2631 int ast_settimeout_full(struct ast_channel *c, unsigned int rate, int (*func)(const void *data), void *data, unsigned int is_ao2_obj);
2632 
2633 /*!
2634  * \brief Transfer a channel (if supported).
2635  * \retval -1 on error
2636  * \retval 0 if not supported
2637  * \retval 1 if supported and requested
2638  * \param chan current channel
2639  * \param dest destination extension for transfer
2640  */
2641 int ast_transfer(struct ast_channel *chan, char *dest);
2642 
2643 /*!
2644  * \brief Inherits channel variable from parent to child channel
2645  * \param parent Parent channel
2646  * \param child Child channel
2647  *
2648  * \details
2649  * Scans all channel variables in the parent channel, looking for those
2650  * that should be copied into the child channel.
2651  * Variables whose names begin with a single '_' are copied into the
2652  * child channel with the prefix removed.
2653  * Variables whose names begin with '__' are copied into the child
2654  * channel with their names unchanged.
2655  */
2656 void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child);
2657 
2658 /*!
2659  * \brief adds a list of channel variables to a channel
2660  * \param chan the channel
2661  * \param vars a linked list of variables
2662  *
2663  * \pre chan is locked
2664  *
2665  * \details
2666  * Variable names can be for a regular channel variable or a dialplan function
2667  * that has the ability to be written to.
2668  */
2669 void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars);
2670 
2671 /*!
2672  * \brief An opaque 'object' structure use by silence generators on channels.
2673  */
2674 struct ast_silence_generator;
2675 
2676 /*!
2677  * \brief Starts a silence generator on the given channel.
2678  * \param chan The channel to generate silence on
2679  * \return An ast_silence_generator pointer, or NULL if an error occurs
2680  *
2681  * \details
2682  * This function will cause SLINEAR silence to be generated on the supplied
2683  * channel until it is disabled; if the channel cannot be put into SLINEAR
2684  * mode then the function will fail.
2685  *
2686  * \note
2687  * The pointer returned by this function must be preserved and passed to
2688  * ast_channel_stop_silence_generator when you wish to stop the silence
2689  * generation.
2690  */
2692 
2693 /*!
2694  * \brief Stops a previously-started silence generator on the given channel.
2695  * \param chan The channel to operate on
2696  * \param state The ast_silence_generator pointer return by a previous call to
2697  * ast_channel_start_silence_generator.
2698  * \return nothing
2699  *
2700  * \details
2701  * This function will stop the operating silence generator and return the channel
2702  * to its previous write format.
2703  */
2704 void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state);
2705 
2706 /*!
2707  * \brief Determine which channel has an older linkedid
2708  * \param a First channel
2709  * \param b Second channel
2710  * \return Returns an ast_channel structure that has oldest linkedid
2711  */
2713 
2714 /*!
2715  * \brief Copy the full linkedid channel id structure from one channel to another
2716  * \param dest Destination to copy linkedid to
2717  * \param source Source channel to copy linkedid from
2718  * \return void
2719  */
2720 void ast_channel_internal_copy_linkedid(struct ast_channel *dest, struct ast_channel *source);
2721 
2722 /*!
2723  * \brief Swap uniqueid and linkedid beteween two channels
2724  * \param a First channel
2725  * \param b Second channel
2726  * \return void
2727  *
2728  * \note
2729  * This is used in masquerade to exchange identities
2730  */
2732 
2733 /*!
2734  * \brief Swap topics beteween two channels
2735  * \param a First channel
2736  * \param b Second channel
2737  * \return void
2738  *
2739  * \note
2740  * This is used in masquerade to exchange topics for message routing
2741  */
2743 
2744 /*!
2745  * \brief Swap endpoint_forward between two channels
2746  * \param a First channel
2747  * \param b Second channel
2748  * \return void
2749  *
2750  * \note
2751  * This is used in masquerade to exchange endpoint details if one of the two or both
2752  * the channels were created with endpoint
2753  */
2755 
2756 /*!
2757  * \brief Swap snapshots beteween two channels
2758  * \param a First channel
2759  * \param b Second channel
2760  * \return void
2761  *
2762  * \note
2763  * This is used in masquerade to exchange snapshots
2764  */
2766 
2767 /*!
2768  * \brief Set uniqueid and linkedid string value only (not time)
2769  * \param chan The channel to set the uniqueid to
2770  * \param uniqueid The uniqueid to set
2771  * \param linkedid The linkedid to set
2772  * \return void
2773  *
2774  * \note
2775  * This is used only by ast_cel_fabricate_channel_from_event()
2776  * to create a temporary fake channel - time values are invalid
2777  */
2778 void ast_channel_internal_set_fake_ids(struct ast_channel *chan, const char *uniqueid, const char *linkedid);
2779 
2780 /* Misc. functions below */
2781 
2782 /*!
2783  * \brief if fd is a valid descriptor, set *pfd with the descriptor
2784  * \return Return 1 (not -1!) if added, 0 otherwise (so we can add the
2785  * return value to the index into the array)
2786  */
2787 static inline int ast_add_fd(struct pollfd *pfd, int fd)
2788 {
2789  pfd->fd = fd;
2790  pfd->events = POLLIN | POLLPRI;
2791  return fd >= 0;
2792 }
2793 
2794 /*! \brief Helper function for migrating select to poll */
2795 static inline int ast_fdisset(struct pollfd *pfds, int fd, int maximum, int *start)
2796 {
2797  int x;
2798  int dummy = 0;
2799 
2800  if (fd < 0)
2801  return 0;
2802  if (!start)
2803  start = &dummy;
2804  for (x = *start; x < maximum; x++)
2805  if (pfds[x].fd == fd) {
2806  if (x == *start)
2807  (*start)++;
2808  return pfds[x].revents;
2809  }
2810  return 0;
2811 }
2812 
2813 /*!
2814  * \brief Retrieves the current T38 state of a channel
2815  *
2816  * \note Absolutely _NO_ channel locks should be held before calling this function.
2817  */
2818 static inline enum ast_t38_state ast_channel_get_t38_state(struct ast_channel *chan)
2819 {
2820  enum ast_t38_state state = T38_STATE_UNAVAILABLE;
2821  int datalen = sizeof(state);
2822 
2823  ast_channel_queryoption(chan, AST_OPTION_T38_STATE, &state, &datalen, 0);
2824 
2825  return state;
2826 }
2827 
2828 /*!
2829  * \brief Set the blocking indication on the channel.
2830  *
2831  * \details
2832  * Indicate that the thread handling the channel is about to do a blocking
2833  * operation to wait for media on the channel. (poll, read, or write)
2834  *
2835  * Masquerading and ast_queue_frame() use this indication to wake up the thread.
2836  *
2837  * \pre The channel needs to be locked
2838  */
2839 #define CHECK_BLOCKING(c) \
2840  do { \
2841  if (ast_test_flag(ast_channel_flags(c), AST_FLAG_BLOCKING)) { \
2842  /* This should not happen as there should only be one thread handling a channel's media at a time. */ \
2843  ast_log(LOG_DEBUG, "Thread LWP %d is blocking '%s', already blocked by thread LWP %d in procedure %s\n", \
2844  ast_get_tid(), ast_channel_name(c), \
2845  ast_channel_blocker_tid(c), ast_channel_blockproc(c)); \
2846  ast_assert(0); \
2847  } \
2848  ast_channel_blocker_tid_set((c), ast_get_tid()); \
2849  ast_channel_blocker_set((c), pthread_self()); \
2850  ast_channel_blockproc_set((c), __PRETTY_FUNCTION__); \
2851  ast_set_flag(ast_channel_flags(c), AST_FLAG_BLOCKING); \
2852  } while (0)
2853 
2854 ast_group_t ast_get_group(const char *s);
2855 
2856 /*! \brief Print call and pickup groups into buffer */
2857 char *ast_print_group(char *buf, int buflen, ast_group_t group);
2858 
2859 /*! \brief Opaque struct holding a namedgroups set, i.e. a set of group names */
2860 struct ast_namedgroups;
2861 
2862 /*! \brief Create an ast_namedgroups set with group names from comma separated string */
2863 struct ast_namedgroups *ast_get_namedgroups(const char *s);
2864 struct ast_namedgroups *ast_unref_namedgroups(struct ast_namedgroups *groups);
2865 struct ast_namedgroups *ast_ref_namedgroups(struct ast_namedgroups *groups);
2866 /*! \brief Return TRUE if group a and b contain at least one common groupname */
2867 int ast_namedgroups_intersect(struct ast_namedgroups *a, struct ast_namedgroups *b);
2868 
2869 /*! \brief Print named call groups and named pickup groups */
2870 char *ast_print_namedgroups(struct ast_str **buf, struct ast_namedgroups *groups);
2871 
2872 /*! \brief return an ast_variable list of channeltypes */
2873 struct ast_variable *ast_channeltype_list(void);
2874 
2875 /*!
2876  * \brief return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument
2877  * \param reason The integer argument, usually taken from AST_CONTROL_ macros
2878  * \return char pointer explaining the code
2879  */
2880 const char *ast_channel_reason2str(int reason);
2881 
2882 /*! \brief channel group info */
2885  char *category;
2886  char *group;
2888 };
2889 
2890 #define ast_channel_lock(chan) ao2_lock(chan)
2891 #define ast_channel_unlock(chan) ao2_unlock(chan)
2892 #define ast_channel_trylock(chan) ao2_trylock(chan)
2893 
2894 /*!
2895  * \brief Lock two channels.
2896  */
2897 #define ast_channel_lock_both(chan1, chan2) do { \
2898  ast_channel_lock(chan1); \
2899  while (ast_channel_trylock(chan2)) { \
2900  ast_channel_unlock(chan1); \
2901  sched_yield(); \
2902  ast_channel_lock(chan1); \
2903  } \
2904  } while (0)
2905 
2906 /*!
2907  * \brief Increase channel reference count
2908  *
2909  * \param c the channel
2910  *
2911  * \retval c always
2912  *
2913  * \since 1.8
2914  */
2915 #define ast_channel_ref(c) ({ ao2_ref(c, +1); (c); })
2916 
2917 /*!
2918  * \brief Decrease channel reference count
2919  *
2920  * \param c the channel
2921  *
2922  * \retval NULL always
2923  *
2924  * \since 1.8
2925  */
2926 #define ast_channel_unref(c) ({ ao2_ref(c, -1); (struct ast_channel *) (NULL); })
2927 
2928 /*!
2929  * \brief Cleanup a channel reference
2930  *
2931  * \param c the channel (NULL tolerant)
2932  *
2933  * \retval NULL always
2934  *
2935  * \since 12.0.0
2936  */
2937 #define ast_channel_cleanup(c) ({ ao2_cleanup(c); (struct ast_channel *) (NULL); })
2938 
2939 /*! Channel Iterating @{ */
2940 
2941 /*!
2942  * \brief A channel iterator
2943  *
2944  * This is an opaque type.
2945  */
2946 struct ast_channel_iterator;
2947 
2948 /*!
2949  * \brief Destroy a channel iterator
2950  *
2951  * \param i the itereator to destroy
2952  *
2953  * \details
2954  * This function is used to destroy a channel iterator that was retrieved by
2955  * using one of the channel_iterator_xxx_new() functions.
2956  *
2957  * \return NULL, for convenience to clear out the pointer to the iterator that
2958  * was just destroyed.
2959  *
2960  * \since 1.8
2961  */
2963 
2964 /*!
2965  * \brief Create a new channel iterator based on extension
2966  *
2967  * \param exten The extension that channels must be in
2968  * \param context The context that channels must be in
2969  *
2970  * \details
2971  * After creating an iterator using this function, the ast_channel_iterator_next()
2972  * function can be used to iterate through all channels that are currently
2973  * in the specified context and extension.
2974  *
2975  * \note You must call ast_channel_iterator_destroy() when done.
2976  *
2977  * \retval NULL on failure
2978  * \retval a new channel iterator based on the specified parameters
2979  *
2980  * \since 1.8
2981  */
2982 struct ast_channel_iterator *ast_channel_iterator_by_exten_new(const char *exten, const char *context);
2983 
2984 /*!
2985  * \brief Create a new channel iterator based on name
2986  *
2987  * \param name channel name or channel uniqueid to match
2988  * \param name_len number of characters in the channel name to match on. This
2989  * would be used to match based on name prefix. If matching on the full
2990  * channel name is desired, then this parameter should be 0.
2991  *
2992  * \details
2993  * After creating an iterator using this function, the ast_channel_iterator_next()
2994  * function can be used to iterate through all channels that exist that have
2995  * the specified name or name prefix.
2996  *
2997  * \note You must call ast_channel_iterator_destroy() when done.
2998  *
2999  * \retval NULL on failure
3000  * \retval a new channel iterator based on the specified parameters
3001  *
3002  * \since 1.8
3003  */
3004 struct ast_channel_iterator *ast_channel_iterator_by_name_new(const char *name, size_t name_len);
3005 
3006 /*!
3007  * \brief Create a new channel iterator
3008  *
3009  * \details
3010  * After creating an iterator using this function, the ast_channel_iterator_next()
3011  * function can be used to iterate through all channels that exist.
3012  *
3013  * \note You must call ast_channel_iterator_destroy() when done.
3014  *
3015  * \retval NULL on failure
3016  * \retval a new channel iterator
3017  *
3018  * \since 1.8
3019  */
3021 
3022 /*!
3023  * \brief Get the next channel for a channel iterator
3024  *
3025  * \param i the channel iterator that was created using one of the
3026  * channel_iterator_xxx_new() functions.
3027  *
3028  * \details
3029  * This function should be used to iterate through all channels that match a
3030  * specified set of parameters that were provided when the iterator was created.
3031  *
3032  * \retval the next channel that matches the parameters used when the iterator
3033  * was created.
3034  * \retval NULL, if no more channels match the iterator parameters.
3035  *
3036  * \since 1.8
3037  */
3039 
3040 /*! @} End channel iterator definitions. */
3041 
3042 /*!
3043  * \brief Call a function with every active channel
3044  *
3045  * \details
3046  * This function executes a callback one time for each active channel on the
3047  * system. The channel is provided as an argument to the function.
3048  *
3049  * \note Absolutely _NO_ channel locks should be held before calling this function.
3050  * \since 1.8
3051  */
3052 struct ast_channel *ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg,
3053  void *data, int ao2_flags);
3054 
3055 /*! @{ Channel search functions */
3056 
3057 /*!
3058  * \brief Find a channel by name
3059  *
3060  * \param name the name or uniqueid of the channel to search for
3061  *
3062  * \details
3063  * Find a channel that has the same name as the provided argument.
3064  *
3065  * \retval a channel with the name specified by the argument
3066  * \retval NULL if no channel was found
3067  *
3068  * \since 1.8
3069  */
3070 struct ast_channel *ast_channel_get_by_name(const char *name);
3071 
3072 /*!
3073  * \brief Find a channel by a name prefix
3074  *
3075  * \param name The channel name or uniqueid prefix to search for
3076  * \param name_len Only search for up to this many characters from the name
3077  *
3078  * \details
3079  * Find a channel that has the same name prefix as specified by the arguments.
3080  *
3081  * \retval a channel with the name prefix specified by the arguments
3082  * \retval NULL if no channel was found
3083  *
3084  * \since 1.8
3085  */
3086 struct ast_channel *ast_channel_get_by_name_prefix(const char *name, size_t name_len);
3087 
3088 /*!
3089  * \brief Find a channel by extension and context
3090  *
3091  * \param exten the extension to search for
3092  * \param context the context to search for
3093  *
3094  * \details
3095  * Return a channel that is currently at the specified extension and context.
3096  *
3097  * \retval a channel that is at the specified extension and context
3098  * \retval NULL if no channel was found
3099  *
3100  * \since 1.8
3101  */
3102 struct ast_channel *ast_channel_get_by_exten(const char *exten, const char *context);
3103 
3104 /*! @} End channel search functions. */
3105 
3106 /*!
3107  * \brief Initialize the given name structure.
3108  * \since 1.8
3109  *
3110  * \param init Name structure to initialize.
3111  *
3112  * \return Nothing
3113  */
3114 void ast_party_name_init(struct ast_party_name *init);
3115 
3116 /*!
3117  * \brief Copy the source party name information to the destination party name.
3118  * \since 1.8
3119  *
3120  * \param dest Destination party name
3121  * \param src Source party name
3122  *
3123  * \return Nothing
3124  */
3125 void ast_party_name_copy(struct ast_party_name *dest, const struct ast_party_name *src);
3126 
3127 /*!
3128  * \brief Initialize the given party name structure using the given guide
3129  * for a set update operation.
3130  * \since 1.8
3131  *
3132  * \details
3133  * The initialization is needed to allow a set operation to know if a
3134  * value needs to be updated. Simple integers need the guide's original
3135  * value in case the set operation is not trying to set a new value.
3136  * String values are simply set to NULL pointers if they are not going
3137  * to be updated.
3138  *
3139  * \param init Party name structure to initialize.
3140  * \param guide Source party name to use as a guide in initializing.
3141  *
3142  * \return Nothing
3143  */
3144 void ast_party_name_set_init(struct ast_party_name *init, const struct ast_party_name *guide);
3145 
3146 /*!
3147  * \brief Set the source party name information into the destination party name.
3148  * \since 1.8
3149  *
3150  * \param dest The name one wishes to update
3151  * \param src The new name values to update the dest
3152  *
3153  * \return Nothing
3154  */
3155 void ast_party_name_set(struct ast_party_name *dest, const struct ast_party_name *src);
3156 
3157 /*!
3158  * \brief Destroy the party name contents
3159  * \since 1.8
3160  *
3161  * \param doomed The party name to destroy.
3162  *
3163  * \return Nothing
3164  */
3165 void ast_party_name_free(struct ast_party_name *doomed);
3166 
3167 /*!
3168  * \brief Initialize the given number structure.
3169  * \since 1.8
3170  *
3171  * \param init Number structure to initialize.
3172  *
3173  * \return Nothing
3174  */
3175 void ast_party_number_init(struct ast_party_number *init);
3176 
3177 /*!
3178  * \brief Copy the source party number information to the destination party number.
3179  * \since 1.8
3180  *
3181  * \param dest Destination party number
3182  * \param src Source party number
3183  *
3184  * \return Nothing
3185  */
3186 void ast_party_number_copy(struct ast_party_number *dest, const struct ast_party_number *src);
3187 
3188 /*!
3189  * \brief Initialize the given party number structure using the given guide
3190  * for a set update operation.
3191  * \since 1.8
3192  *
3193  * \details
3194  * The initialization is needed to allow a set operation to know if a
3195  * value needs to be updated. Simple integers need the guide's original
3196  * value in case the set operation is not trying to set a new value.
3197  * String values are simply set to NULL pointers if they are not going
3198  * to be updated.
3199  *
3200  * \param init Party number structure to initialize.
3201  * \param guide Source party number to use as a guide in initializing.
3202  *
3203  * \return Nothing
3204  */
3205 void ast_party_number_set_init(struct ast_party_number *init, const struct ast_party_number *guide);
3206 
3207 /*!
3208  * \brief Set the source party number information into the destination party number.
3209  * \since 1.8
3210  *
3211  * \param dest The number one wishes to update
3212  * \param src The new number values to update the dest
3213  *
3214  * \return Nothing
3215  */
3216 void ast_party_number_set(struct ast_party_number *dest, const struct ast_party_number *src);
3217 
3218 /*!
3219  * \brief Destroy the party number contents
3220  * \since 1.8
3221  *
3222  * \param doomed The party number to destroy.
3223  *
3224  * \return Nothing
3225  */
3226 void ast_party_number_free(struct ast_party_number *doomed);
3227 
3228 /*!
3229  * \since 1.8
3230  * \brief Initialize the given subaddress structure.
3231  *
3232  * \param init Subaddress structure to initialize.
3233  *
3234  * \return Nothing
3235  */
3237 
3238 /*!
3239  * \since 1.8
3240  * \brief Copy the source party subaddress information to the destination party subaddress.
3241  *
3242  * \param dest Destination party subaddress
3243  * \param src Source party subaddress
3244  *
3245  * \return Nothing
3246  */
3247 void ast_party_subaddress_copy(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src);
3248 
3249 /*!
3250  * \since 1.8
3251  * \brief Initialize the given party subaddress structure using the given guide
3252  * for a set update operation.
3253  *
3254  * \details
3255  * The initialization is needed to allow a set operation to know if a
3256  * value needs to be updated. Simple integers need the guide's original
3257  * value in case the set operation is not trying to set a new value.
3258  * String values are simply set to NULL pointers if they are not going
3259  * to be updated.
3260  *
3261  * \param init Party subaddress structure to initialize.
3262  * \param guide Source party subaddress to use as a guide in initializing.
3263  *
3264  * \return Nothing
3265  */
3266 void ast_party_subaddress_set_init(struct ast_party_subaddress *init, const struct ast_party_subaddress *guide);
3267 
3268 /*!
3269  * \since 1.8
3270  * \brief Set the source party subaddress information into the destination party subaddress.
3271  *
3272  * \param dest The subaddress one wishes to update
3273  * \param src The new subaddress values to update the dest
3274  *
3275  * \return Nothing
3276  */
3277 void ast_party_subaddress_set(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src);
3278 
3279 /*!
3280  * \since 1.8
3281  * \brief Destroy the party subaddress contents
3282  *
3283  * \param doomed The party subaddress to destroy.
3284  *
3285  * \return Nothing
3286  */
3287 void ast_party_subaddress_free(struct ast_party_subaddress *doomed);
3288 
3289 /*!
3290  * \brief Set the update marker to update all information of a corresponding party id.
3291  * \since 11.0
3292  *
3293  * \param update_id The update marker for a corresponding party id.
3294  *
3295  * \return Nothing
3296  */
3297 void ast_set_party_id_all(struct ast_set_party_id *update_id);
3298 
3299 /*!
3300  * \brief Initialize the given party id structure.
3301  * \since 1.8
3302  *
3303  * \param init Party id structure to initialize.
3304  *
3305  * \return Nothing
3306  */
3307 void ast_party_id_init(struct ast_party_id *init);
3308 
3309 /*!
3310  * \brief Copy the source party id information to the destination party id.
3311  * \since 1.8
3312  *
3313  * \param dest Destination party id
3314  * \param src Source party id
3315  *
3316  * \return Nothing
3317  */
3318 void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src);
3319 
3320 /*!
3321  * \brief Initialize the given party id structure using the given guide
3322  * for a set update operation.
3323  * \since 1.8
3324  *
3325  * \details
3326  * The initialization is needed to allow a set operation to know if a
3327  * value needs to be updated. Simple integers need the guide's original
3328  * value in case the set operation is not trying to set a new value.
3329  * String values are simply set to NULL pointers if they are not going
3330  * to be updated.
3331  *
3332  * \param init Party id structure to initialize.
3333  * \param guide Source party id to use as a guide in initializing.
3334  *
3335  * \return Nothing
3336  */
3337 void ast_party_id_set_init(struct ast_party_id *init, const struct ast_party_id *guide);
3338 
3339 /*!
3340  * \brief Set the source party id information into the destination party id.
3341  * \since 1.8
3342  *
3343  * \param dest The id one wishes to update
3344  * \param src The new id values to update the dest
3345  * \param update What id information to update. NULL if all.
3346  *
3347  * \return Nothing
3348  */
3349 void ast_party_id_set(struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update);
3350 
3351 /*!
3352  * \brief Destroy the party id contents
3353  * \since 1.8
3354  *
3355  * \param doomed The party id to destroy.
3356  *
3357  * \return Nothing
3358  */
3359 void ast_party_id_free(struct ast_party_id *doomed);
3360 
3361 /*!
3362  * \brief Determine the overall presentation value for the given party.
3363  * \since 1.8
3364  *
3365  * \param id Party to determine the overall presentation value.
3366  *
3367  * \return Overall presentation value for the given party.
3368  */
3369 int ast_party_id_presentation(const struct ast_party_id *id);
3370 
3371 /*!
3372  * \brief Invalidate all components of the given party id.
3373  * \since 11.0
3374  *
3375  * \param id The party id to invalidate.
3376  *
3377  * \return Nothing
3378  */
3379 void ast_party_id_invalidate(struct ast_party_id *id);
3380 
3381 /*!
3382  * \brief Destroy and initialize the given party id structure.
3383  * \since 11.0
3384  *
3385  * \param id The party id to reset.
3386  *
3387  * \return Nothing
3388  */
3389 void ast_party_id_reset(struct ast_party_id *id);
3390 
3391 /*!
3392  * \brief Merge a given party id into another given party id.
3393  * \since 11.0
3394  *
3395  * \details
3396  * This function will generate an effective party id.
3397  *
3398  * Each party id component of the party id 'base' is overwritten
3399  * by components of the party id 'overlay' if the overlay
3400  * component is marked as valid. However the component 'tag' of
3401  * the base party id remains untouched.
3402  *
3403  * \param base The party id which is merged.
3404  * \param overlay The party id which is used to merge into.
3405  *
3406  * \return The merged party id as a struct, not as a pointer.
3407  * \note The merged party id returned is a shallow copy and must not be freed.
3408  */
3409 struct ast_party_id ast_party_id_merge(struct ast_party_id *base, struct ast_party_id *overlay);
3410 
3411 /*!
3412  * \brief Copy a merge of a given party id into another given party id to a given destination party id.
3413  * \since 11.0
3414  *
3415  * \details
3416  * Each party id component of the party id 'base' is overwritten by components
3417  * of the party id 'overlay' if the 'overlay' component is marked as valid.
3418  * However the component 'tag' of the 'base' party id remains untouched.
3419  * The result is copied into the given party id 'dest'.
3420  *
3421  * \note The resulting merged party id is a real copy and has to be freed.
3422  *
3423  * \param dest The resulting merged party id.
3424  * \param base The party id which is merged.
3425  * \param overlay The party id which is used to merge into.
3426  *
3427  * \return Nothing
3428  */
3429 void ast_party_id_merge_copy(struct ast_party_id *dest, struct ast_party_id *base, struct ast_party_id *overlay);
3430 
3431 /*!
3432  * \brief Initialize the given dialed structure.
3433  * \since 1.8
3434  *
3435  * \param init Dialed structure to initialize.
3436  *
3437  * \return Nothing
3438  */
3439 void ast_party_dialed_init(struct ast_party_dialed *init);
3440 
3441 /*!
3442  * \brief Copy the source dialed party information to the destination dialed party.
3443  * \since 1.8
3444  *
3445  * \param dest Destination dialed party
3446  * \param src Source dialed party
3447  *
3448  * \return Nothing
3449  */
3450 void ast_party_dialed_copy(struct ast_party_dialed *dest, const struct ast_party_dialed *src);
3451 
3452 /*!
3453  * \brief Initialize the given dialed structure using the given
3454  * guide for a set update operation.
3455  * \since 1.8
3456  *
3457  * \details
3458  * The initialization is needed to allow a set operation to know if a
3459  * value needs to be updated. Simple integers need the guide's original
3460  * value in case the set operation is not trying to set a new value.
3461  * String values are simply set to NULL pointers if they are not going
3462  * to be updated.
3463  *
3464  * \param init Caller structure to initialize.
3465  * \param guide Source dialed to use as a guide in initializing.
3466  *
3467  * \return Nothing
3468  */
3469 void ast_party_dialed_set_init(struct ast_party_dialed *init, const struct ast_party_dialed *guide);
3470 
3471 /*!
3472  * \brief Set the dialed information based on another dialed source
3473  * \since 1.8
3474  *
3475  * This is similar to ast_party_dialed_copy, except that NULL values for
3476  * strings in the src parameter indicate not to update the corresponding dest values.
3477  *
3478  * \param dest The dialed one wishes to update
3479  * \param src The new dialed values to update the dest
3480  *
3481  * \return Nada
3482  */
3483 void ast_party_dialed_set(struct ast_party_dialed *dest, const struct ast_party_dialed *src);
3484 
3485 /*!
3486  * \brief Destroy the dialed party contents
3487  * \since 1.8
3488  *
3489  * \param doomed The dialed party to destroy.
3490  *
3491  * \return Nothing
3492  */
3493 void ast_party_dialed_free(struct ast_party_dialed *doomed);
3494 
3495 /*!
3496  * \since 1.8
3497  * \brief Initialize the given caller structure.
3498  *
3499  * \param init Caller structure to initialize.
3500  *
3501  * \return Nothing
3502  */
3503 void ast_party_caller_init(struct ast_party_caller *init);
3504 
3505 /*!
3506  * \since 1.8
3507  * \brief Copy the source caller information to the destination caller.
3508  *
3509  * \param dest Destination caller
3510  * \param src Source caller
3511  *
3512  * \return Nothing
3513  */
3514 void ast_party_caller_copy(struct ast_party_caller *dest, const struct ast_party_caller *src);
3515 
3516 /*!
3517  * \brief Initialize the given caller structure using the given
3518  * guide for a set update operation.
3519  * \since 1.8
3520  *
3521  * \details
3522  * The initialization is needed to allow a set operation to know if a
3523  * value needs to be updated. Simple integers need the guide's original
3524  * value in case the set operation is not trying to set a new value.
3525  * String values are simply set to NULL pointers if they are not going
3526  * to be updated.
3527  *
3528  * \param init Caller structure to initialize.
3529  * \param guide Source caller to use as a guide in initializing.
3530  *
3531  * \return Nothing
3532  */
3533 void ast_party_caller_set_init(struct ast_party_caller *init, const struct ast_party_caller *guide);
3534 
3535 /*!
3536  * \brief Set the caller information based on another caller source
3537  * \since 1.8
3538  *
3539  * This is similar to ast_party_caller_copy, except that NULL values for
3540  * strings in the src parameter indicate not to update the corresponding dest values.
3541  *
3542  * \param dest The caller one wishes to update
3543  * \param src The new caller values to update the dest
3544  * \param update What caller information to update. NULL if all.
3545  *
3546  * \return Nada
3547  */
3548 void ast_party_caller_set(struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update);
3549 
3550 /*!
3551  * \brief Destroy the caller party contents
3552  * \since 1.8
3553  *
3554  * \param doomed The caller party to destroy.
3555  *
3556  * \return Nothing
3557  */
3558 void ast_party_caller_free(struct ast_party_caller *doomed);
3559 
3560 /*!
3561  * \since 1.8
3562  * \brief Initialize the given connected line structure.
3563  *
3564  * \param init Connected line structure to initialize.
3565  *
3566  * \return Nothing
3567  */
3569 
3570 /*!
3571  * \since 1.8
3572  * \brief Copy the source connected line information to the destination connected line.
3573  *
3574  * \param dest Destination connected line
3575  * \param src Source connected line
3576  *
3577  * \return Nothing
3578  */
3580 
3581 /*!
3582  * \since 1.8
3583  * \brief Initialize the given connected line structure using the given
3584  * guide for a set update operation.
3585  *
3586  * \details
3587  * The initialization is needed to allow a set operation to know if a
3588  * value needs to be updated. Simple integers need the guide's original
3589  * value in case the set operation is not trying to set a new value.
3590  * String values are simply set to NULL pointers if they are not going
3591  * to be updated.
3592  *
3593  * \param init Connected line structure to initialize.
3594  * \param guide Source connected line to use as a guide in initializing.
3595  *
3596  * \return Nothing
3597  */
3599 
3600 /*!
3601  * \since 1.8
3602  * \brief Set the connected line information based on another connected line source
3603  *
3604  * This is similar to ast_party_connected_line_copy, except that NULL values for
3605  * strings in the src parameter indicate not to update the corresponding dest values.
3606  *
3607  * \param dest The connected line one wishes to update
3608  * \param src The new connected line values to update the dest
3609  * \param update What connected line information to update. NULL if all.
3610  *
3611  * \return Nothing
3612  */
3614 
3615 /*!
3616  * \since 1.8
3617  * \brief Collect the caller party information into a connected line structure.
3618  *
3619  * \param connected Collected caller information for the connected line
3620  * \param caller Caller information.
3621  *
3622  * \return Nothing
3623  *
3624  * \warning This is a shallow copy.
3625  * \warning DO NOT call ast_party_connected_line_free() on the filled in
3626  * connected line structure!
3627  */
3629 
3630 /*!
3631  * \since 1.8
3632  * \brief Destroy the connected line information contents
3633  *
3634  * \param doomed The connected line information to destroy.
3635  *
3636  * \return Nothing
3637  */
3639 
3640 /*!
3641  * \brief Initialize the given redirecting reason structure
3642  *
3643  * \param init Redirecting reason structure to initialize
3644  *
3645  * \return Nothing
3646  */
3648 
3649 /*!
3650  * \brief Copy the source redirecting reason information to the destination redirecting reason.
3651  *
3652  * \param dest Destination redirecting reason
3653  * \param src Source redirecting reason
3654  *
3655  * \return Nothing
3656  */
3658  const struct ast_party_redirecting_reason *src);
3659 
3660 /*!
3661  * \brief Initialize the given redirecting reason structure using the given guide
3662  * for a set update operation.
3663  *
3664  * \details
3665  * The initialization is needed to allow a set operation to know if a
3666  * value needs to be updated. Simple integers need the guide's original
3667  * value in case the set operation is not trying to set a new value.
3668  * String values are simply set to NULL pointers if they are not going
3669  * to be updated.
3670  *
3671  * \param init Redirecting reason structure to initialize.
3672  * \param guide Source redirecting reason to use as a guide in initializing.
3673  *
3674  * \return Nothing
3675  */
3677  const struct ast_party_redirecting_reason *guide);
3678 
3679 /*!
3680  * \brief Set the redirecting reason information based on another redirecting reason source
3681  *
3682  * This is similar to ast_party_redirecting_reason_copy, except that NULL values for
3683  * strings in the src parameter indicate not to update the corresponding dest values.
3684  *
3685  * \param dest The redirecting reason one wishes to update
3686  * \param src The new redirecting reason values to update the dest
3687  *
3688  * \return Nothing
3689  */
3691  const struct ast_party_redirecting_reason *src);
3692 
3693 /*!
3694  * \brief Destroy the redirecting reason contents
3695  *
3696  * \param doomed The redirecting reason to destroy.
3697  *
3698  * \return Nothing
3699  */
3701 
3702 /*!
3703  * \brief Initialize the given redirecting structure.
3704  * \since 1.8
3705  *
3706  * \param init Redirecting structure to initialize.
3707  *
3708  * \return Nothing
3709  */
3711 
3712 /*!
3713  * \since 1.8
3714  * \brief Copy the source redirecting information to the destination redirecting.
3715  *
3716  * \param dest Destination redirecting
3717  * \param src Source redirecting
3718  *
3719  * \return Nothing
3720  */
3721 void ast_party_redirecting_copy(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src);
3722 
3723 /*!
3724  * \since 1.8
3725  * \brief Initialize the given redirecting id structure using the given guide
3726  * for a set update operation.
3727  *
3728  * \details
3729  * The initialization is needed to allow a set operation to know if a
3730  * value needs to be updated. Simple integers need the guide's original
3731  * value in case the set operation is not trying to set a new value.
3732  * String values are simply set to NULL pointers if they are not going
3733  * to be updated.
3734  *
3735  * \param init Redirecting id structure to initialize.
3736  * \param guide Source redirecting id to use as a guide in initializing.
3737  *
3738  * \return Nothing
3739  */
3740 void ast_party_redirecting_set_init(struct ast_party_redirecting *init, const struct ast_party_redirecting *guide);
3741 
3742 /*!
3743  * \brief Set the redirecting information based on another redirecting source
3744  * \since 1.8
3745  *
3746  * This is similar to ast_party_redirecting_copy, except that NULL values for
3747  * strings in the src parameter indicate not to update the corresponding dest values.
3748  *
3749  * \param dest The redirecting one wishes to update
3750  * \param src The new redirecting values to update the dest
3751  * \param update What redirecting information to update. NULL if all.
3752  *
3753  * \return Nothing
3754  */
3756 
3757 /*!
3758  * \since 1.8
3759  * \brief Destroy the redirecting information contents
3760  *
3761  * \param doomed The redirecting information to destroy.
3762  *
3763  * \return Nothing
3764  */
3766 
3767 /*!
3768  * \since 1.8
3769  * \brief Copy the caller information to the connected line information.
3770  *
3771  * \param dest Destination connected line information
3772  * \param src Source caller information
3773  *
3774  * \return Nothing
3775  *
3776  * \note Assumes locks are already acquired
3777  */
3779 
3780 /*!
3781  * \since 1.8
3782  * \brief Copy the connected line information to the caller information.
3783  *
3784  * \param dest Destination caller information
3785  * \param src Source connected line information
3786  *
3787  * \return Nothing
3788  *
3789  * \note Assumes locks are already acquired
3790  */
3792 
3793 /*!
3794  * \since 1.8
3795  * \brief Set the connected line information in the Asterisk channel
3796  *
3797  * \param chan Asterisk channel to set connected line information
3798  * \param connected Connected line information
3799  * \param update What connected line information to update. NULL if all.
3800  *
3801  * \return Nothing
3802  *
3803  * \note The channel does not need to be locked before calling this function.
3804  */
3806 
3807 /*!
3808  * \since 1.8
3809  * \brief Build the connected line information data frame.
3810  *
3811  * \param data Buffer to fill with the frame data
3812  * \param datalen Size of the buffer to fill
3813  * \param connected Connected line information
3814  * \param update What connected line information to build. NULL if all.
3815  *
3816  * \retval -1 if error
3817  * \retval Amount of data buffer used
3818  */
3819 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);
3820 
3821 /*!
3822  * \since 1.8
3823  * \brief Parse connected line indication frame data
3824  *
3825  * \param data Buffer with the frame data to parse
3826  * \param datalen Size of the buffer
3827  * \param connected Extracted connected line information
3828  *
3829  * \retval 0 on success.
3830  * \retval -1 on error.
3831  *
3832  * \note The filled in connected line structure needs to be initialized by
3833  * ast_party_connected_line_set_init() before calling. If defaults are not
3834  * required use ast_party_connected_line_init().
3835  * \note The filled in connected line structure needs to be destroyed by
3836  * ast_party_connected_line_free() when it is no longer needed.
3837  */
3838 int ast_connected_line_parse_data(const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected);
3839 
3840 /*!
3841  * \since 1.8
3842  * \brief Indicate that the connected line information has changed
3843  *
3844  * \param chan Asterisk channel to indicate connected line information
3845  * \param connected Connected line information
3846  * \param update What connected line information to update. NULL if all.
3847  *
3848  * \return Nothing
3849  */
3851 
3852 /*!
3853  * \since 1.8
3854  * \brief Queue a connected line update frame on a channel
3855  *
3856  * \param chan Asterisk channel to indicate connected line information
3857  * \param connected Connected line information
3858  * \param update What connected line information to update. NULL if all.
3859  *
3860  * \return Nothing
3861  */
3863 
3864 /*!
3865  * \since 1.8
3866  * \brief Set the redirecting id information in the Asterisk channel
3867  *
3868  * \param chan Asterisk channel to set redirecting id information
3869  * \param redirecting Redirecting id information
3870  * \param update What redirecting information to update. NULL if all.
3871  *
3872  * \return Nothing
3873  *
3874  * \note The channel does not need to be locked before calling this function.
3875  */
3876 void ast_channel_set_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3877 
3878 /*!
3879  * \since 1.8
3880  * \brief Build the redirecting id data frame.
3881  *
3882  * \param data Buffer to fill with the frame data
3883  * \param datalen Size of the buffer to fill
3884  * \param redirecting Redirecting id information
3885  * \param update What redirecting information to build. NULL if all.
3886  *
3887  * \retval -1 if error
3888  * \retval Amount of data buffer used
3889  */
3890 int ast_redirecting_build_data(unsigned char *data, size_t datalen, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3891 
3892 /*!
3893  * \since 1.8
3894  * \brief Parse redirecting indication frame data
3895  *
3896  * \param data Buffer with the frame data to parse
3897  * \param datalen Size of the buffer
3898  * \param redirecting Extracted redirecting id information
3899  *
3900  * \retval 0 on success.
3901  * \retval -1 on error.
3902  *
3903  * \note The filled in id structure needs to be initialized by
3904  * ast_party_redirecting_set_init() before calling.
3905  * \note The filled in id structure needs to be destroyed by
3906  * ast_party_redirecting_free() when it is no longer needed.
3907  */
3908 int ast_redirecting_parse_data(const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting);
3909 
3910 /*!
3911  * \since 1.8
3912  * \brief Indicate that the redirecting id has changed
3913  *
3914  * \param chan Asterisk channel to indicate redirecting id information
3915  * \param redirecting Redirecting id information
3916  * \param update What redirecting information to update. NULL if all.
3917  *
3918  * \return Nothing
3919  */
3920 void ast_channel_update_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3921 
3922 /*!
3923  * \since 1.8
3924  * \brief Queue a redirecting update frame on a channel
3925  *
3926  * \param chan Asterisk channel to indicate redirecting id information
3927  * \param redirecting Redirecting id information
3928  * \param update What redirecting information to update. NULL if all.
3929  *
3930  * \return Nothing
3931  */
3932 void ast_channel_queue_redirecting_update(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
3933 
3934 /*!
3935  * \since 1.8
3936  * \brief Run a connected line interception macro and update a channel's connected line
3937  * information
3938  * \deprecated You should use the ast_channel_connected_line_sub() function instead.
3939  *
3940  * Whenever we want to update a channel's connected line information, we may need to run
3941  * a macro so that an administrator can manipulate the information before sending it
3942  * out. This function both runs the macro and sends the update to the channel.
3943  *
3944  * \param autoservice_chan Channel to place into autoservice while the macro is running.
3945  * It is perfectly safe for this to be NULL
3946  * \param macro_chan The channel to run the macro on. Also the channel from which we
3947  * determine which macro we need to run.
3948  * \param connected_info Either an ast_party_connected_line or ast_frame pointer of type
3949  * AST_CONTROL_CONNECTED_LINE
3950  * \param is_caller If true, then run CONNECTED_LINE_CALLER_SEND_MACRO with arguments from
3951  * CONNECTED_LINE_CALLER_SEND_MACRO_ARGS, otherwise run CONNECTED_LINE_CALLEE_SEND_MACRO
3952  * with arguments from CONNECTED_LINE_CALLEE_SEND_MACRO_ARGS
3953  * \param frame If true, then connected_info is an ast_frame pointer, otherwise it is an
3954  * ast_party_connected_line pointer.
3955  * \retval 0 Success
3956  * \retval -1 Either the macro does not exist, or there was an error while attempting to
3957  * run the macro
3958  *
3959  * \todo Have multiple return codes based on the MACRO_RESULT
3960  * \todo Make constants so that caller and frame can be more expressive than just '1' and
3961  * '0'
3962  */
3963 int ast_channel_connected_line_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *connected_info, int is_caller, int frame);
3964 
3965 /*!
3966  * \since 11
3967  * \brief Run a connected line interception subroutine and update a channel's connected line
3968  * information
3969  *
3970  * Whenever we want to update a channel's connected line information, we may need to run
3971  * a subroutine so that an administrator can manipulate the information before sending it
3972  * out. This function both runs the subroutine specified by CONNECTED_LINE_SEND_SUB and
3973  * sends the update to the channel.
3974  *
3975  * \param autoservice_chan Channel to place into autoservice while the sub is running.
3976  * It is perfectly safe for this to be NULL
3977  * \param sub_chan The channel to run the subroutine on. Also the channel from which we
3978  * determine which subroutine we need to run.
3979  * \param connected_info Either an ast_party_connected_line or ast_frame pointer of type
3980  * AST_CONTROL_CONNECTED_LINE
3981  * \param frame If true, then connected_info is an ast_frame pointer, otherwise it is an
3982  * ast_party_connected_line pointer.
3983  * \retval 0 Success
3984  * \retval -1 Either the subroutine does not exist, or there was an error while attempting to
3985  * run the subroutine
3986  */
3987 int ast_channel_connected_line_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *connected_info, int frame);
3988 
3989 /*!
3990  * \since 1.8
3991  * \brief Run a redirecting interception macro and update a channel's redirecting information
3992  * \deprecated You should use the ast_channel_redirecting_sub() function instead.
3993  *
3994  * \details
3995  * Whenever we want to update a channel's redirecting information, we may need to run
3996  * a macro so that an administrator can manipulate the information before sending it
3997  * out. This function both runs the macro and sends the update to the channel.
3998  *
3999  * \param autoservice_chan Channel to place into autoservice while the macro is running.
4000  * It is perfectly safe for this to be NULL
4001  * \param macro_chan The channel to run the macro on. Also the channel from which we
4002  * determine which macro we need to run.
4003  * \param redirecting_info Either an ast_party_redirecting or ast_frame pointer of type
4004  * AST_CONTROL_REDIRECTING
4005  * \param is_caller If true, then run REDIRECTING_CALLER_SEND_MACRO with arguments from
4006  * REDIRECTING_CALLER_SEND_MACRO_ARGS, otherwise run REDIRECTING_CALLEE_SEND_MACRO with
4007  * arguments from REDIRECTING_CALLEE_SEND_MACRO_ARGS
4008  * \param is_frame If true, then redirecting_info is an ast_frame pointer, otherwise it is an
4009  * ast_party_redirecting pointer.
4010  *
4011  * \retval 0 Success
4012  * \retval -1 Either the macro does not exist, or there was an error while attempting to
4013  * run the macro
4014  *
4015  * \todo Have multiple return codes based on the MACRO_RESULT
4016  * \todo Make constants so that caller and frame can be more expressive than just '1' and
4017  * '0'
4018  */
4019 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);
4020 
4021 /*!
4022  * \since 11
4023  * \brief Run a redirecting interception subroutine and update a channel's redirecting information
4024  *
4025  * \details
4026  * Whenever we want to update a channel's redirecting information, we may need to run
4027  * a subroutine so that an administrator can manipulate the information before sending it
4028  * out. This function both runs the subroutine specified by REDIRECTING_SEND_SUB and
4029  * sends the update to the channel.
4030  *
4031  * \param autoservice_chan Channel to place into autoservice while the subroutine is running.
4032  * It is perfectly safe for this to be NULL
4033  * \param sub_chan The channel to run the subroutine on. Also the channel from which we
4034  * determine which subroutine we need to run.
4035  * \param redirecting_info Either an ast_party_redirecting or ast_frame pointer of type
4036  * AST_CONTROL_REDIRECTING
4037  * \param is_frame If true, then redirecting_info is an ast_frame pointer, otherwise it is an
4038  * ast_party_redirecting pointer.
4039  *
4040  * \retval 0 Success
4041  * \retval -1 Either the subroutine does not exist, or there was an error while attempting to
4042  * run the subroutine
4043  */
4044 int ast_channel_redirecting_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *redirecting_info, int is_frame);
4045 
4046 #include "asterisk/ccss.h"
4047 
4048 /*!
4049  * \since 1.8
4050  * \brief Set up datastore with CCSS parameters for a channel
4051  *
4052  * \note
4053  * If base_params is NULL, the channel will get the default
4054  * values for all CCSS parameters.
4055  *
4056  * \details
4057  * This function makes use of datastore operations on the channel, so
4058  * it is important to lock the channel before calling this function.
4059  *
4060  * \param chan The channel to create the datastore on
4061  * \param base_params CCSS parameters we wish to copy into the channel
4062  * \retval 0 Success
4063  * \retval -1 Failure
4064  */
4065 int ast_channel_cc_params_init(struct ast_channel *chan,
4066  const struct ast_cc_config_params *base_params);
4067 
4068 /*!
4069  * \since 1.8
4070  * \brief Get the CCSS parameters from a channel
4071  *
4072  * \details
4073  * This function makes use of datastore operations on the channel, so
4074  * it is important to lock the channel before calling this function.
4075  *
4076  * \param chan Channel to retrieve parameters from
4077  * \retval NULL Failure
4078  * \retval non-NULL The parameters desired
4079  */
4081 
4082 
4083 /*!
4084  * \since 1.8
4085  * \brief Get a device name given its channel structure
4086  *
4087  * \details
4088  * A common practice in Asterisk is to determine the device being talked
4089  * to by dissecting the channel name. For certain channel types, this is not
4090  * accurate. For instance, an ISDN channel is named based on what B channel is
4091  * used, not the device being communicated with.
4092  *
4093  * This function interfaces with a channel tech's queryoption callback to
4094  * retrieve the name of the device being communicated with. If the channel does not
4095  * implement this specific option, then the traditional method of using the channel
4096  * name is used instead.
4097  *
4098  * \param chan The channel to retrieve the information from
4099  * \param[out] device_name The buffer to place the device's name into
4100  * \param name_buffer_length The allocated space for the device_name
4101  * \return 0 always
4102  */
4103 int ast_channel_get_device_name(struct ast_channel *chan, char *device_name, size_t name_buffer_length);
4104 
4105 /*!
4106  * \since 1.8
4107  * \brief Find the appropriate CC agent type to use given a channel
4108  *
4109  * \details
4110  * During call completion, we will need to create a call completion agent structure. To
4111  * figure out the type of agent to construct, we need to ask the channel driver for the
4112  * appropriate type.
4113  *
4114  * Prior to adding this function, the call completion core attempted to figure this
4115  * out for itself by stripping the technology off the channel's name. However, in the
4116  * case of chan_dahdi, there are multiple agent types registered, and so simply searching
4117  * for an agent type called "DAHDI" is not possible. In a case where multiple agent types
4118  * are defined, the channel driver must have a queryoption callback defined in its
4119  * channel_tech, and the queryoption callback must handle AST_OPTION_CC_AGENT_TYPE
4120  *
4121  * If a channel driver does not have a queryoption callback or if the queryoption callback
4122  * does not handle AST_OPTION_CC_AGENT_TYPE, then the old behavior of using the technology
4123  * portion of the channel name is used instead. This is perfectly suitable for channel drivers
4124  * whose channel technologies are a one-to-one match with the agent types defined within.
4125  *
4126  * Note that this function is only called when the agent policy on a given channel is set
4127  * to "native." Generic agents' type can be determined automatically by the core.
4128  *
4129  * \param chan The channel for which we wish to retrieve the agent type
4130  * \param[out] agent_type The type of agent the channel driver wants us to use
4131  * \param size The size of the buffer to write to
4132  */
4133 int ast_channel_get_cc_agent_type(struct ast_channel *chan, char *agent_type, size_t size);
4134 #if defined(__cplusplus) || defined(c_plusplus)
4135 }
4136 #endif
4137 
4138 /*!
4139  * \brief Remove a channel from the global channels container
4140  *
4141  * \param chan channel to remove
4142  *
4143  * In a case where it is desired that a channel not be available in any lookups
4144  * in the global channels conatiner, use this function.
4145  */
4146 void ast_channel_unlink(struct ast_channel *chan);
4147 
4148 /*!
4149  * \brief Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash
4150  * on the given channel
4151  *
4152  * \param chan channel on which to set the cause information
4153  * \param cause_code ast_control_pvt_cause_code structure containing cause information
4154  * \param datalen total length of the structure since it may vary
4155  */
4156 void ast_channel_hangupcause_hash_set(struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen);
4157 
4158 /*!
4159  * \since 12
4160  * \brief Convert a string to a detail record AMA flag
4161  *
4162  * \param flag string form of flag
4163  *
4164  * \retval the enum (integer) form of the flag
4165  */
4166 enum ama_flags ast_channel_string2amaflag(const char *flag);
4167 
4168 /*!
4169  * \since 12
4170  * \brief Convert the enum representation of an AMA flag to a string representation
4171  *
4172  * \param flags integer flag
4173  *
4174  * \retval A string representation of the flag
4175  */
4176 const char *ast_channel_amaflags2string(enum ama_flags flags);
4177 
4181 };
4182 
4183 /*! Responsible for channel monitoring data */
4187  char read_filename[FILENAME_MAX];
4188  char write_filename[FILENAME_MAX];
4189  char filename_base[FILENAME_MAX];
4190  char beep_id[64];
4192  char *format;
4195  int (*stop)(struct ast_channel *chan, int need_lock);
4196 };
4197 
4198 /* ACCESSOR FUNTIONS */
4199 /*! \brief Set the channel name */
4200 void ast_channel_name_set(struct ast_channel *chan, const char *name);
4201 
4202 #define DECLARE_STRINGFIELD_SETTERS_FOR(field) \
4203  void ast_channel_##field##_set(struct ast_channel *chan, const char *field); \
4204  void ast_channel_##field##_build_va(struct ast_channel *chan, const char *fmt, va_list ap) __attribute__((format(printf, 2, 0))); \
4205  void ast_channel_##field##_build(struct ast_channel *chan, const char *fmt, ...) __attribute__((format(printf, 2, 3)))
4206 
4207 /*!
4208  * The following string fields result in channel snapshot creation and
4209  * should have the channel locked when called:
4210  *
4211  * \li language
4212  * \li accountcode
4213  * \li peeraccount
4214  * \li linkedid
4215  */
4229 
4230 const char *ast_channel_name(const struct ast_channel *chan);
4231 const char *ast_channel_language(const struct ast_channel *chan);
4232 const char *ast_channel_musicclass(const struct ast_channel *chan);
4233 const char *ast_channel_latest_musicclass(const struct ast_channel *chan);
4234 const char *ast_channel_accountcode(const struct ast_channel *chan);
4235 const char *ast_channel_peeraccount(const struct ast_channel *chan);
4236 const char *ast_channel_userfield(const struct ast_channel *chan);
4237 const char *ast_channel_call_forward(const struct ast_channel *chan);
4238 const char *ast_channel_uniqueid(const struct ast_channel *chan);
4239 const char *ast_channel_linkedid(const struct ast_channel *chan);
4240 const char *ast_channel_parkinglot(const struct ast_channel *chan);
4241 const char *ast_channel_hangupsource(const struct ast_channel *chan);
4242 const char *ast_channel_dialcontext(const struct ast_channel *chan);
4243 
4244 const char *ast_channel_appl(const struct ast_channel *chan);
4245 void ast_channel_appl_set(struct ast_channel *chan, const char *value);
4246 const char *ast_channel_blockproc(const struct ast_channel *chan);
4247 void ast_channel_blockproc_set(struct ast_channel *chan, const char *value);
4248 const char *ast_channel_data(const struct ast_channel *chan);
4249 void ast_channel_data_set(struct ast_channel *chan, const char *value);
4250 
4251 const char *ast_channel_context(const struct ast_channel *chan);
4252 void ast_channel_context_set(struct ast_channel *chan, const char *value);
4253 const char *ast_channel_exten(const struct ast_channel *chan);
4254 void ast_channel_exten_set(struct ast_channel *chan, const char *value);
4255 const char *ast_channel_macrocontext(const struct ast_channel *chan);
4256 void ast_channel_macrocontext_set(struct ast_channel *chan, const char *value);
4257 const char *ast_channel_macroexten(const struct ast_channel *chan);
4258 void ast_channel_macroexten_set(struct ast_channel *chan, const char *value);
4259 
4260 char ast_channel_dtmf_digit_to_emulate(const struct ast_channel *chan);
4262 char ast_channel_sending_dtmf_digit(const struct ast_channel *chan);
4263 void ast_channel_sending_dtmf_digit_set(struct ast_channel *chan, char value);
4264 struct timeval ast_channel_sending_dtmf_tv(const struct ast_channel *chan);
4265 void ast_channel_sending_dtmf_tv_set(struct ast_channel *chan, struct timeval value);
4266 enum ama_flags ast_channel_amaflags(const struct ast_channel *chan);
4267 
4268 /*!
4269  * \pre chan is locked
4270  */
4271 void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value);
4272 int ast_channel_epfd(const struct ast_channel *chan);
4273 void ast_channel_epfd_set(struct ast_channel *chan, int value);
4274 int ast_channel_fdno(const struct ast_channel *chan);
4275 void ast_channel_fdno_set(struct ast_channel *chan, int value);
4276 int ast_channel_hangupcause(const struct ast_channel *chan);
4277 void ast_channel_hangupcause_set(struct ast_channel *chan, int value);
4278 int ast_channel_macropriority(const struct ast_channel *chan);
4279 void ast_channel_macropriority_set(struct ast_channel *chan, int value);
4280 int ast_channel_priority(const struct ast_channel *chan);
4281 void ast_channel_priority_set(struct ast_channel *chan, int value);
4282 int ast_channel_rings(const struct ast_channel *chan);
4283 void ast_channel_rings_set(struct ast_channel *chan, int value);
4284 int ast_channel_streamid(const struct ast_channel *chan);
4285 void ast_channel_streamid_set(struct ast_channel *chan, int value);
4286 int ast_channel_timingfd(const struct ast_channel *chan);
4287 void ast_channel_timingfd_set(struct ast_channel *chan, int value);
4288 int ast_channel_visible_indication(const struct ast_channel *chan);
4289 void ast_channel_visible_indication_set(struct ast_channel *chan, int value);
4290 int ast_channel_hold_state(const struct ast_channel *chan);
4291 void ast_channel_hold_state_set(struct ast_channel *chan, int value);
4292 int ast_channel_vstreamid(const struct ast_channel *chan);
4293 void ast_channel_vstreamid_set(struct ast_channel *chan, int value);
4294 unsigned short ast_channel_transfercapability(const struct ast_channel *chan);
4295 void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value);
4296 unsigned int ast_channel_emulate_dtmf_duration(const struct ast_channel *chan);
4297 void ast_channel_emulate_dtmf_duration_set(struct ast_channel *chan, unsigned int value);
4298 unsigned int ast_channel_fin(const struct ast_channel *chan);
4299 void ast_channel_fin_set(struct ast_channel *chan, unsigned int value);
4300 unsigned int ast_channel_fout(const struct ast_channel *chan);
4301 void ast_channel_fout_set(struct ast_channel *chan, unsigned int value);
4302 unsigned long ast_channel_insmpl(const struct ast_channel *chan);
4303 void ast_channel_insmpl_set(struct ast_channel *chan, unsigned long value);
4304 unsigned long ast_channel_outsmpl(const struct ast_channel *chan);
4305 void ast_channel_outsmpl_set(struct ast_channel *chan, unsigned long value);
4306 void *ast_channel_generatordata(const struct ast_channel *chan);
4307 void ast_channel_generatordata_set(struct ast_channel *chan, void *value);
4308 void *ast_channel_music_state(const struct ast_channel *chan);
4309 void ast_channel_music_state_set(struct ast_channel *chan, void *value);
4310 void *ast_channel_tech_pvt(const struct ast_channel *chan);
4311 void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value);
4312 void *ast_channel_timingdata(const struct ast_channel *chan);
4313 void ast_channel_timingdata_set(struct ast_channel *chan, void *value);
4314 struct ast_audiohook_list *ast_channel_audiohooks(const struct ast_channel *chan);
4316 struct ast_cdr *ast_channel_cdr(const struct ast_channel *chan);
4317 void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr *value);
4318 struct ast_channel *ast_channel__bridge(const struct ast_channel *chan);
4319 void ast_channel__bridge_set(struct ast_channel *chan, struct ast_channel *value);
4320 struct ast_channel *ast_channel_masq(const struct ast_channel *chan);
4321 void ast_channel_masq_set(struct ast_channel *chan, struct ast_channel *value);
4322 struct ast_channel *ast_channel_masqr(const struct ast_channel *chan);
4323 void ast_channel_masqr_set(struct ast_channel *chan, struct ast_channel *value);
4324 struct ast_channel_monitor *ast_channel_monitor(const struct ast_channel *chan);
4325 void ast_channel_monitor_set(struct ast_channel *chan, struct ast_channel_monitor *value);
4326 struct ast_filestream *ast_channel_stream(const struct ast_channel *chan);
4327 void ast_channel_stream_set(struct ast_channel *chan, struct ast_filestream *value);
4328 struct ast_filestream *ast_channel_vstream(const struct ast_channel *chan);
4329 void ast_channel_vstream_set(struct ast_channel *chan, struct ast_filestream *value);
4330 struct ast_format_cap *ast_channel_nativeformats(const struct ast_channel *chan);
4332 struct ast_framehook_list *ast_channel_framehooks(const struct ast_channel *chan);
4334 struct ast_generator *ast_channel_generator(const struct ast_channel *chan);
4335 void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator *value);
4336 struct ast_pbx *ast_channel_pbx(const struct ast_channel *chan);
4337 void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx *value);
4338 struct ast_sched_context *ast_channel_sched(const struct ast_channel *chan);
4339 void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context *value);
4340 struct ast_timer *ast_channel_timer(const struct ast_channel *chan);
4341 void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer *value);
4342 struct ast_tone_zone *ast_channel_zone(const struct ast_channel *chan);
4343 void ast_channel_zone_set(struct ast_channel *chan, struct ast_tone_zone *value);
4344 struct ast_trans_pvt *ast_channel_readtrans(const struct ast_channel *chan);
4345 void ast_channel_readtrans_set(struct ast_channel *chan, struct ast_trans_pvt *value);
4346 struct ast_trans_pvt *ast_channel_writetrans(const struct ast_channel *chan);
4347 void ast_channel_writetrans_set(struct ast_channel *chan, struct ast_trans_pvt *value);
4348 const struct ast_channel_tech *ast_channel_tech(const struct ast_channel *chan);
4349 void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value);
4350 enum ast_channel_adsicpe ast_channel_adsicpe(const struct ast_channel *chan);
4352 enum ast_channel_state ast_channel_state(const struct ast_channel *chan);
4353 ast_callid ast_channel_callid(const struct ast_channel *chan);
4354 struct ast_channel_snapshot *ast_channel_snapshot(const struct ast_channel *chan);
4355 void ast_channel_snapshot_set(struct ast_channel *chan, struct ast_channel_snapshot *snapshot);
4357 
4358 /*!
4359  * \pre chan is locked
4360  */
4362 
4363 /* XXX Internal use only, make sure to move later */
4364 void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state);
4368 void ast_channel_callid_cleanup(struct ast_channel *chan);
4370 
4371 /* Format getters */
4372 struct ast_format *ast_channel_oldwriteformat(struct ast_channel *chan);
4373 struct ast_format *ast_channel_rawreadformat(struct ast_channel *chan);
4374 struct ast_format *ast_channel_rawwriteformat(struct ast_channel *chan);
4375 struct ast_format *ast_channel_readformat(struct ast_channel *chan);
4376 struct ast_format *ast_channel_writeformat(struct ast_channel *chan);
4377 
4378 /* Format setters - all of these functions will increment the reference count of the format passed in */
4379 void ast_channel_set_oldwriteformat(struct ast_channel *chan, struct ast_format *format);
4380 void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format);
4381 void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format);
4382 void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format);
4383 void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format);
4384 
4385 /* Other struct getters */
4386 struct ast_frame *ast_channel_dtmff(struct ast_channel *chan);
4387 struct ast_jb *ast_channel_jb(struct ast_channel *chan);
4388 struct ast_party_caller *ast_channel_caller(struct ast_channel *chan);
4392 struct ast_party_dialed *ast_channel_dialed(struct ast_channel *chan);
4397 struct timeval *ast_channel_dtmf_tv(struct ast_channel *chan);
4398 struct timeval *ast_channel_whentohangup(struct ast_channel *chan);
4399 struct varshead *ast_channel_varshead(struct ast_channel *chan);
4400 
4401 void ast_channel_dtmff_set(struct ast_channel *chan, struct ast_frame *value);
4402 void ast_channel_jb_set(struct ast_channel *chan, struct ast_jb *value);
4403 void ast_channel_caller_set(struct ast_channel *chan, struct ast_party_caller *value);
4405 void ast_channel_dialed_set(struct ast_channel *chan, struct ast_party_dialed *value);
4407 void ast_channel_dtmf_tv_set(struct ast_channel *chan, struct timeval *value);
4408 
4409 /*!
4410  * \pre chan is locked
4411  */
4412 void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value);
4413 void ast_channel_varshead_set(struct ast_channel *chan, struct varshead *value);
4414 struct timeval ast_channel_creationtime(struct ast_channel *chan);
4415 void ast_channel_creationtime_set(struct ast_channel *chan, struct timeval *value);
4416 struct timeval ast_channel_answertime(struct ast_channel *chan);
4417 void ast_channel_answertime_set(struct ast_channel *chan, struct timeval *value);
4418 
4419 /* List getters */
4423 struct ast_readq_list *ast_channel_readq(struct ast_channel *chan);
4424 
4425 /* Typedef accessors */
4426 ast_group_t ast_channel_callgroup(const struct ast_channel *chan);
4427 /*!
4428  * \pre chan is locked
4429  */
4430 void ast_channel_callgroup_set(struct ast_channel *chan, ast_group_t value);
4431 ast_group_t ast_channel_pickupgroup(const struct ast_channel *chan);
4432 /*!
4433  * \pre chan is locked
4434  */
4435 void ast_channel_pickupgroup_set(struct ast_channel *chan, ast_group_t value);
4436 struct ast_namedgroups *ast_channel_named_callgroups(const struct ast_channel *chan);
4437 void ast_channel_named_callgroups_set(struct ast_channel *chan, struct ast_namedgroups *value);
4438 struct ast_namedgroups *ast_channel_named_pickupgroups(const struct ast_channel *chan);
4439 void ast_channel_named_pickupgroups_set(struct ast_channel *chan, struct ast_namedgroups *value);
4440 
4441 /* Alertpipe accessors--the "internal" functions for channel.c use only */
4442 int ast_channel_alert_write(struct ast_channel *chan);
4443 int ast_channel_alert_writable(struct ast_channel *chan);
4451 /*! \brief Swap the interal alertpipe between two channels
4452  * \note Handle all of the necessary locking before calling this
4453  */
4454 void ast_channel_internal_alertpipe_swap(struct ast_channel *chan1, struct ast_channel *chan2);
4455 
4456 /* file descriptor array accessors */
4457 void ast_channel_internal_fd_clear(struct ast_channel *chan, int which);
4459 void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value);
4460 int ast_channel_fd(const struct ast_channel *chan, int which);
4461 int ast_channel_fd_isset(const struct ast_channel *chan, int which);
4462 
4463 /*!
4464  * \since 15
4465  * \brief Retrieve the number of file decriptor positions present on the channel
4466  *
4467  * \param chan The channel to get the count of
4468  *
4469  * \pre chan is locked
4470  *
4471  * \return The number of file descriptor positions
4472  */
4473 int ast_channel_fd_count(const struct ast_channel *chan);
4474 
4475 /*!
4476  * \since 15
4477  * \brief Add a file descriptor to the channel without a fixed position
4478  *
4479  * \param chan The channel to add the file descriptor to
4480  * \param value The file descriptor
4481  *
4482  * \pre chan is locked
4483  *
4484  * \return The position of the file descriptor
4485  */
4486 int ast_channel_fd_add(struct ast_channel *chan, int value);
4487 
4488 pthread_t ast_channel_blocker(const struct ast_channel *chan);
4489 void ast_channel_blocker_set(struct ast_channel *chan, pthread_t value);
4490 
4491 int ast_channel_blocker_tid(const struct ast_channel *chan);
4492 void ast_channel_blocker_tid_set(struct ast_channel *chan, int tid);
4493 
4496 
4497 struct ast_bridge *ast_channel_internal_bridge(const struct ast_channel *chan);
4498 /*!
4499  * \pre chan is locked
4500  */
4501 void ast_channel_internal_bridge_set(struct ast_channel *chan, struct ast_bridge *value);
4502 
4505 
4508 
4509 /*!
4510  * \since 11
4511  * \brief Retrieve a comma-separated list of channels for which dialed cause information is available
4512  *
4513  * \details
4514  * This function makes use of datastore operations on the channel, so
4515  * it is important to lock the channel before calling this function.
4516  *
4517  * \param chan The channel from which to retrieve information
4518  * \retval NULL on allocation failure
4519  * \retval Pointer to an ast_str object containing the desired information which must be freed
4520  */
4521 struct ast_str *ast_channel_dialed_causes_channels(const struct ast_channel *chan);
4522 
4523 /*!
4524  * \since 11
4525  * \brief Retrieve a ref-counted cause code information structure
4526  *
4527  * \details
4528  * This function makes use of datastore operations on the channel, so
4529  * it is important to lock the channel before calling this function.
4530  * This function increases the ref count of the returned object, so the
4531  * calling function must decrease the reference count when it is finished
4532  * with the object.
4533  *
4534  * \param chan The channel from which to retrieve information
4535  * \param chan_name The name of the channel about which to retrieve information
4536  * \retval NULL on search failure
4537  * \retval Pointer to a ref-counted ast_control_pvt_cause_code object containing the desired information
4538  */
4539 struct ast_control_pvt_cause_code *ast_channel_dialed_causes_find(const struct ast_channel *chan, const char *chan_name);
4540 
4541 /*!
4542  * \since 11
4543  * \brief Add cause code information to the channel
4544  *
4545  * \details
4546  * This function makes use of datastore operations on the channel, so
4547  * it is important to lock the channel before calling this function.
4548  * The passed in data is copied and so is still owned by the caller.
4549  *
4550  * \param chan The channel on which to add information
4551  * \param cause_code The cause information to be added to the channel
4552  * \param datalen The total length of the structure since its length is variable
4553  * \retval 0 on success
4554  * \retval -1 on error
4555  */
4556 int ast_channel_dialed_causes_add(const struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen);
4557 
4558 /*!
4559  * \since 11
4560  * \brief Clear all cause information from the channel
4561  *
4562  * \details
4563  * This function makes use of datastore operations on the channel, so
4564  * it is important to lock the channel before calling this function.
4565  *
4566  * \param chan The channel from which to clear information
4567  */
4568 void ast_channel_dialed_causes_clear(const struct ast_channel *chan);
4569 
4570 struct ast_flags *ast_channel_flags(struct ast_channel *chan);
4571 
4572 /*!
4573  * \since 13.17.0
4574  * \brief Set a flag on a channel
4575  *
4576  * \param chan The channel to set the flag on
4577  * \param flag The flag to set
4578  *
4579  * \note This will lock the channel internally. If the channel is already
4580  * locked it is still safe to call.
4581  */
4582 
4583 void ast_channel_set_flag(struct ast_channel *chan, unsigned int flag);
4584 
4585 /*!
4586  * \since 13.17.0
4587  * \param Clear a flag on a channel
4588  *
4589  * \param chan The channel to clear the flag from
4590  * \param flag The flag to clear
4591  *
4592  * \note This will lock the channel internally. If the channel is already
4593  * locked it is still safe to call.
4594  */
4595 void ast_channel_clear_flag(struct ast_channel *chan, unsigned int flag);
4596 
4597 /*!
4598  * \since 12.4.0
4599  * \brief Return whether or not any manager variables have been set
4600  *
4601  * \retval 0 if no manager variables are expected
4602  * \retval 1 if manager variables are expected
4603  */
4605 
4606 /*!
4607  * \since 12
4608  * \brief Sets the variables to be stored in the \a manager_vars field of all
4609  * snapshots.
4610  * \param varc Number of variable names.
4611  * \param vars Array of variable names.
4612  */
4613 void ast_channel_set_manager_vars(size_t varc, char **vars);
4614 
4615 /*!
4616  * \since 12
4617  * \brief Gets the variables for a given channel, as specified by ast_channel_set_manager_vars().
4618  *
4619  * The returned variable list is an AO2 object, so ao2_cleanup() to free it.
4620  *
4621  * \param chan Channel to get variables for.
4622  * \return List of channel variables.
4623  * \return \c NULL on error
4624  */
4625 struct varshead *ast_channel_get_manager_vars(struct ast_channel *chan);
4626 
4627 /*!
4628  * \since 14.2.0
4629  * \brief Return whether or not any ARI variables have been set
4630  *
4631  * \retval 0 if no ARI variables are expected
4632  * \retval 1 if ARI variables are expected
4633  */
4634 int ast_channel_has_ari_vars(void);
4635 
4636 /*!
4637  * \since 14.2.0
4638  * \brief Sets the variables to be stored in the \a ari_vars field of all
4639  * snapshots.
4640  * \param varc Number of variable names.
4641  * \param vars Array of variable names.
4642  */
4643 void ast_channel_set_ari_vars(size_t varc, char **vars);
4644 
4645 /*!
4646  * \since 14.2.0
4647  * \brief Gets the variables for a given channel, as specified by ast_channel_set_ari_vars().
4648  *
4649  * The returned variable list is an AO2 object, so ao2_cleanup() to free it.
4650  *
4651  * \param chan Channel to get variables for.
4652  * \return List of channel variables.
4653  * \return \c NULL on error
4654  */
4655 struct varshead *ast_channel_get_ari_vars(struct ast_channel *chan);
4656 
4657 /*!
4658  * \since 12
4659  * \brief Gets the variables for a given channel, as set using pbx_builtin_setvar_helper().
4660  *
4661  * The returned variable list is an AO2 object, so ao2_cleanup() to free it.
4662  *
4663  * \param chan Channel to get variables for
4664  * \return List of channel variables.
4665  * \return \c NULL on error
4666  */
4667 struct varshead *ast_channel_get_vars(struct ast_channel *chan);
4668 
4669 /*!
4670  * \since 12
4671  * \brief A topic which publishes the events for a particular channel.
4672  *
4673  * If the given \a chan is \c NULL, ast_channel_topic_all() is returned.
4674  *
4675  * \param chan Channel, or \c NULL.
4676  *
4677  * \retval Topic for channel's events.
4678  * \retval ast_channel_topic_all() if \a chan is \c NULL.
4679  */
4680 struct stasis_topic *ast_channel_topic(struct ast_channel *chan);
4681 
4682 /*!
4683  * \brief Get the bridge associated with a channel
4684  * \since 12.0.0
4685  *
4686  * \param chan The channel whose bridge we want
4687  *
4688  * \details
4689  * The bridge returned has its reference count incremented. Use
4690  * ao2_cleanup() or ao2_ref() in order to decrement the
4691  * reference count when you are finished with the bridge.
4692  *
4693  * \note This function expects the channel to be locked prior to
4694  * being called and will not grab the channel lock.
4695  *
4696  * \retval NULL No bridge present on the channel
4697  * \retval non-NULL The bridge the channel is in
4698  */
4699 struct ast_bridge *ast_channel_get_bridge(const struct ast_channel *chan);
4700 
4701 /*!
4702  * \brief Determine if a channel is in a bridge
4703  * \since 12.0.0
4704  *
4705  * \param chan The channel to test
4706  *
4707  * \note This function expects the channel to be locked prior to
4708  * being called and will not grab the channel lock.
4709  *
4710  * \retval 0 The channel is not bridged
4711  * \retval non-zero The channel is bridged
4712  */
4713 int ast_channel_is_bridged(const struct ast_channel *chan);
4714 
4715 /*!
4716  * \brief Determine if a channel is leaving a bridge, but \em not hung up
4717  * \since 12.4.0
4718  *
4719  * \param chan The channel to test
4720  *
4721  * \note If a channel is hung up, it is implicitly leaving any bridge it
4722  * may be in. This function is used to test if a channel is leaving a bridge
4723  * but may survive the experience, if it has a place to go to (dialplan or
4724  * otherwise)
4725  *
4726  * \retval 0 The channel is not leaving the bridge or is hung up
4727  * \retval non-zero The channel is leaving the bridge
4728  */
4729 int ast_channel_is_leaving_bridge(struct ast_channel *chan);
4730 
4731 /*!
4732  * \brief Get the channel's bridge peer only if the bridge is two-party.
4733  * \since 12.0.0
4734  *
4735  * \param chan Channel desiring the bridge peer channel.
4736  *
4737  * \note The returned peer channel is the current peer in the
4738  * bridge when called.
4739  *
4740  * \note Absolutely _NO_ channel locks should be held when calling this function.
4741  *
4742  * \retval NULL Channel not in a bridge or the bridge is not two-party.
4743  * \retval non-NULL Reffed peer channel at time of calling.
4744  */
4745 struct ast_channel *ast_channel_bridge_peer(struct ast_channel *chan);
4746 
4747 /*!
4748  * \brief Get a reference to the channel's bridge pointer.
4749  * \since 12.0.0
4750  *
4751  * \param chan The channel whose bridge channel is desired
4752  *
4753  * \note This increases the reference count of the bridge_channel.
4754  * Use ao2_ref() or ao2_cleanup() to decrement the refcount when
4755  * you are finished with it.
4756  *
4757  * \note It is expected that the channel is locked prior to
4758  * placing this call.
4759  *
4760  * \retval NULL The channel has no bridge_channel
4761  * \retval non-NULL A reference to the bridge_channel
4762  */
4764 
4765 /*!
4766  * \since 12
4767  * \brief Gain control of a channel in the system
4768  *
4769  * The intention of this function is to take a channel that currently
4770  * is running in one thread and gain control of it in the current thread.
4771  * This can be used to redirect a channel to a different place in the dialplan,
4772  * for instance.
4773  *
4774  * \note This function is NOT intended to be used on bridged channels. If you
4775  * need to control a bridged channel, you can set a callback to be called
4776  * once the channel exits the bridge, and run your controlling logic in that
4777  * callback
4778  *
4779  * XXX Put name of callback-setting function in above paragraph once it is written
4780  *
4781  * \note When this function returns successfully, the yankee channel is in a state where
4782  * it cannot be used any further. Always use the returned channel instead.
4783  *
4784  * \note absolutely _NO_ channel locks should be held before calling this function.
4785  *
4786  * \note The dialplan location on the returned channel is where the channel
4787  * should be started in the dialplan if it is returned to it.
4788  *
4789  * \param yankee The channel to gain control of
4790  * \retval NULL Could not gain control of the channel
4791  * \retval non-NULL The channel
4792  */
4793 struct ast_channel *ast_channel_yank(struct ast_channel *yankee);
4794 
4795 /*!
4796  * \since 12
4797  * \brief Move a channel from its current location to a new location
4798  *
4799  * The intention of this function is to have the destination channel
4800  * take on the identity of the source channel.
4801  *
4802  * \note This function is NOT intended to be used on bridged channels. If you
4803  * wish to move an unbridged channel into the place of a bridged channel, then
4804  * use ast_bridge_join() or ast_bridge_impart(). If you wish to move a bridged
4805  * channel into the place of another bridged channel, then use ast_bridge_move().
4806  *
4807  * \note When this function returns succesfully, the source channel is in a
4808  * state where its continued use is unreliable.
4809  *
4810  * \note absolutely _NO_ channel locks should be held before calling this function.
4811  *
4812  * \param dest The place to move the source channel
4813  * \param source The channel to move
4814  * \retval 0 Success
4815  * \retval non-zero Failure
4816  */
4817 int ast_channel_move(struct ast_channel *dest, struct ast_channel *source);
4818 
4819 /*!
4820  * \since 12
4821  * \brief Forward channel stasis messages to the given endpoint
4822  *
4823  * \param chan The channel to forward from
4824  * \param endpoint The endpoint to forward to
4825  *
4826  * \retval 0 Success
4827  * \retval non-zero Failure
4828  */
4829 int ast_channel_forward_endpoint(struct ast_channel *chan, struct ast_endpoint *endpoint);
4830 
4831 /*!
4832  * \brief Return the oldest linkedid between two channels.
4833  *
4834  * A channel linkedid is derived from the channel uniqueid which is formed like this:
4835  * [systemname-]ctime.seq
4836  *
4837  * The systemname, and the dash are optional, followed by the epoch time followed by an
4838  * integer sequence. Note that this is not a decimal number, since 1.2 is less than 1.11
4839  * in uniqueid land.
4840  *
4841  * To compare two uniqueids, we parse out the integer values of the time and the sequence
4842  * numbers and compare them, with time trumping sequence.
4843  *
4844  * \param a The linkedid value of the first channel to compare
4845  * \param b The linkedid value of the second channel to compare
4846  *
4847  * \retval NULL on failure
4848  * \retval The oldest linkedid value
4849  * \since 12.0.0
4850 */
4851 const char *ast_channel_oldest_linkedid(const char *a, const char *b);
4852 
4853 /*!
4854  * \brief Check if the channel has active audiohooks, active framehooks, or a monitor.
4855  * \since 12.0.0
4856  *
4857  * \param chan The channel to check.
4858  *
4859  * \retval non-zero if channel has active audiohooks, framehooks, or monitor.
4860  */
4862 
4863 /*!
4864  * \brief Check if the channel has any active hooks that require audio.
4865  * \since 12.3.0
4866  *
4867  * \param chan The channel to check.
4868  *
4869  * \retval non-zero if channel has active audiohooks, audio framehooks, or monitor.
4870  */
4872 
4873 /*!
4874  * \brief Removes the trailing identifiers from a channel name string
4875  * \since 12.0.0
4876  *
4877  * \param channel_name string that you wish to turn into a dial string.
4878  * This string will be edited in place.
4879  */
4880 void ast_channel_name_to_dial_string(char *channel_name);
4881 
4882 #define AST_MUTE_DIRECTION_READ (1 << 0)
4883 #define AST_MUTE_DIRECTION_WRITE (1 << 1)
4884 
4885 /*!
4886  * \brief Suppress passing of a frame type on a channel
4887  *
4888  * \note The channel should be locked before calling this function.
4889  *
4890  * \param chan The channel to suppress
4891  * \param direction The direction in which to suppress
4892  * \param frametype The type of frame (AST_FRAME_VOICE, etc) to suppress
4893  *
4894  * \retval 0 Success
4895  * \retval -1 Failure
4896  */
4897 int ast_channel_suppress(struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype);
4898 
4899 /*!
4900  * \brief Stop suppressing of a frame type on a channel
4901  *
4902  * \note The channel should be locked before calling this function.
4903  *
4904  * \param chan The channel to stop suppressing
4905  * \param direction The direction in which to stop suppressing
4906  * \param frametype The type of frame (AST_FRAME_VOICE, etc) to stop suppressing
4907  *
4908  * \retval 0 Success
4909  * \retval -1 Failure
4910  */
4911 int ast_channel_unsuppress(struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype);
4912 
4913 /*!
4914  * \brief Simulate a DTMF end on a broken bridge channel.
4915  *
4916  * \param chan Channel sending DTMF that has not ended.
4917  * \param digit DTMF digit to stop.
4918  * \param start DTMF digit start time.
4919  * \param why Reason bridge broken.
4920  *
4921  * \return Nothing
4922  */
4923 void ast_channel_end_dtmf(struct ast_channel *chan, char digit, struct timeval start, const char *why);
4924 
4925 struct ast_bridge_features;
4926 
4927 /*!
4928  * \brief Gets the channel-attached features a channel has access to upon being bridged.
4929  *
4930  * \note The channel must be locked when calling this function.
4931  *
4932  * \param chan Which channel to get features for
4933  *
4934  * \retval non-NULL The features currently set for this channel
4935  * \retval NULL if the features have not been set
4936  */
4938 
4939 /*!
4940  * \brief Appends to the channel-attached features a channel has access to upon being bridged.
4941  *
4942  * \note The channel must be locked when calling this function.
4943  *
4944  * \param chan Which channel to set features for
4945  * \param features The feature set to append to the channel's features
4946  *
4947  * \retval 0 on success
4948  * \retval -1 on failure
4949  */
4950 int ast_channel_feature_hooks_append(struct ast_channel *chan, struct ast_bridge_features *features);
4951 
4952 /*!
4953  * \brief Sets the channel-attached features a channel has access to upon being bridged.
4954  *
4955  * \note The channel must be locked when calling this function.
4956  *
4957  * \param chan Which channel to set features for
4958  * \param features The feature set with which to replace the channel's features
4959  *
4960  * \retval 0 on success
4961  * \retval -1 on failure
4962  */
4963 int ast_channel_feature_hooks_replace(struct ast_channel *chan, struct ast_bridge_features *features);
4964 
4966  /* Unable to determine what error occurred. */
4968  /* Channel with this ID already exists */
4970 };
4971 
4972 /*!
4973  * \brief Get error code for latest channel operation.
4974  */
4976 
4977 /*!
4978  * \brief Am I currently running an intercept dialplan routine.
4979  * \since 13.14.0
4980  *
4981  * \details
4982  * A dialplan intercept routine is equivalent to an interrupt
4983  * routine. As such, the routine must be done quickly and you
4984  * do not have access to the media stream. These restrictions
4985  * are necessary because the media stream is the responsibility
4986  * of some other code and interfering with or delaying that
4987  * processing is bad.
4988  *
4989  * \retval 0 Not in an intercept routine.
4990  * \retval 1 In an intercept routine.
4991  */
4993 
4994 /*!
4995  * \brief Retrieve the topology of streams on a channel
4996  *
4997  * \param chan The channel to get the stream topology of
4998  *
4999  * \pre chan is locked
5000  *
5001  * \retval non-NULL success
5002  * \retval NULL failure
5003  */
5005  const struct ast_channel *chan);
5006 
5007 /*!
5008  * \brief Set the topology of streams on a channel
5009  *
5010  * \param chan The channel to set the stream topology on
5011  * \param topology The stream topology to set
5012  *
5013  * \pre chan is locked
5014  *
5015  * \note If topology is NULL a new empty topology will be created
5016  * and returned.
5017  *
5018  * \retval non-NULL Success
5019  * \retval NULL failure
5020  */
5022  struct ast_channel *chan, struct ast_stream_topology *topology);
5023 
5024 /*!
5025  * \brief Retrieve the default stream of a specific media type on a channel
5026  *
5027  * \param channel The channel to get the stream from
5028  * \param type The media type of the default stream
5029  *
5030  * \pre chan is locked
5031  *
5032  * \retval non-NULL success
5033  * \retval NULL failure
5034  */
5035 struct ast_stream *ast_channel_get_default_stream(struct ast_channel *chan, enum ast_media_type type);
5036 
5037 /*!
5038  * \brief Determine if a channel is multi-stream capable
5039  *
5040  * \param channel The channel to test
5041  *
5042  * \pre chan is locked
5043  *
5044  * \return Returns true if the channel is multi-stream capable.
5045  */
5046 int ast_channel_is_multistream(struct ast_channel *chan);
5047 
5048 /*!
5049  * \brief Request that the stream topology of a channel change
5050  *
5051  * \param chan The channel to change
5052  * \param topology The new stream topology
5053  * \param change_source The source that initiated the change
5054  *
5055  * \note Absolutely _NO_ channel locks should be held before calling this function.
5056  *
5057  * \retval 0 request has been accepted to be attempted
5058  * \retval -1 request could not be attempted
5059  *
5060  * \note This function initiates an asynchronous request to change the stream topology. It is not
5061  * guaranteed that the topology will change and until an AST_CONTROL_STREAM_TOPOLOGY_CHANGED
5062  * frame is received from the channel the current handler of the channel must tolerate the
5063  * stream topology as it currently exists.
5064  *
5065  * \note This interface is provided for applications and resources to request that the topology change.
5066  * It is not for use by the channel driver itself.
5067  */
5069  struct ast_stream_topology *topology, void *change_source);
5070 
5071 /*!
5072  * \brief Provide notice to a channel that the stream topology has changed
5073  *
5074  * \param chan The channel to provide notice to
5075  * \param topology The new stream topology
5076  *
5077  * \pre chan is locked Absolutely _NO_ other channels can be locked.
5078  *
5079  * \retval 0 success
5080  * \retval -1 failure
5081  *
5082  * \note This interface is provided for applications and resources to accept a topology change.
5083  * It is not for use by the channel driver itself.
5084  */
5085 int ast_channel_stream_topology_changed(struct ast_channel *chan, struct ast_stream_topology *topology);
5086 
5087 /*!
5088  * \brief Provide notice from a channel that the topology has changed on it as a result
5089  * of the remote party renegotiating.
5090  *
5091  * \param chan The channel to provide notice from
5092  *
5093  * \retval 0 success
5094  * \retval -1 failure
5095  *
5096  * \note This interface is provided for channels to provide notice that a topology change
5097  * has occurred as a result of a remote party renegotiating the stream topology.
5098  */
5100 
5101 /*!
5102  * \brief Retrieve the source that initiated the last stream topology change
5103  *
5104  * \param chan The channel
5105  *
5106  * \retval The channel's stream topology change source
5107  */
5109 
5110 /*!
5111  * \brief Checks if a channel's technology implements a particular callback function
5112  * \since 18.0.0
5113  *
5114  * \param chan The channel
5115  * \param function The function to look for
5116  *
5117  * \retval 1 if the channel has a technology set and it implements the function
5118  * \retval 0 if the channel doesn't have a technology set or it doesn't implement the function
5119  */
5120 #define ast_channel_has_tech_function(chan, function) \
5121  (ast_channel_tech(chan) ? ast_channel_tech(chan)->function != NULL : 0)
5122 
5123 
5124 #endif /* _ASTERISK_CHANNEL_H */
#define FILENAME_MAX
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:1602
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
const ast_string_field peeraccount
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:2049
enum ast_channel_state ast_channel_state(const struct ast_channel *chan)
void ast_channel_dtmf_digit_to_emulate_set(struct ast_channel *chan, char value)
static char musicclass[MAX_MUSICCLASS]
Definition: chan_mgcp.c:162
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:2818
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:3152
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
Definition: channel.c:1565
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:1585
void ast_channel_internal_bridge_channel_set(struct ast_channel *chan, struct ast_bridge_channel *value)
int ast_queue_hangup(struct ast_channel *chan)
Queue a hangup frame.
Definition: channel.c:1146
unsigned long long ast_group_t
Definition: channel.h:214
void ast_channel_internal_alertpipe_clear(struct ast_channel *chan)
void ast_channel_snapshot_set(struct ast_channel *chan, struct ast_channel_snapshot *snapshot)
void ast_channel_fdno_set(struct ast_channel *chan, int value)
int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1)
Bridge two channels together (early)
Definition: channel.c:7375
int ast_channel_vstreamid(const struct ast_channel *chan)
Information needed to identify an endpoint in a call.
Definition: channel.h:339
enum sip_cc_notify_state state
Definition: chan_sip.c:957
const char * ast_channel_blockproc(const struct ast_channel *chan)
int ast_recvchar(struct ast_channel *chan, int timeout)
Receives a text character from a channel.
Definition: channel.c:4720
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
Definition: channel.c:2008
static char accountcode[AST_MAX_ACCOUNT_CODE]
Definition: chan_iax2.c:429
void ast_channel_timingfunc_set(struct ast_channel *chan, ast_timing_func_t value)
void ast_channel_pickupgroup_set(struct ast_channel *chan, ast_group_t value)
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:278
Channels with this particular technology are an implementation detail of Asterisk and should generall...
Definition: channel.h:972
int ast_channel_fd_isset(const struct ast_channel *chan, int which)
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:7297
#define attribute_pure
Definition: compiler.h:35
void ast_channel_req_accountcodes_precious(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship)
Setup new channel accountcodes from the requestor channel after ast_request().
Definition: channel.c:6423
static int indicate(void *data)
Definition: chan_pjsip.c:1349
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
Main Channel structure associated with a channel.
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:2152
channel group info
Definition: channel.h:2883
Definition: test_heap.c:38
const char * cid_num
Definition: channel.h:1110
struct ast_channel * ast_channel_get_by_exten(const char *exten, const char *context)
Find a channel by extension and context.
Definition: channel.c:1455
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:8650
void ast_channel_blocker_tid_set(struct ast_channel *chan, int tid)
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:389
char * str
Subscriber phone number (Malloced)
Definition: channel.h:292
int64_t ast_channel_get_duration_ms(struct ast_channel *chan)
Obtain how long it&#39;s been, in milliseconds, since the channel was created.
Definition: channel.c:2815
int ast_channel_hold_state(const struct ast_channel *chan)
const char *const type
Definition: channel.h:630
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:1418
void ast_channel_internal_fd_clear(struct ast_channel *chan, int which)
int ast_channel_connected_line_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *connected_info, int is_caller, int frame)
Run a connected line interception macro and update a channel&#39;s connected line information.
Definition: channel.c:10292
void ast_channel_visible_indication_set(struct ast_channel *chan, int value)
char * str
Subscriber phone number (Malloced)
Definition: channel.h:387
char chan_name[AST_CHANNEL_NAME]
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:7335
void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer *value)
static char parkinglot[AST_MAX_CONTEXT]
Definition: chan_mgcp.c:163
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
Definition: channel.c:1227
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:9431
struct ast_party_caller caller
Channel Caller ID information.
struct ast_filestream * ast_channel_vstream(const struct ast_channel *chan)
void * ast_channel_generatordata(const struct ast_channel *chan)
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...
void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value)
int ast_channel_is_multistream(struct ast_channel *chan)
Determine if a channel is multi-stream capable.
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
Definition: autoservice.c:200
int ast_channel_internal_alert_readfd(struct ast_channel *chan)
struct ast_party_id ast_channel_redirecting_effective_from(struct ast_channel *chan)
unsigned short ast_channel_transfercapability(const struct ast_channel *chan)
void ast_channel_insmpl_set(struct ast_channel *chan, unsigned long value)
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:1652
struct ast_cdr * ast_channel_cdr(const struct ast_channel *chan)
struct ast_channel_id linkedid
void ast_channel_dtmff_set(struct ast_channel *chan, struct ast_frame *value)
struct ast_stream_topology * ast_channel_get_stream_topology(const struct ast_channel *chan)
Retrieve the topology of streams on a channel.
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:296
ast_channel_requestor_relationship
Definition: channel.h:1477
channelreloadreason
Channel reload reasons for manager events at load or reload of configuration.
Definition: channel.h:1167
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_set_oldwriteformat(struct ast_channel *chan, struct ast_format *format)
struct ast_channel * parent_channel
Definition: channel.h:1114
struct ast_stream_topology * answer_topology
Definition: channel.h:1100
int ast_auto_answer(struct ast_channel *chan)
Answer a channel, if it&#39;s not already answered.
Definition: channel.c:2806
void ast_party_id_reset(struct ast_party_id *id)
Destroy and initialize the given party id structure.
Definition: channel.c:1882
Structure that contains features information.
void * ast_channel_tech_pvt(const struct ast_channel *chan)
const struct ast_channel_tech * ast_get_channel_tech(const char *name)
Get a channel technology structure by name.
Definition: channel.c:588
int ast_channel_epfd(const struct ast_channel *chan)
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:2031
char ast_channel_sending_dtmf_digit(const struct ast_channel *chan)
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:1691
unsigned int ast_channel_fout(const struct ast_channel *chan)
void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset)
Set when to hang a channel up.
Definition: channel.c:506
struct ast_channel * ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, 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:6163
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
Definition: channel.c:2946
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
void ast_channel_blockproc_set(struct ast_channel *chan, const char *value)
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4291
struct ast_channel * ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, struct ast_format_cap *cap, struct outgoing_helper *oh, int *outstate)
Forwards a call to a new channel specified by the original channel&#39;s call_forward str...
Definition: channel.c:5887
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
Definition: channel.c:566
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
void ast_channel_appl_set(struct ast_channel *chan, const char *value)
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
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:7405
static struct aco_type agent_type
int ast_channel_is_t38_active_nolock(struct ast_channel *chan)
ast_channel_is_t38_active variant. Use this if the channel is already locked prior to calling...
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:10236
int64_t ast_channel_get_up_time_ms(struct ast_channel *chan)
Obtain how long it has been since the channel was answered in ms.
Definition: channel.c:2830
Channel Variables.
int ast_queue_unhold(struct ast_channel *chan)
Queue an unhold frame.
Definition: channel.c:1212
void ast_channel_framehooks_set(struct ast_channel *chan, struct ast_framehook_list *value)
int ast_channel_forward_endpoint(struct ast_channel *chan, struct ast_endpoint *endpoint)
Forward channel stasis messages to the given endpoint.
struct ast_variable * ast_channeltype_list(void)
return an ast_variable list of channeltypes
Definition: channel.c:184
struct ast_channel * ast_channel_release(struct ast_channel *chan)
Unlink and release reference to a channel.
Definition: channel.c:1570
void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format)
int ast_channel_supports_html(struct ast_channel *channel)
Checks for HTML support on a channel.
Definition: channel.c:6583
int ast_check_hangup_locked(struct ast_channel *chan)
Definition: channel.c:455
struct ast_framehook_list * ast_channel_framehooks(const struct ast_channel *chan)
struct varshead * ast_channel_get_manager_vars(struct ast_channel *chan)
Gets the variables for a given channel, as specified by ast_channel_set_manager_vars().
Definition: channel.c:7948
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
void ast_channel_dialed_set(struct ast_channel *chan, struct ast_party_dialed *value)
struct ast_channel * ast_channel__bridge(const struct ast_channel *chan)
unsigned long ast_channel_insmpl(const struct ast_channel *chan)
static int ast_fdisset(struct pollfd *pfds, int fd, int maximum, int *start)
Helper function for migrating select to poll.
Definition: channel.h:2795