sig_pri.h 29 KB

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