Debian Codegraph @

channels/chan_dahdi.h

raw symbols SCIP
1 /*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2013 Digium, Inc.
5 *
6 * Richard Mudgett <[email protected]>
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 <[email protected]>
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"
41 #include "asterisk/app.h"
42 #include "asterisk/mwi.h"
43
44 #if defined(__cplusplus) || defined(c_plusplus)
45 extern "C" {
46 #endif
47
48 /* ------------------------------------------------------------------- */
49
50 #if defined(HAVE_PRI)
51 struct sig_pri_span;
52 #endif /* defined(HAVE_PRI) */
53 #if defined(HAVE_SS7)
54 struct 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
62 struct distRingData {
63 int ring[3];
64 int range;
65 };
66 struct ringContextData {
67 char contextData[AST_MAX_CONTEXT];
68 };
69 struct dahdi_distRings {
70 struct distRingData ringnum[3];
71 struct ringContextData ringContext[3];
72 };
73
74
75 extern const char * const subnames[];
76
77 struct 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 */
100 typedef 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
110 struct mwisend_info {
111 struct timeval pause;
112 mwisend_states mwisend_current;
113 };
114
115 /*! Specify the lists dahdi_pvt can be put in. */
116 enum 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
124 struct 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;
149 enum analog_dialmode permdialmode; /*!< Dialing Modes Allowed (Pulse/Tone). Used for reading in chan_dahdi.conf only, the perm setting pair is in sig_analog */
150 int outsigmod; /*!< Outbound Signalling style (modifier) */
151 int oprmode; /*!< "Operator Services" mode */
152 struct dahdi_pvt *oprpeer; /*!< "Operator Services" peer tech_pvt ptr */
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;
157 /*! \brief Amount of gain to increase during caller id */
158 float cid_rxgain;
159 /*! \brief Software Rx gain set by chan_dahdi.conf */
160 float rxgain;
161 /*! \brief Software Tx gain set by chan_dahdi.conf */
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;
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;
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;
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;
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;
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;
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;
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;
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 Call Waiting Deluxe options should be available
337 */
338 unsigned int callwaitingdeluxe:1;
339 /*!
340 * \brief TRUE if the outgoing caller ID is blocked/restricted/hidden.
341 * \note Set from the "hidecallerid" value read in from chan_dahdi.conf
342 */
343 unsigned int permhidecallerid:1;
344 /*!
345 * \brief TRUE if PRI congestion/busy indications are sent out-of-band.
346 * \note Set from the "priindication" value read in from chan_dahdi.conf
347 */
348 unsigned int priindication_oob:1;
349 /*!
350 * \brief TRUE if PRI B channels are always exclusively selected.
351 * \note Set from the "priexclusive" value read in from chan_dahdi.conf
352 */
353 unsigned int priexclusive:1;
354 /*!
355 * \brief TRUE if we will pulse dial.
356 * \note Set from the "pulsedial" value read in from chan_dahdi.conf
357 */
358 unsigned int pulse:1;
359 /*! \brief TRUE if a pulsed digit was detected. (Pulse dial phone detected) */
360 unsigned int pulsedial:1;
361 unsigned int restartpending:1; /*!< flag to ensure counted only once for restart */
362 /*!
363 * \brief TRUE if caller ID is restricted.
364 * \note Set but not used. Should be deleted. Redundant with permhidecallerid.
365 * \note Set from the "restrictcid" value read in from chan_dahdi.conf
366 */
367 unsigned int restrictcid:1;
368 /*!
369 * \brief TRUE if three way calling is enabled
370 * \note Set from the "threewaycalling" value read in from chan_dahdi.conf
371 */
372 unsigned int threewaycalling:1;
373 /*!
374 * \brief TRUE if a three way dial tone should time out to silence
375 * \note Set from the "threewaysilenthold" value read in from chan_dahdi.conf
376 */
377 unsigned int threewaysilenthold:1;
378 /*!
379 * \brief TRUE if call transfer is enabled
380 * \note For FXS ports (either direct analog or over T1/E1):
381 * Support flash-hook call transfer
382 * \note For digital ports using ISDN PRI protocols:
383 * Support switch-side transfer (called 2BCT, RLT or other names)
384 * \note Set from the "transfer" value read in from chan_dahdi.conf
385 */
386 unsigned int transfer:1;
387 /*!
388 * \brief TRUE if caller ID is used on this channel.
389 * \note PRI and SS7 spans will save caller ID from the networking peer.
390 * \note FXS ports will generate the caller ID spill.
391 * \note FXO ports will listen for the caller ID spill.
392 * \note Set from the "usecallerid" value read in from chan_dahdi.conf
393 */
394 unsigned int use_callerid:1;
395 /*!
396 * \brief TRUE if we will use the calling presentation setting
397 * from the Asterisk channel for outgoing calls.
398 * \note Only applies to PRI and SS7 channels.
399 * \note Set from the "usecallingpres" value read in from chan_dahdi.conf
400 */
401 unsigned int use_callingpres:1;
402 /*!
403 * \brief TRUE if distinctive rings are to be detected.
404 * \note For FXO lines
405 * \note Set indirectly from the "usedistinctiveringdetection" value read in from chan_dahdi.conf
406 */
407 unsigned int usedistinctiveringdetection:1;
408 /*!
409 * \brief TRUE if we should use the callerid from incoming call on dahdi transfer.
410 * \note Set from the "useincomingcalleridondahditransfer" value read in from chan_dahdi.conf
411 */
412 unsigned int dahditrcallerid:1;
413 /*!
414 * \brief TRUE if allowed to flash-transfer to busy channels.
415 * \note Set from the "transfertobusy" value read in from chan_dahdi.conf
416 */
417 unsigned int transfertobusy:1;
418 /*!
419 * \brief TRUE if the FXO port monitors for neon type MWI indications from the other end.
420 * \note Set if the "mwimonitor" value read in contains "neon" from chan_dahdi.conf
421 */
422 unsigned int mwimonitor_neon:1;
423 /*!
424 * \brief TRUE if the FXO port monitors for fsk type MWI indications from the other end.
425 * \note Set if the "mwimonitor" value read in contains "fsk" from chan_dahdi.conf
426 */
427 unsigned int mwimonitor_fsk:1;
428 /*!
429 * \brief TRUE if the FXO port monitors for rpas precursor to fsk MWI indications from the other end.
430 * \note RPAS - Ring Pulse Alert Signal
431 * \note Set if the "mwimonitor" value read in contains "rpas" from chan_dahdi.conf
432 */
433 unsigned int mwimonitor_rpas:1;
434 /*! \brief TRUE if an MWI monitor thread is currently active */
435 unsigned int mwimonitoractive:1;
436 /*! \brief TRUE if a MWI message sending thread is active */
437 unsigned int mwisendactive:1;
438 /*! \brief TRUE if a manual MWI override is active for a channel */
439 unsigned int mwioverride_active:1;
440 /*! \brief Manual MWI disposition (on/off) */
441 unsigned int mwioverride_disposition:1;
442 /*!
443 * \brief TRUE if channel is out of reset and ready
444 * \note Used by SS7. Otherwise set but not used.
445 */
446 unsigned int inservice:1;
447 /*! *\brief TRUE if last number redial enabled */
448 unsigned int lastnumredial:1;
449 /*!
450 * \brief Bitmask for the channel being locally blocked.
451 * \note Applies to SS7 and MFCR2 channels.
452 * \note For MFCR2 only the first bit is used - TRUE if blocked
453 * \note For SS7 two bits are used
454 * \note Bit 0 - TRUE if maintenance blocked
455 * \note Bit 1 - TRUE if hardware blocked
456 */
457 unsigned int locallyblocked:2;
458 /*!
459 * \brief Bitmask for the channel being remotely blocked. 1 maintenance, 2 blocked in hardware.
460 * \note Applies to SS7 and MFCR2 channels.
461 * \note For MFCR2 only the first bit is used - TRUE if blocked
462 * \note For SS7 two bits are used
463 * \note Bit 0 - TRUE if maintenance blocked
464 * \note Bit 1 - TRUE if hardware blocked
465 */
466 unsigned int remotelyblocked:2;
467 /*!
468 * \brief TRUE if the channel alarms will be managed also as Span ones
469 * \note Applies to all channels
470 */
471 unsigned int manages_span_alarms:1;
472 /*! \brief TRUE if hardware Rx gain set by Asterisk */
473 unsigned int hwrxgain_enabled;
474 /*! \brief TRUE if hardware Tx gain set by Asterisk */
475 unsigned int hwtxgain_enabled;
476
477 #if defined(HAVE_PRI)
478 struct sig_pri_span *pri;
479 int logicalspan;
480 #endif /* defined(HAVE_PRI) */
481 /*!
482 * \brief TRUE if SMDI (Simplified Message Desk Interface) is enabled
483 * \note Set from the "usesmdi" value read in from chan_dahdi.conf
484 */
485 unsigned int use_smdi:1;
486 struct mwisend_info mwisend_data;
487 /*! \brief The SMDI interface to get SMDI messages from. */
488 struct ast_smdi_interface *smdi_iface;
489
490 /*! \brief Distinctive Ring data */
491 struct dahdi_distRings drings;
492
493 /*!
494 * \brief The configured context for incoming calls.
495 * \note The "context" string read in from chan_dahdi.conf
496 */
497 char context[AST_MAX_CONTEXT];
498 /*!
499 * \brief A description for the channel configuration
500 * \note The "description" string read in from chan_dahdi.conf
501 */
502 char description[32];
503 /*!
504 * \brief Default distinctive ring context.
505 */
506 char defcontext[AST_MAX_CONTEXT];
507 /*! \brief Extension to use in the dialplan. */
508 char exten[AST_MAX_EXTENSION];
509 /*!
510 * \brief Language configured for calls.
511 * \note The "language" string read in from chan_dahdi.conf
512 */
513 char language[MAX_LANGUAGE];
514 /*!
515 * \brief The configured music-on-hold class to use for calls.
516 * \note The "musicclass" or "mohinterpret" or "musiconhold" string read in from chan_dahdi.conf
517 */
518 char mohinterpret[MAX_MUSICCLASS];
519 /*!
520 * \brief Suggested music-on-hold class for peer channel to use for calls.
521 * \note The "mohsuggest" string read in from chan_dahdi.conf
522 */
523 char mohsuggest[MAX_MUSICCLASS];
524 char parkinglot[AST_MAX_EXTENSION]; /*!< Parking lot for this channel */
525 #if defined(HAVE_PRI) || defined(HAVE_SS7)
526 /*! \brief Automatic Number Identification number (Alternate PRI caller ID number) */
527 char cid_ani[AST_MAX_EXTENSION];
528 #endif /* defined(HAVE_PRI) || defined(HAVE_SS7) */
529 /*! \brief Automatic Number Identification code from PRI */
530 int cid_ani2;
531 /*! \brief Caller ID number from an incoming call. */
532 char cid_num[AST_MAX_EXTENSION];
533 /*!
534 * \brief Caller ID tag from incoming call
535 * \note the "cid_tag" string read in from chan_dahdi.conf
536 */
537 char cid_tag[AST_MAX_EXTENSION];
538 /*! \brief Caller ID Q.931 TON/NPI field values. Set by PRI. Zero otherwise. */
539 int cid_ton;
540 /*! \brief Caller ID name from an incoming call. */
541 char cid_name[AST_MAX_EXTENSION];
542 /*! \brief Caller ID subaddress from an incoming call. */
543 char cid_subaddr[AST_MAX_EXTENSION];
544 char *origcid_num; /*!< malloced original callerid */
545 char *origcid_name; /*!< malloced original callerid */
546 /*! \brief Call waiting number. */
547 char callwait_num[AST_MAX_EXTENSION];
548 /*! \brief Call waiting name. */
549 char callwait_name[AST_MAX_EXTENSION];
550 /*! \brief Redirecting Directory Number Information Service (RDNIS) number */
551 char rdnis[AST_MAX_EXTENSION];
552 /*! \brief Dialed Number Identifier */
553 char dnid[AST_MAX_EXTENSION];
554 /*!
555 * \brief Bitmapped groups this belongs to.
556 * \note The "group" bitmapped group string read in from chan_dahdi.conf
557 */
558 ast_group_t group;
559 /*! \brief Default call PCM encoding format: DAHDI_LAW_ALAW or DAHDI_LAW_MULAW. */
560 int law_default;
561 /*! \brief Active PCM encoding format: DAHDI_LAW_ALAW or DAHDI_LAW_MULAW */
562 int law;
563 int confno; /*!< Our conference */
564 int confusers; /*!< Who is using our conference */
565 int propconfno; /*!< Propagated conference number */
566 /*!
567 * \brief Bitmapped call groups this belongs to.
568 * \note The "callgroup" bitmapped group string read in from chan_dahdi.conf
569 */
570 ast_group_t callgroup;
571 /*!
572 * \brief Bitmapped pickup groups this belongs to.
573 * \note The "pickupgroup" bitmapped group string read in from chan_dahdi.conf
574 */
575 ast_group_t pickupgroup;
576 /*!
577 * \brief Named call groups this belongs to.
578 * \note The "namedcallgroup" string read in from chan_dahdi.conf
579 */
580 struct ast_namedgroups *named_callgroups;
581 /*!
582 * \brief Named pickup groups this belongs to.
583 * \note The "namedpickupgroup" string read in from chan_dahdi.conf
584 */
585 struct ast_namedgroups *named_pickupgroups;
586 /*!
587 * \brief Channel variable list with associated values to set when a channel is created.
588 * \note The "setvar" strings read in from chan_dahdi.conf
589 */
590 struct ast_variable *vars;
591 int channel; /*!< Channel Number */
592 int span; /*!< Span number */
593 time_t guardtime; /*!< Must wait this much time before using for new call */
594 int cid_signalling; /*!< CID signalling type bell202 or v23 */
595 int cid_start; /*!< CID start indicator, polarity or ring or DTMF without warning event */
596 int dtmfcid_holdoff_state; /*!< State indicator that allows for line to settle before checking for dtmf energy */
597 struct timeval dtmfcid_delay; /*!< Time value used for allow line to settle */
598 int callingpres; /*!< The value of calling presentation that we're going to use when placing a PRI call */
599 int callwaitingrepeat; /*!< How many samples to wait before repeating call waiting */
600 int cidcwexpire; /*!< When to stop waiting for CID/CW CAS response (In samples) */
601 int cid_suppress_expire; /*!< How many samples to suppress after a CID spill. */
602 /*! \brief Analog caller ID waveform sample buffer */
603 unsigned char *cidspill;
604 /*! \brief Position in the cidspill buffer to send out next. */
605 int cidpos;
606 /*! \brief Length of the cidspill buffer containing samples. */
607 int cidlen;
608 /*! \brief Ring timeout timer?? */
609 int ringt;
610 /*!
611 * \brief Ring timeout base.
612 * \note Value computed indirectly from "ringtimeout" read in from chan_dahdi.conf
613 */
614 int ringt_base;
615 /*!
616 * \brief Number of most significant digits/characters to strip from the dialed number.
617 * \note Feature is deprecated. Use dialplan logic.
618 * \note The characters are stripped before the PRI TON/NPI prefix
619 * characters are processed.
620 */
621 int stripmsd;
622 /*!
623 * \brief TRUE if Call Waiting (CW) CPE Alert Signal (CAS) is being sent.
624 * \note
625 * After CAS is sent, the call waiting caller id will be sent if the phone
626 * gives a positive reply.
627 */
628 int callwaitcas;
629 /*! \brief Number of call waiting rings. */
630 int callwaitrings;
631 /*! \brief Echo cancel parameters. */
632 struct {
633 struct dahdi_echocanparams head;
634 struct dahdi_echocanparam params[DAHDI_MAX_ECHOCANPARAMS];
635 } echocancel;
636 /*!
637 * \brief Echo training time. 0 = disabled
638 * \note Set from the "echotraining" value read in from chan_dahdi.conf
639 */
640 int echotraining;
641 /*! \brief Filled with 'w'. XXX Purpose?? */
642 char echorest[20];
643 /*!
644 * \brief Number of times to see "busy" tone before hanging up.
645 * \note Set from the "busycount" value read in from chan_dahdi.conf
646 */
647 int busycount;
648 /*!
649 * \brief Busy cadence pattern description.
650 * \note Set from the "busypattern" value read from chan_dahdi.conf
651 */
652 struct ast_dsp_busy_pattern busy_cadence;
653 /*!
654 * \brief Bitmapped call progress detection flags. CALLPROGRESS_xxx values.
655 * \note Bits set from the "callprogress" and "faxdetect" values read in from chan_dahdi.conf
656 */
657 int callprogress;
658 /*!
659 * \brief Number of milliseconds to wait for dialtone.
660 * \note Set from the "waitfordialtone" value read in from chan_dahdi.conf
661 */
662 int waitfordialtone;
663 /*!
664 * \brief Transient variable. Same as waitfordialtone, but temporarily set for a specific call, rather than permanently for the channel.
665 */
666 int waitfordialtonetemp;
667 /*!
668 * \brief Transient variable. Stored off waitfordialtone duration at runtime.
669 */
670 int waitfordialtoneduration;
671 /*!
672 * \brief Number of frames to watch for dialtone in incoming calls
673 * \note Set from the "dialtone_detect" value read in from chan_dahdi.conf
674 */
675 int dialtone_detect;
676 int dialtone_scanning_time_elapsed; /*!< Amount of audio scanned for dialtone, in frames */
677 /*!
678 * \brief The number of seconds into call to disable fax detection. (0 = disabled)
679 * \note Set from the "faxdetect_timeout" value read in from chan_dahdi.conf
680 */
681 unsigned int faxdetect_timeout;
682 /*!
683 * \brief Time (ms) to detect first digit (in an analog phone)
684 * \note Set from the "firstdigit_timeout" value read in from chan_dahdi.conf
685 */
686 int firstdigit_timeout;
687 /*!
688 * \brief Time (ms) to detect following digits (in an analog phone)
689 * \note Set from the "interdigit_timeout" value read in from chan_dahdi.conf
690 */
691 int interdigit_timeout;
692 /*!
693 * \brief Time (ms) to wait, in case of ambiguous match (in an analog phone)
694 * \note Set from the "matchdigit_timeout" value read in from chan_dahdi.conf
695 */
696 int matchdigit_timeout;
697 struct timeval waitingfordt; /*!< Time we started waiting for dialtone */
698 struct timeval flashtime; /*!< Last flash-hook time */
699 /*! \brief Opaque DSP configuration structure. */
700 struct ast_dsp *dsp;
701 /*! \brief DAHDI dial operation command struct for ioctl() call. */
702 struct dahdi_dialoperation dop;
703 int whichwink; /*!< SIG_FEATDMF_TA Which wink are we on? */
704 /*! \brief Second part of SIG_FEATDMF_TA wink operation. */
705 char finaldial[64];
706 char accountcode[AST_MAX_ACCOUNT_CODE]; /*!< Account code */
707 int amaflags; /*!< AMA Flags */
708 struct tdd_state *tdd; /*!< TDD flag */
709 /*! \brief Accumulated call forwarding number. */
710 char call_forward[AST_MAX_EXTENSION];
711 /*!
712 * \brief Voice mailbox location.
713 * \note Set from the "mailbox" string read in from chan_dahdi.conf
714 */
715 char mailbox[AST_MAX_MAILBOX_UNIQUEID];
716 /*! \brief Opaque event subscription parameters for message waiting indication support. */
717 struct ast_mwi_subscriber *mwi_event_sub;
718 /*! \brief Delayed dialing for E911. Overlap digits for ISDN. */
719 char dialdest[256];
720 #ifdef HAVE_DAHDI_LINEREVERSE_VMWI
721 struct dahdi_vmwi_info mwisend_setting; /*!< Which VMWI methods to use */
722 unsigned int mwisend_fsk: 1; /*! Variable for enabling FSK MWI handling in chan_dahdi */
723 unsigned int mwisend_rpas:1; /*! Variable for enabling Ring Pulse Alert before MWI FSK Spill */
724 #endif
725 int distinctivering; /*!< Which distinctivering to use */
726 int dtmfrelax; /*!< whether to run in relaxed DTMF mode */
727 /*! \brief Holding place for event injected from outside normal operation. */
728 int fake_event;
729 /*!
730 * \brief Minimal time period (ms) between the answer polarity
731 * switch and hangup polarity switch.
732 */
733 int polarityonanswerdelay;
734 /*! \brief Start delay time if polarityonanswerdelay is nonzero. */
735 struct timeval polaritydelaytv;
736 /*!
737 * \brief Send caller ID on FXS after this many rings. Set to 1 for US.
738 * \note Set from the "sendcalleridafter" value read in from chan_dahdi.conf
739 */
740 int sendcalleridafter;
741 /*! \brief Current line interface polarity. POLARITY_IDLE, POLARITY_REV */
742 int polarity;
743 /*! \brief DSP feature flags: DSP_FEATURE_xxx */
744 int dsp_features;
745 #if defined(HAVE_SS7)
746 /*! \brief SS7 control parameters */
747 struct sig_ss7_linkset *ss7;
748 #endif /* defined(HAVE_SS7) */
749 #if defined(HAVE_OPENR2)
750 struct dahdi_mfcr2 *mfcr2;
751 openr2_chan_t *r2chan;
752 openr2_calling_party_category_t mfcr2_recvd_category;
753 openr2_calling_party_category_t mfcr2_category;
754 int mfcr2_dnis_index;
755 int mfcr2_ani_index;
756 unsigned int mfcr2call:1;
757 unsigned int mfcr2_answer_pending:1;
758 unsigned int mfcr2_charge_calls:1;
759 unsigned int mfcr2_allow_collect_calls:1;
760 unsigned int mfcr2_forced_release:1;
761 unsigned int mfcr2_dnis_matched:1;
762 unsigned int mfcr2_call_accepted:1;
763 unsigned int mfcr2_accept_on_offer:1;
764 unsigned int mfcr2_progress_sent:1;
765 #endif /* defined(HAVE_OPENR2) */
766 /*! \brief DTMF digit in progress. 0 when no digit in progress. */
767 char begindigit;
768 /*! \brief TRUE if confrence is muted. */
769 int muting;
770 void *sig_pvt;
771 struct ast_cc_config_params *cc_params;
772 /* DAHDI channel names may differ greatly from the
773 * string that was provided to an app such as Dial. We
774 * need to save the original string passed to dahdi_request
775 * for call completion purposes. This way, we can replicate
776 * the original dialed string later.
777 */
778 char dialstring[AST_CHANNEL_NAME];
779 };
780
781
782 /* Analog signaling */
783 #define SIG_EM DAHDI_SIG_EM
784 #define SIG_EMWINK (0x0100000 | DAHDI_SIG_EM)
785 #define SIG_FEATD (0x0200000 | DAHDI_SIG_EM)
786 #define SIG_FEATDMF (0x0400000 | DAHDI_SIG_EM)
787 #define SIG_FEATB (0x0800000 | DAHDI_SIG_EM)
788 #define SIG_E911 (0x1000000 | DAHDI_SIG_EM)
789 #define SIG_FEATDMF_TA (0x2000000 | DAHDI_SIG_EM)
790 #define SIG_FGC_CAMA (0x4000000 | DAHDI_SIG_EM)
791 #define SIG_FGC_CAMAMF (0x8000000 | DAHDI_SIG_EM)
792 #define SIG_FXSLS DAHDI_SIG_FXSLS
793 #define SIG_FXSGS DAHDI_SIG_FXSGS
794 #define SIG_FXSKS DAHDI_SIG_FXSKS
795 #define SIG_FXOLS DAHDI_SIG_FXOLS
796 #define SIG_FXOGS DAHDI_SIG_FXOGS
797 #define SIG_FXOKS DAHDI_SIG_FXOKS
798 #define SIG_SF DAHDI_SIG_SF
799 #define SIG_SFWINK (0x0100000 | DAHDI_SIG_SF)
800 #define SIG_SF_FEATD (0x0200000 | DAHDI_SIG_SF)
801 #define SIG_SF_FEATDMF (0x0400000 | DAHDI_SIG_SF)
802 #define SIG_SF_FEATB (0x0800000 | DAHDI_SIG_SF)
803 #define SIG_EM_E1 DAHDI_SIG_EM_E1
804
805 /* PRI signaling */
806 #define SIG_PRI DAHDI_SIG_CLEAR
807 #define SIG_BRI (0x2000000 | DAHDI_SIG_CLEAR)
808 #define SIG_BRI_PTMP (0X4000000 | DAHDI_SIG_CLEAR)
809
810 /* SS7 signaling */
811 #define SIG_SS7 (0x1000000 | DAHDI_SIG_CLEAR)
812
813 /* MFC/R2 signaling */
814 #define SIG_MFCR2 DAHDI_SIG_CAS
815
816
817 #define SIG_PRI_LIB_HANDLE_CASES \
818 SIG_PRI: \
819 case SIG_BRI: \
820 case SIG_BRI_PTMP
821
822 /*!
823 * \internal
824 * \brief Determine if sig_pri handles the signaling.
825 * \since 1.8
826 *
827 * \param signaling Signaling to determine if is for sig_pri.
828 *
829 * \return TRUE if the signaling is for sig_pri.
830 */
831 static inline int dahdi_sig_pri_lib_handles(int signaling)
832 {
833 int handles;
834
835 switch (signaling) {
836 case SIG_PRI_LIB_HANDLE_CASES:
837 handles = 1;
838 break;
839 default:
840 handles = 0;
841 break;
842 }
843
844 return handles;
845 }
846
847 static inline int dahdi_analog_lib_handles(int signalling, int radio, int oprmode)
848 {
849 switch (signalling) {
850 case SIG_FXOLS:
851 case SIG_FXOGS:
852 case SIG_FXOKS:
853 case SIG_FXSLS:
854 case SIG_FXSGS:
855 case SIG_FXSKS:
856 case SIG_EMWINK:
857 case SIG_EM:
858 case SIG_EM_E1:
859 case SIG_FEATD:
860 case SIG_FEATDMF:
861 case SIG_E911:
862 case SIG_FGC_CAMA:
863 case SIG_FGC_CAMAMF:
864 case SIG_FEATB:
865 case SIG_SFWINK:
866 case SIG_SF:
867 case SIG_SF_FEATD:
868 case SIG_SF_FEATDMF:
869 case SIG_FEATDMF_TA:
870 case SIG_SF_FEATB:
871 break;
872 default:
873 /* The rest of the function should cover the remainder of signalling types */
874 return 0;
875 }
876
877 if (radio) {
878 return 0;
879 }
880
881 if (oprmode) {
882 return 0;
883 }
884
885 return 1;
886 }
887
888 #define dahdi_get_index(ast, p, nullok) _dahdi_get_index(ast, p, nullok, __PRETTY_FUNCTION__, __LINE__)
889 int _dahdi_get_index(struct ast_channel *ast, struct dahdi_pvt *p, int nullok, const char *fname, unsigned long line);
890
891 void dahdi_dtmf_detect_disable(struct dahdi_pvt *p);
892 void dahdi_dtmf_detect_enable(struct dahdi_pvt *p);
893
894 void dahdi_ec_enable(struct dahdi_pvt *p);
895 void dahdi_ec_disable(struct dahdi_pvt *p);
896
897 void dahdi_conf_update(struct dahdi_pvt *p);
898 void dahdi_master_slave_link(struct dahdi_pvt *slave, struct dahdi_pvt *master);
899 void dahdi_master_slave_unlink(struct dahdi_pvt *slave, struct dahdi_pvt *master, int needlock);
900
901 /* ------------------------------------------------------------------- */
902
903 #if defined(__cplusplus) || defined(c_plusplus)
904 }
905 #endif
906
907 #endif /* _ASTERISK_CHAN_DAHDI_H */