sig_pri.h 30 KB

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