sig_pri.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  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_DUMP | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q921_STATE \
  36. | PRI_DEBUG_CC)
  37. /*! PRI debug message flags when intense PRI debugging is turned on at the command line. */
  38. #define SIG_PRI_DEBUG_INTENSE \
  39. (PRI_DEBUG_APDU | PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q921_STATE \
  40. | PRI_DEBUG_CC | PRI_DEBUG_Q921_RAW | PRI_DEBUG_Q921_DUMP)
  41. #else
  42. /*! PRI debug message flags when normal PRI debugging is turned on at the command line. */
  43. #define SIG_PRI_DEBUG_NORMAL \
  44. (PRI_DEBUG_APDU | PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q921_STATE)
  45. /*! PRI debug message flags when intense PRI debugging is turned on at the command line. */
  46. #define SIG_PRI_DEBUG_INTENSE \
  47. (PRI_DEBUG_APDU | PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q921_STATE \
  48. | PRI_DEBUG_Q921_RAW | PRI_DEBUG_Q921_DUMP)
  49. #endif /* !defined(HAVE_PRI_CCSS) */
  50. #if 0
  51. /*! PRI debug message flags set on initial startup. */
  52. #define SIG_PRI_DEBUG_DEFAULT SIG_PRI_DEBUG_NORMAL
  53. #else
  54. /*! PRI debug message flags set on initial startup. */
  55. #define SIG_PRI_DEBUG_DEFAULT 0
  56. #endif
  57. #define SIG_PRI_AOC_GRANT_S (1 << 0)
  58. #define SIG_PRI_AOC_GRANT_D (1 << 1)
  59. #define SIG_PRI_AOC_GRANT_E (1 << 2)
  60. enum sig_pri_tone {
  61. SIG_PRI_TONE_RINGTONE = 0,
  62. SIG_PRI_TONE_STUTTER,
  63. SIG_PRI_TONE_CONGESTION,
  64. SIG_PRI_TONE_DIALTONE,
  65. SIG_PRI_TONE_DIALRECALL,
  66. SIG_PRI_TONE_INFO,
  67. SIG_PRI_TONE_BUSY,
  68. };
  69. enum sig_pri_law {
  70. SIG_PRI_DEFLAW = 0,
  71. SIG_PRI_ULAW,
  72. SIG_PRI_ALAW
  73. };
  74. /*! Call establishment life cycle level for simple comparisons. */
  75. enum sig_pri_call_level {
  76. /*! Call does not exist. */
  77. SIG_PRI_CALL_LEVEL_IDLE,
  78. /*! Call is present but has no response yet. (SETUP) */
  79. SIG_PRI_CALL_LEVEL_SETUP,
  80. /*! Call is collecting digits for overlap dialing. (SETUP ACKNOWLEDGE) */
  81. SIG_PRI_CALL_LEVEL_OVERLAP,
  82. /*! Call routing is happening. (PROCEEDING) */
  83. SIG_PRI_CALL_LEVEL_PROCEEDING,
  84. /*! Called party is being alerted of the call. (ALERTING) */
  85. SIG_PRI_CALL_LEVEL_ALERTING,
  86. /*! Call is dialing 'w' deferred digits. (CONNECT) */
  87. SIG_PRI_CALL_LEVEL_DEFER_DIAL,
  88. /*! Call is connected/answered. (CONNECT) */
  89. SIG_PRI_CALL_LEVEL_CONNECT,
  90. };
  91. struct sig_pri_span;
  92. struct sig_pri_callback {
  93. /* Unlock the private in the signalling private structure. This is used for three way calling madness. */
  94. void (* const unlock_private)(void *pvt);
  95. /* Lock the private in the signalling private structure. ... */
  96. void (* const lock_private)(void *pvt);
  97. /* Function which is called back to handle any other DTMF events that are received. Called by analog_handle_event. Why is this
  98. * important to use, instead of just directly using events received before they are passed into the library? Because sometimes,
  99. * (CWCID) the library absorbs DTMF events received. */
  100. //void (* const handle_dtmf)(void *pvt, struct ast_channel *ast, enum analog_sub analog_index, struct ast_frame **dest);
  101. //int (* const dial_digits)(void *pvt, enum analog_sub sub, struct analog_dialoperation *dop);
  102. int (* const play_tone)(void *pvt, enum sig_pri_tone tone);
  103. int (* const set_echocanceller)(void *pvt, int enable);
  104. int (* const train_echocanceller)(void *pvt);
  105. int (* const dsp_reset_and_flush_digits)(void *pvt);
  106. struct ast_channel * (* const new_ast_channel)(void *pvt, int state, enum sig_pri_law law, char *exten, const struct ast_channel *chan);
  107. void (* const fixup_chans)(void *old_chan, void *new_chan);
  108. /* Note: Called with PRI lock held */
  109. void (* const handle_dchan_exception)(struct sig_pri_span *pri, int index);
  110. void (* const set_alarm)(void *pvt, int in_alarm);
  111. void (* const set_dialing)(void *pvt, int is_dialing);
  112. void (* const set_digital)(void *pvt, int is_digital);
  113. void (* const set_outgoing)(void *pvt, int is_outgoing);
  114. void (* const set_callerid)(void *pvt, const struct ast_party_caller *caller);
  115. void (* const set_dnid)(void *pvt, const char *dnid);
  116. void (* const set_rdnis)(void *pvt, const char *rdnis);
  117. void (* const queue_control)(void *pvt, int subclass);
  118. int (* const new_nobch_intf)(struct sig_pri_span *pri);
  119. void (* const init_config)(void *pvt, struct sig_pri_span *pri);
  120. const char *(* const get_orig_dialstring)(void *pvt);
  121. void (* const make_cc_dialstring)(void *pvt, char *buf, size_t buf_size);
  122. void (* const update_span_devstate)(struct sig_pri_span *pri);
  123. void (* const dial_digits)(void *pvt, const char *dial_string);
  124. void (* const open_media)(void *pvt);
  125. /*!
  126. * \brief Post an AMI B channel association event.
  127. *
  128. * \param pvt Private structure of the user of this module.
  129. * \param chan Channel associated with the private pointer
  130. *
  131. * \return Nothing
  132. */
  133. void (* const ami_channel_event)(void *pvt, struct ast_channel *chan);
  134. /*! Reference the parent module. */
  135. void (*module_ref)(void);
  136. /*! Unreference the parent module. */
  137. void (*module_unref)(void);
  138. };
  139. #define SIG_PRI_NUM_DCHANS 4 /*!< No more than 4 d-channels */
  140. #define SIG_PRI_MAX_CHANNELS 672 /*!< No more than a DS3 per trunk group */
  141. #define SIG_PRI DAHDI_SIG_CLEAR
  142. #define SIG_BRI (0x2000000 | DAHDI_SIG_CLEAR)
  143. #define SIG_BRI_PTMP (0X4000000 | DAHDI_SIG_CLEAR)
  144. /* QSIG channel mapping option types */
  145. #define DAHDI_CHAN_MAPPING_PHYSICAL 0
  146. #define DAHDI_CHAN_MAPPING_LOGICAL 1
  147. /* Overlap dialing option types */
  148. #define DAHDI_OVERLAPDIAL_NONE 0
  149. #define DAHDI_OVERLAPDIAL_OUTGOING 1
  150. #define DAHDI_OVERLAPDIAL_INCOMING 2
  151. #define DAHDI_OVERLAPDIAL_BOTH (DAHDI_OVERLAPDIAL_INCOMING|DAHDI_OVERLAPDIAL_OUTGOING)
  152. #if defined(HAVE_PRI_SERVICE_MESSAGES)
  153. /*! \brief Persistent Service State */
  154. #define SRVST_DBKEY "service-state"
  155. /*! \brief The out-of-service SERVICE state */
  156. #define SRVST_TYPE_OOS "O"
  157. /*! \brief SRVST_INITIALIZED is used to indicate a channel being out-of-service
  158. * The SRVST_INITIALIZED is mostly used maintain backwards compatibility but also may
  159. * mean that the channel has not yet received a RESTART message. If a channel is
  160. * out-of-service with this reason a RESTART message will result in the channel
  161. * being put into service. */
  162. #define SRVST_INITIALIZED 0
  163. /*! \brief SRVST_NEAREND is used to indicate that the near end was put out-of-service */
  164. #define SRVST_NEAREND (1 << 0)
  165. /*! \brief SRVST_FAREND is used to indicate that the far end was taken out-of-service */
  166. #define SRVST_FAREND (1 << 1)
  167. /*! \brief SRVST_BOTH is used to indicate that both sides of the channel are out-of-service */
  168. #define SRVST_BOTH (SRVST_NEAREND | SRVST_FAREND)
  169. /*! \brief The AstDB family */
  170. static const char dahdi_db[] = "dahdi/registry";
  171. #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */
  172. struct sig_pri_chan {
  173. /* Options to be set by user */
  174. unsigned int hidecallerid:1;
  175. unsigned int hidecalleridname:1; /*!< Hide just the name not the number for legacy PBX use */
  176. unsigned int immediate:1; /*!< Answer before getting digits? */
  177. unsigned int priexclusive:1; /*!< Whether or not to override and use exculsive mode for channel selection */
  178. unsigned int priindication_oob:1;
  179. unsigned int use_callerid:1; /*!< Whether or not to use caller id on this channel */
  180. unsigned int use_callingpres:1; /*!< Whether to use the callingpres the calling switch sends */
  181. char context[AST_MAX_CONTEXT];
  182. char mohinterpret[MAX_MUSICCLASS];
  183. int stripmsd;
  184. int channel; /*!< Channel Number or CRV */
  185. /* Options to be checked by user */
  186. int cid_ani2; /*!< Automatic Number Identification number (Alternate PRI caller ID number) */
  187. int cid_ton; /*!< Type Of Number (TON) */
  188. int callingpres; /*!< The value of calling presentation that we're going to use when placing a PRI call */
  189. char cid_num[AST_MAX_EXTENSION];
  190. char cid_subaddr[AST_MAX_EXTENSION];
  191. char cid_name[AST_MAX_EXTENSION];
  192. char cid_ani[AST_MAX_EXTENSION];
  193. /*! \brief User tag for party id's sent from this device driver. */
  194. char user_tag[AST_MAX_EXTENSION];
  195. char exten[AST_MAX_EXTENSION];
  196. /* Internal variables -- Don't touch */
  197. /* Probably will need DS0 number, DS1 number, and a few other things */
  198. char dialdest[256]; /* Queued up digits for overlap dialing. They will be sent out as information messages when setup ACK is received */
  199. #if defined(HAVE_PRI_SETUP_KEYPAD)
  200. /*! \brief Keypad digits that came in with the SETUP message. */
  201. char keypad_digits[AST_MAX_EXTENSION];
  202. #endif /* defined(HAVE_PRI_SETUP_KEYPAD) */
  203. /*! 'w' deferred dialing digits. */
  204. char deferred_digits[AST_MAX_EXTENSION];
  205. #if defined(HAVE_PRI_AOC_EVENTS)
  206. struct pri_subcmd_aoc_e aoc_e;
  207. 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 */
  208. unsigned int aoc_s_request_invoke_id_valid:1; /*!< This is set when the AOC-S invoke id is present */
  209. 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. */
  210. unsigned int holding_aoce:1; /*!< received AOC-E msg from asterisk. holding for disconnect/release */
  211. #endif /* defined(HAVE_PRI_AOC_EVENTS) */
  212. unsigned int inalarm:1;
  213. unsigned int alreadyhungup:1; /*!< TRUE if the call has already gone/hungup */
  214. unsigned int isidlecall:1; /*!< TRUE if this is an idle call */
  215. unsigned int progress:1; /*!< TRUE if the call has seen inband-information progress through the network */
  216. unsigned int resetting:1; /*!< TRUE if this channel is being reset/restarted */
  217. /*!
  218. * \brief TRUE when this channel is allocated.
  219. *
  220. * \details
  221. * Needed to hold an outgoing channel allocation before the
  222. * owner pointer is created.
  223. *
  224. * \note This is one of several items to check to see if a
  225. * channel is available for use.
  226. */
  227. unsigned int allocated:1;
  228. unsigned int outgoing:1;
  229. unsigned int digital:1;
  230. /*! \brief TRUE if this interface has no B channel. (call hold and call waiting) */
  231. unsigned int no_b_channel:1;
  232. #if defined(HAVE_PRI_CALL_WAITING)
  233. /*! \brief TRUE if this is a call waiting call */
  234. unsigned int is_call_waiting:1;
  235. #endif /* defined(HAVE_PRI_CALL_WAITING) */
  236. struct ast_channel *owner;
  237. struct sig_pri_span *pri;
  238. q931_call *call; /*!< opaque libpri call control structure */
  239. /*! Call establishment life cycle level for simple comparisons. */
  240. enum sig_pri_call_level call_level;
  241. int prioffset; /*!< channel number in span */
  242. int logicalspan; /*!< logical span number within trunk group */
  243. int mastertrunkgroup; /*!< what trunk group is our master */
  244. #if defined(HAVE_PRI_SERVICE_MESSAGES)
  245. /*! \brief Active SRVST_DBKEY out-of-service status value. */
  246. unsigned service_status;
  247. #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */
  248. struct sig_pri_callback *calls;
  249. void *chan_pvt; /*!< Private structure of the user of this module. */
  250. #if defined(HAVE_PRI_REVERSE_CHARGE)
  251. /*!
  252. * \brief Reverse charging indication
  253. * \details
  254. * -1 - No reverse charging,
  255. * 1 - Reverse charging,
  256. * 0,2-7 - Reserved for future use
  257. */
  258. int reverse_charging_indication;
  259. #endif
  260. };
  261. #if defined(HAVE_PRI_MWI)
  262. /*! Maximum number of mailboxes per span. */
  263. #define SIG_PRI_MAX_MWI_MAILBOXES 8
  264. /*! Typical maximum length of mwi mailbox number */
  265. #define SIG_PRI_MAX_MWI_MBOX_NUMBER_LEN 10 /* digits in number */
  266. /*! Typical maximum length of mwi mailbox context */
  267. #define SIG_PRI_MAX_MWI_CONTEXT_LEN 10
  268. /*!
  269. * \brief Maximum mwi_mailbox string length.
  270. * \details
  271. * max_length = #mailboxes * (mbox_number + '@' + context + ',')
  272. * The last ',' is a null terminator instead.
  273. */
  274. #define SIG_PRI_MAX_MWI_MAILBOX_STR (SIG_PRI_MAX_MWI_MAILBOXES \
  275. * (SIG_PRI_MAX_MWI_MBOX_NUMBER_LEN + 1 + SIG_PRI_MAX_MWI_CONTEXT_LEN + 1))
  276. struct sig_pri_mbox {
  277. /*!
  278. * \brief MWI mailbox event subscription.
  279. * \note NULL if mailbox not configured.
  280. */
  281. struct ast_event_sub *sub;
  282. /*! \brief Mailbox number */
  283. const char *number;
  284. /*! \brief Mailbox context. */
  285. const char *context;
  286. };
  287. #endif /* defined(HAVE_PRI_MWI) */
  288. struct sig_pri_span {
  289. /* Should be set by user */
  290. struct ast_cc_config_params *cc_params; /*!< CC config parameters for each new call. */
  291. int pritimers[PRI_MAX_TIMERS];
  292. int overlapdial; /*!< In overlap dialing mode */
  293. int qsigchannelmapping; /*!< QSIG channel mapping type */
  294. int discardremoteholdretrieval; /*!< shall remote hold or remote retrieval notifications be discarded? */
  295. int facilityenable; /*!< Enable facility IEs */
  296. #if defined(HAVE_PRI_L2_PERSISTENCE)
  297. /*! Layer 2 persistence option. */
  298. int l2_persistence;
  299. #endif /* defined(HAVE_PRI_L2_PERSISTENCE) */
  300. int dchan_logical_span[SIG_PRI_NUM_DCHANS]; /*!< Logical offset the DCHAN sits in */
  301. int fds[SIG_PRI_NUM_DCHANS]; /*!< FD's for d-channels */
  302. #if defined(HAVE_PRI_AOC_EVENTS)
  303. int aoc_passthrough_flag; /*!< Represents what AOC messages (S,D,E) are allowed to pass-through */
  304. unsigned int aoce_delayhangup:1; /*!< defines whether the aoce_delayhangup option is enabled or not */
  305. #endif /* defined(HAVE_PRI_AOC_EVENTS) */
  306. #if defined(HAVE_PRI_SERVICE_MESSAGES)
  307. unsigned int enable_service_message_support:1; /*!< enable SERVICE message support */
  308. #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */
  309. #ifdef HAVE_PRI_INBANDDISCONNECT
  310. unsigned int inbanddisconnect:1; /*!< Should we support inband audio after receiving DISCONNECT? */
  311. #endif
  312. #if defined(HAVE_PRI_CALL_HOLD)
  313. /*! \brief TRUE if held calls are transferred on disconnect. */
  314. unsigned int hold_disconnect_transfer:1;
  315. #endif /* defined(HAVE_PRI_CALL_HOLD) */
  316. /*!
  317. * \brief TRUE if call transfer is enabled for the span.
  318. * \note Support switch-side transfer (called 2BCT, RLT or other names)
  319. */
  320. unsigned int transfer:1;
  321. #if defined(HAVE_PRI_CALL_WAITING)
  322. /*! \brief TRUE if we will allow incoming ISDN call waiting calls. */
  323. unsigned int allow_call_waiting_calls:1;
  324. #endif /* defined(HAVE_PRI_CALL_WAITING) */
  325. /*!
  326. * TRUE if a new call's sig_pri_chan.user_tag[] has the MSN
  327. * appended to the initial_user_tag[].
  328. */
  329. unsigned int append_msn_to_user_tag:1;
  330. int dialplan; /*!< Dialing plan */
  331. int localdialplan; /*!< Local dialing plan */
  332. char internationalprefix[10]; /*!< country access code ('00' for european dialplans) */
  333. char nationalprefix[10]; /*!< area access code ('0' for european dialplans) */
  334. char localprefix[20]; /*!< area access code + area code ('0'+area code for european dialplans) */
  335. char privateprefix[20]; /*!< for private dialplans */
  336. char unknownprefix[20]; /*!< for unknown dialplans */
  337. long resetinterval; /*!< Interval (in seconds) for resetting unused channels */
  338. #if defined(HAVE_PRI_MWI)
  339. /*! \brief Active MWI mailboxes */
  340. struct sig_pri_mbox mbox[SIG_PRI_MAX_MWI_MAILBOXES];
  341. /*!
  342. * \brief Comma separated list of mailboxes to indicate MWI.
  343. * \note Empty if disabled.
  344. * \note Format: mailbox_number[@context]{,mailbox_number[@context]}
  345. * \note String is split apart when span is started.
  346. */
  347. char mwi_mailboxes[SIG_PRI_MAX_MWI_MAILBOX_STR];
  348. #endif /* defined(HAVE_PRI_MWI) */
  349. /*!
  350. * \brief Initial user tag for party id's sent from this device driver.
  351. * \note String set by config file.
  352. */
  353. char initial_user_tag[AST_MAX_EXTENSION];
  354. char msn_list[AST_MAX_EXTENSION]; /*!< Comma separated list of MSNs to handle. Empty if disabled. */
  355. char idleext[AST_MAX_EXTENSION]; /*!< Where to idle extra calls */
  356. char idlecontext[AST_MAX_CONTEXT]; /*!< What context to use for idle */
  357. char idledial[AST_MAX_EXTENSION]; /*!< What to dial before dumping */
  358. int minunused; /*!< Min # of channels to keep empty */
  359. int minidle; /*!< Min # of "idling" calls to keep active */
  360. int nodetype; /*!< Node type */
  361. int switchtype; /*!< Type of switch to emulate */
  362. int nsf; /*!< Network-Specific Facilities */
  363. int trunkgroup; /*!< What our trunkgroup is */
  364. #if defined(HAVE_PRI_CCSS)
  365. int cc_ptmp_recall_mode; /*!< CC PTMP recall mode. globalRecall(0), specificRecall(1) */
  366. int cc_qsig_signaling_link_req; /*!< CC Q.SIG signaling link retention (Party A) release(0), retain(1), do-not-care(2) */
  367. int cc_qsig_signaling_link_rsp; /*!< CC Q.SIG signaling link retention (Party B) release(0), retain(1) */
  368. #endif /* defined(HAVE_PRI_CCSS) */
  369. #if defined(HAVE_PRI_CALL_WAITING)
  370. /*!
  371. * \brief Number of extra outgoing calls to allow on a span before
  372. * considering that span congested.
  373. */
  374. int max_call_waiting_calls;
  375. struct {
  376. int stripmsd;
  377. unsigned int hidecallerid:1;
  378. unsigned int hidecalleridname:1; /*!< Hide just the name not the number for legacy PBX use */
  379. unsigned int immediate:1; /*!< Answer before getting digits? */
  380. unsigned int priexclusive:1; /*!< Whether or not to override and use exculsive mode for channel selection */
  381. unsigned int priindication_oob:1;
  382. unsigned int use_callerid:1; /*!< Whether or not to use caller id on this channel */
  383. unsigned int use_callingpres:1; /*!< Whether to use the callingpres the calling switch sends */
  384. char context[AST_MAX_CONTEXT];
  385. char mohinterpret[MAX_MUSICCLASS];
  386. } ch_cfg;
  387. /*!
  388. * \brief Number of outstanding call waiting calls.
  389. * \note Must be zero to allow new calls from asterisk to
  390. * immediately allocate a B channel.
  391. */
  392. int num_call_waiting_calls;
  393. #endif /* defined(HAVE_PRI_CALL_WAITING) */
  394. int dchanavail[SIG_PRI_NUM_DCHANS]; /*!< Whether each channel is available */
  395. int debug; /*!< set to true if to dump PRI event info */
  396. int span; /*!< span number put into user output messages */
  397. int resetting; /*!< true if span is being reset/restarted */
  398. int resetpos; /*!< current position during a reset (-1 if not started) */
  399. int sig; /*!< ISDN signalling type (SIG_PRI, SIG_BRI, SIG_BRI_PTMP, etc...) */
  400. int new_chan_seq; /*!< New struct ast_channel sequence number */
  401. /*! TRUE if we have already whined about no D channels available. */
  402. unsigned int no_d_channels:1;
  403. /* Everything after here is internally set */
  404. struct pri *dchans[SIG_PRI_NUM_DCHANS]; /*!< Actual d-channels */
  405. struct pri *pri; /*!< Currently active D-channel */
  406. /*!
  407. * List of private structures of the user of this module for no B channel
  408. * interfaces. (hold and call waiting interfaces)
  409. */
  410. void *no_b_chan_iflist;
  411. /*!
  412. * List of private structures of the user of this module for no B channel
  413. * interfaces. (hold and call waiting interfaces)
  414. */
  415. void *no_b_chan_end;
  416. int numchans; /*!< Num of channels we represent */
  417. struct sig_pri_chan *pvts[SIG_PRI_MAX_CHANNELS];/*!< Member channel pvt structs */
  418. pthread_t master; /*!< Thread of master */
  419. ast_mutex_t lock; /*!< libpri access Mutex */
  420. time_t lastreset; /*!< time when unused channels were last reset */
  421. struct sig_pri_callback *calls;
  422. /*!
  423. * \brief Congestion device state of the span.
  424. * \details
  425. * AST_DEVICE_NOT_INUSE - Span does not have all B channels in use.
  426. * AST_DEVICE_BUSY - All B channels are in use.
  427. * AST_DEVICE_UNAVAILABLE - Span is in alarm.
  428. * \note
  429. * Device name: \startverbatim DAHDI/I<span>/congestion. \endverbatim
  430. */
  431. int congestion_devstate;
  432. #if defined(THRESHOLD_DEVSTATE_PLACEHOLDER)
  433. /*! \todo An ISDN span threshold device state could be useful in determining how often a span utilization goes over a configurable threshold. */
  434. /*!
  435. * \brief User threshold device state of the span.
  436. * \details
  437. * AST_DEVICE_NOT_INUSE - There are no B channels in use.
  438. * AST_DEVICE_INUSE - The number of B channels in use is less than
  439. * the configured threshold but not zero.
  440. * AST_DEVICE_BUSY - The number of B channels in use meets or exceeds
  441. * the configured threshold.
  442. * AST_DEVICE_UNAVAILABLE - Span is in alarm.
  443. * \note
  444. * Device name: DAHDI/I<span>/threshold
  445. */
  446. int threshold_devstate;
  447. /*!
  448. * \brief Number of B channels in use to consider the span in a busy state.
  449. * \note Setting the threshold to zero is interpreted as all B channels.
  450. */
  451. int user_busy_threshold;
  452. #endif /* defined(THRESHOLD_DEVSTATE_PLACEHOLDER) */
  453. };
  454. void sig_pri_extract_called_num_subaddr(struct sig_pri_chan *p, const char *rdest, char *called, size_t called_buff_size);
  455. int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, char *rdest, int timeout, int layer1);
  456. int sig_pri_hangup(struct sig_pri_chan *p, struct ast_channel *ast);
  457. int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condition, const void *data, size_t datalen);
  458. int sig_pri_answer(struct sig_pri_chan *p, struct ast_channel *ast);
  459. int sig_pri_is_chan_available(struct sig_pri_chan *pvt);
  460. int sig_pri_available(struct sig_pri_chan **pvt, int is_specific_channel);
  461. void sig_pri_init_pri(struct sig_pri_span *pri);
  462. /* If return 0, it means this function was able to handle it (pre setup digits). If non zero, the user of this
  463. * functions should handle it normally (generate inband DTMF) */
  464. int sig_pri_digit_begin(struct sig_pri_chan *pvt, struct ast_channel *ast, char digit);
  465. void sig_pri_dial_complete(struct sig_pri_chan *pvt, struct ast_channel *ast);
  466. void sig_pri_stop_pri(struct sig_pri_span *pri);
  467. int sig_pri_start_pri(struct sig_pri_span *pri);
  468. void sig_pri_set_alarm(struct sig_pri_chan *p, int in_alarm);
  469. void sig_pri_chan_alarm_notify(struct sig_pri_chan *p, int noalarm);
  470. void pri_event_alarm(struct sig_pri_span *pri, int index, int before_start_pri);
  471. void pri_event_noalarm(struct sig_pri_span *pri, int index, int before_start_pri);
  472. struct ast_channel *sig_pri_request(struct sig_pri_chan *p, enum sig_pri_law law, const struct ast_channel *requestor, int transfercapability);
  473. struct sig_pri_chan *sig_pri_chan_new(void *pvt_data, struct sig_pri_callback *callback, struct sig_pri_span *pri, int logicalspan, int channo, int trunkgroup);
  474. void sig_pri_chan_delete(struct sig_pri_chan *doomed);
  475. int pri_is_up(struct sig_pri_span *pri);
  476. void sig_pri_cli_show_channels_header(int fd);
  477. void sig_pri_cli_show_channels(int fd, struct sig_pri_span *pri);
  478. void sig_pri_cli_show_spans(int fd, int span, struct sig_pri_span *pri);
  479. void sig_pri_cli_show_span(int fd, int *dchannels, struct sig_pri_span *pri);
  480. int pri_send_keypad_facility_exec(struct sig_pri_chan *p, const char *digits);
  481. 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);
  482. #if defined(HAVE_PRI_SERVICE_MESSAGES)
  483. int pri_maintenance_bservice(struct pri *pri, struct sig_pri_chan *p, int changestatus);
  484. #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */
  485. void sig_pri_fixup(struct ast_channel *oldchan, struct ast_channel *newchan, struct sig_pri_chan *pchan);
  486. int sig_pri_cc_agent_init(struct ast_cc_agent *agent, struct sig_pri_chan *pvt_chan);
  487. int sig_pri_cc_agent_start_offer_timer(struct ast_cc_agent *agent);
  488. int sig_pri_cc_agent_stop_offer_timer(struct ast_cc_agent *agent);
  489. void sig_pri_cc_agent_req_rsp(struct ast_cc_agent *agent, enum ast_cc_agent_response_reason reason);
  490. int sig_pri_cc_agent_status_req(struct ast_cc_agent *agent);
  491. int sig_pri_cc_agent_stop_ringing(struct ast_cc_agent *agent);
  492. int sig_pri_cc_agent_party_b_free(struct ast_cc_agent *agent);
  493. int sig_pri_cc_agent_start_monitoring(struct ast_cc_agent *agent);
  494. int sig_pri_cc_agent_callee_available(struct ast_cc_agent *agent);
  495. void sig_pri_cc_agent_destructor(struct ast_cc_agent *agent);
  496. int sig_pri_cc_monitor_req_cc(struct ast_cc_monitor *monitor, int *available_timer_id);
  497. int sig_pri_cc_monitor_suspend(struct ast_cc_monitor *monitor);
  498. int sig_pri_cc_monitor_unsuspend(struct ast_cc_monitor *monitor);
  499. int sig_pri_cc_monitor_status_rsp(struct ast_cc_monitor *monitor, enum ast_device_state devstate);
  500. int sig_pri_cc_monitor_cancel_available_timer(struct ast_cc_monitor *monitor, int *sched_id);
  501. void sig_pri_cc_monitor_destructor(void *monitor_pvt);
  502. int sig_pri_load(const char *cc_type_name);
  503. void sig_pri_unload(void);
  504. #endif /* _SIG_PRI_H */