Asterisk - The Open Source Telephony Project  18.5.0
sig_pri.h
Go to the documentation of this file.
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 
65 };
66 
71 };
72 
74  /*! Generate MOH to the remote party. */
76  /*! Send hold notification signaling to the remote party. */
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 
85  /*! Bridged peer has not put us on hold. */
87  /*! Bridged peer has put us on hold and we were to notify the remote party. */
89  /*! Bridged peer has put us on hold and we were to play MOH or HOLD/RETRIEVE fallback. */
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. */
108 };
109 
111  /*! Reset the MOH state machine. (Because of hangup.) */
113  /*! Bridged peer placed this channel on hold. */
115  /*! Bridged peer took this channel off hold. */
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. */
132 };
133 
134 /*! Call establishment life cycle level for simple comparisons. */
136  /*! Call does not exist. */
138  /*! Call is present but has no response yet. (SETUP) */
140  /*! Call is collecting digits for overlap dialing. (SETUP ACKNOWLEDGE) */
142  /*! Call routing is happening. (PROCEEDING) */
144  /*! Called party is being alerted of the call. (ALERTING) */
146  /*! Call is dialing 'w' deferred digits. (CONNECT) */
148  /*! Call is connected/answered. (CONNECT) */
150 };
151 
153  /*! \brief The channel is not being RESTARTed. */
155  /*!
156  * \brief The channel is being RESTARTed.
157  * \note Waiting for a RESTART ACKNOWLEDGE from the peer.
158  */
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  */
171 };
172 
173 struct sig_pri_span;
174 struct xfer_rsp_data;
175 
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  * \return Nothing
227  */
228  void (* const ami_channel_event)(void *pvt, struct ast_channel *chan);
229 
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);
236 };
237 
238 /*! Global sig_pri callbacks to the upper layer. */
239 extern struct sig_pri_callback sig_pri_callbacks;
240 
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 */
243 
244 #define SIG_PRI DAHDI_SIG_CLEAR
245 #define SIG_BRI (0x2000000 | DAHDI_SIG_CLEAR)
246 #define SIG_BRI_PTMP (0X4000000 | DAHDI_SIG_CLEAR)
247 
248 /* QSIG channel mapping option types */
249 #define DAHDI_CHAN_MAPPING_PHYSICAL 0
250 #define DAHDI_CHAN_MAPPING_LOGICAL 1
251 
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)
257 
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)
275 
276 /*! \brief The AstDB family */
277 static const char dahdi_db[] = "dahdi/registry";
278 #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */
279 
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 */
291  int stripmsd;
292  int channel; /*!< Channel Number or CRV */
293 
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 */
299  char cid_subaddr[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 * 2];
305 
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;
318 
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 */
330 
331  /*!
332  * \brief TRUE when this channel is allocated.
333  *
334  * \details
335  * Needed to hold an outgoing channel allocation before the
336  * owner pointer is created.
337  *
338  * \note This is one of several items to check to see if a
339  * channel is available for use.
340  */
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) */
354 
356 
357  struct sig_pri_span *pri;
358  q931_call *call; /*!< opaque libpri call control structure */
359 
360  /*! Call establishment life cycle level for simple comparisons. */
361  enum sig_pri_call_level call_level;
362  /*! \brief Channel reset/restart state. */
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) */
375 
376  void *chan_pvt; /*!< Private structure of the user of this module. */
377 #if defined(HAVE_PRI_REVERSE_CHARGE)
378  /*!
379  * \brief Reverse charging indication
380  * \details
381  * -1 - No reverse charging,
382  * 1 - Reverse charging,
383  * 0,2-7 - Reserved for future use
384  */
385  int reverse_charging_indication;
386 #endif
387 };
388 
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
398 /*!
399  * \brief Maximum mwi_vm_numbers and mwi_vm_boxes string length.
400  * \details
401  * max_length = #mailboxes * (vm_number + ',')
402  * The last ',' is a null terminator instead.
403  */
404 #define SIG_PRI_MAX_MWI_VM_NUMBER_STR (SIG_PRI_MAX_MWI_MAILBOXES \
405  * (SIG_PRI_MAX_MWI_VM_NUMBER_LEN + 1))
406 /*!
407  * \brief Maximum length of vm_mailbox string.
408  * \details
409  * max_length = vm_box + '@' + context.
410  */
411 #define SIG_PRI_MAX_MWI_VM_MAILBOX (SIG_PRI_MAX_MWI_MBOX_NUMBER_LEN \
412  + 1 + SIG_PRI_MAX_MWI_CONTEXT_LEN)
413 /*!
414  * \brief Maximum mwi_mailboxs string length.
415  * \details
416  * max_length = #mailboxes * (vm_mailbox + ',')
417  * The last ',' is a null terminator instead.
418  */
419 #define SIG_PRI_MAX_MWI_MAILBOX_STR (SIG_PRI_MAX_MWI_MAILBOXES \
420  * (SIG_PRI_MAX_MWI_VM_MAILBOX + 1))
421 
422 struct sig_pri_mbox {
423  /*!
424  * \brief MWI mailbox event subscription.
425  * \note NULL if mailbox not configured.
426  */
427  struct ast_mwi_subscriber *sub;
428  /*! \brief Mailbox uniqueid. */
429  const char *uniqueid;
430  /*! \brief Mailbox number sent to span. */
431  const char *vm_box;
432  /*! \brief Voicemail access controlling number sent to span. */
433  const char *vm_number;
434 };
435 #endif /* defined(HAVE_PRI_MWI) */
436 
438  /*! Block all connected line updates. */
440  /*! Only send connected line information with the CONNECT message. */
442  /*! Allow all connected line updates. */
444 };
445 
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. */
456  int l2_persistence;
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 */
460 
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) */
465 
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? */
471 #endif
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) */
476  /*!
477  * \brief TRUE if call transfer is enabled for the span.
478  * \note Support switch-side transfer (called 2BCT, RLT or other names)
479  */
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;
487  /*!
488  * TRUE if a new call's sig_pri_chan.user_tag[] has the MSN
489  * appended to the initial_user_tag[].
490  */
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 #endif /* defined(HAVE_PRI_MCID) */
500  /*! \brief TRUE if forcing RESTART when receive cause 44 on this span. */
502 #if defined(HAVE_PRI_DATETIME_SEND)
503  /*! \brief Configured date/time ie send policy option. */
504  int datetime_send;
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];
525  /*!
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.
530  */
531  char mwi_mailboxes[SIG_PRI_MAX_MWI_MAILBOX_STR];
532  /*!
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.
537  */
538  char mwi_vm_boxes[SIG_PRI_MAX_MWI_VM_NUMBER_STR];
539  /*!
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.
543  */
544  char mwi_vm_numbers[SIG_PRI_MAX_MWI_VM_NUMBER_STR];
545 #endif /* defined(HAVE_PRI_MWI) */
546  /*!
547  * \brief Initial user tag for party id's sent from this device driver.
548  * \note String set by config file.
549  */
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)
567  /*!
568  * \brief Number of extra outgoing calls to allow on a span before
569  * considering that span congested.
570  */
571  int max_call_waiting_calls;
572  struct {
573  int stripmsd;
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];
583  } ch_cfg;
584 
585  /*!
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.
589  */
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;
601 
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 */
605  /*!
606  * List of private structures of the user of this module for no B channel
607  * interfaces. (hold and call waiting interfaces)
608  */
610  /*!
611  * List of private structures of the user of this module for no B channel
612  * interfaces. (hold and call waiting interfaces)
613  */
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 */
620  /*!
621  * \brief Congestion device state of the span.
622  * \details
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.
626  * \note
627  * Device name: \verbatim DAHDI/I<span>/congestion. \endverbatim
628  */
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. */
632  /*!
633  * \brief User threshold device state of the span.
634  * \details
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.
641  * \note
642  * Device name: DAHDI/I<span>/threshold
643  */
644  int threshold_devstate;
645  /*!
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.
648  */
649  int user_busy_threshold;
650 #endif /* defined(THRESHOLD_DEVSTATE_PLACEHOLDER) */
651 };
652 
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);
655 
656 int sig_pri_hangup(struct sig_pri_chan *p, struct ast_channel *ast);
657 
658 int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condition, const void *data, size_t datalen);
659 
660 int sig_pri_answer(struct sig_pri_chan *p, struct ast_channel *ast);
661 
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);
664 
665 void sig_pri_init_pri(struct sig_pri_span *pri);
666 
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);
671 
672 void sig_pri_stop_pri(struct sig_pri_span *pri);
673 int sig_pri_start_pri(struct sig_pri_span *pri);
674 
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);
677 
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);
681 
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);
685 
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);
688 
689 int pri_is_up(struct sig_pri_span *pri);
690 
691 struct mansession;
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);
693 
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);
697 
698 void sig_pri_cli_show_span(int fd, int *dchannels, struct sig_pri_span *pri);
699 
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);
702 
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) */
706 
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) */
711 
712 int sig_pri_cc_agent_init(struct ast_cc_agent *agent, struct sig_pri_chan *pvt_chan);
716 int sig_pri_cc_agent_status_req(struct ast_cc_agent *agent);
721 void sig_pri_cc_agent_destructor(struct ast_cc_agent *agent);
722 
723 int sig_pri_cc_monitor_req_cc(struct ast_cc_monitor *monitor, int *available_timer_id);
728 void sig_pri_cc_monitor_destructor(void *monitor_pvt);
729 
730 int sig_pri_load(const char *cc_type_name);
731 void sig_pri_unload(void);
732 
733 #endif /* _SIG_PRI_H */
void(*const lock_private)(void *pvt)
Definition: sig_pri.h:180
int cid_ton
Definition: sig_pri.h:296
void sig_pri_unload(void)
int sig_pri_cc_monitor_unsuspend(struct ast_cc_monitor *monitor)
int nodetype
Definition: sig_pri.h:557
void sig_pri_chan_alarm_notify(struct sig_pri_chan *p, int noalarm)
char digit
long resetinterval
Definition: sig_pri.h:517
static char mohinterpret[MAX_MUSICCLASS]
Definition: chan_alsa.c:119
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
Main Channel structure associated with a channel.
int logicalspan
Definition: sig_pri.h:369
int sig_pri_cc_agent_party_b_free(struct ast_cc_agent *agent)
ast_device_state
Device States.
Definition: devicestate.h:52
unsigned int alreadyhungup
Definition: sig_pri.h:327
int sig_pri_available(struct sig_pri_chan **pvt, int is_specific_channel)
unsigned int priexclusive
Definition: sig_pri.h:285
int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condition, const void *data, size_t datalen)
int congestion_devstate
Congestion device state of the span.
Definition: sig_pri.h:629
unsigned int use_callingpres
Definition: sig_pri.h:288
int callingpres
Definition: sig_pri.h:297
void sig_pri_cli_show_span(int fd, int *dchannels, struct sig_pri_span *pri)
void sig_pri_cli_show_spans(int fd, int span, struct sig_pri_span *pri)
void(*const init_config)(void *pvt, struct sig_pri_span *pri)
Definition: sig_pri.h:212
void sig_pri_cli_show_channels(int fd, struct sig_pri_span *pri)
void sig_pri_cli_show_channels_header(int fd)
sig_pri_moh_event
Definition: sig_pri.h:110
unsigned int priindication_oob
Definition: sig_pri.h:286
unsigned int use_callerid
Definition: sig_pri.h:287
#define MAX_MUSICCLASS
Definition: channel.h:174
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
void pri_event_alarm(struct sig_pri_span *pri, int index, int before_start_pri)
int sig_pri_cc_agent_stop_offer_timer(struct ast_cc_agent *agent)
unsigned int transfer
TRUE if call transfer is enabled for the span.
Definition: sig_pri.h:480
struct sig_pri_callback sig_pri_callbacks
int facilityenable
Definition: sig_pri.h:453
int sig_pri_cc_monitor_req_cc(struct ast_cc_monitor *monitor, int *available_timer_id)
q931_call * call
Definition: sig_pri.h:358
unsigned int progress
Definition: sig_pri.h:329
static int timeout
Definition: cdr_mysql.c:86
int sig_pri_cc_monitor_suspend(struct ast_cc_monitor *monitor)
struct ast_channel * owner
Definition: sig_pri.h:355
sig_pri_reset_state
Definition: sig_pri.h:152
void(*const set_rdnis)(void *pvt, const char *rdnis)
Definition: sig_pri.h:209
struct ast_cc_config_params * cc_params
Definition: sig_pri.h:448
int minidle
Definition: sig_pri.h:556
Structure to pass both assignedid values to channel drivers.
Definition: channel.h:605
void(*const deadlock_avoidance_private)(void *pvt)
Definition: sig_pri.h:182
void(*const set_dialing)(void *pvt, int is_dialing)
Definition: sig_pri.h:204
ast_channel_state
ast_channel states
Definition: channelstate.h:35
int(*const train_echocanceller)(void *pvt)
Definition: sig_pri.h:192
Scheduler ID holder.
Definition: sched.c:70
unsigned int isidlecall
Definition: sig_pri.h:328
unsigned int no_b_channel
TRUE if this interface has no B channel. (call hold and call waiting)
Definition: sig_pri.h:345
void(*const set_callerid)(void *pvt, const struct ast_party_caller *caller)
Definition: sig_pri.h:207
The channel is not being RESTARTed.
Definition: sig_pri.h:154
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)
void(*const fixup_chans)(void *old_chan, void *new_chan)
Definition: sig_pri.h:199
int dialplan
Definition: sig_pri.h:506
int localdialplan
Definition: sig_pri.h:507
char * text
Definition: app_queue.c:1508
ast_cc_agent_response_reason
Definition: ccss.h:878
int switchtype
Definition: sig_pri.h:558
unsigned int inalarm
Definition: sig_pri.h:326
int qsigchannelmapping
Definition: sig_pri.h:451
void(*const dial_digits)(void *pvt, const char *dial_string)
Definition: sig_pri.h:216
unsigned int inband_on_setup_ack
Definition: sig_pri.h:493
void * chan_pvt
Definition: sig_pri.h:376
static char cid_num[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:164
void(* module_ref)(void)
Definition: sig_pri.h:231
void sig_pri_extract_called_num_subaddr(struct sig_pri_chan *p, const char *rdest, char *called, size_t called_buff_size)
void(*const unlock_private)(void *pvt)
Definition: sig_pri.h:178
int mastertrunkgroup
Definition: sig_pri.h:370
ast_mutex_t lock
Definition: sig_pri.h:618
unsigned int no_d_channels
Definition: sig_pri.h:600
int sig_pri_hangup(struct sig_pri_chan *p, struct ast_channel *ast)
static const char * mbox(struct ast_vm_user *vmu, int id)
int pri_send_keypad_facility_exec(struct sig_pri_chan *p, const char *digits)
void(* destroy_later)(struct sig_pri_span *pri)
Definition: sig_pri.h:235
void(*const open_media)(void *pvt)
Definition: sig_pri.h:218
void sig_pri_init_pri(struct sig_pri_span *pri)
int(*const play_tone)(void *pvt, enum sig_pri_tone tone)
Definition: sig_pri.h:189
int sig_pri_cc_monitor_cancel_available_timer(struct ast_cc_monitor *monitor, int *sched_id)
static int immediate
Definition: chan_mgcp.c:183
General Asterisk PBX channel definitions.
unsigned int inband_on_proceeding
Definition: sig_pri.h:495
sig_pri_law
Definition: sig_pri.h:67
int sig_pri_cc_agent_stop_ringing(struct ast_cc_agent *agent)
int stripmsd
Definition: sig_pri.h:291
void(*const handle_dchan_exception)(struct sig_pri_span *pri, int index)
Definition: sig_pri.h:202
#define AST_MAX_EXTENSION
Definition: channel.h:135
Caller Party information.
Definition: channel.h:419
Asterisk internal frame definitions.
In case you didn&#39;t read that giant block of text above the mansession_session struct, the struct mansession is named this solely to keep the API the same in Asterisk. This structure really represents data that is different from Manager action to Manager action. The mansession_session pointer contained within points to session-specific data.
Definition: manager.c:1625
The channel is being RESTARTed.
Definition: sig_pri.h:159
static struct ao2_container * pvts
Definition: chan_console.c:174
void * no_b_chan_end
Definition: sig_pri.h:614
void(*const ami_channel_event)(void *pvt, struct ast_channel *chan)
Post an AMI B channel association event.
Definition: sig_pri.h:228
int overlapdial
Definition: sig_pri.h:450
void sig_pri_chan_delete(struct sig_pri_chan *doomed)
int(*const set_echocanceller)(void *pvt, int enable)
Definition: sig_pri.h:191
int(*const dsp_reset_and_flush_digits)(void *pvt)
Definition: sig_pri.h:193
int sig_pri_cc_agent_init(struct ast_cc_agent *agent, struct sig_pri_chan *pvt_chan)
int(*const new_nobch_intf)(struct sig_pri_span *pri)
Definition: sig_pri.h:211
int sig_pri_cc_monitor_status_rsp(struct ast_cc_monitor *monitor, enum ast_device_state devstate)
pthread_t master
Definition: sig_pri.h:617
unsigned int force_restart_unavailable_chans
TRUE if forcing RESTART when receive cause 44 on this span.
Definition: sig_pri.h:501
int minunused
Definition: sig_pri.h:555
static unsigned int monitor
Definition: chan_phone.c:116
time_t lastreset
Definition: sig_pri.h:619
sig_pri_colp_signaling
Definition: sig_pri.h:437
#define SIG_PRI_NUM_DCHANS
Definition: sig_pri.h:241
int cpndialplan
Definition: sig_pri.h:508
void(*const set_digital)(void *pvt, int is_digital)
Definition: sig_pri.h:205
unsigned int immediate
Definition: sig_pri.h:284
void sig_pri_fixup(struct ast_channel *oldchan, struct ast_channel *newchan, struct sig_pri_chan *pchan)
#define AST_MAX_CONTEXT
Definition: channel.h:136
int resetpos
Definition: sig_pri.h:596
unsigned int hidecalleridname
Definition: sig_pri.h:283
struct ast_channel *(*const new_ast_channel)(void *pvt, int state, enum sig_pri_law law, char *exten, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor)
Definition: sig_pri.h:195
unsigned int append_msn_to_user_tag
Definition: sig_pri.h:491
void sig_pri_set_alarm(struct sig_pri_chan *p, int in_alarm)
Call Completion Supplementary Services API.
sig_pri_moh_state
Definition: sig_pri.h:84
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)
void sig_pri_cc_monitor_destructor(void *monitor_pvt)
int sig_pri_start_pri(struct sig_pri_span *pri)
sig_pri_moh_signaling
Definition: sig_pri.h:73
int sig_pri_cc_agent_start_monitoring(struct ast_cc_agent *agent)
void(*const set_alarm)(void *pvt, int in_alarm)
Definition: sig_pri.h:203
static char cid_name[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:165
int numchans
Definition: sig_pri.h:615
int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, const char *rdest, int timeout, int layer1)
void(*const set_dnid)(void *pvt, const char *dnid)
Definition: sig_pri.h:208
unsigned int hidecallerid
Definition: sig_pri.h:282
int sig_pri_answer(struct sig_pri_chan *p, struct ast_channel *ast)
int resetting
Definition: sig_pri.h:595
sig_pri_tone
Definition: sig_pri.h:57
struct ast_channel * sig_pri_request(struct sig_pri_chan *p, enum sig_pri_law law, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, int transfercapability)
void sig_pri_stop_pri(struct sig_pri_span *pri)
int cid_ani2
Definition: sig_pri.h:295
#define SIG_PRI_MAX_CHANNELS
Definition: sig_pri.h:242
Peer may not be sending the expected RESTART ACKNOWLEDGE.
Definition: sig_pri.h:170
void(*const update_span_devstate)(struct sig_pri_span *pri)
Definition: sig_pri.h:215
int sig_pri_digit_begin(struct sig_pri_chan *pvt, struct ast_channel *ast, char digit)
void sig_pri_cc_agent_destructor(struct ast_cc_agent *agent)
unsigned int digital
Definition: sig_pri.h:343
int discardremoteholdretrieval
Definition: sig_pri.h:452
void sig_pri_dial_complete(struct sig_pri_chan *pvt, struct ast_channel *ast)
vm_box
struct stasis_forward * sub
Definition: res_corosync.c:240
sig_pri_call_level
Definition: sig_pri.h:135
void(*const make_cc_dialstring)(void *pvt, char *buf, size_t buf_size)
Definition: sig_pri.h:214
struct sig_pri_span * pri
Definition: sig_pri.h:357
unsigned int layer1_ignored
Definition: sig_pri.h:486
void * no_b_chan_iflist
Definition: sig_pri.h:609
int sig_pri_is_chan_available(struct sig_pri_chan *pvt)
void(*const set_outgoing)(void *pvt, int is_outgoing)
Definition: sig_pri.h:206
int prioffset
Definition: sig_pri.h:368
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116
int sig_pri_cc_agent_start_offer_timer(struct ast_cc_agent *agent)
unsigned int outgoing
Definition: sig_pri.h:342
int sig_pri_load(const char *cc_type_name)
struct sig_pri_chan * sig_pri_chan_new(void *pvt_data, struct sig_pri_span *pri, int logicalspan, int channo, int trunkgroup)
int new_chan_seq
Definition: sig_pri.h:598
const char *(*const get_orig_dialstring)(void *pvt)
Definition: sig_pri.h:213
unsigned int allocated
TRUE when this channel is allocated.
Definition: sig_pri.h:341
void(* module_unref)(void)
Definition: sig_pri.h:233
void sig_pri_cc_agent_req_rsp(struct ast_cc_agent *agent, enum ast_cc_agent_response_reason reason)
struct pri * pri
Definition: sig_pri.h:604
int sig_pri_is_alarm_ignored(struct sig_pri_span *pri)
int sig_pri_cc_agent_callee_available(struct ast_cc_agent *agent)
int pri_is_up(struct sig_pri_span *pri)
void(*const queue_control)(void *pvt, int subclass)
Definition: sig_pri.h:210
Structure for mutex and tracking information.
Definition: lock.h:135
int channel
Definition: sig_pri.h:292
int trunkgroup
Definition: sig_pri.h:560
void pri_event_noalarm(struct sig_pri_span *pri, int index, int before_start_pri)
int sig_pri_cc_agent_status_req(struct ast_cc_agent *agent)