chan_dahdi.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2013 Digium, Inc.
  5. *
  6. * Richard Mudgett <rmudgett@digium.com>
  7. *
  8. * See http://www.asterisk.org for more information about
  9. * the Asterisk project. Please do not directly contact
  10. * any of the maintainers of this project for assistance;
  11. * the project provides a web site, mailing lists and IRC
  12. * channels for your use.
  13. *
  14. * This program is free software, distributed under the terms of
  15. * the GNU General Public License Version 2. See the LICENSE file
  16. * at the top of the source tree.
  17. */
  18. /*!
  19. * \file
  20. * \brief DAHDI internal API definitions.
  21. *
  22. * \author Richard Mudgett <rmudgett@digium.com>
  23. *
  24. * See Also:
  25. * \arg \ref AstCREDITS
  26. */
  27. #ifndef _ASTERISK_CHAN_DAHDI_H
  28. #define _ASTERISK_CHAN_DAHDI_H
  29. #if defined(HAVE_OPENR2)
  30. #include <openr2.h>
  31. #endif /* defined(HAVE_OPENR2) */
  32. #include <dahdi/user.h>
  33. #include <dahdi/tonezone.h>
  34. #include "asterisk/channel.h"
  35. #include "asterisk/dsp.h"
  36. #include "asterisk/app.h"
  37. #if defined(__cplusplus) || defined(c_plusplus)
  38. extern "C" {
  39. #endif
  40. /* ------------------------------------------------------------------- */
  41. #if defined(HAVE_PRI)
  42. struct sig_pri_span;
  43. #endif /* defined(HAVE_PRI) */
  44. #if defined(HAVE_SS7)
  45. struct sig_ss7_linkset;
  46. #endif /* defined(HAVE_SS7) */
  47. #define SUB_REAL 0 /*!< Active call */
  48. #define SUB_CALLWAIT 1 /*!< Call-Waiting call on hold */
  49. #define SUB_THREEWAY 2 /*!< Three-way call */
  50. struct distRingData {
  51. int ring[3];
  52. int range;
  53. };
  54. struct ringContextData {
  55. char contextData[AST_MAX_CONTEXT];
  56. };
  57. struct dahdi_distRings {
  58. struct distRingData ringnum[3];
  59. struct ringContextData ringContext[3];
  60. };
  61. extern const char * const subnames[];
  62. struct dahdi_subchannel {
  63. int dfd;
  64. struct ast_channel *owner;
  65. int chan;
  66. short buffer[AST_FRIENDLY_OFFSET/2 + READ_SIZE];
  67. struct ast_frame f; /*!< One frame for each channel. How did this ever work before? */
  68. unsigned int needringing:1;
  69. unsigned int needbusy:1;
  70. unsigned int needcongestion:1;
  71. unsigned int needanswer:1;
  72. unsigned int needflash:1;
  73. unsigned int needhold:1;
  74. unsigned int needunhold:1;
  75. unsigned int linear:1;
  76. unsigned int inthreeway:1;
  77. struct dahdi_confinfo curconf;
  78. };
  79. #define MAX_SLAVES 4
  80. /* States for sending MWI message
  81. * First three states are required for send Ring Pulse Alert Signal
  82. */
  83. typedef enum {
  84. MWI_SEND_NULL = 0,
  85. MWI_SEND_SA,
  86. MWI_SEND_SA_WAIT,
  87. MWI_SEND_PAUSE,
  88. MWI_SEND_SPILL,
  89. MWI_SEND_CLEANUP,
  90. MWI_SEND_DONE,
  91. } mwisend_states;
  92. struct mwisend_info {
  93. struct timeval pause;
  94. mwisend_states mwisend_current;
  95. };
  96. /*! Specify the lists dahdi_pvt can be put in. */
  97. enum DAHDI_IFLIST {
  98. DAHDI_IFLIST_NONE, /*!< The dahdi_pvt is not in any list. */
  99. DAHDI_IFLIST_MAIN, /*!< The dahdi_pvt is in the main interface list */
  100. #if defined(HAVE_PRI)
  101. DAHDI_IFLIST_NO_B_CHAN, /*!< The dahdi_pvt is in a no B channel interface list */
  102. #endif /* defined(HAVE_PRI) */
  103. };
  104. struct dahdi_pvt {
  105. ast_mutex_t lock; /*!< Channel private lock. */
  106. struct callerid_state *cs;
  107. struct ast_channel *owner; /*!< Our current active owner (if applicable) */
  108. /*!< Up to three channels can be associated with this call */
  109. struct dahdi_subchannel sub_unused; /*!< Just a safety precaution */
  110. struct dahdi_subchannel subs[3]; /*!< Sub-channels */
  111. struct dahdi_confinfo saveconf; /*!< Saved conference info */
  112. struct dahdi_pvt *slaves[MAX_SLAVES]; /*!< Slave to us (follows our conferencing) */
  113. struct dahdi_pvt *master; /*!< Master to us (we follow their conferencing) */
  114. int inconference; /*!< If our real should be in the conference */
  115. int bufsize; /*!< Size of the buffers */
  116. int buf_no; /*!< Number of buffers */
  117. int buf_policy; /*!< Buffer policy */
  118. int faxbuf_no; /*!< Number of Fax buffers */
  119. int faxbuf_policy; /*!< Fax buffer policy */
  120. int sig; /*!< Signalling style */
  121. /*!
  122. * \brief Nonzero if the signaling type is sent over a radio.
  123. * \note Set to a couple of nonzero values but it is only tested like a boolean.
  124. */
  125. int radio;
  126. int outsigmod; /*!< Outbound Signalling style (modifier) */
  127. int oprmode; /*!< "Operator Services" mode */
  128. struct dahdi_pvt *oprpeer; /*!< "Operator Services" peer tech_pvt ptr */
  129. /*! \brief Hardware Rx gain set by chan_dahdi.conf */
  130. float hwrxgain;
  131. /*! \brief Hardware Tx gain set by chan_dahdi.conf */
  132. float hwtxgain;
  133. /*! \brief Amount of gain to increase during caller id */
  134. float cid_rxgain;
  135. /*! \brief Software Rx gain set by chan_dahdi.conf */
  136. float rxgain;
  137. /*! \brief Software Tx gain set by chan_dahdi.conf */
  138. float txgain;
  139. float txdrc; /*!< Dynamic Range Compression factor. a number between 1 and 6ish */
  140. float rxdrc;
  141. int tonezone; /*!< tone zone for this chan, or -1 for default */
  142. enum DAHDI_IFLIST which_iflist; /*!< Which interface list is this structure listed? */
  143. struct dahdi_pvt *next; /*!< Next channel in list */
  144. struct dahdi_pvt *prev; /*!< Prev channel in list */
  145. /* flags */
  146. /*!
  147. * \brief TRUE if ADSI (Analog Display Services Interface) available
  148. * \note Set from the "adsi" value read in from chan_dahdi.conf
  149. */
  150. unsigned int adsi:1;
  151. /*!
  152. * \brief TRUE if we can use a polarity reversal to mark when an outgoing
  153. * call is answered by the remote party.
  154. * \note Set from the "answeronpolarityswitch" value read in from chan_dahdi.conf
  155. */
  156. unsigned int answeronpolarityswitch:1;
  157. /*!
  158. * \brief TRUE if busy detection is enabled.
  159. * (Listens for the beep-beep busy pattern.)
  160. * \note Set from the "busydetect" value read in from chan_dahdi.conf
  161. */
  162. unsigned int busydetect:1;
  163. /*!
  164. * \brief TRUE if call return is enabled.
  165. * (*69, if your dialplan doesn't catch this first)
  166. * \note Set from the "callreturn" value read in from chan_dahdi.conf
  167. */
  168. unsigned int callreturn:1;
  169. /*!
  170. * \brief TRUE if busy extensions will hear the call-waiting tone
  171. * and can use hook-flash to switch between callers.
  172. * \note Can be disabled by dialing *70.
  173. * \note Initialized with the "callwaiting" value read in from chan_dahdi.conf
  174. */
  175. unsigned int callwaiting:1;
  176. /*!
  177. * \brief TRUE if send caller ID for Call Waiting
  178. * \note Set from the "callwaitingcallerid" value read in from chan_dahdi.conf
  179. */
  180. unsigned int callwaitingcallerid:1;
  181. /*!
  182. * \brief TRUE if support for call forwarding enabled.
  183. * Dial *72 to enable call forwarding.
  184. * Dial *73 to disable call forwarding.
  185. * \note Set from the "cancallforward" value read in from chan_dahdi.conf
  186. */
  187. unsigned int cancallforward:1;
  188. /*!
  189. * \brief TRUE if support for call parking is enabled.
  190. * \note Set from the "canpark" value read in from chan_dahdi.conf
  191. */
  192. unsigned int canpark:1;
  193. /*! \brief TRUE if to wait for a DTMF digit to confirm answer */
  194. unsigned int confirmanswer:1;
  195. /*!
  196. * \brief TRUE if the channel is to be destroyed on hangup.
  197. * (Used by pseudo channels.)
  198. */
  199. unsigned int destroy:1;
  200. unsigned int didtdd:1; /*!< flag to say its done it once */
  201. /*! \brief TRUE if analog type line dialed no digits in Dial() */
  202. unsigned int dialednone:1;
  203. /*!
  204. * \brief TRUE if in the process of dialing digits or sending something.
  205. * \note This is used as a receive squelch for ISDN until connected.
  206. */
  207. unsigned int dialing:1;
  208. /*! \brief TRUE if the transfer capability of the call is digital. */
  209. unsigned int digital:1;
  210. /*! \brief TRUE if Do-Not-Disturb is enabled, present only for non sig_analog */
  211. unsigned int dnd:1;
  212. /*! \brief XXX BOOLEAN Purpose??? */
  213. unsigned int echobreak:1;
  214. /*!
  215. * \brief TRUE if echo cancellation enabled when bridged.
  216. * \note Initialized with the "echocancelwhenbridged" value read in from chan_dahdi.conf
  217. * \note Disabled if the echo canceller is not setup.
  218. */
  219. unsigned int echocanbridged:1;
  220. /*! \brief TRUE if echo cancellation is turned on. */
  221. unsigned int echocanon:1;
  222. /*! \brief TRUE if a fax tone has already been handled. */
  223. unsigned int faxhandled:1;
  224. /*! TRUE if dynamic faxbuffers are configured for use, default is OFF */
  225. unsigned int usefaxbuffers:1;
  226. /*! TRUE while buffer configuration override is in use */
  227. unsigned int bufferoverrideinuse:1;
  228. /*! \brief TRUE if over a radio and dahdi_read() has been called. */
  229. unsigned int firstradio:1;
  230. /*!
  231. * \brief TRUE if the call will be considered "hung up" on a polarity reversal.
  232. * \note Set from the "hanguponpolarityswitch" value read in from chan_dahdi.conf
  233. */
  234. unsigned int hanguponpolarityswitch:1;
  235. /*! \brief TRUE if DTMF detection needs to be done by hardware. */
  236. unsigned int hardwaredtmf:1;
  237. /*!
  238. * \brief TRUE if the outgoing caller ID is blocked/hidden.
  239. * \note Caller ID can be disabled by dialing *67.
  240. * \note Caller ID can be enabled by dialing *82.
  241. * \note Initialized with the "hidecallerid" value read in from chan_dahdi.conf
  242. */
  243. unsigned int hidecallerid:1;
  244. /*!
  245. * \brief TRUE if hide just the name not the number for legacy PBX use.
  246. * \note Only applies to PRI channels.
  247. * \note Set from the "hidecalleridname" value read in from chan_dahdi.conf
  248. */
  249. unsigned int hidecalleridname:1;
  250. /*! \brief TRUE if DTMF detection is disabled. */
  251. unsigned int ignoredtmf:1;
  252. /*!
  253. * \brief TRUE if the channel should be answered immediately
  254. * without attempting to gather any digits.
  255. * \note Set from the "immediate" value read in from chan_dahdi.conf
  256. */
  257. unsigned int immediate:1;
  258. /*! \brief TRUE if in an alarm condition. */
  259. unsigned int inalarm:1;
  260. /*! \brief TRUE if TDD in MATE mode */
  261. unsigned int mate:1;
  262. /*! \brief TRUE if we originated the call leg. */
  263. unsigned int outgoing:1;
  264. /*!
  265. * \brief TRUE if busy extensions will hear the call-waiting tone
  266. * and can use hook-flash to switch between callers.
  267. * \note Set from the "callwaiting" value read in from chan_dahdi.conf
  268. */
  269. unsigned int permcallwaiting:1;
  270. /*!
  271. * \brief TRUE if the outgoing caller ID is blocked/restricted/hidden.
  272. * \note Set from the "hidecallerid" value read in from chan_dahdi.conf
  273. */
  274. unsigned int permhidecallerid:1;
  275. /*!
  276. * \brief TRUE if PRI congestion/busy indications are sent out-of-band.
  277. * \note Set from the "priindication" value read in from chan_dahdi.conf
  278. */
  279. unsigned int priindication_oob:1;
  280. /*!
  281. * \brief TRUE if PRI B channels are always exclusively selected.
  282. * \note Set from the "priexclusive" value read in from chan_dahdi.conf
  283. */
  284. unsigned int priexclusive:1;
  285. /*!
  286. * \brief TRUE if we will pulse dial.
  287. * \note Set from the "pulsedial" value read in from chan_dahdi.conf
  288. */
  289. unsigned int pulse:1;
  290. /*! \brief TRUE if a pulsed digit was detected. (Pulse dial phone detected) */
  291. unsigned int pulsedial:1;
  292. unsigned int restartpending:1; /*!< flag to ensure counted only once for restart */
  293. /*!
  294. * \brief TRUE if caller ID is restricted.
  295. * \note Set but not used. Should be deleted. Redundant with permhidecallerid.
  296. * \note Set from the "restrictcid" value read in from chan_dahdi.conf
  297. */
  298. unsigned int restrictcid:1;
  299. /*!
  300. * \brief TRUE if three way calling is enabled
  301. * \note Set from the "threewaycalling" value read in from chan_dahdi.conf
  302. */
  303. unsigned int threewaycalling:1;
  304. /*!
  305. * \brief TRUE if call transfer is enabled
  306. * \note For FXS ports (either direct analog or over T1/E1):
  307. * Support flash-hook call transfer
  308. * \note For digital ports using ISDN PRI protocols:
  309. * Support switch-side transfer (called 2BCT, RLT or other names)
  310. * \note Set from the "transfer" value read in from chan_dahdi.conf
  311. */
  312. unsigned int transfer:1;
  313. /*!
  314. * \brief TRUE if caller ID is used on this channel.
  315. * \note PRI and SS7 spans will save caller ID from the networking peer.
  316. * \note FXS ports will generate the caller ID spill.
  317. * \note FXO ports will listen for the caller ID spill.
  318. * \note Set from the "usecallerid" value read in from chan_dahdi.conf
  319. */
  320. unsigned int use_callerid:1;
  321. /*!
  322. * \brief TRUE if we will use the calling presentation setting
  323. * from the Asterisk channel for outgoing calls.
  324. * \note Only applies to PRI and SS7 channels.
  325. * \note Set from the "usecallingpres" value read in from chan_dahdi.conf
  326. */
  327. unsigned int use_callingpres:1;
  328. /*!
  329. * \brief TRUE if distinctive rings are to be detected.
  330. * \note For FXO lines
  331. * \note Set indirectly from the "usedistinctiveringdetection" value read in from chan_dahdi.conf
  332. */
  333. unsigned int usedistinctiveringdetection:1;
  334. /*!
  335. * \brief TRUE if we should use the callerid from incoming call on dahdi transfer.
  336. * \note Set from the "useincomingcalleridondahditransfer" value read in from chan_dahdi.conf
  337. */
  338. unsigned int dahditrcallerid:1;
  339. /*!
  340. * \brief TRUE if allowed to flash-transfer to busy channels.
  341. * \note Set from the "transfertobusy" value read in from chan_dahdi.conf
  342. */
  343. unsigned int transfertobusy:1;
  344. /*!
  345. * \brief TRUE if the FXO port monitors for neon type MWI indications from the other end.
  346. * \note Set if the "mwimonitor" value read in contains "neon" from chan_dahdi.conf
  347. */
  348. unsigned int mwimonitor_neon:1;
  349. /*!
  350. * \brief TRUE if the FXO port monitors for fsk type MWI indications from the other end.
  351. * \note Set if the "mwimonitor" value read in contains "fsk" from chan_dahdi.conf
  352. */
  353. unsigned int mwimonitor_fsk:1;
  354. /*!
  355. * \brief TRUE if the FXO port monitors for rpas precursor to fsk MWI indications from the other end.
  356. * \note RPAS - Ring Pulse Alert Signal
  357. * \note Set if the "mwimonitor" value read in contains "rpas" from chan_dahdi.conf
  358. */
  359. unsigned int mwimonitor_rpas:1;
  360. /*! \brief TRUE if an MWI monitor thread is currently active */
  361. unsigned int mwimonitoractive:1;
  362. /*! \brief TRUE if a MWI message sending thread is active */
  363. unsigned int mwisendactive:1;
  364. /*!
  365. * \brief TRUE if channel is out of reset and ready
  366. * \note Used by SS7. Otherwise set but not used.
  367. */
  368. unsigned int inservice:1;
  369. /*!
  370. * \brief Bitmask for the channel being locally blocked.
  371. * \note Applies to SS7 and MFCR2 channels.
  372. * \note For MFCR2 only the first bit is used - TRUE if blocked
  373. * \note For SS7 two bits are used
  374. * \note Bit 0 - TRUE if maintenance blocked
  375. * \note Bit 1 - TRUE if hardware blocked
  376. */
  377. unsigned int locallyblocked:2;
  378. /*!
  379. * \brief Bitmask for the channel being remotely blocked. 1 maintenance, 2 blocked in hardware.
  380. * \note Applies to SS7 and MFCR2 channels.
  381. * \note For MFCR2 only the first bit is used - TRUE if blocked
  382. * \note For SS7 two bits are used
  383. * \note Bit 0 - TRUE if maintenance blocked
  384. * \note Bit 1 - TRUE if hardware blocked
  385. */
  386. unsigned int remotelyblocked:2;
  387. /*!
  388. * \brief TRUE if the channel alarms will be managed also as Span ones
  389. * \note Applies to all channels
  390. */
  391. unsigned int manages_span_alarms:1;
  392. /*! \brief TRUE if hardware Rx gain set by Asterisk */
  393. unsigned int hwrxgain_enabled;
  394. /*! \brief TRUE if hardware Tx gain set by Asterisk */
  395. unsigned int hwtxgain_enabled;
  396. #if defined(HAVE_PRI)
  397. struct sig_pri_span *pri;
  398. int logicalspan;
  399. #endif /* defined(HAVE_PRI) */
  400. /*!
  401. * \brief TRUE if SMDI (Simplified Message Desk Interface) is enabled
  402. * \note Set from the "usesmdi" value read in from chan_dahdi.conf
  403. */
  404. unsigned int use_smdi:1;
  405. struct mwisend_info mwisend_data;
  406. /*! \brief The SMDI interface to get SMDI messages from. */
  407. struct ast_smdi_interface *smdi_iface;
  408. /*! \brief Distinctive Ring data */
  409. struct dahdi_distRings drings;
  410. /*!
  411. * \brief The configured context for incoming calls.
  412. * \note The "context" string read in from chan_dahdi.conf
  413. */
  414. char context[AST_MAX_CONTEXT];
  415. /*!
  416. * \brief A description for the channel configuration
  417. * \note The "description" string read in from chan_dahdi.conf
  418. */
  419. char description[32];
  420. /*!
  421. * \brief Default distinctive ring context.
  422. */
  423. char defcontext[AST_MAX_CONTEXT];
  424. /*! \brief Extension to use in the dialplan. */
  425. char exten[AST_MAX_EXTENSION];
  426. /*!
  427. * \brief Language configured for calls.
  428. * \note The "language" string read in from chan_dahdi.conf
  429. */
  430. char language[MAX_LANGUAGE];
  431. /*!
  432. * \brief The configured music-on-hold class to use for calls.
  433. * \note The "musicclass" or "mohinterpret" or "musiconhold" string read in from chan_dahdi.conf
  434. */
  435. char mohinterpret[MAX_MUSICCLASS];
  436. /*!
  437. * \brief Suggested music-on-hold class for peer channel to use for calls.
  438. * \note The "mohsuggest" string read in from chan_dahdi.conf
  439. */
  440. char mohsuggest[MAX_MUSICCLASS];
  441. char parkinglot[AST_MAX_EXTENSION]; /*!< Parking lot for this channel */
  442. #if defined(HAVE_PRI) || defined(HAVE_SS7)
  443. /*! \brief Automatic Number Identification number (Alternate PRI caller ID number) */
  444. char cid_ani[AST_MAX_EXTENSION];
  445. #endif /* defined(HAVE_PRI) || defined(HAVE_SS7) */
  446. /*! \brief Automatic Number Identification code from PRI */
  447. int cid_ani2;
  448. /*! \brief Caller ID number from an incoming call. */
  449. char cid_num[AST_MAX_EXTENSION];
  450. /*!
  451. * \brief Caller ID tag from incoming call
  452. * \note the "cid_tag" string read in from chan_dahdi.conf
  453. */
  454. char cid_tag[AST_MAX_EXTENSION];
  455. /*! \brief Caller ID Q.931 TON/NPI field values. Set by PRI. Zero otherwise. */
  456. int cid_ton;
  457. /*! \brief Caller ID name from an incoming call. */
  458. char cid_name[AST_MAX_EXTENSION];
  459. /*! \brief Caller ID subaddress from an incoming call. */
  460. char cid_subaddr[AST_MAX_EXTENSION];
  461. char *origcid_num; /*!< malloced original callerid */
  462. char *origcid_name; /*!< malloced original callerid */
  463. /*! \brief Call waiting number. */
  464. char callwait_num[AST_MAX_EXTENSION];
  465. /*! \brief Call waiting name. */
  466. char callwait_name[AST_MAX_EXTENSION];
  467. /*! \brief Redirecting Directory Number Information Service (RDNIS) number */
  468. char rdnis[AST_MAX_EXTENSION];
  469. /*! \brief Dialed Number Identifier */
  470. char dnid[AST_MAX_EXTENSION];
  471. /*!
  472. * \brief Bitmapped groups this belongs to.
  473. * \note The "group" bitmapped group string read in from chan_dahdi.conf
  474. */
  475. ast_group_t group;
  476. /*! \brief Default call PCM encoding format: DAHDI_LAW_ALAW or DAHDI_LAW_MULAW. */
  477. int law_default;
  478. /*! \brief Active PCM encoding format: DAHDI_LAW_ALAW or DAHDI_LAW_MULAW */
  479. int law;
  480. int confno; /*!< Our conference */
  481. int confusers; /*!< Who is using our conference */
  482. int propconfno; /*!< Propagated conference number */
  483. /*!
  484. * \brief Bitmapped call groups this belongs to.
  485. * \note The "callgroup" bitmapped group string read in from chan_dahdi.conf
  486. */
  487. ast_group_t callgroup;
  488. /*!
  489. * \brief Bitmapped pickup groups this belongs to.
  490. * \note The "pickupgroup" bitmapped group string read in from chan_dahdi.conf
  491. */
  492. ast_group_t pickupgroup;
  493. /*!
  494. * \brief Named call groups this belongs to.
  495. * \note The "namedcallgroup" string read in from chan_dahdi.conf
  496. */
  497. struct ast_namedgroups *named_callgroups;
  498. /*!
  499. * \brief Named pickup groups this belongs to.
  500. * \note The "namedpickupgroup" string read in from chan_dahdi.conf
  501. */
  502. struct ast_namedgroups *named_pickupgroups;
  503. /*!
  504. * \brief Channel variable list with associated values to set when a channel is created.
  505. * \note The "setvar" strings read in from chan_dahdi.conf
  506. */
  507. struct ast_variable *vars;
  508. int channel; /*!< Channel Number */
  509. int span; /*!< Span number */
  510. time_t guardtime; /*!< Must wait this much time before using for new call */
  511. int cid_signalling; /*!< CID signalling type bell202 or v23 */
  512. int cid_start; /*!< CID start indicator, polarity or ring or DTMF without warning event */
  513. int dtmfcid_holdoff_state; /*!< State indicator that allows for line to settle before checking for dtmf energy */
  514. struct timeval dtmfcid_delay; /*!< Time value used for allow line to settle */
  515. int callingpres; /*!< The value of calling presentation that we're going to use when placing a PRI call */
  516. int callwaitingrepeat; /*!< How many samples to wait before repeating call waiting */
  517. int cidcwexpire; /*!< When to stop waiting for CID/CW CAS response (In samples) */
  518. int cid_suppress_expire; /*!< How many samples to suppress after a CID spill. */
  519. /*! \brief Analog caller ID waveform sample buffer */
  520. unsigned char *cidspill;
  521. /*! \brief Position in the cidspill buffer to send out next. */
  522. int cidpos;
  523. /*! \brief Length of the cidspill buffer containing samples. */
  524. int cidlen;
  525. /*! \brief Ring timeout timer?? */
  526. int ringt;
  527. /*!
  528. * \brief Ring timeout base.
  529. * \note Value computed indirectly from "ringtimeout" read in from chan_dahdi.conf
  530. */
  531. int ringt_base;
  532. /*!
  533. * \brief Number of most significant digits/characters to strip from the dialed number.
  534. * \note Feature is deprecated. Use dialplan logic.
  535. * \note The characters are stripped before the PRI TON/NPI prefix
  536. * characters are processed.
  537. */
  538. int stripmsd;
  539. /*!
  540. * \brief TRUE if Call Waiting (CW) CPE Alert Signal (CAS) is being sent.
  541. * \note
  542. * After CAS is sent, the call waiting caller id will be sent if the phone
  543. * gives a positive reply.
  544. */
  545. int callwaitcas;
  546. /*! \brief Number of call waiting rings. */
  547. int callwaitrings;
  548. /*! \brief Echo cancel parameters. */
  549. struct {
  550. struct dahdi_echocanparams head;
  551. struct dahdi_echocanparam params[DAHDI_MAX_ECHOCANPARAMS];
  552. } echocancel;
  553. /*!
  554. * \brief Echo training time. 0 = disabled
  555. * \note Set from the "echotraining" value read in from chan_dahdi.conf
  556. */
  557. int echotraining;
  558. /*! \brief Filled with 'w'. XXX Purpose?? */
  559. char echorest[20];
  560. /*!
  561. * \brief Number of times to see "busy" tone before hanging up.
  562. * \note Set from the "busycount" value read in from chan_dahdi.conf
  563. */
  564. int busycount;
  565. /*!
  566. * \brief Busy cadence pattern description.
  567. * \note Set from the "busypattern" value read from chan_dahdi.conf
  568. */
  569. struct ast_dsp_busy_pattern busy_cadence;
  570. /*!
  571. * \brief Bitmapped call progress detection flags. CALLPROGRESS_xxx values.
  572. * \note Bits set from the "callprogress" and "faxdetect" values read in from chan_dahdi.conf
  573. */
  574. int callprogress;
  575. /*!
  576. * \brief Number of milliseconds to wait for dialtone.
  577. * \note Set from the "waitfordialtone" value read in from chan_dahdi.conf
  578. */
  579. int waitfordialtone;
  580. /*!
  581. * \brief Number of frames to watch for dialtone in incoming calls
  582. * \note Set from the "dialtone_detect" value read in from chan_dahdi.conf
  583. */
  584. int dialtone_detect;
  585. int dialtone_scanning_time_elapsed; /*!< Amount of audio scanned for dialtone, in frames */
  586. /*!
  587. * \brief The number of seconds into call to disable fax detection. (0 = disabled)
  588. * \note Set from the "faxdetect_timeout" value read in from chan_dahdi.conf
  589. */
  590. unsigned int faxdetect_timeout;
  591. struct timeval waitingfordt; /*!< Time we started waiting for dialtone */
  592. struct timeval flashtime; /*!< Last flash-hook time */
  593. /*! \brief Opaque DSP configuration structure. */
  594. struct ast_dsp *dsp;
  595. /*! \brief DAHDI dial operation command struct for ioctl() call. */
  596. struct dahdi_dialoperation dop;
  597. int whichwink; /*!< SIG_FEATDMF_TA Which wink are we on? */
  598. /*! \brief Second part of SIG_FEATDMF_TA wink operation. */
  599. char finaldial[64];
  600. char accountcode[AST_MAX_ACCOUNT_CODE]; /*!< Account code */
  601. int amaflags; /*!< AMA Flags */
  602. struct tdd_state *tdd; /*!< TDD flag */
  603. /*! \brief Accumulated call forwarding number. */
  604. char call_forward[AST_MAX_EXTENSION];
  605. /*!
  606. * \brief Voice mailbox location.
  607. * \note Set from the "mailbox" string read in from chan_dahdi.conf
  608. */
  609. char mailbox[AST_MAX_MAILBOX_UNIQUEID];
  610. /*! \brief Opaque event subscription parameters for message waiting indication support. */
  611. struct stasis_subscription *mwi_event_sub;
  612. /*! \brief Delayed dialing for E911. Overlap digits for ISDN. */
  613. char dialdest[256];
  614. #ifdef HAVE_DAHDI_LINEREVERSE_VMWI
  615. struct dahdi_vmwi_info mwisend_setting; /*!< Which VMWI methods to use */
  616. unsigned int mwisend_fsk: 1; /*! Variable for enabling FSK MWI handling in chan_dahdi */
  617. unsigned int mwisend_rpas:1; /*! Variable for enabling Ring Pulse Alert before MWI FSK Spill */
  618. #endif
  619. int distinctivering; /*!< Which distinctivering to use */
  620. int dtmfrelax; /*!< whether to run in relaxed DTMF mode */
  621. /*! \brief Holding place for event injected from outside normal operation. */
  622. int fake_event;
  623. /*!
  624. * \brief Minimal time period (ms) between the answer polarity
  625. * switch and hangup polarity switch.
  626. */
  627. int polarityonanswerdelay;
  628. /*! \brief Start delay time if polarityonanswerdelay is nonzero. */
  629. struct timeval polaritydelaytv;
  630. /*!
  631. * \brief Send caller ID on FXS after this many rings. Set to 1 for US.
  632. * \note Set from the "sendcalleridafter" value read in from chan_dahdi.conf
  633. */
  634. int sendcalleridafter;
  635. /*! \brief Current line interface polarity. POLARITY_IDLE, POLARITY_REV */
  636. int polarity;
  637. /*! \brief DSP feature flags: DSP_FEATURE_xxx */
  638. int dsp_features;
  639. #if defined(HAVE_SS7)
  640. /*! \brief SS7 control parameters */
  641. struct sig_ss7_linkset *ss7;
  642. #endif /* defined(HAVE_SS7) */
  643. #if defined(HAVE_OPENR2)
  644. struct dahdi_mfcr2 *mfcr2;
  645. openr2_chan_t *r2chan;
  646. openr2_calling_party_category_t mfcr2_recvd_category;
  647. openr2_calling_party_category_t mfcr2_category;
  648. int mfcr2_dnis_index;
  649. int mfcr2_ani_index;
  650. int mfcr2call:1;
  651. int mfcr2_answer_pending:1;
  652. int mfcr2_charge_calls:1;
  653. int mfcr2_allow_collect_calls:1;
  654. int mfcr2_forced_release:1;
  655. int mfcr2_dnis_matched:1;
  656. int mfcr2_call_accepted:1;
  657. int mfcr2_accept_on_offer:1;
  658. int mfcr2_progress_sent:1;
  659. #endif /* defined(HAVE_OPENR2) */
  660. /*! \brief DTMF digit in progress. 0 when no digit in progress. */
  661. char begindigit;
  662. /*! \brief TRUE if confrence is muted. */
  663. int muting;
  664. void *sig_pvt;
  665. struct ast_cc_config_params *cc_params;
  666. /* DAHDI channel names may differ greatly from the
  667. * string that was provided to an app such as Dial. We
  668. * need to save the original string passed to dahdi_request
  669. * for call completion purposes. This way, we can replicate
  670. * the original dialed string later.
  671. */
  672. char dialstring[AST_CHANNEL_NAME];
  673. };
  674. /* Analog signaling */
  675. #define SIG_EM DAHDI_SIG_EM
  676. #define SIG_EMWINK (0x0100000 | DAHDI_SIG_EM)
  677. #define SIG_FEATD (0x0200000 | DAHDI_SIG_EM)
  678. #define SIG_FEATDMF (0x0400000 | DAHDI_SIG_EM)
  679. #define SIG_FEATB (0x0800000 | DAHDI_SIG_EM)
  680. #define SIG_E911 (0x1000000 | DAHDI_SIG_EM)
  681. #define SIG_FEATDMF_TA (0x2000000 | DAHDI_SIG_EM)
  682. #define SIG_FGC_CAMA (0x4000000 | DAHDI_SIG_EM)
  683. #define SIG_FGC_CAMAMF (0x8000000 | DAHDI_SIG_EM)
  684. #define SIG_FXSLS DAHDI_SIG_FXSLS
  685. #define SIG_FXSGS DAHDI_SIG_FXSGS
  686. #define SIG_FXSKS DAHDI_SIG_FXSKS
  687. #define SIG_FXOLS DAHDI_SIG_FXOLS
  688. #define SIG_FXOGS DAHDI_SIG_FXOGS
  689. #define SIG_FXOKS DAHDI_SIG_FXOKS
  690. #define SIG_SF DAHDI_SIG_SF
  691. #define SIG_SFWINK (0x0100000 | DAHDI_SIG_SF)
  692. #define SIG_SF_FEATD (0x0200000 | DAHDI_SIG_SF)
  693. #define SIG_SF_FEATDMF (0x0400000 | DAHDI_SIG_SF)
  694. #define SIG_SF_FEATB (0x0800000 | DAHDI_SIG_SF)
  695. #define SIG_EM_E1 DAHDI_SIG_EM_E1
  696. /* PRI signaling */
  697. #define SIG_PRI DAHDI_SIG_CLEAR
  698. #define SIG_BRI (0x2000000 | DAHDI_SIG_CLEAR)
  699. #define SIG_BRI_PTMP (0X4000000 | DAHDI_SIG_CLEAR)
  700. /* SS7 signaling */
  701. #define SIG_SS7 (0x1000000 | DAHDI_SIG_CLEAR)
  702. /* MFC/R2 signaling */
  703. #define SIG_MFCR2 DAHDI_SIG_CAS
  704. #define SIG_PRI_LIB_HANDLE_CASES \
  705. SIG_PRI: \
  706. case SIG_BRI: \
  707. case SIG_BRI_PTMP
  708. /*!
  709. * \internal
  710. * \brief Determine if sig_pri handles the signaling.
  711. * \since 1.8
  712. *
  713. * \param signaling Signaling to determine if is for sig_pri.
  714. *
  715. * \return TRUE if the signaling is for sig_pri.
  716. */
  717. static inline int dahdi_sig_pri_lib_handles(int signaling)
  718. {
  719. int handles;
  720. switch (signaling) {
  721. case SIG_PRI_LIB_HANDLE_CASES:
  722. handles = 1;
  723. break;
  724. default:
  725. handles = 0;
  726. break;
  727. }
  728. return handles;
  729. }
  730. static inline int dahdi_analog_lib_handles(int signalling, int radio, int oprmode)
  731. {
  732. switch (signalling) {
  733. case SIG_FXOLS:
  734. case SIG_FXOGS:
  735. case SIG_FXOKS:
  736. case SIG_FXSLS:
  737. case SIG_FXSGS:
  738. case SIG_FXSKS:
  739. case SIG_EMWINK:
  740. case SIG_EM:
  741. case SIG_EM_E1:
  742. case SIG_FEATD:
  743. case SIG_FEATDMF:
  744. case SIG_E911:
  745. case SIG_FGC_CAMA:
  746. case SIG_FGC_CAMAMF:
  747. case SIG_FEATB:
  748. case SIG_SFWINK:
  749. case SIG_SF:
  750. case SIG_SF_FEATD:
  751. case SIG_SF_FEATDMF:
  752. case SIG_FEATDMF_TA:
  753. case SIG_SF_FEATB:
  754. break;
  755. default:
  756. /* The rest of the function should cover the remainder of signalling types */
  757. return 0;
  758. }
  759. if (radio) {
  760. return 0;
  761. }
  762. if (oprmode) {
  763. return 0;
  764. }
  765. return 1;
  766. }
  767. #define dahdi_get_index(ast, p, nullok) _dahdi_get_index(ast, p, nullok, __PRETTY_FUNCTION__, __LINE__)
  768. int _dahdi_get_index(struct ast_channel *ast, struct dahdi_pvt *p, int nullok, const char *fname, unsigned long line);
  769. void dahdi_dtmf_detect_disable(struct dahdi_pvt *p);
  770. void dahdi_dtmf_detect_enable(struct dahdi_pvt *p);
  771. void dahdi_ec_enable(struct dahdi_pvt *p);
  772. void dahdi_ec_disable(struct dahdi_pvt *p);
  773. void dahdi_conf_update(struct dahdi_pvt *p);
  774. void dahdi_master_slave_link(struct dahdi_pvt *slave, struct dahdi_pvt *master);
  775. void dahdi_master_slave_unlink(struct dahdi_pvt *slave, struct dahdi_pvt *master, int needlock);
  776. /* ------------------------------------------------------------------- */
  777. #if defined(__cplusplus) || defined(c_plusplus)
  778. }
  779. #endif
  780. #endif /* _ASTERISK_CHAN_DAHDI_H */