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/ccss.h"
32 #include <dahdi/user.h>
34 #if defined(HAVE_PRI_CCSS)
35 /*! PRI debug message flags when normal PRI debugging is turned on at the command line. */
36 #define SIG_PRI_DEBUG_NORMAL \
37 (PRI_DEBUG_APDU | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q921_STATE | PRI_DEBUG_CC)
40 /*! PRI debug message flags when normal PRI debugging is turned on at the command line. */
41 #define SIG_PRI_DEBUG_NORMAL \
42 (PRI_DEBUG_APDU | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q921_STATE)
43 #endif /* !defined(HAVE_PRI_CCSS) */
46 /*! PRI debug message flags set on initial startup. */
47 #define SIG_PRI_DEBUG_DEFAULT (SIG_PRI_DEBUG_NORMAL | PRI_DEBUG_Q931_DUMP)
49 /*! PRI debug message flags set on initial startup. */
50 #define SIG_PRI_DEBUG_DEFAULT 0
53 #define SIG_PRI_AOC_GRANT_S (1 << 0)
54 #define SIG_PRI_AOC_GRANT_D (1 << 1)
55 #define SIG_PRI_AOC_GRANT_E (1 << 2)
58 SIG_PRI_TONE_RINGTONE = 0,
60 SIG_PRI_TONE_CONGESTION,
61 SIG_PRI_TONE_DIALTONE,
62 SIG_PRI_TONE_DIALRECALL,
73 enum sig_pri_moh_signaling {
74 /*! Generate MOH to the remote party. */
75 SIG_PRI_MOH_SIGNALING_MOH,
76 /*! Send hold notification signaling to the remote party. */
77 SIG_PRI_MOH_SIGNALING_NOTIFY,
78 #if defined(HAVE_PRI_CALL_HOLD)
79 /*! Use HOLD/RETRIEVE signaling to release the B channel while on hold. */
80 SIG_PRI_MOH_SIGNALING_HOLD,
81 #endif /* defined(HAVE_PRI_CALL_HOLD) */
84 enum sig_pri_moh_state {
85 /*! Bridged peer has not put us on hold. */
86 SIG_PRI_MOH_STATE_IDLE,
87 /*! Bridged peer has put us on hold and we were to notify the remote party. */
88 SIG_PRI_MOH_STATE_NOTIFY,
89 /*! Bridged peer has put us on hold and we were to play MOH or HOLD/RETRIEVE fallback. */
90 SIG_PRI_MOH_STATE_MOH,
91 #if defined(HAVE_PRI_CALL_HOLD)
92 /*! Requesting to put channel on hold. */
93 SIG_PRI_MOH_STATE_HOLD_REQ,
94 /*! Trying to go on hold when bridged peer requested to unhold. */
95 SIG_PRI_MOH_STATE_PEND_UNHOLD,
96 /*! Channel is held. */
97 SIG_PRI_MOH_STATE_HOLD,
98 /*! Requesting to take channel out of hold. */
99 SIG_PRI_MOH_STATE_RETRIEVE_REQ,
100 /*! Trying to take channel out of hold when bridged peer requested to hold. */
101 SIG_PRI_MOH_STATE_PEND_HOLD,
102 /*! Failed to take the channel out of hold. No B channels were available? */
103 SIG_PRI_MOH_STATE_RETRIEVE_FAIL,
104 #endif /* defined(HAVE_PRI_CALL_HOLD) */
106 /*! Number of MOH states. Must be last in enum. */
107 SIG_PRI_MOH_STATE_NUM
110 enum sig_pri_moh_event {
111 /*! Reset the MOH state machine. (Because of hangup.) */
112 SIG_PRI_MOH_EVENT_RESET,
113 /*! Bridged peer placed this channel on hold. */
114 SIG_PRI_MOH_EVENT_HOLD,
115 /*! Bridged peer took this channel off hold. */
116 SIG_PRI_MOH_EVENT_UNHOLD,
117 #if defined(HAVE_PRI_CALL_HOLD)
118 /*! The hold request was successfully acknowledged. */
119 SIG_PRI_MOH_EVENT_HOLD_ACK,
120 /*! The hold request was rejected. */
121 SIG_PRI_MOH_EVENT_HOLD_REJ,
122 /*! The unhold request was successfully acknowledged. */
123 SIG_PRI_MOH_EVENT_RETRIEVE_ACK,
124 /*! The unhold request was rejected. */
125 SIG_PRI_MOH_EVENT_RETRIEVE_REJ,
126 /*! The remote party took this channel off hold. */
127 SIG_PRI_MOH_EVENT_REMOTE_RETRIEVE_ACK,
128 #endif /* defined(HAVE_PRI_CALL_HOLD) */
130 /*! Number of MOH events. Must be last in enum. */
131 SIG_PRI_MOH_EVENT_NUM
134 /*! Call establishment life cycle level for simple comparisons. */
135 enum sig_pri_call_level {
136 /*! Call does not exist. */
137 SIG_PRI_CALL_LEVEL_IDLE,
138 /*! Call is present but has no response yet. (SETUP) */
139 SIG_PRI_CALL_LEVEL_SETUP,
140 /*! Call is collecting digits for overlap dialing. (SETUP ACKNOWLEDGE) */
141 SIG_PRI_CALL_LEVEL_OVERLAP,
142 /*! Call routing is happening. (PROCEEDING) */
143 SIG_PRI_CALL_LEVEL_PROCEEDING,
144 /*! Called party is being alerted of the call. (ALERTING) */
145 SIG_PRI_CALL_LEVEL_ALERTING,
146 /*! Call is dialing 'w' deferred digits. (CONNECT) */
147 SIG_PRI_CALL_LEVEL_DEFER_DIAL,
148 /*! Call is connected/answered. (CONNECT) */
149 SIG_PRI_CALL_LEVEL_CONNECT,
152 enum sig_pri_reset_state {
153 /*! \brief The channel is not being RESTARTed. */
156 * \brief The channel is being RESTARTed.
157 * \note Waiting for a RESTART ACKNOWLEDGE from the peer.
159 SIG_PRI_RESET_ACTIVE,
161 * \brief Peer may not be sending the expected RESTART ACKNOWLEDGE.
163 * \details We have already received a SETUP on this channel.
164 * If another SETUP comes in on this channel then the peer
165 * considers this channel useable. Assume that the peer is
166 * never going to give us a RESTART ACKNOWLEDGE and assume that
167 * we have received one. This is not according to Q.931, but
168 * some peers occasionally fail to send a RESTART ACKNOWLEDGE.
170 SIG_PRI_RESET_NO_ACK,
174 struct xfer_rsp_data;
176 struct sig_pri_callback {
177 /* Unlock the private in the signalling private structure. This is used for three way calling madness. */
178 void (* const unlock_private)(void *pvt);
179 /* Lock the private in the signalling private structure. ... */
180 void (* const lock_private)(void *pvt);
181 /* Do deadlock avoidance for the private signaling structure lock. */
182 void (* const deadlock_avoidance_private)(void *pvt);
183 /* Function which is called back to handle any other DTMF events that are received. Called by analog_handle_event. Why is this
184 * important to use, instead of just directly using events received before they are passed into the library? Because sometimes,
185 * (CWCID) the library absorbs DTMF events received. */
186 //void (* const handle_dtmf)(void *pvt, struct ast_channel *ast, enum analog_sub analog_index, struct ast_frame **dest);
188 //int (* const dial_digits)(void *pvt, enum analog_sub sub, struct analog_dialoperation *dop);
189 int (* const play_tone)(void *pvt, enum sig_pri_tone tone);
191 int (* const set_echocanceller)(void *pvt, int enable);
192 int (* const train_echocanceller)(void *pvt);
193 int (* const dsp_reset_and_flush_digits)(void *pvt);
195 struct ast_channel * (* const new_ast_channel)(void *pvt, int state,
196 enum sig_pri_law law, char *exten, const struct ast_assigned_ids *assignedids,
197 const struct ast_channel *requestor);
199 void (* const fixup_chans)(void *old_chan, void *new_chan);
201 /* Note: Called with PRI lock held */
202 void (* const handle_dchan_exception)(struct sig_pri_span *pri, int index);
203 void (* const set_alarm)(void *pvt, int in_alarm);
204 void (* const set_dialing)(void *pvt, int is_dialing);
205 void (* const set_digital)(void *pvt, int is_digital);
206 void (* const set_outgoing)(void *pvt, int is_outgoing);
207 void (* const set_callerid)(void *pvt, const struct ast_party_caller *caller);
208 void (* const set_dnid)(void *pvt, const char *dnid);
209 void (* const set_rdnis)(void *pvt, const char *rdnis);
210 void (* const queue_control)(void *pvt, int subclass);
211 int (* const new_nobch_intf)(struct sig_pri_span *pri);
212 void (* const init_config)(void *pvt, struct sig_pri_span *pri);
213 const char *(* const get_orig_dialstring)(void *pvt);
214 void (* const make_cc_dialstring)(void *pvt, char *buf, size_t buf_size);
215 void (* const update_span_devstate)(struct sig_pri_span *pri);
216 void (* const dial_digits)(void *pvt, const char *dial_string);
218 void (* const open_media)(void *pvt);
221 * \brief Post an AMI B channel association event.
223 * \param pvt Private structure of the user of this module.
224 * \param chan Channel associated with the private pointer
228 void (* const ami_channel_event)(void *pvt, struct ast_channel *chan);
230 /*! Reference the parent module. */
231 void (*module_ref)(void);
232 /*! Unreference the parent module. */
233 void (*module_unref)(void);
234 /*! Mark the span for destruction. */
235 void (*destroy_later)(struct sig_pri_span *pri);
238 /*! Global sig_pri callbacks to the upper layer. */
239 extern struct sig_pri_callback sig_pri_callbacks;
241 #define SIG_PRI_NUM_DCHANS 4 /*!< No more than 4 d-channels */
242 #define SIG_PRI_MAX_CHANNELS 672 /*!< No more than a DS3 per trunk group */
244 #define SIG_PRI DAHDI_SIG_CLEAR
245 #define SIG_BRI (0x2000000 | DAHDI_SIG_CLEAR)
246 #define SIG_BRI_PTMP (0X4000000 | DAHDI_SIG_CLEAR)
248 /* QSIG channel mapping option types */
249 #define DAHDI_CHAN_MAPPING_PHYSICAL 0
250 #define DAHDI_CHAN_MAPPING_LOGICAL 1
252 /* Overlap dialing option types */
253 #define DAHDI_OVERLAPDIAL_NONE 0
254 #define DAHDI_OVERLAPDIAL_OUTGOING 1
255 #define DAHDI_OVERLAPDIAL_INCOMING 2
256 #define DAHDI_OVERLAPDIAL_BOTH (DAHDI_OVERLAPDIAL_INCOMING|DAHDI_OVERLAPDIAL_OUTGOING)
258 #if defined(HAVE_PRI_SERVICE_MESSAGES)
259 /*! \brief Persistent Service State */
260 #define SRVST_DBKEY "service-state"
261 /*! \brief The out-of-service SERVICE state */
262 #define SRVST_TYPE_OOS "O"
263 /*! \brief SRVST_INITIALIZED is used to indicate a channel being out-of-service
264 * The SRVST_INITIALIZED is mostly used maintain backwards compatibility but also may
265 * mean that the channel has not yet received a RESTART message. If a channel is
266 * out-of-service with this reason a RESTART message will result in the channel
267 * being put into service. */
268 #define SRVST_INITIALIZED 0
269 /*! \brief SRVST_NEAREND is used to indicate that the near end was put out-of-service */
270 #define SRVST_NEAREND (1 << 0)
271 /*! \brief SRVST_FAREND is used to indicate that the far end was taken out-of-service */
272 #define SRVST_FAREND (1 << 1)
273 /*! \brief SRVST_BOTH is used to indicate that both sides of the channel are out-of-service */
274 #define SRVST_BOTH (SRVST_NEAREND | SRVST_FAREND)
276 /*! \brief The AstDB family */
277 static const char dahdi_db[] = "dahdi/registry";
278 #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */
280 struct sig_pri_chan {
281 /* Options to be set by user */
282 unsigned int hidecallerid:1;
283 unsigned int hidecalleridname:1; /*!< Hide just the name not the number for legacy PBX use */
284 unsigned int immediate:1; /*!< Answer before getting digits? */
285 unsigned int priexclusive:1; /*!< Whether or not to override and use exculsive mode for channel selection */
286 unsigned int priindication_oob:1;
287 unsigned int use_callerid:1; /*!< Whether or not to use caller id on this channel */
288 unsigned int use_callingpres:1; /*!< Whether to use the callingpres the calling switch sends */
289 char context[AST_MAX_CONTEXT];
290 char mohinterpret[MAX_MUSICCLASS];
292 int channel; /*!< Channel Number or CRV */
294 /* Options to be checked by user */
295 int cid_ani2; /*!< Automatic Number Identification number (Alternate PRI caller ID number) */
296 int cid_ton; /*!< Type Of Number (TON) */
297 int callingpres; /*!< The value of calling presentation that we're going to use when placing a PRI call */
298 char cid_num[AST_MAX_EXTENSION];
299 char cid_subaddr[AST_MAX_EXTENSION];
300 char cid_name[AST_MAX_EXTENSION];
301 char cid_ani[AST_MAX_EXTENSION];
302 /*! \brief User tag for party id's sent from this device driver. */
303 char user_tag[AST_MAX_EXTENSION];
304 char exten[AST_MAX_EXTENSION];
306 /* Internal variables -- Don't touch */
307 /* Probably will need DS0 number, DS1 number, and a few other things */
308 char dialdest[256]; /* Queued up digits for overlap dialing. They will be sent out as information messages when setup ACK is received */
309 #if defined(HAVE_PRI_SETUP_KEYPAD)
310 /*! \brief Keypad digits that came in with the SETUP message. */
311 char keypad_digits[AST_MAX_EXTENSION];
312 #endif /* defined(HAVE_PRI_SETUP_KEYPAD) */
313 /*! 'w' deferred dialing digits. */
314 char deferred_digits[AST_MAX_EXTENSION];
315 /*! Music class suggested with AST_CONTROL_HOLD. */
316 char moh_suggested[MAX_MUSICCLASS];
317 enum sig_pri_moh_state moh_state;
319 #if defined(HAVE_PRI_AOC_EVENTS)
320 struct pri_subcmd_aoc_e aoc_e;
321 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 */
322 unsigned int aoc_s_request_invoke_id_valid:1; /*!< This is set when the AOC-S invoke id is present */
323 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. */
324 unsigned int holding_aoce:1; /*!< received AOC-E msg from asterisk. holding for disconnect/release */
325 #endif /* defined(HAVE_PRI_AOC_EVENTS) */
326 unsigned int inalarm:1;
327 unsigned int alreadyhungup:1; /*!< TRUE if the call has already gone/hungup */
328 unsigned int isidlecall:1; /*!< TRUE if this is an idle call */
329 unsigned int progress:1; /*!< TRUE if the call has seen inband-information progress through the network */
332 * \brief TRUE when this channel is allocated.
335 * Needed to hold an outgoing channel allocation before the
336 * owner pointer is created.
338 * \note This is one of several items to check to see if a
339 * channel is available for use.
341 unsigned int allocated:1;
342 unsigned int outgoing:1;
343 unsigned int digital:1;
344 /*! \brief TRUE if this interface has no B channel. (call hold and call waiting) */
345 unsigned int no_b_channel:1;
346 #if defined(HAVE_PRI_CALL_WAITING)
347 /*! \brief TRUE if this is a call waiting call */
348 unsigned int is_call_waiting:1;
349 #endif /* defined(HAVE_PRI_CALL_WAITING) */
350 #if defined(HAVE_PRI_SETUP_ACK_INBAND)
351 /*! TRUE if outgoing SETUP had no called digits */
352 unsigned int no_dialed_digits:1;
353 #endif /* defined(HAVE_PRI_SETUP_ACK_INBAND) */
355 struct ast_channel *owner;
357 struct sig_pri_span *pri;
358 q931_call *call; /*!< opaque libpri call control structure */
360 /*! Call establishment life cycle level for simple comparisons. */
361 enum sig_pri_call_level call_level;
362 /*! \brief Channel reset/restart state. */
363 enum sig_pri_reset_state resetting;
364 #if defined(HAVE_PRI_TRANSFER)
365 /*! If non-NULL, send transfer disconnect successfull response to first call disconnecting. */
366 struct xfer_rsp_data *xfer_data;
367 #endif /* defined(HAVE_PRI_TRANSFER) */
368 int prioffset; /*!< channel number in span */
369 int logicalspan; /*!< logical span number within trunk group */
370 int mastertrunkgroup; /*!< what trunk group is our master */
371 #if defined(HAVE_PRI_SERVICE_MESSAGES)
372 /*! \brief Active SRVST_DBKEY out-of-service status value. */
373 unsigned service_status;
374 #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */
376 void *chan_pvt; /*!< Private structure of the user of this module. */
377 #if defined(HAVE_PRI_REVERSE_CHARGE)
379 * \brief Reverse charging indication
381 * -1 - No reverse charging,
382 * 1 - Reverse charging,
383 * 0,2-7 - Reserved for future use
385 int reverse_charging_indication;
389 #if defined(HAVE_PRI_MWI)
390 /*! Maximum number of mailboxes per span. */
391 #define SIG_PRI_MAX_MWI_MAILBOXES 8
392 /*! Typical maximum length of mwi voicemail controlling number */
393 #define SIG_PRI_MAX_MWI_VM_NUMBER_LEN 10 /* digits in number */
394 /*! Typical maximum length of mwi mailbox number */
395 #define SIG_PRI_MAX_MWI_MBOX_NUMBER_LEN 10 /* digits in number */
396 /*! Typical maximum length of mwi mailbox context */
397 #define SIG_PRI_MAX_MWI_CONTEXT_LEN 10
399 * \brief Maximum mwi_vm_numbers and mwi_vm_boxes string length.
401 * max_length = #mailboxes * (vm_number + ',')
402 * The last ',' is a null terminator instead.
404 #define SIG_PRI_MAX_MWI_VM_NUMBER_STR (SIG_PRI_MAX_MWI_MAILBOXES \
405 * (SIG_PRI_MAX_MWI_VM_NUMBER_LEN + 1))
407 * \brief Maximum length of vm_mailbox string.
409 * max_length = vm_box + '@' + context.
411 #define SIG_PRI_MAX_MWI_VM_MAILBOX (SIG_PRI_MAX_MWI_MBOX_NUMBER_LEN \
412 + 1 + SIG_PRI_MAX_MWI_CONTEXT_LEN)
414 * \brief Maximum mwi_mailboxs string length.
416 * max_length = #mailboxes * (vm_mailbox + ',')
417 * The last ',' is a null terminator instead.
419 #define SIG_PRI_MAX_MWI_MAILBOX_STR (SIG_PRI_MAX_MWI_MAILBOXES \
420 * (SIG_PRI_MAX_MWI_VM_MAILBOX + 1))
422 struct sig_pri_mbox {
424 * \brief MWI mailbox event subscription.
425 * \note NULL if mailbox not configured.
427 struct stasis_subscription *sub;
428 /*! \brief Mailbox uniqueid. */
429 const char *uniqueid;
430 /*! \brief Mailbox number sent to span. */
432 /*! \brief Voicemail access controlling number sent to span. */
433 const char *vm_number;
435 #endif /* defined(HAVE_PRI_MWI) */
437 enum sig_pri_colp_signaling {
438 /*! Block all connected line updates. */
440 /*! Only send connected line information with the CONNECT message. */
441 SIG_PRI_COLP_CONNECT,
442 /*! Allow all connected line updates. */
446 struct sig_pri_span {
447 /* Should be set by user */
448 struct ast_cc_config_params *cc_params; /*!< CC config parameters for each new call. */
449 int pritimers[PRI_MAX_TIMERS];
450 int overlapdial; /*!< In overlap dialing mode */
451 int qsigchannelmapping; /*!< QSIG channel mapping type */
452 int discardremoteholdretrieval; /*!< shall remote hold or remote retrieval notifications be discarded? */
453 int facilityenable; /*!< Enable facility IEs */
454 #if defined(HAVE_PRI_L2_PERSISTENCE)
455 /*! Layer 2 persistence option. */
457 #endif /* defined(HAVE_PRI_L2_PERSISTENCE) */
458 int dchan_logical_span[SIG_PRI_NUM_DCHANS]; /*!< Logical offset the DCHAN sits in */
459 int fds[SIG_PRI_NUM_DCHANS]; /*!< FD's for d-channels */
461 #if defined(HAVE_PRI_AOC_EVENTS)
462 int aoc_passthrough_flag; /*!< Represents what AOC messages (S,D,E) are allowed to pass-through */
463 unsigned int aoce_delayhangup:1; /*!< defines whether the aoce_delayhangup option is enabled or not */
464 #endif /* defined(HAVE_PRI_AOC_EVENTS) */
466 #if defined(HAVE_PRI_SERVICE_MESSAGES)
467 unsigned int enable_service_message_support:1; /*!< enable SERVICE message support */
468 #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */
469 #ifdef HAVE_PRI_INBANDDISCONNECT
470 unsigned int inbanddisconnect:1; /*!< Should we support inband audio after receiving DISCONNECT? */
472 #if defined(HAVE_PRI_CALL_HOLD)
473 /*! \brief TRUE if held calls are transferred on disconnect. */
474 unsigned int hold_disconnect_transfer:1;
475 #endif /* defined(HAVE_PRI_CALL_HOLD) */
477 * \brief TRUE if call transfer is enabled for the span.
478 * \note Support switch-side transfer (called 2BCT, RLT or other names)
480 unsigned int transfer:1;
481 #if defined(HAVE_PRI_CALL_WAITING)
482 /*! \brief TRUE if we will allow incoming ISDN call waiting calls. */
483 unsigned int allow_call_waiting_calls:1;
484 #endif /* defined(HAVE_PRI_CALL_WAITING) */
485 /*! TRUE if layer 1 alarm status is ignored */
486 unsigned int layer1_ignored:1;
488 * TRUE if a new call's sig_pri_chan.user_tag[] has the MSN
489 * appended to the initial_user_tag[].
491 unsigned int append_msn_to_user_tag:1;
492 /*! TRUE if a SETUP ACK message needs to open the audio path. */
493 unsigned int inband_on_setup_ack:1;
494 /*! TRUE if a PROCEEDING message needs to unsquelch the received audio. */
495 unsigned int inband_on_proceeding:1;
496 #if defined(HAVE_PRI_MCID)
497 /*! \brief TRUE if allow sending MCID request on this span. */
498 unsigned int mcid_send:1;
499 /*! \brief TRUE if forcing RESTART when receive cause 44 on this span. */
500 unsigned int force_restart_unavailable_chans:1;
501 #endif /* defined(HAVE_PRI_MCID) */
502 #if defined(HAVE_PRI_DATETIME_SEND)
503 /*! \brief Configured date/time ie send policy option. */
505 #endif /* defined(HAVE_PRI_DATETIME_SEND) */
506 int dialplan; /*!< Dialing plan */
507 int localdialplan; /*!< Local dialing plan */
508 int cpndialplan; /*!< Connected party dialing plan */
509 char internationalprefix[10]; /*!< country access code ('00' for european dialplans) */
510 char nationalprefix[10]; /*!< area access code ('0' for european dialplans) */
511 char localprefix[20]; /*!< area access code + area code ('0'+area code for european dialplans) */
512 char privateprefix[20]; /*!< for private dialplans */
513 char unknownprefix[20]; /*!< for unknown dialplans */
514 enum sig_pri_moh_signaling moh_signaling;
515 /*! Send connected line signaling to peer option. */
516 enum sig_pri_colp_signaling colp_send;
517 long resetinterval; /*!< Interval (in seconds) for resetting unused channels */
518 #if defined(HAVE_PRI_DISPLAY_TEXT)
519 unsigned long display_flags_send; /*!< PRI_DISPLAY_OPTION_xxx flags for display text sending */
520 unsigned long display_flags_receive; /*!< PRI_DISPLAY_OPTION_xxx flags for display text receiving */
521 #endif /* defined(HAVE_PRI_DISPLAY_TEXT) */
522 #if defined(HAVE_PRI_MWI)
523 /*! \brief Active MWI mailboxes */
524 struct sig_pri_mbox mbox[SIG_PRI_MAX_MWI_MAILBOXES];
526 * \brief Comma separated list of mailboxes to indicate MWI.
527 * \note Empty if disabled.
528 * \note Format: vm_mailbox{,vm_mailbox}
529 * \note String is split apart when span is started.
531 char mwi_mailboxes[SIG_PRI_MAX_MWI_MAILBOX_STR];
533 * \brief Comma separated list of mailbox numbers sent over ISDN span for MWI.
534 * \note Empty if disabled.
535 * \note Format: vm_box{,vm_box}
536 * \note String is split apart when span is started.
538 char mwi_vm_boxes[SIG_PRI_MAX_MWI_VM_NUMBER_STR];
540 * \brief Comma separated list of voicemail access controlling numbers for MWI.
541 * \note Format: vm_number{,vm_number}
542 * \note String is split apart when span is started.
544 char mwi_vm_numbers[SIG_PRI_MAX_MWI_VM_NUMBER_STR];
545 #endif /* defined(HAVE_PRI_MWI) */
547 * \brief Initial user tag for party id's sent from this device driver.
548 * \note String set by config file.
550 char initial_user_tag[AST_MAX_EXTENSION];
551 char msn_list[AST_MAX_EXTENSION]; /*!< Comma separated list of MSNs to handle. Empty if disabled. */
552 char idleext[AST_MAX_EXTENSION]; /*!< Where to idle extra calls */
553 char idlecontext[AST_MAX_CONTEXT]; /*!< What context to use for idle */
554 char idledial[AST_MAX_EXTENSION]; /*!< What to dial before dumping */
555 int minunused; /*!< Min # of channels to keep empty */
556 int minidle; /*!< Min # of "idling" calls to keep active */
557 int nodetype; /*!< Node type */
558 int switchtype; /*!< Type of switch to emulate */
559 int nsf; /*!< Network-Specific Facilities */
560 int trunkgroup; /*!< What our trunkgroup is */
561 #if defined(HAVE_PRI_CCSS)
562 int cc_ptmp_recall_mode; /*!< CC PTMP recall mode. globalRecall(0), specificRecall(1) */
563 int cc_qsig_signaling_link_req; /*!< CC Q.SIG signaling link retention (Party A) release(0), retain(1), do-not-care(2) */
564 int cc_qsig_signaling_link_rsp; /*!< CC Q.SIG signaling link retention (Party B) release(0), retain(1) */
565 #endif /* defined(HAVE_PRI_CCSS) */
566 #if defined(HAVE_PRI_CALL_WAITING)
568 * \brief Number of extra outgoing calls to allow on a span before
569 * considering that span congested.
571 int max_call_waiting_calls;
574 unsigned int hidecallerid:1;
575 unsigned int hidecalleridname:1; /*!< Hide just the name not the number for legacy PBX use */
576 unsigned int immediate:1; /*!< Answer before getting digits? */
577 unsigned int priexclusive:1; /*!< Whether or not to override and use exculsive mode for channel selection */
578 unsigned int priindication_oob:1;
579 unsigned int use_callerid:1; /*!< Whether or not to use caller id on this channel */
580 unsigned int use_callingpres:1; /*!< Whether to use the callingpres the calling switch sends */
581 char context[AST_MAX_CONTEXT];
582 char mohinterpret[MAX_MUSICCLASS];
586 * \brief Number of outstanding call waiting calls.
587 * \note Must be zero to allow new calls from asterisk to
588 * immediately allocate a B channel.
590 int num_call_waiting_calls;
591 #endif /* defined(HAVE_PRI_CALL_WAITING) */
592 int dchanavail[SIG_PRI_NUM_DCHANS]; /*!< Whether each channel is available */
593 int debug; /*!< set to true if to dump PRI event info */
594 int span; /*!< span number put into user output messages */
595 int resetting; /*!< true if span is being reset/restarted */
596 int resetpos; /*!< current position during a reset (-1 if not started) */
597 int sig; /*!< ISDN signalling type (SIG_PRI, SIG_BRI, SIG_BRI_PTMP, etc...) */
598 int new_chan_seq; /*!< New struct ast_channel sequence number */
599 /*! TRUE if we have already whined about no D channels available. */
600 unsigned int no_d_channels:1;
602 /* Everything after here is internally set */
603 struct pri *dchans[SIG_PRI_NUM_DCHANS]; /*!< Actual d-channels */
604 struct pri *pri; /*!< Currently active D-channel */
606 * List of private structures of the user of this module for no B channel
607 * interfaces. (hold and call waiting interfaces)
609 void *no_b_chan_iflist;
611 * List of private structures of the user of this module for no B channel
612 * interfaces. (hold and call waiting interfaces)
615 int numchans; /*!< Num of channels we represent */
616 struct sig_pri_chan *pvts[SIG_PRI_MAX_CHANNELS];/*!< Member channel pvt structs */
617 pthread_t master; /*!< Thread of master */
618 ast_mutex_t lock; /*!< libpri access Mutex */
619 time_t lastreset; /*!< time when unused channels were last reset */
621 * \brief Congestion device state of the span.
623 * AST_DEVICE_NOT_INUSE - Span does not have all B channels in use.
624 * AST_DEVICE_BUSY - All B channels are in use.
625 * AST_DEVICE_UNAVAILABLE - Span is in alarm.
627 * Device name: \verbatim DAHDI/I<span>/congestion. \endverbatim
629 int congestion_devstate;
630 #if defined(THRESHOLD_DEVSTATE_PLACEHOLDER)
631 /*! \todo An ISDN span threshold device state could be useful in determining how often a span utilization goes over a configurable threshold. */
633 * \brief User threshold device state of the span.
635 * AST_DEVICE_NOT_INUSE - There are no B channels in use.
636 * AST_DEVICE_INUSE - The number of B channels in use is less than
637 * the configured threshold but not zero.
638 * AST_DEVICE_BUSY - The number of B channels in use meets or exceeds
639 * the configured threshold.
640 * AST_DEVICE_UNAVAILABLE - Span is in alarm.
642 * Device name: DAHDI/I<span>/threshold
644 int threshold_devstate;
646 * \brief Number of B channels in use to consider the span in a busy state.
647 * \note Setting the threshold to zero is interpreted as all B channels.
649 int user_busy_threshold;
650 #endif /* defined(THRESHOLD_DEVSTATE_PLACEHOLDER) */
653 void sig_pri_extract_called_num_subaddr(struct sig_pri_chan *p, const char *rdest, char *called, size_t called_buff_size);
654 int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, const char *rdest, int timeout, int layer1);
656 int sig_pri_hangup(struct sig_pri_chan *p, struct ast_channel *ast);
658 int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condition, const void *data, size_t datalen);
660 int sig_pri_answer(struct sig_pri_chan *p, struct ast_channel *ast);
662 int sig_pri_is_chan_available(struct sig_pri_chan *pvt);
663 int sig_pri_available(struct sig_pri_chan **pvt, int is_specific_channel);
665 void sig_pri_init_pri(struct sig_pri_span *pri);
667 /* If return 0, it means this function was able to handle it (pre setup digits). If non zero, the user of this
668 * functions should handle it normally (generate inband DTMF) */
669 int sig_pri_digit_begin(struct sig_pri_chan *pvt, struct ast_channel *ast, char digit);
670 void sig_pri_dial_complete(struct sig_pri_chan *pvt, struct ast_channel *ast);
672 void sig_pri_stop_pri(struct sig_pri_span *pri);
673 int sig_pri_start_pri(struct sig_pri_span *pri);
675 void sig_pri_set_alarm(struct sig_pri_chan *p, int in_alarm);
676 void sig_pri_chan_alarm_notify(struct sig_pri_chan *p, int noalarm);
678 int sig_pri_is_alarm_ignored(struct sig_pri_span *pri);
679 void pri_event_alarm(struct sig_pri_span *pri, int index, int before_start_pri);
680 void pri_event_noalarm(struct sig_pri_span *pri, int index, int before_start_pri);
682 struct ast_channel *sig_pri_request(struct sig_pri_chan *p, enum sig_pri_law law,
683 const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor,
684 int transfercapability);
686 struct sig_pri_chan *sig_pri_chan_new(void *pvt_data, struct sig_pri_span *pri, int logicalspan, int channo, int trunkgroup);
687 void sig_pri_chan_delete(struct sig_pri_chan *doomed);
689 int pri_is_up(struct sig_pri_span *pri);
692 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);
694 void sig_pri_cli_show_channels_header(int fd);
695 void sig_pri_cli_show_channels(int fd, struct sig_pri_span *pri);
696 void sig_pri_cli_show_spans(int fd, int span, struct sig_pri_span *pri);
698 void sig_pri_cli_show_span(int fd, int *dchannels, struct sig_pri_span *pri);
700 int pri_send_keypad_facility_exec(struct sig_pri_chan *p, const char *digits);
701 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);
703 #if defined(HAVE_PRI_SERVICE_MESSAGES)
704 int pri_maintenance_bservice(struct pri *pri, struct sig_pri_chan *p, int changestatus);
705 #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */
707 void sig_pri_fixup(struct ast_channel *oldchan, struct ast_channel *newchan, struct sig_pri_chan *pchan);
708 #if defined(HAVE_PRI_DISPLAY_TEXT)
709 void sig_pri_sendtext(struct sig_pri_chan *pchan, const char *text);
710 #endif /* defined(HAVE_PRI_DISPLAY_TEXT) */
712 int sig_pri_cc_agent_init(struct ast_cc_agent *agent, struct sig_pri_chan *pvt_chan);
713 int sig_pri_cc_agent_start_offer_timer(struct ast_cc_agent *agent);
714 int sig_pri_cc_agent_stop_offer_timer(struct ast_cc_agent *agent);
715 void sig_pri_cc_agent_req_rsp(struct ast_cc_agent *agent, enum ast_cc_agent_response_reason reason);
716 int sig_pri_cc_agent_status_req(struct ast_cc_agent *agent);
717 int sig_pri_cc_agent_stop_ringing(struct ast_cc_agent *agent);
718 int sig_pri_cc_agent_party_b_free(struct ast_cc_agent *agent);
719 int sig_pri_cc_agent_start_monitoring(struct ast_cc_agent *agent);
720 int sig_pri_cc_agent_callee_available(struct ast_cc_agent *agent);
721 void sig_pri_cc_agent_destructor(struct ast_cc_agent *agent);
723 int sig_pri_cc_monitor_req_cc(struct ast_cc_monitor *monitor, int *available_timer_id);
724 int sig_pri_cc_monitor_suspend(struct ast_cc_monitor *monitor);
725 int sig_pri_cc_monitor_unsuspend(struct ast_cc_monitor *monitor);
726 int sig_pri_cc_monitor_status_rsp(struct ast_cc_monitor *monitor, enum ast_device_state devstate);
727 int sig_pri_cc_monitor_cancel_available_timer(struct ast_cc_monitor *monitor, int *sched_id);
728 void sig_pri_cc_monitor_destructor(void *monitor_pvt);
730 int sig_pri_load(const char *cc_type_name);
731 void sig_pri_unload(void);
733 #endif /* _SIG_PRI_H */