4 * Asterisk -- An open source telephony toolkit.
6 * Copyright (C) 1999 - 2009, Digium, Inc.
8 * Mark Spencer <markster@digium.com>
10 * See http://www.asterisk.org for more information about
11 * the Asterisk project. Please do not directly contact
12 * any of the maintainers of this project for assistance;
13 * the project provides a web site, mailing lists and IRC
14 * channels for your use.
16 * This program is free software, distributed under the terms of
17 * the GNU General Public License Version 2. See the LICENSE file
18 * at the top of the source tree.
23 * \brief Interface header for PRI signaling module
25 * \author Matthew Fredrickson <creslin@digium.com>
28 #include "asterisk/channel.h"
29 #include "asterisk/frame.h"
30 #include "asterisk/event.h"
31 #include "asterisk/ccss.h"
33 #include <dahdi/user.h>
35 #if defined(HAVE_PRI_CCSS)
36 /*! PRI debug message flags when normal PRI debugging is turned on at the command line. */
37 #define SIG_PRI_DEBUG_NORMAL \
38 (PRI_DEBUG_APDU | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q921_STATE | PRI_DEBUG_CC)
41 /*! PRI debug message flags when normal PRI debugging is turned on at the command line. */
42 #define SIG_PRI_DEBUG_NORMAL \
43 (PRI_DEBUG_APDU | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q921_STATE)
44 #endif /* !defined(HAVE_PRI_CCSS) */
47 /*! PRI debug message flags set on initial startup. */
48 #define SIG_PRI_DEBUG_DEFAULT (SIG_PRI_DEBUG_NORMAL | PRI_DEBUG_Q931_DUMP)
50 /*! PRI debug message flags set on initial startup. */
51 #define SIG_PRI_DEBUG_DEFAULT 0
54 #define SIG_PRI_AOC_GRANT_S (1 << 0)
55 #define SIG_PRI_AOC_GRANT_D (1 << 1)
56 #define SIG_PRI_AOC_GRANT_E (1 << 2)
59 SIG_PRI_TONE_RINGTONE = 0,
61 SIG_PRI_TONE_CONGESTION,
62 SIG_PRI_TONE_DIALTONE,
63 SIG_PRI_TONE_DIALRECALL,
74 enum sig_pri_moh_signaling {
75 /*! Generate MOH to the remote party. */
76 SIG_PRI_MOH_SIGNALING_MOH,
77 /*! Send hold notification signaling to the remote party. */
78 SIG_PRI_MOH_SIGNALING_NOTIFY,
79 #if defined(HAVE_PRI_CALL_HOLD)
80 /*! Use HOLD/RETRIEVE signaling to release the B channel while on hold. */
81 SIG_PRI_MOH_SIGNALING_HOLD,
82 #endif /* defined(HAVE_PRI_CALL_HOLD) */
85 enum sig_pri_moh_state {
86 /*! Bridged peer has not put us on hold. */
87 SIG_PRI_MOH_STATE_IDLE,
88 /*! Bridged peer has put us on hold and we were to notify the remote party. */
89 SIG_PRI_MOH_STATE_NOTIFY,
90 /*! Bridged peer has put us on hold and we were to play MOH or HOLD/RETRIEVE fallback. */
91 SIG_PRI_MOH_STATE_MOH,
92 #if defined(HAVE_PRI_CALL_HOLD)
93 /*! Requesting to put channel on hold. */
94 SIG_PRI_MOH_STATE_HOLD_REQ,
95 /*! Trying to go on hold when bridged peer requested to unhold. */
96 SIG_PRI_MOH_STATE_PEND_UNHOLD,
97 /*! Channel is held. */
98 SIG_PRI_MOH_STATE_HOLD,
99 /*! Requesting to take channel out of hold. */
100 SIG_PRI_MOH_STATE_RETRIEVE_REQ,
101 /*! Trying to take channel out of hold when bridged peer requested to hold. */
102 SIG_PRI_MOH_STATE_PEND_HOLD,
103 /*! Failed to take the channel out of hold. No B channels were available? */
104 SIG_PRI_MOH_STATE_RETRIEVE_FAIL,
105 #endif /* defined(HAVE_PRI_CALL_HOLD) */
107 /*! Number of MOH states. Must be last in enum. */
108 SIG_PRI_MOH_STATE_NUM
111 enum sig_pri_moh_event {
112 /*! Reset the MOH state machine. (Because of hangup.) */
113 SIG_PRI_MOH_EVENT_RESET,
114 /*! Bridged peer placed this channel on hold. */
115 SIG_PRI_MOH_EVENT_HOLD,
116 /*! Bridged peer took this channel off hold. */
117 SIG_PRI_MOH_EVENT_UNHOLD,
118 #if defined(HAVE_PRI_CALL_HOLD)
119 /*! The hold request was successfully acknowledged. */
120 SIG_PRI_MOH_EVENT_HOLD_ACK,
121 /*! The hold request was rejected. */
122 SIG_PRI_MOH_EVENT_HOLD_REJ,
123 /*! The unhold request was successfully acknowledged. */
124 SIG_PRI_MOH_EVENT_RETRIEVE_ACK,
125 /*! The unhold request was rejected. */
126 SIG_PRI_MOH_EVENT_RETRIEVE_REJ,
127 /*! The remote party took this channel off hold. */
128 SIG_PRI_MOH_EVENT_REMOTE_RETRIEVE_ACK,
129 #endif /* defined(HAVE_PRI_CALL_HOLD) */
131 /*! Number of MOH events. Must be last in enum. */
132 SIG_PRI_MOH_EVENT_NUM
135 /*! Call establishment life cycle level for simple comparisons. */
136 enum sig_pri_call_level {
137 /*! Call does not exist. */
138 SIG_PRI_CALL_LEVEL_IDLE,
139 /*! Call is present but has no response yet. (SETUP) */
140 SIG_PRI_CALL_LEVEL_SETUP,
141 /*! Call is collecting digits for overlap dialing. (SETUP ACKNOWLEDGE) */
142 SIG_PRI_CALL_LEVEL_OVERLAP,
143 /*! Call routing is happening. (PROCEEDING) */
144 SIG_PRI_CALL_LEVEL_PROCEEDING,
145 /*! Called party is being alerted of the call. (ALERTING) */
146 SIG_PRI_CALL_LEVEL_ALERTING,
147 /*! Call is dialing 'w' deferred digits. (CONNECT) */
148 SIG_PRI_CALL_LEVEL_DEFER_DIAL,
149 /*! Call is connected/answered. (CONNECT) */
150 SIG_PRI_CALL_LEVEL_CONNECT,
155 struct sig_pri_callback {
156 /* Unlock the private in the signalling private structure. This is used for three way calling madness. */
157 void (* const unlock_private)(void *pvt);
158 /* Lock the private in the signalling private structure. ... */
159 void (* const lock_private)(void *pvt);
160 /* Do deadlock avoidance for the private signaling structure lock. */
161 void (* const deadlock_avoidance_private)(void *pvt);
162 /* Function which is called back to handle any other DTMF events that are received. Called by analog_handle_event. Why is this
163 * important to use, instead of just directly using events received before they are passed into the library? Because sometimes,
164 * (CWCID) the library absorbs DTMF events received. */
165 //void (* const handle_dtmf)(void *pvt, struct ast_channel *ast, enum analog_sub analog_index, struct ast_frame **dest);
167 //int (* const dial_digits)(void *pvt, enum analog_sub sub, struct analog_dialoperation *dop);
168 int (* const play_tone)(void *pvt, enum sig_pri_tone tone);
170 int (* const set_echocanceller)(void *pvt, int enable);
171 int (* const train_echocanceller)(void *pvt);
172 int (* const dsp_reset_and_flush_digits)(void *pvt);
174 struct ast_channel * (* const new_ast_channel)(void *pvt, int state, enum sig_pri_law law, char *exten, const struct ast_channel *chan);
176 void (* const fixup_chans)(void *old_chan, void *new_chan);
178 /* Note: Called with PRI lock held */
179 void (* const handle_dchan_exception)(struct sig_pri_span *pri, int index);
180 void (* const set_alarm)(void *pvt, int in_alarm);
181 void (* const set_dialing)(void *pvt, int is_dialing);
182 void (* const set_digital)(void *pvt, int is_digital);
183 void (* const set_outgoing)(void *pvt, int is_outgoing);
184 void (* const set_callerid)(void *pvt, const struct ast_party_caller *caller);
185 void (* const set_dnid)(void *pvt, const char *dnid);
186 void (* const set_rdnis)(void *pvt, const char *rdnis);
187 void (* const queue_control)(void *pvt, int subclass);
188 int (* const new_nobch_intf)(struct sig_pri_span *pri);
189 void (* const init_config)(void *pvt, struct sig_pri_span *pri);
190 const char *(* const get_orig_dialstring)(void *pvt);
191 void (* const make_cc_dialstring)(void *pvt, char *buf, size_t buf_size);
192 void (* const update_span_devstate)(struct sig_pri_span *pri);
193 void (* const dial_digits)(void *pvt, const char *dial_string);
195 void (* const open_media)(void *pvt);
198 * \brief Post an AMI B channel association event.
200 * \param pvt Private structure of the user of this module.
201 * \param chan Channel associated with the private pointer
205 void (* const ami_channel_event)(void *pvt, struct ast_channel *chan);
207 /*! Reference the parent module. */
208 void (*module_ref)(void);
209 /*! Unreference the parent module. */
210 void (*module_unref)(void);
213 #define SIG_PRI_NUM_DCHANS 4 /*!< No more than 4 d-channels */
214 #define SIG_PRI_MAX_CHANNELS 672 /*!< No more than a DS3 per trunk group */
216 #define SIG_PRI DAHDI_SIG_CLEAR
217 #define SIG_BRI (0x2000000 | DAHDI_SIG_CLEAR)
218 #define SIG_BRI_PTMP (0X4000000 | DAHDI_SIG_CLEAR)
220 /* QSIG channel mapping option types */
221 #define DAHDI_CHAN_MAPPING_PHYSICAL 0
222 #define DAHDI_CHAN_MAPPING_LOGICAL 1
224 /* Overlap dialing option types */
225 #define DAHDI_OVERLAPDIAL_NONE 0
226 #define DAHDI_OVERLAPDIAL_OUTGOING 1
227 #define DAHDI_OVERLAPDIAL_INCOMING 2
228 #define DAHDI_OVERLAPDIAL_BOTH (DAHDI_OVERLAPDIAL_INCOMING|DAHDI_OVERLAPDIAL_OUTGOING)
230 #if defined(HAVE_PRI_SERVICE_MESSAGES)
231 /*! \brief Persistent Service State */
232 #define SRVST_DBKEY "service-state"
233 /*! \brief The out-of-service SERVICE state */
234 #define SRVST_TYPE_OOS "O"
235 /*! \brief SRVST_INITIALIZED is used to indicate a channel being out-of-service
236 * The SRVST_INITIALIZED is mostly used maintain backwards compatibility but also may
237 * mean that the channel has not yet received a RESTART message. If a channel is
238 * out-of-service with this reason a RESTART message will result in the channel
239 * being put into service. */
240 #define SRVST_INITIALIZED 0
241 /*! \brief SRVST_NEAREND is used to indicate that the near end was put out-of-service */
242 #define SRVST_NEAREND (1 << 0)
243 /*! \brief SRVST_FAREND is used to indicate that the far end was taken out-of-service */
244 #define SRVST_FAREND (1 << 1)
245 /*! \brief SRVST_BOTH is used to indicate that both sides of the channel are out-of-service */
246 #define SRVST_BOTH (SRVST_NEAREND | SRVST_FAREND)
248 /*! \brief The AstDB family */
249 static const char dahdi_db[] = "dahdi/registry";
250 #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */
252 struct sig_pri_chan {
253 /* Options to be set by user */
254 unsigned int hidecallerid:1;
255 unsigned int hidecalleridname:1; /*!< Hide just the name not the number for legacy PBX use */
256 unsigned int immediate:1; /*!< Answer before getting digits? */
257 unsigned int priexclusive:1; /*!< Whether or not to override and use exculsive mode for channel selection */
258 unsigned int priindication_oob:1;
259 unsigned int use_callerid:1; /*!< Whether or not to use caller id on this channel */
260 unsigned int use_callingpres:1; /*!< Whether to use the callingpres the calling switch sends */
261 char context[AST_MAX_CONTEXT];
262 char mohinterpret[MAX_MUSICCLASS];
264 int channel; /*!< Channel Number or CRV */
266 /* Options to be checked by user */
267 int cid_ani2; /*!< Automatic Number Identification number (Alternate PRI caller ID number) */
268 int cid_ton; /*!< Type Of Number (TON) */
269 int callingpres; /*!< The value of calling presentation that we're going to use when placing a PRI call */
270 char cid_num[AST_MAX_EXTENSION];
271 char cid_subaddr[AST_MAX_EXTENSION];
272 char cid_name[AST_MAX_EXTENSION];
273 char cid_ani[AST_MAX_EXTENSION];
274 /*! \brief User tag for party id's sent from this device driver. */
275 char user_tag[AST_MAX_EXTENSION];
276 char exten[AST_MAX_EXTENSION];
278 /* Internal variables -- Don't touch */
279 /* Probably will need DS0 number, DS1 number, and a few other things */
280 char dialdest[256]; /* Queued up digits for overlap dialing. They will be sent out as information messages when setup ACK is received */
281 #if defined(HAVE_PRI_SETUP_KEYPAD)
282 /*! \brief Keypad digits that came in with the SETUP message. */
283 char keypad_digits[AST_MAX_EXTENSION];
284 #endif /* defined(HAVE_PRI_SETUP_KEYPAD) */
285 /*! 'w' deferred dialing digits. */
286 char deferred_digits[AST_MAX_EXTENSION];
287 /*! Music class suggested with AST_CONTROL_HOLD. */
288 char moh_suggested[MAX_MUSICCLASS];
289 enum sig_pri_moh_state moh_state;
291 #if defined(HAVE_PRI_AOC_EVENTS)
292 struct pri_subcmd_aoc_e aoc_e;
293 int aoc_s_request_invoke_id; /*!< If an AOC-S request was present for the call, this is the invoke_id to use for the response */
294 unsigned int aoc_s_request_invoke_id_valid:1; /*!< This is set when the AOC-S invoke id is present */
295 unsigned int waiting_for_aoce:1; /*!< Delaying hangup for AOC-E msg. If this is set and AOC-E is received, continue with hangup before timeout period. */
296 unsigned int holding_aoce:1; /*!< received AOC-E msg from asterisk. holding for disconnect/release */
297 #endif /* defined(HAVE_PRI_AOC_EVENTS) */
298 unsigned int inalarm:1;
299 unsigned int alreadyhungup:1; /*!< TRUE if the call has already gone/hungup */
300 unsigned int isidlecall:1; /*!< TRUE if this is an idle call */
301 unsigned int progress:1; /*!< TRUE if the call has seen inband-information progress through the network */
302 unsigned int resetting:1; /*!< TRUE if this channel is being reset/restarted */
305 * \brief TRUE when this channel is allocated.
308 * Needed to hold an outgoing channel allocation before the
309 * owner pointer is created.
311 * \note This is one of several items to check to see if a
312 * channel is available for use.
314 unsigned int allocated:1;
315 unsigned int outgoing:1;
316 unsigned int digital:1;
317 /*! \brief TRUE if this interface has no B channel. (call hold and call waiting) */
318 unsigned int no_b_channel:1;
319 #if defined(HAVE_PRI_CALL_WAITING)
320 /*! \brief TRUE if this is a call waiting call */
321 unsigned int is_call_waiting:1;
322 #endif /* defined(HAVE_PRI_CALL_WAITING) */
324 struct ast_channel *owner;
326 struct sig_pri_span *pri;
327 q931_call *call; /*!< opaque libpri call control structure */
329 /*! Call establishment life cycle level for simple comparisons. */
330 enum sig_pri_call_level call_level;
331 int prioffset; /*!< channel number in span */
332 int logicalspan; /*!< logical span number within trunk group */
333 int mastertrunkgroup; /*!< what trunk group is our master */
334 #if defined(HAVE_PRI_SERVICE_MESSAGES)
335 /*! \brief Active SRVST_DBKEY out-of-service status value. */
336 unsigned service_status;
337 #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */
339 struct sig_pri_callback *calls;
340 void *chan_pvt; /*!< Private structure of the user of this module. */
341 #if defined(HAVE_PRI_REVERSE_CHARGE)
343 * \brief Reverse charging indication
345 * -1 - No reverse charging,
346 * 1 - Reverse charging,
347 * 0,2-7 - Reserved for future use
349 int reverse_charging_indication;
353 #if defined(HAVE_PRI_MWI)
354 /*! Maximum number of mailboxes per span. */
355 #define SIG_PRI_MAX_MWI_MAILBOXES 8
356 /*! Typical maximum length of mwi voicemail controlling number */
357 #define SIG_PRI_MAX_MWI_VM_NUMBER_LEN 10 /* digits in number */
358 /*! Typical maximum length of mwi mailbox number */
359 #define SIG_PRI_MAX_MWI_MBOX_NUMBER_LEN 10 /* digits in number */
360 /*! Typical maximum length of mwi mailbox context */
361 #define SIG_PRI_MAX_MWI_CONTEXT_LEN 10
363 * \brief Maximum mwi_vm_numbers string length.
365 * max_length = #mailboxes * (vm_number + ',')
366 * The last ',' is a null terminator instead.
368 #define SIG_PRI_MAX_MWI_VM_NUMBER_STR (SIG_PRI_MAX_MWI_MAILBOXES \
369 * (SIG_PRI_MAX_MWI_VM_NUMBER_LEN + 1))
371 * \brief Maximum mwi_mailboxs string length.
373 * max_length = #mailboxes * (mbox_number + '@' + context + ',')
374 * The last ',' is a null terminator instead.
376 #define SIG_PRI_MAX_MWI_MAILBOX_STR (SIG_PRI_MAX_MWI_MAILBOXES \
377 * (SIG_PRI_MAX_MWI_MBOX_NUMBER_LEN + 1 + SIG_PRI_MAX_MWI_CONTEXT_LEN + 1))
379 struct sig_pri_mbox {
381 * \brief MWI mailbox event subscription.
382 * \note NULL if mailbox not configured.
384 struct ast_event_sub *sub;
385 /*! \brief Mailbox number */
387 /*! \brief Mailbox context. */
389 /*! \brief Voicemail controlling number. */
390 const char *vm_number;
392 #endif /* defined(HAVE_PRI_MWI) */
394 enum sig_pri_colp_signaling {
395 /*! Block all connected line updates. */
397 /*! Only send connected line information with the CONNECT message. */
398 SIG_PRI_COLP_CONNECT,
399 /*! Allow all connected line updates. */
403 struct sig_pri_span {
404 /* Should be set by user */
405 struct ast_cc_config_params *cc_params; /*!< CC config parameters for each new call. */
406 int pritimers[PRI_MAX_TIMERS];
407 int overlapdial; /*!< In overlap dialing mode */
408 int qsigchannelmapping; /*!< QSIG channel mapping type */
409 int discardremoteholdretrieval; /*!< shall remote hold or remote retrieval notifications be discarded? */
410 int facilityenable; /*!< Enable facility IEs */
411 #if defined(HAVE_PRI_L2_PERSISTENCE)
412 /*! Layer 2 persistence option. */
414 #endif /* defined(HAVE_PRI_L2_PERSISTENCE) */
415 int dchan_logical_span[SIG_PRI_NUM_DCHANS]; /*!< Logical offset the DCHAN sits in */
416 int fds[SIG_PRI_NUM_DCHANS]; /*!< FD's for d-channels */
418 #if defined(HAVE_PRI_AOC_EVENTS)
419 int aoc_passthrough_flag; /*!< Represents what AOC messages (S,D,E) are allowed to pass-through */
420 unsigned int aoce_delayhangup:1; /*!< defines whether the aoce_delayhangup option is enabled or not */
421 #endif /* defined(HAVE_PRI_AOC_EVENTS) */
423 #if defined(HAVE_PRI_SERVICE_MESSAGES)
424 unsigned int enable_service_message_support:1; /*!< enable SERVICE message support */
425 #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */
426 #ifdef HAVE_PRI_INBANDDISCONNECT
427 unsigned int inbanddisconnect:1; /*!< Should we support inband audio after receiving DISCONNECT? */
429 #if defined(HAVE_PRI_CALL_HOLD)
430 /*! \brief TRUE if held calls are transferred on disconnect. */
431 unsigned int hold_disconnect_transfer:1;
432 #endif /* defined(HAVE_PRI_CALL_HOLD) */
434 * \brief TRUE if call transfer is enabled for the span.
435 * \note Support switch-side transfer (called 2BCT, RLT or other names)
437 unsigned int transfer:1;
438 #if defined(HAVE_PRI_CALL_WAITING)
439 /*! \brief TRUE if we will allow incoming ISDN call waiting calls. */
440 unsigned int allow_call_waiting_calls:1;
441 #endif /* defined(HAVE_PRI_CALL_WAITING) */
442 /*! TRUE if layer 1 alarm status is ignored */
443 unsigned int layer1_ignored:1;
445 * TRUE if a new call's sig_pri_chan.user_tag[] has the MSN
446 * appended to the initial_user_tag[].
448 unsigned int append_msn_to_user_tag:1;
449 #if defined(HAVE_PRI_MCID)
450 /*! \brief TRUE if allow sending MCID request on this span. */
451 unsigned int mcid_send:1;
452 #endif /* defined(HAVE_PRI_MCID) */
453 #if defined(HAVE_PRI_DATETIME_SEND)
454 /*! \brief Configured date/time ie send policy option. */
456 #endif /* defined(HAVE_PRI_DATETIME_SEND) */
457 int dialplan; /*!< Dialing plan */
458 int localdialplan; /*!< Local dialing plan */
459 int cpndialplan; /*!< Connected party dialing plan */
460 char internationalprefix[10]; /*!< country access code ('00' for european dialplans) */
461 char nationalprefix[10]; /*!< area access code ('0' for european dialplans) */
462 char localprefix[20]; /*!< area access code + area code ('0'+area code for european dialplans) */
463 char privateprefix[20]; /*!< for private dialplans */
464 char unknownprefix[20]; /*!< for unknown dialplans */
465 enum sig_pri_moh_signaling moh_signaling;
466 /*! Send connected line signaling to peer option. */
467 enum sig_pri_colp_signaling colp_send;
468 long resetinterval; /*!< Interval (in seconds) for resetting unused channels */
469 #if defined(HAVE_PRI_DISPLAY_TEXT)
470 unsigned long display_flags_send; /*!< PRI_DISPLAY_OPTION_xxx flags for display text sending */
471 unsigned long display_flags_receive; /*!< PRI_DISPLAY_OPTION_xxx flags for display text receiving */
472 #endif /* defined(HAVE_PRI_DISPLAY_TEXT) */
473 #if defined(HAVE_PRI_MWI)
474 /*! \brief Active MWI mailboxes */
475 struct sig_pri_mbox mbox[SIG_PRI_MAX_MWI_MAILBOXES];
477 * \brief Comma separated list of mailboxes to indicate MWI.
478 * \note Empty if disabled.
479 * \note Format: mailbox_number[@context]{,mailbox_number[@context]}
480 * \note String is split apart when span is started.
482 char mwi_mailboxes[SIG_PRI_MAX_MWI_MAILBOX_STR];
484 * \brief Comma separated list of voicemail access controlling numbers for MWI.
485 * \note Format: vm_number{,vm_number}
486 * \note String is split apart when span is started.
488 char mwi_vm_numbers[SIG_PRI_MAX_MWI_VM_NUMBER_STR];
489 #endif /* defined(HAVE_PRI_MWI) */
491 * \brief Initial user tag for party id's sent from this device driver.
492 * \note String set by config file.
494 char initial_user_tag[AST_MAX_EXTENSION];
495 char msn_list[AST_MAX_EXTENSION]; /*!< Comma separated list of MSNs to handle. Empty if disabled. */
496 char idleext[AST_MAX_EXTENSION]; /*!< Where to idle extra calls */
497 char idlecontext[AST_MAX_CONTEXT]; /*!< What context to use for idle */
498 char idledial[AST_MAX_EXTENSION]; /*!< What to dial before dumping */
499 int minunused; /*!< Min # of channels to keep empty */
500 int minidle; /*!< Min # of "idling" calls to keep active */
501 int nodetype; /*!< Node type */
502 int switchtype; /*!< Type of switch to emulate */
503 int nsf; /*!< Network-Specific Facilities */
504 int trunkgroup; /*!< What our trunkgroup is */
505 #if defined(HAVE_PRI_CCSS)
506 int cc_ptmp_recall_mode; /*!< CC PTMP recall mode. globalRecall(0), specificRecall(1) */
507 int cc_qsig_signaling_link_req; /*!< CC Q.SIG signaling link retention (Party A) release(0), retain(1), do-not-care(2) */
508 int cc_qsig_signaling_link_rsp; /*!< CC Q.SIG signaling link retention (Party B) release(0), retain(1) */
509 #endif /* defined(HAVE_PRI_CCSS) */
510 #if defined(HAVE_PRI_CALL_WAITING)
512 * \brief Number of extra outgoing calls to allow on a span before
513 * considering that span congested.
515 int max_call_waiting_calls;
518 unsigned int hidecallerid:1;
519 unsigned int hidecalleridname:1; /*!< Hide just the name not the number for legacy PBX use */
520 unsigned int immediate:1; /*!< Answer before getting digits? */
521 unsigned int priexclusive:1; /*!< Whether or not to override and use exculsive mode for channel selection */
522 unsigned int priindication_oob:1;
523 unsigned int use_callerid:1; /*!< Whether or not to use caller id on this channel */
524 unsigned int use_callingpres:1; /*!< Whether to use the callingpres the calling switch sends */
525 char context[AST_MAX_CONTEXT];
526 char mohinterpret[MAX_MUSICCLASS];
530 * \brief Number of outstanding call waiting calls.
531 * \note Must be zero to allow new calls from asterisk to
532 * immediately allocate a B channel.
534 int num_call_waiting_calls;
535 #endif /* defined(HAVE_PRI_CALL_WAITING) */
536 int dchanavail[SIG_PRI_NUM_DCHANS]; /*!< Whether each channel is available */
537 int debug; /*!< set to true if to dump PRI event info */
538 int span; /*!< span number put into user output messages */
539 int resetting; /*!< true if span is being reset/restarted */
540 int resetpos; /*!< current position during a reset (-1 if not started) */
541 int sig; /*!< ISDN signalling type (SIG_PRI, SIG_BRI, SIG_BRI_PTMP, etc...) */
542 int new_chan_seq; /*!< New struct ast_channel sequence number */
543 /*! TRUE if we have already whined about no D channels available. */
544 unsigned int no_d_channels:1;
546 /* Everything after here is internally set */
547 struct pri *dchans[SIG_PRI_NUM_DCHANS]; /*!< Actual d-channels */
548 struct pri *pri; /*!< Currently active D-channel */
550 * List of private structures of the user of this module for no B channel
551 * interfaces. (hold and call waiting interfaces)
553 void *no_b_chan_iflist;
555 * List of private structures of the user of this module for no B channel
556 * interfaces. (hold and call waiting interfaces)
559 int numchans; /*!< Num of channels we represent */
560 struct sig_pri_chan *pvts[SIG_PRI_MAX_CHANNELS];/*!< Member channel pvt structs */
561 pthread_t master; /*!< Thread of master */
562 ast_mutex_t lock; /*!< libpri access Mutex */
563 time_t lastreset; /*!< time when unused channels were last reset */
564 struct sig_pri_callback *calls;
566 * \brief Congestion device state of the span.
568 * AST_DEVICE_NOT_INUSE - Span does not have all B channels in use.
569 * AST_DEVICE_BUSY - All B channels are in use.
570 * AST_DEVICE_UNAVAILABLE - Span is in alarm.
572 * Device name: \startverbatim DAHDI/I<span>/congestion. \endverbatim
574 int congestion_devstate;
575 #if defined(THRESHOLD_DEVSTATE_PLACEHOLDER)
576 /*! \todo An ISDN span threshold device state could be useful in determining how often a span utilization goes over a configurable threshold. */
578 * \brief User threshold device state of the span.
580 * AST_DEVICE_NOT_INUSE - There are no B channels in use.
581 * AST_DEVICE_INUSE - The number of B channels in use is less than
582 * the configured threshold but not zero.
583 * AST_DEVICE_BUSY - The number of B channels in use meets or exceeds
584 * the configured threshold.
585 * AST_DEVICE_UNAVAILABLE - Span is in alarm.
587 * Device name: DAHDI/I<span>/threshold
589 int threshold_devstate;
591 * \brief Number of B channels in use to consider the span in a busy state.
592 * \note Setting the threshold to zero is interpreted as all B channels.
594 int user_busy_threshold;
595 #endif /* defined(THRESHOLD_DEVSTATE_PLACEHOLDER) */
598 void sig_pri_extract_called_num_subaddr(struct sig_pri_chan *p, const char *rdest, char *called, size_t called_buff_size);
599 int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, const char *rdest, int timeout, int layer1);
601 int sig_pri_hangup(struct sig_pri_chan *p, struct ast_channel *ast);
603 int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condition, const void *data, size_t datalen);
605 int sig_pri_answer(struct sig_pri_chan *p, struct ast_channel *ast);
607 int sig_pri_is_chan_available(struct sig_pri_chan *pvt);
608 int sig_pri_available(struct sig_pri_chan **pvt, int is_specific_channel);
610 void sig_pri_init_pri(struct sig_pri_span *pri);
612 /* If return 0, it means this function was able to handle it (pre setup digits). If non zero, the user of this
613 * functions should handle it normally (generate inband DTMF) */
614 int sig_pri_digit_begin(struct sig_pri_chan *pvt, struct ast_channel *ast, char digit);
615 void sig_pri_dial_complete(struct sig_pri_chan *pvt, struct ast_channel *ast);
617 void sig_pri_stop_pri(struct sig_pri_span *pri);
618 int sig_pri_start_pri(struct sig_pri_span *pri);
620 void sig_pri_set_alarm(struct sig_pri_chan *p, int in_alarm);
621 void sig_pri_chan_alarm_notify(struct sig_pri_chan *p, int noalarm);
623 int sig_pri_is_alarm_ignored(struct sig_pri_span *pri);
624 void pri_event_alarm(struct sig_pri_span *pri, int index, int before_start_pri);
625 void pri_event_noalarm(struct sig_pri_span *pri, int index, int before_start_pri);
627 struct ast_channel *sig_pri_request(struct sig_pri_chan *p, enum sig_pri_law law, const struct ast_channel *requestor, int transfercapability);
629 struct sig_pri_chan *sig_pri_chan_new(void *pvt_data, struct sig_pri_callback *callback, struct sig_pri_span *pri, int logicalspan, int channo, int trunkgroup);
630 void sig_pri_chan_delete(struct sig_pri_chan *doomed);
632 int pri_is_up(struct sig_pri_span *pri);
635 int sig_pri_ami_show_spans(struct mansession *s, const char *show_cmd, struct sig_pri_span *pri, const int *dchannels, const char *action_id);
637 void sig_pri_cli_show_channels_header(int fd);
638 void sig_pri_cli_show_channels(int fd, struct sig_pri_span *pri);
639 void sig_pri_cli_show_spans(int fd, int span, struct sig_pri_span *pri);
641 void sig_pri_cli_show_span(int fd, int *dchannels, struct sig_pri_span *pri);
643 int pri_send_keypad_facility_exec(struct sig_pri_chan *p, const char *digits);
644 int pri_send_callrerouting_facility_exec(struct sig_pri_chan *p, enum ast_channel_state chanstate, const char *destination, const char *original, const char *reason);
646 #if defined(HAVE_PRI_SERVICE_MESSAGES)
647 int pri_maintenance_bservice(struct pri *pri, struct sig_pri_chan *p, int changestatus);
648 #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */
650 void sig_pri_fixup(struct ast_channel *oldchan, struct ast_channel *newchan, struct sig_pri_chan *pchan);
651 #if defined(HAVE_PRI_DISPLAY_TEXT)
652 void sig_pri_sendtext(struct sig_pri_chan *pchan, const char *text);
653 #endif /* defined(HAVE_PRI_DISPLAY_TEXT) */
655 int sig_pri_cc_agent_init(struct ast_cc_agent *agent, struct sig_pri_chan *pvt_chan);
656 int sig_pri_cc_agent_start_offer_timer(struct ast_cc_agent *agent);
657 int sig_pri_cc_agent_stop_offer_timer(struct ast_cc_agent *agent);
658 void sig_pri_cc_agent_req_rsp(struct ast_cc_agent *agent, enum ast_cc_agent_response_reason reason);
659 int sig_pri_cc_agent_status_req(struct ast_cc_agent *agent);
660 int sig_pri_cc_agent_stop_ringing(struct ast_cc_agent *agent);
661 int sig_pri_cc_agent_party_b_free(struct ast_cc_agent *agent);
662 int sig_pri_cc_agent_start_monitoring(struct ast_cc_agent *agent);
663 int sig_pri_cc_agent_callee_available(struct ast_cc_agent *agent);
664 void sig_pri_cc_agent_destructor(struct ast_cc_agent *agent);
666 int sig_pri_cc_monitor_req_cc(struct ast_cc_monitor *monitor, int *available_timer_id);
667 int sig_pri_cc_monitor_suspend(struct ast_cc_monitor *monitor);
668 int sig_pri_cc_monitor_unsuspend(struct ast_cc_monitor *monitor);
669 int sig_pri_cc_monitor_status_rsp(struct ast_cc_monitor *monitor, enum ast_device_state devstate);
670 int sig_pri_cc_monitor_cancel_available_timer(struct ast_cc_monitor *monitor, int *sched_id);
671 void sig_pri_cc_monitor_destructor(void *monitor_pvt);
673 int sig_pri_load(const char *cc_type_name);
674 void sig_pri_unload(void);
676 #endif /* _SIG_PRI_H */