]> git.ipfire.org Git - thirdparty/asterisk.git/blame - channels/chan_dahdi.h
chan_dahdi: Allow MWI to be manually toggled on channels.
[thirdparty/asterisk.git] / channels / chan_dahdi.h
CommitLineData
83a871ea
RM
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2013 Digium, Inc.
5 *
6 * Richard Mudgett <rmudgett@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/*!
20 * \file
21 * \brief DAHDI internal API definitions.
22 *
23 * \author Richard Mudgett <rmudgett@digium.com>
24 *
25 * See Also:
26 * \arg \ref AstCREDITS
27 */
28
29#ifndef _ASTERISK_CHAN_DAHDI_H
30#define _ASTERISK_CHAN_DAHDI_H
31
32#if defined(HAVE_OPENR2)
33#include <openr2.h>
34#endif /* defined(HAVE_OPENR2) */
35
36#include <dahdi/user.h>
37#include <dahdi/tonezone.h>
38
39#include "asterisk/channel.h"
40#include "asterisk/dsp.h"
e4803bbd 41#include "asterisk/app.h"
db535439 42#include "asterisk/mwi.h"
83a871ea
RM
43
44#if defined(__cplusplus) || defined(c_plusplus)
45extern "C" {
46#endif
47
48/* ------------------------------------------------------------------- */
49
50#if defined(HAVE_PRI)
51struct sig_pri_span;
52#endif /* defined(HAVE_PRI) */
53#if defined(HAVE_SS7)
54struct sig_ss7_linkset;
55#endif /* defined(HAVE_SS7) */
56
57#define SUB_REAL 0 /*!< Active call */
58#define SUB_CALLWAIT 1 /*!< Call-Waiting call on hold */
59#define SUB_THREEWAY 2 /*!< Three-way call */
60
61
62struct distRingData {
63 int ring[3];
64 int range;
65};
66struct ringContextData {
67 char contextData[AST_MAX_CONTEXT];
68};
69struct dahdi_distRings {
70 struct distRingData ringnum[3];
71 struct ringContextData ringContext[3];
72};
73
74
75extern const char * const subnames[];
76
77struct dahdi_subchannel {
78 int dfd;
79 struct ast_channel *owner;
80 int chan;
81 short buffer[AST_FRIENDLY_OFFSET/2 + READ_SIZE];
82 struct ast_frame f; /*!< One frame for each channel. How did this ever work before? */
83 unsigned int needringing:1;
84 unsigned int needbusy:1;
85 unsigned int needcongestion:1;
86 unsigned int needanswer:1;
87 unsigned int needflash:1;
88 unsigned int needhold:1;
89 unsigned int needunhold:1;
90 unsigned int linear:1;
91 unsigned int inthreeway:1;
92 struct dahdi_confinfo curconf;
93};
94
95#define MAX_SLAVES 4
96
97/* States for sending MWI message
98 * First three states are required for send Ring Pulse Alert Signal
99 */
100typedef enum {
101 MWI_SEND_NULL = 0,
102 MWI_SEND_SA,
103 MWI_SEND_SA_WAIT,
104 MWI_SEND_PAUSE,
105 MWI_SEND_SPILL,
106 MWI_SEND_CLEANUP,
107 MWI_SEND_DONE,
108} mwisend_states;
109
110struct mwisend_info {
111 struct timeval pause;
112 mwisend_states mwisend_current;
113};
114
115/*! Specify the lists dahdi_pvt can be put in. */
116enum DAHDI_IFLIST {
117 DAHDI_IFLIST_NONE, /*!< The dahdi_pvt is not in any list. */
118 DAHDI_IFLIST_MAIN, /*!< The dahdi_pvt is in the main interface list */
119#if defined(HAVE_PRI)
120 DAHDI_IFLIST_NO_B_CHAN, /*!< The dahdi_pvt is in a no B channel interface list */
121#endif /* defined(HAVE_PRI) */
122};
123
124struct dahdi_pvt {
125 ast_mutex_t lock; /*!< Channel private lock. */
126 struct callerid_state *cs;
127 struct ast_channel *owner; /*!< Our current active owner (if applicable) */
128 /*!< Up to three channels can be associated with this call */
129
130 struct dahdi_subchannel sub_unused; /*!< Just a safety precaution */
131 struct dahdi_subchannel subs[3]; /*!< Sub-channels */
132 struct dahdi_confinfo saveconf; /*!< Saved conference info */
133
134 struct dahdi_pvt *slaves[MAX_SLAVES]; /*!< Slave to us (follows our conferencing) */
135 struct dahdi_pvt *master; /*!< Master to us (we follow their conferencing) */
136 int inconference; /*!< If our real should be in the conference */
137
138 int bufsize; /*!< Size of the buffers */
139 int buf_no; /*!< Number of buffers */
140 int buf_policy; /*!< Buffer policy */
141 int faxbuf_no; /*!< Number of Fax buffers */
142 int faxbuf_policy; /*!< Fax buffer policy */
143 int sig; /*!< Signalling style */
144 /*!
145 * \brief Nonzero if the signaling type is sent over a radio.
146 * \note Set to a couple of nonzero values but it is only tested like a boolean.
147 */
148 int radio;
9a999242 149 int dialmode; /*!< Dialing Modes Allowed (Pulse/Tone) */
83a871ea
RM
150 int outsigmod; /*!< Outbound Signalling style (modifier) */
151 int oprmode; /*!< "Operator Services" mode */
152 struct dahdi_pvt *oprpeer; /*!< "Operator Services" peer tech_pvt ptr */
2127848d
RM
153 /*! \brief Hardware Rx gain set by chan_dahdi.conf */
154 float hwrxgain;
155 /*! \brief Hardware Tx gain set by chan_dahdi.conf */
156 float hwtxgain;
83a871ea
RM
157 /*! \brief Amount of gain to increase during caller id */
158 float cid_rxgain;
edb437ee 159 /*! \brief Software Rx gain set by chan_dahdi.conf */
83a871ea 160 float rxgain;
edb437ee 161 /*! \brief Software Tx gain set by chan_dahdi.conf */
83a871ea
RM
162 float txgain;
163
164 float txdrc; /*!< Dynamic Range Compression factor. a number between 1 and 6ish */
165 float rxdrc;
166
167 int tonezone; /*!< tone zone for this chan, or -1 for default */
168 enum DAHDI_IFLIST which_iflist; /*!< Which interface list is this structure listed? */
169 struct dahdi_pvt *next; /*!< Next channel in list */
170 struct dahdi_pvt *prev; /*!< Prev channel in list */
171
172 /* flags */
173
174 /*!
175 * \brief TRUE if ADSI (Analog Display Services Interface) available
176 * \note Set from the "adsi" value read in from chan_dahdi.conf
177 */
178 unsigned int adsi:1;
179 /*!
180 * \brief TRUE if we can use a polarity reversal to mark when an outgoing
181 * call is answered by the remote party.
182 * \note Set from the "answeronpolarityswitch" value read in from chan_dahdi.conf
183 */
184 unsigned int answeronpolarityswitch:1;
466eb4a5
SA
185 /*!
186 * \brief INTEGER, number of ANI INFO digits on a CAMA trunk.
187 * older switches use 1 INFO digit, newer switches use 2 INFO digits
188 * \note Set from the "ani_info_digits" value read in from chan_dahdi.conf
189 */
190 unsigned int ani_info_digits:8;
191 /*!
192 * \brief INTEGER, length of ANI failure timeout in ms.
193 * \note Set from the "ani_timeout" value read in from chan_dahdi.conf
194 */
195 unsigned int ani_timeout:16;
196 /*!
197 * \brief INTEGER, length of time to wait before sending ANI wink in ms.
198 * \note Set from the "ani_wink_time" value read in from chan_dahdi.conf
199 */
200 unsigned int ani_wink_time:16;
83a871ea
RM
201 /*!
202 * \brief TRUE if busy detection is enabled.
203 * (Listens for the beep-beep busy pattern.)
204 * \note Set from the "busydetect" value read in from chan_dahdi.conf
205 */
206 unsigned int busydetect:1;
301b0258
NA
207 /*!
208 * \brief TRUE if Called Subscriber held is enabled.
209 * This allows a single incoming call to hold a DAHDI channel up,
210 * allowing a recipient to hang up an extension and pick up another
211 * phone on the same line without disconnecting the call.
212 */
213 unsigned int calledsubscriberheld:1;
83a871ea
RM
214 /*!
215 * \brief TRUE if call return is enabled.
216 * (*69, if your dialplan doesn't catch this first)
217 * \note Set from the "callreturn" value read in from chan_dahdi.conf
218 */
219 unsigned int callreturn:1;
220 /*!
221 * \brief TRUE if busy extensions will hear the call-waiting tone
222 * and can use hook-flash to switch between callers.
223 * \note Can be disabled by dialing *70.
224 * \note Initialized with the "callwaiting" value read in from chan_dahdi.conf
225 */
226 unsigned int callwaiting:1;
227 /*!
228 * \brief TRUE if send caller ID for Call Waiting
229 * \note Set from the "callwaitingcallerid" value read in from chan_dahdi.conf
230 */
231 unsigned int callwaitingcallerid:1;
232 /*!
233 * \brief TRUE if support for call forwarding enabled.
234 * Dial *72 to enable call forwarding.
235 * Dial *73 to disable call forwarding.
236 * \note Set from the "cancallforward" value read in from chan_dahdi.conf
237 */
238 unsigned int cancallforward:1;
239 /*!
240 * \brief TRUE if support for call parking is enabled.
241 * \note Set from the "canpark" value read in from chan_dahdi.conf
242 */
243 unsigned int canpark:1;
244 /*! \brief TRUE if to wait for a DTMF digit to confirm answer */
245 unsigned int confirmanswer:1;
246 /*!
247 * \brief TRUE if the channel is to be destroyed on hangup.
248 * (Used by pseudo channels.)
249 */
250 unsigned int destroy:1;
251 unsigned int didtdd:1; /*!< flag to say its done it once */
252 /*! \brief TRUE if analog type line dialed no digits in Dial() */
253 unsigned int dialednone:1;
254 /*!
255 * \brief TRUE if in the process of dialing digits or sending something.
256 * \note This is used as a receive squelch for ISDN until connected.
257 */
258 unsigned int dialing:1;
259 /*! \brief TRUE if the transfer capability of the call is digital. */
260 unsigned int digital:1;
261 /*! \brief TRUE if Do-Not-Disturb is enabled, present only for non sig_analog */
262 unsigned int dnd:1;
263 /*! \brief XXX BOOLEAN Purpose??? */
264 unsigned int echobreak:1;
265 /*!
266 * \brief TRUE if echo cancellation enabled when bridged.
267 * \note Initialized with the "echocancelwhenbridged" value read in from chan_dahdi.conf
268 * \note Disabled if the echo canceller is not setup.
269 */
270 unsigned int echocanbridged:1;
271 /*! \brief TRUE if echo cancellation is turned on. */
272 unsigned int echocanon:1;
273 /*! \brief TRUE if a fax tone has already been handled. */
274 unsigned int faxhandled:1;
275 /*! TRUE if dynamic faxbuffers are configured for use, default is OFF */
276 unsigned int usefaxbuffers:1;
277 /*! TRUE while buffer configuration override is in use */
278 unsigned int bufferoverrideinuse:1;
279 /*! \brief TRUE if over a radio and dahdi_read() has been called. */
280 unsigned int firstradio:1;
281 /*!
282 * \brief TRUE if the call will be considered "hung up" on a polarity reversal.
283 * \note Set from the "hanguponpolarityswitch" value read in from chan_dahdi.conf
284 */
285 unsigned int hanguponpolarityswitch:1;
d16046e4
NA
286 /*!
287 * \brief TRUE if FXS (FXO-signalled) channel should reoriginate for user to make a new call.
288 */
289 unsigned int reoriginate:1;
290 /*!
291 * \brief Internal flag for if we should actually process a reorigination.
292 */
293 unsigned int doreoriginate:1;
83a871ea
RM
294 /*! \brief TRUE if DTMF detection needs to be done by hardware. */
295 unsigned int hardwaredtmf:1;
296 /*!
297 * \brief TRUE if the outgoing caller ID is blocked/hidden.
298 * \note Caller ID can be disabled by dialing *67.
299 * \note Caller ID can be enabled by dialing *82.
300 * \note Initialized with the "hidecallerid" value read in from chan_dahdi.conf
301 */
302 unsigned int hidecallerid:1;
303 /*!
304 * \brief TRUE if hide just the name not the number for legacy PBX use.
305 * \note Only applies to PRI channels.
306 * \note Set from the "hidecalleridname" value read in from chan_dahdi.conf
307 */
308 unsigned int hidecalleridname:1;
309 /*! \brief TRUE if DTMF detection is disabled. */
310 unsigned int ignoredtmf:1;
311 /*!
312 * \brief TRUE if the channel should be answered immediately
313 * without attempting to gather any digits.
314 * \note Set from the "immediate" value read in from chan_dahdi.conf
315 */
316 unsigned int immediate:1;
8cd7548e
NA
317 /*!
318 * \brief TRUE if audible ringback should be provided
319 * when immediate = yes.
320 * \note Set from the "immediatering" value read in from chan_dahdi.conf
321 */
322 unsigned int immediatering:1;
83a871ea
RM
323 /*! \brief TRUE if in an alarm condition. */
324 unsigned int inalarm:1;
325 /*! \brief TRUE if TDD in MATE mode */
326 unsigned int mate:1;
327 /*! \brief TRUE if we originated the call leg. */
328 unsigned int outgoing:1;
329 /*!
330 * \brief TRUE if busy extensions will hear the call-waiting tone
331 * and can use hook-flash to switch between callers.
332 * \note Set from the "callwaiting" value read in from chan_dahdi.conf
333 */
334 unsigned int permcallwaiting:1;
335 /*!
336 * \brief TRUE if the outgoing caller ID is blocked/restricted/hidden.
337 * \note Set from the "hidecallerid" value read in from chan_dahdi.conf
338 */
339 unsigned int permhidecallerid:1;
340 /*!
341 * \brief TRUE if PRI congestion/busy indications are sent out-of-band.
342 * \note Set from the "priindication" value read in from chan_dahdi.conf
343 */
344 unsigned int priindication_oob:1;
345 /*!
346 * \brief TRUE if PRI B channels are always exclusively selected.
347 * \note Set from the "priexclusive" value read in from chan_dahdi.conf
348 */
349 unsigned int priexclusive:1;
350 /*!
351 * \brief TRUE if we will pulse dial.
352 * \note Set from the "pulsedial" value read in from chan_dahdi.conf
353 */
354 unsigned int pulse:1;
355 /*! \brief TRUE if a pulsed digit was detected. (Pulse dial phone detected) */
356 unsigned int pulsedial:1;
357 unsigned int restartpending:1; /*!< flag to ensure counted only once for restart */
358 /*!
359 * \brief TRUE if caller ID is restricted.
360 * \note Set but not used. Should be deleted. Redundant with permhidecallerid.
361 * \note Set from the "restrictcid" value read in from chan_dahdi.conf
362 */
363 unsigned int restrictcid:1;
364 /*!
365 * \brief TRUE if three way calling is enabled
366 * \note Set from the "threewaycalling" value read in from chan_dahdi.conf
367 */
368 unsigned int threewaycalling:1;
e1a1ae93
NA
369 /*!
370 * \brief TRUE if a three way dial tone should time out to silence
371 * \note Set from the "threewaysilenthold" value read in from chan_dahdi.conf
372 */
373 unsigned int threewaysilenthold:1;
83a871ea
RM
374 /*!
375 * \brief TRUE if call transfer is enabled
376 * \note For FXS ports (either direct analog or over T1/E1):
377 * Support flash-hook call transfer
378 * \note For digital ports using ISDN PRI protocols:
379 * Support switch-side transfer (called 2BCT, RLT or other names)
380 * \note Set from the "transfer" value read in from chan_dahdi.conf
381 */
382 unsigned int transfer:1;
383 /*!
384 * \brief TRUE if caller ID is used on this channel.
385 * \note PRI and SS7 spans will save caller ID from the networking peer.
386 * \note FXS ports will generate the caller ID spill.
387 * \note FXO ports will listen for the caller ID spill.
388 * \note Set from the "usecallerid" value read in from chan_dahdi.conf
389 */
390 unsigned int use_callerid:1;
391 /*!
392 * \brief TRUE if we will use the calling presentation setting
393 * from the Asterisk channel for outgoing calls.
394 * \note Only applies to PRI and SS7 channels.
395 * \note Set from the "usecallingpres" value read in from chan_dahdi.conf
396 */
397 unsigned int use_callingpres:1;
398 /*!
399 * \brief TRUE if distinctive rings are to be detected.
400 * \note For FXO lines
401 * \note Set indirectly from the "usedistinctiveringdetection" value read in from chan_dahdi.conf
402 */
403 unsigned int usedistinctiveringdetection:1;
404 /*!
405 * \brief TRUE if we should use the callerid from incoming call on dahdi transfer.
406 * \note Set from the "useincomingcalleridondahditransfer" value read in from chan_dahdi.conf
407 */
408 unsigned int dahditrcallerid:1;
409 /*!
410 * \brief TRUE if allowed to flash-transfer to busy channels.
411 * \note Set from the "transfertobusy" value read in from chan_dahdi.conf
412 */
413 unsigned int transfertobusy:1;
414 /*!
415 * \brief TRUE if the FXO port monitors for neon type MWI indications from the other end.
416 * \note Set if the "mwimonitor" value read in contains "neon" from chan_dahdi.conf
417 */
418 unsigned int mwimonitor_neon:1;
419 /*!
420 * \brief TRUE if the FXO port monitors for fsk type MWI indications from the other end.
421 * \note Set if the "mwimonitor" value read in contains "fsk" from chan_dahdi.conf
422 */
423 unsigned int mwimonitor_fsk:1;
424 /*!
425 * \brief TRUE if the FXO port monitors for rpas precursor to fsk MWI indications from the other end.
426 * \note RPAS - Ring Pulse Alert Signal
427 * \note Set if the "mwimonitor" value read in contains "rpas" from chan_dahdi.conf
428 */
429 unsigned int mwimonitor_rpas:1;
430 /*! \brief TRUE if an MWI monitor thread is currently active */
431 unsigned int mwimonitoractive:1;
432 /*! \brief TRUE if a MWI message sending thread is active */
433 unsigned int mwisendactive:1;
a3be6a45
NA
434 /*! \brief TRUE if a manual MWI override is active for a channel */
435 unsigned int mwioverride_active:1;
436 /*! \brief Manual MWI disposition (on/off) */
437 unsigned int mwioverride_disposition:1;
83a871ea
RM
438 /*!
439 * \brief TRUE if channel is out of reset and ready
0c896d8b 440 * \note Used by SS7. Otherwise set but not used.
83a871ea
RM
441 */
442 unsigned int inservice:1;
443 /*!
0c896d8b 444 * \brief Bitmask for the channel being locally blocked.
83a871ea 445 * \note Applies to SS7 and MFCR2 channels.
0c896d8b
RM
446 * \note For MFCR2 only the first bit is used - TRUE if blocked
447 * \note For SS7 two bits are used
448 * \note Bit 0 - TRUE if maintenance blocked
449 * \note Bit 1 - TRUE if hardware blocked
83a871ea 450 */
0c896d8b 451 unsigned int locallyblocked:2;
83a871ea 452 /*!
0c896d8b 453 * \brief Bitmask for the channel being remotely blocked. 1 maintenance, 2 blocked in hardware.
83a871ea 454 * \note Applies to SS7 and MFCR2 channels.
0c896d8b
RM
455 * \note For MFCR2 only the first bit is used - TRUE if blocked
456 * \note For SS7 two bits are used
457 * \note Bit 0 - TRUE if maintenance blocked
458 * \note Bit 1 - TRUE if hardware blocked
83a871ea 459 */
0c896d8b 460 unsigned int remotelyblocked:2;
83a871ea
RM
461 /*!
462 * \brief TRUE if the channel alarms will be managed also as Span ones
463 * \note Applies to all channels
464 */
465 unsigned int manages_span_alarms:1;
2127848d
RM
466 /*! \brief TRUE if hardware Rx gain set by Asterisk */
467 unsigned int hwrxgain_enabled;
468 /*! \brief TRUE if hardware Tx gain set by Asterisk */
469 unsigned int hwtxgain_enabled;
83a871ea
RM
470
471#if defined(HAVE_PRI)
472 struct sig_pri_span *pri;
473 int logicalspan;
474#endif /* defined(HAVE_PRI) */
475 /*!
476 * \brief TRUE if SMDI (Simplified Message Desk Interface) is enabled
477 * \note Set from the "usesmdi" value read in from chan_dahdi.conf
478 */
479 unsigned int use_smdi:1;
480 struct mwisend_info mwisend_data;
481 /*! \brief The SMDI interface to get SMDI messages from. */
482 struct ast_smdi_interface *smdi_iface;
483
484 /*! \brief Distinctive Ring data */
485 struct dahdi_distRings drings;
486
487 /*!
488 * \brief The configured context for incoming calls.
489 * \note The "context" string read in from chan_dahdi.conf
490 */
491 char context[AST_MAX_CONTEXT];
492 /*!
493 * \brief A description for the channel configuration
494 * \note The "description" string read in from chan_dahdi.conf
495 */
496 char description[32];
497 /*!
c7cc1b30 498 * \brief Default distinctive ring context.
83a871ea
RM
499 */
500 char defcontext[AST_MAX_CONTEXT];
501 /*! \brief Extension to use in the dialplan. */
502 char exten[AST_MAX_EXTENSION];
503 /*!
504 * \brief Language configured for calls.
505 * \note The "language" string read in from chan_dahdi.conf
506 */
507 char language[MAX_LANGUAGE];
508 /*!
509 * \brief The configured music-on-hold class to use for calls.
510 * \note The "musicclass" or "mohinterpret" or "musiconhold" string read in from chan_dahdi.conf
511 */
512 char mohinterpret[MAX_MUSICCLASS];
513 /*!
514 * \brief Suggested music-on-hold class for peer channel to use for calls.
515 * \note The "mohsuggest" string read in from chan_dahdi.conf
516 */
517 char mohsuggest[MAX_MUSICCLASS];
518 char parkinglot[AST_MAX_EXTENSION]; /*!< Parking lot for this channel */
519#if defined(HAVE_PRI) || defined(HAVE_SS7)
520 /*! \brief Automatic Number Identification number (Alternate PRI caller ID number) */
521 char cid_ani[AST_MAX_EXTENSION];
522#endif /* defined(HAVE_PRI) || defined(HAVE_SS7) */
523 /*! \brief Automatic Number Identification code from PRI */
524 int cid_ani2;
525 /*! \brief Caller ID number from an incoming call. */
526 char cid_num[AST_MAX_EXTENSION];
527 /*!
528 * \brief Caller ID tag from incoming call
529 * \note the "cid_tag" string read in from chan_dahdi.conf
530 */
531 char cid_tag[AST_MAX_EXTENSION];
532 /*! \brief Caller ID Q.931 TON/NPI field values. Set by PRI. Zero otherwise. */
533 int cid_ton;
534 /*! \brief Caller ID name from an incoming call. */
535 char cid_name[AST_MAX_EXTENSION];
536 /*! \brief Caller ID subaddress from an incoming call. */
537 char cid_subaddr[AST_MAX_EXTENSION];
538 char *origcid_num; /*!< malloced original callerid */
539 char *origcid_name; /*!< malloced original callerid */
540 /*! \brief Call waiting number. */
541 char callwait_num[AST_MAX_EXTENSION];
542 /*! \brief Call waiting name. */
543 char callwait_name[AST_MAX_EXTENSION];
544 /*! \brief Redirecting Directory Number Information Service (RDNIS) number */
545 char rdnis[AST_MAX_EXTENSION];
546 /*! \brief Dialed Number Identifier */
547 char dnid[AST_MAX_EXTENSION];
548 /*!
549 * \brief Bitmapped groups this belongs to.
550 * \note The "group" bitmapped group string read in from chan_dahdi.conf
551 */
552 ast_group_t group;
553 /*! \brief Default call PCM encoding format: DAHDI_LAW_ALAW or DAHDI_LAW_MULAW. */
554 int law_default;
555 /*! \brief Active PCM encoding format: DAHDI_LAW_ALAW or DAHDI_LAW_MULAW */
556 int law;
557 int confno; /*!< Our conference */
558 int confusers; /*!< Who is using our conference */
559 int propconfno; /*!< Propagated conference number */
560 /*!
561 * \brief Bitmapped call groups this belongs to.
562 * \note The "callgroup" bitmapped group string read in from chan_dahdi.conf
563 */
564 ast_group_t callgroup;
565 /*!
566 * \brief Bitmapped pickup groups this belongs to.
567 * \note The "pickupgroup" bitmapped group string read in from chan_dahdi.conf
568 */
569 ast_group_t pickupgroup;
570 /*!
571 * \brief Named call groups this belongs to.
572 * \note The "namedcallgroup" string read in from chan_dahdi.conf
573 */
574 struct ast_namedgroups *named_callgroups;
575 /*!
576 * \brief Named pickup groups this belongs to.
577 * \note The "namedpickupgroup" string read in from chan_dahdi.conf
578 */
579 struct ast_namedgroups *named_pickupgroups;
580 /*!
581 * \brief Channel variable list with associated values to set when a channel is created.
582 * \note The "setvar" strings read in from chan_dahdi.conf
583 */
584 struct ast_variable *vars;
585 int channel; /*!< Channel Number */
586 int span; /*!< Span number */
587 time_t guardtime; /*!< Must wait this much time before using for new call */
588 int cid_signalling; /*!< CID signalling type bell202 or v23 */
589 int cid_start; /*!< CID start indicator, polarity or ring or DTMF without warning event */
590 int dtmfcid_holdoff_state; /*!< State indicator that allows for line to settle before checking for dtmf energy */
591 struct timeval dtmfcid_delay; /*!< Time value used for allow line to settle */
592 int callingpres; /*!< The value of calling presentation that we're going to use when placing a PRI call */
593 int callwaitingrepeat; /*!< How many samples to wait before repeating call waiting */
594 int cidcwexpire; /*!< When to stop waiting for CID/CW CAS response (In samples) */
595 int cid_suppress_expire; /*!< How many samples to suppress after a CID spill. */
596 /*! \brief Analog caller ID waveform sample buffer */
597 unsigned char *cidspill;
598 /*! \brief Position in the cidspill buffer to send out next. */
599 int cidpos;
600 /*! \brief Length of the cidspill buffer containing samples. */
601 int cidlen;
602 /*! \brief Ring timeout timer?? */
603 int ringt;
604 /*!
605 * \brief Ring timeout base.
606 * \note Value computed indirectly from "ringtimeout" read in from chan_dahdi.conf
607 */
608 int ringt_base;
609 /*!
610 * \brief Number of most significant digits/characters to strip from the dialed number.
611 * \note Feature is deprecated. Use dialplan logic.
612 * \note The characters are stripped before the PRI TON/NPI prefix
613 * characters are processed.
614 */
615 int stripmsd;
616 /*!
617 * \brief TRUE if Call Waiting (CW) CPE Alert Signal (CAS) is being sent.
618 * \note
619 * After CAS is sent, the call waiting caller id will be sent if the phone
620 * gives a positive reply.
621 */
622 int callwaitcas;
623 /*! \brief Number of call waiting rings. */
624 int callwaitrings;
625 /*! \brief Echo cancel parameters. */
626 struct {
627 struct dahdi_echocanparams head;
628 struct dahdi_echocanparam params[DAHDI_MAX_ECHOCANPARAMS];
629 } echocancel;
630 /*!
631 * \brief Echo training time. 0 = disabled
632 * \note Set from the "echotraining" value read in from chan_dahdi.conf
633 */
634 int echotraining;
635 /*! \brief Filled with 'w'. XXX Purpose?? */
636 char echorest[20];
637 /*!
638 * \brief Number of times to see "busy" tone before hanging up.
639 * \note Set from the "busycount" value read in from chan_dahdi.conf
640 */
641 int busycount;
642 /*!
643 * \brief Busy cadence pattern description.
644 * \note Set from the "busypattern" value read from chan_dahdi.conf
645 */
646 struct ast_dsp_busy_pattern busy_cadence;
647 /*!
648 * \brief Bitmapped call progress detection flags. CALLPROGRESS_xxx values.
649 * \note Bits set from the "callprogress" and "faxdetect" values read in from chan_dahdi.conf
650 */
651 int callprogress;
652 /*!
653 * \brief Number of milliseconds to wait for dialtone.
654 * \note Set from the "waitfordialtone" value read in from chan_dahdi.conf
655 */
656 int waitfordialtone;
657 /*!
658 * \brief Number of frames to watch for dialtone in incoming calls
659 * \note Set from the "dialtone_detect" value read in from chan_dahdi.conf
660 */
661 int dialtone_detect;
662 int dialtone_scanning_time_elapsed; /*!< Amount of audio scanned for dialtone, in frames */
0d1744e1
RM
663 /*!
664 * \brief The number of seconds into call to disable fax detection. (0 = disabled)
665 * \note Set from the "faxdetect_timeout" value read in from chan_dahdi.conf
666 */
667 unsigned int faxdetect_timeout;
63015314
TC
668 /*!
669 * \brief Time (ms) to detect first digit (in an analog phone)
670 * \note Set from the "firstdigit_timeout" value read in from chan_dahdi.conf
671 */
672 int firstdigit_timeout;
673 /*!
674 * \brief Time (ms) to detect following digits (in an analog phone)
675 * \note Set from the "interdigit_timeout" value read in from chan_dahdi.conf
676 */
677 int interdigit_timeout;
678 /*!
679 * \brief Time (ms) to wait, in case of ambiguous match (in an analog phone)
680 * \note Set from the "matchdigit_timeout" value read in from chan_dahdi.conf
681 */
682 int matchdigit_timeout;
83a871ea
RM
683 struct timeval waitingfordt; /*!< Time we started waiting for dialtone */
684 struct timeval flashtime; /*!< Last flash-hook time */
685 /*! \brief Opaque DSP configuration structure. */
686 struct ast_dsp *dsp;
687 /*! \brief DAHDI dial operation command struct for ioctl() call. */
688 struct dahdi_dialoperation dop;
689 int whichwink; /*!< SIG_FEATDMF_TA Which wink are we on? */
690 /*! \brief Second part of SIG_FEATDMF_TA wink operation. */
691 char finaldial[64];
692 char accountcode[AST_MAX_ACCOUNT_CODE]; /*!< Account code */
693 int amaflags; /*!< AMA Flags */
694 struct tdd_state *tdd; /*!< TDD flag */
695 /*! \brief Accumulated call forwarding number. */
696 char call_forward[AST_MAX_EXTENSION];
697 /*!
698 * \brief Voice mailbox location.
699 * \note Set from the "mailbox" string read in from chan_dahdi.conf
700 */
e4803bbd 701 char mailbox[AST_MAX_MAILBOX_UNIQUEID];
83a871ea 702 /*! \brief Opaque event subscription parameters for message waiting indication support. */
9637e1df 703 struct ast_mwi_subscriber *mwi_event_sub;
83a871ea
RM
704 /*! \brief Delayed dialing for E911. Overlap digits for ISDN. */
705 char dialdest[256];
706#ifdef HAVE_DAHDI_LINEREVERSE_VMWI
707 struct dahdi_vmwi_info mwisend_setting; /*!< Which VMWI methods to use */
708 unsigned int mwisend_fsk: 1; /*! Variable for enabling FSK MWI handling in chan_dahdi */
709 unsigned int mwisend_rpas:1; /*! Variable for enabling Ring Pulse Alert before MWI FSK Spill */
710#endif
711 int distinctivering; /*!< Which distinctivering to use */
712 int dtmfrelax; /*!< whether to run in relaxed DTMF mode */
713 /*! \brief Holding place for event injected from outside normal operation. */
714 int fake_event;
715 /*!
716 * \brief Minimal time period (ms) between the answer polarity
717 * switch and hangup polarity switch.
718 */
719 int polarityonanswerdelay;
720 /*! \brief Start delay time if polarityonanswerdelay is nonzero. */
721 struct timeval polaritydelaytv;
722 /*!
723 * \brief Send caller ID on FXS after this many rings. Set to 1 for US.
724 * \note Set from the "sendcalleridafter" value read in from chan_dahdi.conf
725 */
726 int sendcalleridafter;
727 /*! \brief Current line interface polarity. POLARITY_IDLE, POLARITY_REV */
728 int polarity;
729 /*! \brief DSP feature flags: DSP_FEATURE_xxx */
730 int dsp_features;
731#if defined(HAVE_SS7)
732 /*! \brief SS7 control parameters */
733 struct sig_ss7_linkset *ss7;
734#endif /* defined(HAVE_SS7) */
735#if defined(HAVE_OPENR2)
736 struct dahdi_mfcr2 *mfcr2;
737 openr2_chan_t *r2chan;
738 openr2_calling_party_category_t mfcr2_recvd_category;
739 openr2_calling_party_category_t mfcr2_category;
740 int mfcr2_dnis_index;
741 int mfcr2_ani_index;
bdd785d3
KH
742 unsigned int mfcr2call:1;
743 unsigned int mfcr2_answer_pending:1;
744 unsigned int mfcr2_charge_calls:1;
745 unsigned int mfcr2_allow_collect_calls:1;
746 unsigned int mfcr2_forced_release:1;
747 unsigned int mfcr2_dnis_matched:1;
748 unsigned int mfcr2_call_accepted:1;
749 unsigned int mfcr2_accept_on_offer:1;
750 unsigned int mfcr2_progress_sent:1;
83a871ea
RM
751#endif /* defined(HAVE_OPENR2) */
752 /*! \brief DTMF digit in progress. 0 when no digit in progress. */
753 char begindigit;
754 /*! \brief TRUE if confrence is muted. */
755 int muting;
756 void *sig_pvt;
757 struct ast_cc_config_params *cc_params;
758 /* DAHDI channel names may differ greatly from the
759 * string that was provided to an app such as Dial. We
760 * need to save the original string passed to dahdi_request
761 * for call completion purposes. This way, we can replicate
762 * the original dialed string later.
763 */
764 char dialstring[AST_CHANNEL_NAME];
765};
766
767
768/* Analog signaling */
769#define SIG_EM DAHDI_SIG_EM
770#define SIG_EMWINK (0x0100000 | DAHDI_SIG_EM)
771#define SIG_FEATD (0x0200000 | DAHDI_SIG_EM)
772#define SIG_FEATDMF (0x0400000 | DAHDI_SIG_EM)
773#define SIG_FEATB (0x0800000 | DAHDI_SIG_EM)
774#define SIG_E911 (0x1000000 | DAHDI_SIG_EM)
775#define SIG_FEATDMF_TA (0x2000000 | DAHDI_SIG_EM)
776#define SIG_FGC_CAMA (0x4000000 | DAHDI_SIG_EM)
777#define SIG_FGC_CAMAMF (0x8000000 | DAHDI_SIG_EM)
778#define SIG_FXSLS DAHDI_SIG_FXSLS
779#define SIG_FXSGS DAHDI_SIG_FXSGS
780#define SIG_FXSKS DAHDI_SIG_FXSKS
781#define SIG_FXOLS DAHDI_SIG_FXOLS
782#define SIG_FXOGS DAHDI_SIG_FXOGS
783#define SIG_FXOKS DAHDI_SIG_FXOKS
784#define SIG_SF DAHDI_SIG_SF
785#define SIG_SFWINK (0x0100000 | DAHDI_SIG_SF)
786#define SIG_SF_FEATD (0x0200000 | DAHDI_SIG_SF)
787#define SIG_SF_FEATDMF (0x0400000 | DAHDI_SIG_SF)
788#define SIG_SF_FEATB (0x0800000 | DAHDI_SIG_SF)
789#define SIG_EM_E1 DAHDI_SIG_EM_E1
790
791/* PRI signaling */
792#define SIG_PRI DAHDI_SIG_CLEAR
793#define SIG_BRI (0x2000000 | DAHDI_SIG_CLEAR)
794#define SIG_BRI_PTMP (0X4000000 | DAHDI_SIG_CLEAR)
795
796/* SS7 signaling */
797#define SIG_SS7 (0x1000000 | DAHDI_SIG_CLEAR)
798
799/* MFC/R2 signaling */
800#define SIG_MFCR2 DAHDI_SIG_CAS
801
802
803#define SIG_PRI_LIB_HANDLE_CASES \
804 SIG_PRI: \
805 case SIG_BRI: \
806 case SIG_BRI_PTMP
807
808/*!
809 * \internal
810 * \brief Determine if sig_pri handles the signaling.
811 * \since 1.8
812 *
813 * \param signaling Signaling to determine if is for sig_pri.
814 *
815 * \return TRUE if the signaling is for sig_pri.
816 */
817static inline int dahdi_sig_pri_lib_handles(int signaling)
818{
819 int handles;
820
821 switch (signaling) {
822 case SIG_PRI_LIB_HANDLE_CASES:
823 handles = 1;
824 break;
825 default:
826 handles = 0;
827 break;
828 }
829
830 return handles;
831}
832
b4dd4ffb 833static inline int dahdi_analog_lib_handles(int signalling, int radio, int oprmode)
83a871ea
RM
834{
835 switch (signalling) {
836 case SIG_FXOLS:
837 case SIG_FXOGS:
838 case SIG_FXOKS:
839 case SIG_FXSLS:
840 case SIG_FXSGS:
841 case SIG_FXSKS:
842 case SIG_EMWINK:
843 case SIG_EM:
844 case SIG_EM_E1:
845 case SIG_FEATD:
846 case SIG_FEATDMF:
847 case SIG_E911:
848 case SIG_FGC_CAMA:
849 case SIG_FGC_CAMAMF:
850 case SIG_FEATB:
851 case SIG_SFWINK:
852 case SIG_SF:
853 case SIG_SF_FEATD:
854 case SIG_SF_FEATDMF:
855 case SIG_FEATDMF_TA:
856 case SIG_SF_FEATB:
857 break;
858 default:
859 /* The rest of the function should cover the remainder of signalling types */
860 return 0;
861 }
862
863 if (radio) {
864 return 0;
865 }
866
867 if (oprmode) {
868 return 0;
869 }
870
871 return 1;
872}
873
874#define dahdi_get_index(ast, p, nullok) _dahdi_get_index(ast, p, nullok, __PRETTY_FUNCTION__, __LINE__)
875int _dahdi_get_index(struct ast_channel *ast, struct dahdi_pvt *p, int nullok, const char *fname, unsigned long line);
876
b4dd4ffb
RM
877void dahdi_dtmf_detect_disable(struct dahdi_pvt *p);
878void dahdi_dtmf_detect_enable(struct dahdi_pvt *p);
83a871ea 879
b4dd4ffb
RM
880void dahdi_ec_enable(struct dahdi_pvt *p);
881void dahdi_ec_disable(struct dahdi_pvt *p);
83a871ea 882
b4dd4ffb
RM
883void dahdi_conf_update(struct dahdi_pvt *p);
884void dahdi_master_slave_link(struct dahdi_pvt *slave, struct dahdi_pvt *master);
885void dahdi_master_slave_unlink(struct dahdi_pvt *slave, struct dahdi_pvt *master, int needlock);
83a871ea
RM
886
887/* ------------------------------------------------------------------- */
888
889#if defined(__cplusplus) || defined(c_plusplus)
890}
891#endif
892
893#endif /* _ASTERISK_CHAN_DAHDI_H */