Debian Codegraph @

channels/sig_pri.h

raw symbols SCIP
1 #ifndef _SIG_PRI_H
2 #define _SIG_PRI_H
3 /*
4 * Asterisk -- An open source telephony toolkit.
5 *
6 * Copyright (C) 1999 - 2009, Digium, Inc.
7 *
8 * Mark Spencer <[email protected]>
9 *
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.
15 *
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.
19 */
20
21 /*! \file
22 *
23 * \brief Interface header for PRI signaling module
24 *
25 * \author Matthew Fredrickson <[email protected]>
26 */
27
28 #include "asterisk/channel.h"
29 #include "asterisk/frame.h"
30 #include "asterisk/ccss.h"
31 #include <libpri.h>
32 #include <dahdi/user.h>
33
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)
38 #else
39
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) */
44
45 #if 0
46 /*! PRI debug message flags set on initial startup. */
47 #define SIG_PRI_DEBUG_DEFAULT (SIG_PRI_DEBUG_NORMAL | PRI_DEBUG_Q931_DUMP)
48 #else
49 /*! PRI debug message flags set on initial startup. */
50 #define SIG_PRI_DEBUG_DEFAULT 0
51 #endif
52
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)
56
57 enum sig_pri_tone {
58 SIG_PRI_TONE_RINGTONE = 0,
59 SIG_PRI_TONE_STUTTER,
60 SIG_PRI_TONE_CONGESTION,
61 SIG_PRI_TONE_DIALTONE,
62 SIG_PRI_TONE_DIALRECALL,
63 SIG_PRI_TONE_INFO,
64 SIG_PRI_TONE_BUSY,
65 };
66
67 enum sig_pri_law {
68 SIG_PRI_DEFLAW = 0,
69 SIG_PRI_ULAW,
70 SIG_PRI_ALAW
71 };
72
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) */
82 };
83
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) */
105
106 /*! Number of MOH states. Must be last in enum. */
107 SIG_PRI_MOH_STATE_NUM
108 };
109
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) */
129
130 /*! Number of MOH events. Must be last in enum. */
131 SIG_PRI_MOH_EVENT_NUM
132 };
133
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,
150 };
151
152 enum sig_pri_reset_state {
153 /*! \brief The channel is not being RESTARTed. */
154 SIG_PRI_RESET_IDLE,
155 /*!
156 * \brief The channel is being RESTARTed.
157 * \note Waiting for a RESTART ACKNOWLEDGE from the peer.
158 */
159 SIG_PRI_RESET_ACTIVE,
160 /*!
161 * \brief Peer may not be sending the expected RESTART ACKNOWLEDGE.
162 *
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.
169 */
170 SIG_PRI_RESET_NO_ACK,
171 };
172
173 struct sig_pri_span;
174 struct xfer_rsp_data;
175
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);
187
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);
190
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);
194
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);
198
199 void (* const fixup_chans)(void *old_chan, void *new_chan);
200
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);
217
218 void (* const open_media)(void *pvt);
219
220 /*!
221 * \brief Post an AMI B channel association event.
222 *
223 * \param pvt Private structure of the user of this module.
224 * \param chan Channel associated with the private pointer
225 */
226 void (* const ami_channel_event)(void *pvt, struct ast_channel *chan);
227
228 /*! Reference the parent module. */
229 void (*module_ref)(void);
230 /*! Unreference the parent module. */
231 void (*module_unref)(void);
232 /*! Mark the span for destruction. */
233 void (*destroy_later)(struct sig_pri_span *pri);
234 };
235
236 /*! Global sig_pri callbacks to the upper layer. */
237 extern struct sig_pri_callback sig_pri_callbacks;
238
239 #define SIG_PRI_NUM_DCHANS 4 /*!< No more than 4 d-channels */
240 #define SIG_PRI_MAX_CHANNELS 672 /*!< No more than a DS3 per trunk group */
241
242 #define SIG_PRI DAHDI_SIG_CLEAR
243 #define SIG_BRI (0x2000000 | DAHDI_SIG_CLEAR)
244 #define SIG_BRI_PTMP (0X4000000 | DAHDI_SIG_CLEAR)
245
246 /* QSIG channel mapping option types */
247 #define DAHDI_CHAN_MAPPING_PHYSICAL 0
248 #define DAHDI_CHAN_MAPPING_LOGICAL 1
249
250 /* Overlap dialing option types */
251 #define DAHDI_OVERLAPDIAL_NONE 0
252 #define DAHDI_OVERLAPDIAL_OUTGOING 1
253 #define DAHDI_OVERLAPDIAL_INCOMING 2
254 #define DAHDI_OVERLAPDIAL_BOTH (DAHDI_OVERLAPDIAL_INCOMING|DAHDI_OVERLAPDIAL_OUTGOING)
255
256 #if defined(HAVE_PRI_SERVICE_MESSAGES)
257 /*! \brief Persistent Service State */
258 #define SRVST_DBKEY "service-state"
259 /*! \brief The out-of-service SERVICE state */
260 #define SRVST_TYPE_OOS "O"
261 /*! \brief SRVST_INITIALIZED is used to indicate a channel being out-of-service
262 * The SRVST_INITIALIZED is mostly used maintain backwards compatibility but also may
263 * mean that the channel has not yet received a RESTART message. If a channel is
264 * out-of-service with this reason a RESTART message will result in the channel
265 * being put into service. */
266 #define SRVST_INITIALIZED 0
267 /*! \brief SRVST_NEAREND is used to indicate that the near end was put out-of-service */
268 #define SRVST_NEAREND (1 << 0)
269 /*! \brief SRVST_FAREND is used to indicate that the far end was taken out-of-service */
270 #define SRVST_FAREND (1 << 1)
271 /*! \brief SRVST_BOTH is used to indicate that both sides of the channel are out-of-service */
272 #define SRVST_BOTH (SRVST_NEAREND | SRVST_FAREND)
273
274 /*! \brief The AstDB family */
275 static const char dahdi_db[] = "dahdi/registry";
276 #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */
277
278 struct sig_pri_chan {
279 /* Options to be set by user */
280 unsigned int hidecallerid:1;
281 unsigned int hidecalleridname:1; /*!< Hide just the name not the number for legacy PBX use */
282 unsigned int immediate:1; /*!< Answer before getting digits? */
283 unsigned int priexclusive:1; /*!< Whether or not to override and use exclusive mode for channel selection */
284 unsigned int priindication_oob:1;
285 unsigned int use_callerid:1; /*!< Whether or not to use caller id on this channel */
286 unsigned int use_callingpres:1; /*!< Whether to use the callingpres the calling switch sends */
287 char context[AST_MAX_CONTEXT];
288 char mohinterpret[MAX_MUSICCLASS];
289 int stripmsd;
290 int channel; /*!< Channel Number or CRV */
291
292 /* Options to be checked by user */
293 int cid_ani2; /*!< Automatic Number Identification number (Alternate PRI caller ID number) */
294 int cid_ton; /*!< Type Of Number (TON) */
295 int callingpres; /*!< The value of calling presentation that we're going to use when placing a PRI call */
296 char cid_num[AST_MAX_EXTENSION];
297 char cid_subaddr[AST_MAX_EXTENSION];
298 char cid_name[AST_MAX_EXTENSION];
299 char cid_ani[AST_MAX_EXTENSION];
300 /*! \brief User tag for party id's sent from this device driver. */
301 char user_tag[AST_MAX_EXTENSION * 2];
302 char exten[AST_MAX_EXTENSION];
303
304 /* Internal variables -- Don't touch */
305 /* Probably will need DS0 number, DS1 number, and a few other things */
306 char dialdest[256]; /* Queued up digits for overlap dialing. They will be sent out as information messages when setup ACK is received */
307 #if defined(HAVE_PRI_SETUP_KEYPAD)
308 /*! \brief Keypad digits that came in with the SETUP message. */
309 char keypad_digits[AST_MAX_EXTENSION];
310 #endif /* defined(HAVE_PRI_SETUP_KEYPAD) */
311 /*! 'w' deferred dialing digits. */
312 char deferred_digits[AST_MAX_EXTENSION];
313 /*! Music class suggested with AST_CONTROL_HOLD. */
314 char moh_suggested[MAX_MUSICCLASS];
315 enum sig_pri_moh_state moh_state;
316
317 #if defined(HAVE_PRI_AOC_EVENTS)
318 struct pri_subcmd_aoc_e aoc_e;
319 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 */
320 unsigned int aoc_s_request_invoke_id_valid:1; /*!< This is set when the AOC-S invoke id is present */
321 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. */
322 unsigned int holding_aoce:1; /*!< received AOC-E msg from asterisk. holding for disconnect/release */
323 #endif /* defined(HAVE_PRI_AOC_EVENTS) */
324 unsigned int inalarm:1;
325 unsigned int alreadyhungup:1; /*!< TRUE if the call has already gone/hungup */
326 unsigned int isidlecall:1; /*!< TRUE if this is an idle call */
327 unsigned int progress:1; /*!< TRUE if the call has seen inband-information progress through the network */
328
329 /*!
330 * \brief TRUE when this channel is allocated.
331 *
332 * \details
333 * Needed to hold an outgoing channel allocation before the
334 * owner pointer is created.
335 *
336 * \note This is one of several items to check to see if a
337 * channel is available for use.
338 */
339 unsigned int allocated:1;
340 unsigned int outgoing:1;
341 unsigned int digital:1;
342 /*! \brief TRUE if this interface has no B channel. (call hold and call waiting) */
343 unsigned int no_b_channel:1;
344 #if defined(HAVE_PRI_CALL_WAITING)
345 /*! \brief TRUE if this is a call waiting call */
346 unsigned int is_call_waiting:1;
347 #endif /* defined(HAVE_PRI_CALL_WAITING) */
348 #if defined(HAVE_PRI_SETUP_ACK_INBAND)
349 /*! TRUE if outgoing SETUP had no called digits */
350 unsigned int no_dialed_digits:1;
351 #endif /* defined(HAVE_PRI_SETUP_ACK_INBAND) */
352
353 struct ast_channel *owner;
354
355 struct sig_pri_span *pri;
356 q931_call *call; /*!< opaque libpri call control structure */
357
358 /*! Call establishment life cycle level for simple comparisons. */
359 enum sig_pri_call_level call_level;
360 /*! \brief Channel reset/restart state. */
361 enum sig_pri_reset_state resetting;
362 #if defined(HAVE_PRI_TRANSFER)
363 /*! If non-NULL, send transfer disconnect successful response to first call disconnecting. */
364 struct xfer_rsp_data *xfer_data;
365 #endif /* defined(HAVE_PRI_TRANSFER) */
366 int prioffset; /*!< channel number in span */
367 int logicalspan; /*!< logical span number within trunk group */
368 int mastertrunkgroup; /*!< what trunk group is our master */
369 #if defined(HAVE_PRI_SERVICE_MESSAGES)
370 /*! \brief Active SRVST_DBKEY out-of-service status value. */
371 unsigned service_status;
372 #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */
373
374 void *chan_pvt; /*!< Private structure of the user of this module. */
375 #if defined(HAVE_PRI_REVERSE_CHARGE)
376 /*!
377 * \brief Reverse charging indication
378 * \details
379 * -1 - No reverse charging,
380 * 1 - Reverse charging,
381 * 0,2-7 - Reserved for future use
382 */
383 int reverse_charging_indication;
384 #endif
385 };
386
387 #if defined(HAVE_PRI_MWI)
388 /*! Maximum number of mailboxes per span. */
389 #define SIG_PRI_MAX_MWI_MAILBOXES 8
390 /*! Typical maximum length of mwi voicemail controlling number */
391 #define SIG_PRI_MAX_MWI_VM_NUMBER_LEN 10 /* digits in number */
392 /*! Typical maximum length of mwi mailbox number */
393 #define SIG_PRI_MAX_MWI_MBOX_NUMBER_LEN 10 /* digits in number */
394 /*! Typical maximum length of mwi mailbox context */
395 #define SIG_PRI_MAX_MWI_CONTEXT_LEN 10
396 /*!
397 * \brief Maximum mwi_vm_numbers and mwi_vm_boxes string length.
398 * \details
399 * max_length = #mailboxes * (vm_number + ',')
400 * The last ',' is a null terminator instead.
401 */
402 #define SIG_PRI_MAX_MWI_VM_NUMBER_STR (SIG_PRI_MAX_MWI_MAILBOXES \
403 * (SIG_PRI_MAX_MWI_VM_NUMBER_LEN + 1))
404 /*!
405 * \brief Maximum length of vm_mailbox string.
406 * \details
407 * max_length = vm_box + '@' + context.
408 */
409 #define SIG_PRI_MAX_MWI_VM_MAILBOX (SIG_PRI_MAX_MWI_MBOX_NUMBER_LEN \
410 + 1 + SIG_PRI_MAX_MWI_CONTEXT_LEN)
411 /*!
412 * \brief Maximum mwi_mailboxs string length.
413 * \details
414 * max_length = #mailboxes * (vm_mailbox + ',')
415 * The last ',' is a null terminator instead.
416 */
417 #define SIG_PRI_MAX_MWI_MAILBOX_STR (SIG_PRI_MAX_MWI_MAILBOXES \
418 * (SIG_PRI_MAX_MWI_VM_MAILBOX + 1))
419
420 struct sig_pri_mbox {
421 /*!
422 * \brief MWI mailbox event subscription.
423 * \note NULL if mailbox not configured.
424 */
425 struct ast_mwi_subscriber *sub;
426 /*! \brief Mailbox uniqueid. */
427 const char *uniqueid;
428 /*! \brief Mailbox number sent to span. */
429 const char *vm_box;
430 /*! \brief Voicemail access controlling number sent to span. */
431 const char *vm_number;
432 };
433 #endif /* defined(HAVE_PRI_MWI) */
434
435 enum sig_pri_colp_signaling {
436 /*! Block all connected line updates. */
437 SIG_PRI_COLP_BLOCK,
438 /*! Only send connected line information with the CONNECT message. */
439 SIG_PRI_COLP_CONNECT,
440 /*! Allow all connected line updates. */
441 SIG_PRI_COLP_UPDATE,
442 };
443
444 struct sig_pri_span {
445 /* Should be set by user */
446 struct ast_cc_config_params *cc_params; /*!< CC config parameters for each new call. */
447 int pritimers[PRI_MAX_TIMERS];
448 int overlapdial; /*!< In overlap dialing mode */
449 int qsigchannelmapping; /*!< QSIG channel mapping type */
450 int discardremoteholdretrieval; /*!< shall remote hold or remote retrieval notifications be discarded? */
451 int facilityenable; /*!< Enable facility IEs */
452 #if defined(HAVE_PRI_L2_PERSISTENCE)
453 /*! Layer 2 persistence option. */
454 int l2_persistence;
455 #endif /* defined(HAVE_PRI_L2_PERSISTENCE) */
456 int dchan_logical_span[SIG_PRI_NUM_DCHANS]; /*!< Logical offset the DCHAN sits in */
457 int fds[SIG_PRI_NUM_DCHANS]; /*!< FD's for d-channels */
458
459 #if defined(HAVE_PRI_AOC_EVENTS)
460 int aoc_passthrough_flag; /*!< Represents what AOC messages (S,D,E) are allowed to pass-through */
461 unsigned int aoce_delayhangup:1; /*!< defines whether the aoce_delayhangup option is enabled or not */
462 #endif /* defined(HAVE_PRI_AOC_EVENTS) */
463
464 #if defined(HAVE_PRI_SERVICE_MESSAGES)
465 unsigned int enable_service_message_support:1; /*!< enable SERVICE message support */
466 #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */
467 #ifdef HAVE_PRI_INBANDDISCONNECT
468 unsigned int inbanddisconnect:1; /*!< Should we support inband audio after receiving DISCONNECT? */
469 #endif
470 #if defined(HAVE_PRI_CALL_HOLD)
471 /*! \brief TRUE if held calls are transferred on disconnect. */
472 unsigned int hold_disconnect_transfer:1;
473 #endif /* defined(HAVE_PRI_CALL_HOLD) */
474 /*!
475 * \brief TRUE if call transfer is enabled for the span.
476 * \note Support switch-side transfer (called 2BCT, RLT or other names)
477 */
478 unsigned int transfer:1;
479 #if defined(HAVE_PRI_CALL_WAITING)
480 /*! \brief TRUE if we will allow incoming ISDN call waiting calls. */
481 unsigned int allow_call_waiting_calls:1;
482 #endif /* defined(HAVE_PRI_CALL_WAITING) */
483 /*! TRUE if layer 1 alarm status is ignored */
484 unsigned int layer1_ignored:1;
485 /*!
486 * TRUE if a new call's sig_pri_chan.user_tag[] has the MSN
487 * appended to the initial_user_tag[].
488 */
489 unsigned int append_msn_to_user_tag:1;
490 /*! TRUE if a SETUP ACK message needs to open the audio path. */
491 unsigned int inband_on_setup_ack:1;
492 /*! TRUE if a PROCEEDING message needs to unsquelch the received audio. */
493 unsigned int inband_on_proceeding:1;
494 #if defined(HAVE_PRI_MCID)
495 /*! \brief TRUE if allow sending MCID request on this span. */
496 unsigned int mcid_send:1;
497 #endif /* defined(HAVE_PRI_MCID) */
498 /*! \brief TRUE if forcing RESTART when receive cause 44 on this span. */
499 unsigned int force_restart_unavailable_chans:1;
500 #if defined(HAVE_PRI_DATETIME_SEND)
501 /*! \brief Configured date/time ie send policy option. */
502 int datetime_send;
503 #endif /* defined(HAVE_PRI_DATETIME_SEND) */
504 int dialplan; /*!< Dialing plan */
505 int localdialplan; /*!< Local dialing plan */
506 int cpndialplan; /*!< Connected party dialing plan */
507 char internationalprefix[10]; /*!< country access code ('00' for european dialplans) */
508 char nationalprefix[10]; /*!< area access code ('0' for european dialplans) */
509 char localprefix[20]; /*!< area access code + area code ('0'+area code for european dialplans) */
510 char privateprefix[20]; /*!< for private dialplans */
511 char unknownprefix[20]; /*!< for unknown dialplans */
512 enum sig_pri_moh_signaling moh_signaling;
513 /*! Send connected line signaling to peer option. */
514 enum sig_pri_colp_signaling colp_send;
515 long resetinterval; /*!< Interval (in seconds) for resetting unused channels */
516 #if defined(HAVE_PRI_DISPLAY_TEXT)
517 unsigned long display_flags_send; /*!< PRI_DISPLAY_OPTION_xxx flags for display text sending */
518 unsigned long display_flags_receive; /*!< PRI_DISPLAY_OPTION_xxx flags for display text receiving */
519 #endif /* defined(HAVE_PRI_DISPLAY_TEXT) */
520 #if defined(HAVE_PRI_MWI)
521 /*! \brief Active MWI mailboxes */
522 struct sig_pri_mbox mbox[SIG_PRI_MAX_MWI_MAILBOXES];
523 /*!
524 * \brief Comma separated list of mailboxes to indicate MWI.
525 * \note Empty if disabled.
526 * \note Format: vm_mailbox{,vm_mailbox}
527 * \note String is split apart when span is started.
528 */
529 char mwi_mailboxes[SIG_PRI_MAX_MWI_MAILBOX_STR];
530 /*!
531 * \brief Comma separated list of mailbox numbers sent over ISDN span for MWI.
532 * \note Empty if disabled.
533 * \note Format: vm_box{,vm_box}
534 * \note String is split apart when span is started.
535 */
536 char mwi_vm_boxes[SIG_PRI_MAX_MWI_VM_NUMBER_STR];
537 /*!
538 * \brief Comma separated list of voicemail access controlling numbers for MWI.
539 * \note Format: vm_number{,vm_number}
540 * \note String is split apart when span is started.
541 */
542 char mwi_vm_numbers[SIG_PRI_MAX_MWI_VM_NUMBER_STR];
543 #endif /* defined(HAVE_PRI_MWI) */
544 /*!
545 * \brief Initial user tag for party id's sent from this device driver.
546 * \note String set by config file.
547 */
548 char initial_user_tag[AST_MAX_EXTENSION];
549 char msn_list[AST_MAX_EXTENSION]; /*!< Comma separated list of MSNs to handle. Empty if disabled. */
550 char idleext[AST_MAX_EXTENSION]; /*!< Where to idle extra calls */
551 char idlecontext[AST_MAX_CONTEXT]; /*!< What context to use for idle */
552 char idledial[AST_MAX_EXTENSION]; /*!< What to dial before dumping */
553 int minunused; /*!< Min # of channels to keep empty */
554 int minidle; /*!< Min # of "idling" calls to keep active */
555 int nodetype; /*!< Node type */
556 int switchtype; /*!< Type of switch to emulate */
557 int nsf; /*!< Network-Specific Facilities */
558 int trunkgroup; /*!< What our trunkgroup is */
559 #if defined(HAVE_PRI_CCSS)
560 int cc_ptmp_recall_mode; /*!< CC PTMP recall mode. globalRecall(0), specificRecall(1) */
561 int cc_qsig_signaling_link_req; /*!< CC Q.SIG signaling link retention (Party A) release(0), retain(1), do-not-care(2) */
562 int cc_qsig_signaling_link_rsp; /*!< CC Q.SIG signaling link retention (Party B) release(0), retain(1) */
563 #endif /* defined(HAVE_PRI_CCSS) */
564 #if defined(HAVE_PRI_CALL_WAITING)
565 /*!
566 * \brief Number of extra outgoing calls to allow on a span before
567 * considering that span congested.
568 */
569 int max_call_waiting_calls;
570 struct {
571 int stripmsd;
572 unsigned int hidecallerid:1;
573 unsigned int hidecalleridname:1; /*!< Hide just the name not the number for legacy PBX use */
574 unsigned int immediate:1; /*!< Answer before getting digits? */
575 unsigned int priexclusive:1; /*!< Whether or not to override and use exclusive mode for channel selection */
576 unsigned int priindication_oob:1;
577 unsigned int use_callerid:1; /*!< Whether or not to use caller id on this channel */
578 unsigned int use_callingpres:1; /*!< Whether to use the callingpres the calling switch sends */
579 char context[AST_MAX_CONTEXT];
580 char mohinterpret[MAX_MUSICCLASS];
581 } ch_cfg;
582
583 /*!
584 * \brief Number of outstanding call waiting calls.
585 * \note Must be zero to allow new calls from asterisk to
586 * immediately allocate a B channel.
587 */
588 int num_call_waiting_calls;
589 #endif /* defined(HAVE_PRI_CALL_WAITING) */
590 int dchanavail[SIG_PRI_NUM_DCHANS]; /*!< Whether each channel is available */
591 int debug; /*!< set to true if to dump PRI event info */
592 int span; /*!< span number put into user output messages */
593 int resetting; /*!< true if span is being reset/restarted */
594 int resetpos; /*!< current position during a reset (-1 if not started) */
595 int sig; /*!< ISDN signalling type (SIG_PRI, SIG_BRI, SIG_BRI_PTMP, etc...) */
596 int new_chan_seq; /*!< New struct ast_channel sequence number */
597 /*! TRUE if we have already whined about no D channels available. */
598 unsigned int no_d_channels:1;
599
600 /* Everything after here is internally set */
601 struct pri *dchans[SIG_PRI_NUM_DCHANS]; /*!< Actual d-channels */
602 struct pri *pri; /*!< Currently active D-channel */
603 /*!
604 * List of private structures of the user of this module for no B channel
605 * interfaces. (hold and call waiting interfaces)
606 */
607 void *no_b_chan_iflist;
608 /*!
609 * List of private structures of the user of this module for no B channel
610 * interfaces. (hold and call waiting interfaces)
611 */
612 void *no_b_chan_end;
613 int numchans; /*!< Num of channels we represent */
614 struct sig_pri_chan *pvts[SIG_PRI_MAX_CHANNELS];/*!< Member channel pvt structs */
615 pthread_t master; /*!< Thread of master */
616 ast_mutex_t lock; /*!< libpri access Mutex */
617 time_t lastreset; /*!< time when unused channels were last reset */
618 /*!
619 * \brief Congestion device state of the span.
620 * \details
621 * AST_DEVICE_NOT_INUSE - Span does not have all B channels in use.
622 * AST_DEVICE_BUSY - All B channels are in use.
623 * AST_DEVICE_UNAVAILABLE - Span is in alarm.
624 * \note
625 * Device name: \verbatim DAHDI/I<span>/congestion. \endverbatim
626 */
627 int congestion_devstate;
628 #if defined(THRESHOLD_DEVSTATE_PLACEHOLDER)
629 /*! \todo An ISDN span threshold device state could be useful in determining how often a span utilization goes over a configurable threshold. */
630 /*!
631 * \brief User threshold device state of the span.
632 * \details
633 * AST_DEVICE_NOT_INUSE - There are no B channels in use.
634 * AST_DEVICE_INUSE - The number of B channels in use is less than
635 * the configured threshold but not zero.
636 * AST_DEVICE_BUSY - The number of B channels in use meets or exceeds
637 * the configured threshold.
638 * AST_DEVICE_UNAVAILABLE - Span is in alarm.
639 * \note
640 * Device name: \verbatim DAHDI/I<span>/threshold \endverbatim
641 */
642 int threshold_devstate;
643 /*!
644 * \brief Number of B channels in use to consider the span in a busy state.
645 * \note Setting the threshold to zero is interpreted as all B channels.
646 */
647 int user_busy_threshold;
648 #endif /* defined(THRESHOLD_DEVSTATE_PLACEHOLDER) */
649 };
650
651 void sig_pri_extract_called_num_subaddr(struct sig_pri_chan *p, const char *rdest, char *called, size_t called_buff_size);
652 int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, const char *rdest, int timeout, int layer1);
653
654 int sig_pri_hangup(struct sig_pri_chan *p, struct ast_channel *ast);
655
656 int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condition, const void *data, size_t datalen);
657
658 int sig_pri_answer(struct sig_pri_chan *p, struct ast_channel *ast);
659
660 int sig_pri_is_chan_available(struct sig_pri_chan *pvt);
661 int sig_pri_available(struct sig_pri_chan **pvt, int is_specific_channel);
662
663 void sig_pri_init_pri(struct sig_pri_span *pri);
664
665 /* If return 0, it means this function was able to handle it (pre setup digits). If non zero, the user of this
666 * functions should handle it normally (generate inband DTMF) */
667 int sig_pri_digit_begin(struct sig_pri_chan *pvt, struct ast_channel *ast, char digit);
668 void sig_pri_dial_complete(struct sig_pri_chan *pvt, struct ast_channel *ast);
669
670 void sig_pri_stop_pri(struct sig_pri_span *pri);
671 int sig_pri_start_pri(struct sig_pri_span *pri);
672
673 void sig_pri_set_alarm(struct sig_pri_chan *p, int in_alarm);
674 void sig_pri_chan_alarm_notify(struct sig_pri_chan *p, int noalarm);
675
676 int sig_pri_is_alarm_ignored(struct sig_pri_span *pri);
677 void pri_event_alarm(struct sig_pri_span *pri, int index, int before_start_pri);
678 void pri_event_noalarm(struct sig_pri_span *pri, int index, int before_start_pri);
679
680 struct ast_channel *sig_pri_request(struct sig_pri_chan *p, enum sig_pri_law law,
681 const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor,
682 int transfercapability);
683
684 struct sig_pri_chan *sig_pri_chan_new(void *pvt_data, struct sig_pri_span *pri, int logicalspan, int channo, int trunkgroup);
685 void sig_pri_chan_delete(struct sig_pri_chan *doomed);
686
687 int pri_is_up(struct sig_pri_span *pri);
688
689 struct mansession;
690 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);
691
692 void sig_pri_cli_show_channels_header(int fd);
693 void sig_pri_cli_show_channels(int fd, struct sig_pri_span *pri);
694 void sig_pri_cli_show_spans(int fd, int span, struct sig_pri_span *pri);
695
696 void sig_pri_cli_show_span(int fd, int *dchannels, struct sig_pri_span *pri);
697
698 int pri_send_keypad_facility_exec(struct sig_pri_chan *p, const char *digits);
699 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);
700
701 #if defined(HAVE_PRI_SERVICE_MESSAGES)
702 int pri_maintenance_bservice(struct pri *pri, struct sig_pri_chan *p, int changestatus);
703 #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */
704
705 void sig_pri_fixup(struct ast_channel *oldchan, struct ast_channel *newchan, struct sig_pri_chan *pchan);
706 #if defined(HAVE_PRI_DISPLAY_TEXT)
707 void sig_pri_sendtext(struct sig_pri_chan *pchan, const char *text);
708 #endif /* defined(HAVE_PRI_DISPLAY_TEXT) */
709
710 int sig_pri_cc_agent_init(struct ast_cc_agent *agent, struct sig_pri_chan *pvt_chan);
711 int sig_pri_cc_agent_start_offer_timer(struct ast_cc_agent *agent);
712 int sig_pri_cc_agent_stop_offer_timer(struct ast_cc_agent *agent);
713 void sig_pri_cc_agent_req_rsp(struct ast_cc_agent *agent, enum ast_cc_agent_response_reason reason);
714 int sig_pri_cc_agent_status_req(struct ast_cc_agent *agent);
715 int sig_pri_cc_agent_stop_ringing(struct ast_cc_agent *agent);
716 int sig_pri_cc_agent_party_b_free(struct ast_cc_agent *agent);
717 int sig_pri_cc_agent_start_monitoring(struct ast_cc_agent *agent);
718 int sig_pri_cc_agent_callee_available(struct ast_cc_agent *agent);
719 void sig_pri_cc_agent_destructor(struct ast_cc_agent *agent);
720
721 int sig_pri_cc_monitor_req_cc(struct ast_cc_monitor *monitor, int *available_timer_id);
722 int sig_pri_cc_monitor_suspend(struct ast_cc_monitor *monitor);
723 int sig_pri_cc_monitor_unsuspend(struct ast_cc_monitor *monitor);
724 int sig_pri_cc_monitor_status_rsp(struct ast_cc_monitor *monitor, enum ast_device_state devstate);
725 int sig_pri_cc_monitor_cancel_available_timer(struct ast_cc_monitor *monitor, int *sched_id);
726 void sig_pri_cc_monitor_destructor(void *monitor_pvt);
727
728 int sig_pri_load(const char *cc_type_name);
729 void sig_pri_unload(void);
730
731 #endif /* _SIG_PRI_H */