isdn_lib.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834
  1. /*
  2. * Chan_Misdn -- Channel Driver for Asterisk
  3. *
  4. * Interface to mISDN
  5. *
  6. * Copyright (C) 2004, Christian Richter
  7. *
  8. * Christian Richter <crich@beronet.com>
  9. *
  10. * This program is free software, distributed under the terms of
  11. * the GNU General Public License
  12. */
  13. /*! \file
  14. * \brief Interface to mISDN
  15. *
  16. * \author Christian Richter <crich@beronet.com>
  17. */
  18. #ifndef TE_LIB
  19. #define TE_LIB
  20. #include <mISDNuser/suppserv.h>
  21. /** For initialization usage **/
  22. /* typedef int ie_nothing_t ;*/
  23. /** end of init usage **/
  24. /*
  25. * uncomment the following to make chan_misdn create
  26. * record files in /tmp/misdn-{rx|tx}-PortChannel format
  27. * */
  28. /*#define MISDN_SAVE_DATA*/
  29. #ifdef WITH_BEROEC
  30. typedef int beroec_t;
  31. enum beroec_type {
  32. BEROEC_FULLBAND=0,
  33. BEROEC_SUBBAND,
  34. BEROEC_FASTSUBBAND
  35. };
  36. void beroec_init(void);
  37. void beroec_exit(void);
  38. beroec_t *beroec_new(int tail, enum beroec_type type, int anti_howl,
  39. int tonedisable, int zerocoeff, int adapt, int nlp);
  40. void beroec_destroy(beroec_t *ec);
  41. int beroec_cancel_alaw_chunk(beroec_t *ec,
  42. char *send,
  43. char *receive,
  44. int len);
  45. int beroec_version(void);
  46. #endif
  47. enum tone_e {
  48. TONE_NONE=0,
  49. TONE_DIAL,
  50. TONE_ALERTING,
  51. TONE_FAR_ALERTING,
  52. TONE_BUSY,
  53. TONE_HANGUP,
  54. TONE_CUSTOM,
  55. TONE_FILE
  56. };
  57. #define MAX_BCHANS 31
  58. enum bchannel_state {
  59. BCHAN_CLEANED=0,
  60. BCHAN_EMPTY,
  61. BCHAN_ACTIVATED,
  62. BCHAN_BRIDGED,
  63. BCHAN_RELEASE,
  64. BCHAN_ERROR
  65. };
  66. enum misdn_err_e {
  67. ENOCHAN=1
  68. };
  69. enum mISDN_NUMBER_PLAN {
  70. NUMPLAN_UNKNOWN = 0x0,
  71. NUMPLAN_ISDN = 0x1, /* ISDN/Telephony numbering plan E.164 */
  72. NUMPLAN_DATA = 0x3, /* Data numbering plan X.121 */
  73. NUMPLAN_TELEX = 0x4, /* Telex numbering plan F.69 */
  74. NUMPLAN_NATIONAL = 0x8,
  75. NUMPLAN_PRIVATE = 0x9
  76. };
  77. enum mISDN_NUMBER_TYPE {
  78. NUMTYPE_UNKNOWN = 0x0,
  79. NUMTYPE_INTERNATIONAL = 0x1,
  80. NUMTYPE_NATIONAL = 0x2,
  81. NUMTYPE_NETWORK_SPECIFIC = 0x3,
  82. NUMTYPE_SUBSCRIBER = 0x4,
  83. NUMTYPE_ABBREVIATED = 0x5
  84. };
  85. enum event_response_e {
  86. RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE,
  87. RESPONSE_IGNORE_SETUP,
  88. RESPONSE_RELEASE_SETUP,
  89. RESPONSE_ERR,
  90. RESPONSE_OK
  91. };
  92. enum event_e {
  93. EVENT_NOTHING,
  94. EVENT_TONE_GENERATE,
  95. EVENT_BCHAN_DATA,
  96. EVENT_BCHAN_ACTIVATED,
  97. EVENT_BCHAN_ERROR,
  98. EVENT_CLEANUP,
  99. EVENT_PROCEEDING,
  100. EVENT_PROGRESS,
  101. EVENT_SETUP,
  102. EVENT_REGISTER,
  103. EVENT_ALERTING,
  104. EVENT_CONNECT,
  105. EVENT_SETUP_ACKNOWLEDGE,
  106. EVENT_CONNECT_ACKNOWLEDGE ,
  107. EVENT_USER_INFORMATION,
  108. EVENT_SUSPEND_REJECT,
  109. EVENT_RESUME_REJECT,
  110. EVENT_HOLD,
  111. EVENT_SUSPEND,
  112. EVENT_RESUME,
  113. EVENT_HOLD_ACKNOWLEDGE,
  114. EVENT_SUSPEND_ACKNOWLEDGE,
  115. EVENT_RESUME_ACKNOWLEDGE,
  116. EVENT_HOLD_REJECT,
  117. EVENT_RETRIEVE,
  118. EVENT_RETRIEVE_ACKNOWLEDGE,
  119. EVENT_RETRIEVE_REJECT,
  120. EVENT_DISCONNECT,
  121. EVENT_RESTART,
  122. EVENT_RELEASE,
  123. EVENT_RELEASE_COMPLETE,
  124. EVENT_FACILITY,
  125. EVENT_NOTIFY,
  126. EVENT_STATUS_ENQUIRY,
  127. EVENT_INFORMATION,
  128. EVENT_STATUS,
  129. EVENT_TIMEOUT,
  130. EVENT_DTMF_TONE,
  131. EVENT_NEW_L3ID,
  132. EVENT_NEW_BC,
  133. EVENT_PORT_ALARM,
  134. EVENT_NEW_CHANNEL,
  135. EVENT_UNKNOWN
  136. };
  137. enum ie_name_e {
  138. IE_DUMMY,
  139. IE_LAST
  140. };
  141. enum { /* bearer capability */
  142. INFO_CAPABILITY_SPEECH=0,
  143. INFO_CAPABILITY_AUDIO_3_1K=0x10 ,
  144. INFO_CAPABILITY_AUDIO_7K=0x11 ,
  145. INFO_CAPABILITY_VIDEO =0x18,
  146. INFO_CAPABILITY_DIGITAL_UNRESTRICTED =0x8,
  147. INFO_CAPABILITY_DIGITAL_RESTRICTED =0x09,
  148. INFO_CAPABILITY_DIGITAL_UNRESTRICTED_TONES
  149. };
  150. enum { /* progress indicators */
  151. INFO_PI_CALL_NOT_E2E_ISDN =0x01,
  152. INFO_PI_CALLED_NOT_ISDN =0x02,
  153. INFO_PI_CALLER_NOT_ISDN =0x03,
  154. INFO_PI_CALLER_RETURNED_TO_ISDN =0x04,
  155. INFO_PI_INBAND_AVAILABLE =0x08,
  156. INFO_PI_DELAY_AT_INTERF =0x0a,
  157. INFO_PI_INTERWORKING_WITH_PUBLIC =0x10,
  158. INFO_PI_INTERWORKING_NO_RELEASE =0x11,
  159. INFO_PI_INTERWORKING_NO_RELEASE_PRE_ANSWER =0x12,
  160. INFO_PI_INTERWORKING_NO_RELEASE_POST_ANSWER =0x13
  161. };
  162. /*!
  163. * \brief Q.931 encoded redirecting reason
  164. */
  165. enum mISDN_REDIRECTING_REASON {
  166. mISDN_REDIRECTING_REASON_UNKNOWN = 0x0,
  167. /*! Call forwarding busy or called DTE busy */
  168. mISDN_REDIRECTING_REASON_CALL_FWD_BUSY = 0x1,
  169. /*! Call forwarding no reply */
  170. mISDN_REDIRECTING_REASON_NO_REPLY = 0x2,
  171. /*! Call deflection */
  172. mISDN_REDIRECTING_REASON_DEFLECTION = 0x4,
  173. /*! Called DTE out of order */
  174. mISDN_REDIRECTING_REASON_OUT_OF_ORDER = 0x9,
  175. /*! Call forwarding by the called DTE */
  176. mISDN_REDIRECTING_REASON_CALL_FWD_DTE = 0xA,
  177. /*! Call forwarding unconditional or systematic call redirection */
  178. mISDN_REDIRECTING_REASON_CALL_FWD = 0xF
  179. };
  180. /*!
  181. * \brief Notification description code enumeration
  182. */
  183. enum mISDN_NOTIFY_CODE {
  184. mISDN_NOTIFY_CODE_INVALID = -1,
  185. /*! Call is placed on hold (Q.931) */
  186. mISDN_NOTIFY_CODE_USER_SUSPEND = 0x00,
  187. /*! Call is taken off of hold (Q.931) */
  188. mISDN_NOTIFY_CODE_USER_RESUME = 0x01,
  189. /*! Call is diverting (EN 300 207-1 Section 7.2.1) */
  190. mISDN_NOTIFY_CODE_CALL_IS_DIVERTING = 0x7B,
  191. /*! Call diversion is enabled (cfu, cfb, cfnr) (EN 300 207-1 Section 7.2.1) */
  192. mISDN_NOTIFY_CODE_DIVERSION_ACTIVATED = 0x68,
  193. /*! Call transfer, alerting (EN 300 369-1 Section 7.2) */
  194. mISDN_NOTIFY_CODE_CALL_TRANSFER_ALERTING = 0x69,
  195. /*! Call transfer, active(answered) (EN 300 369-1 Section 7.2) */
  196. mISDN_NOTIFY_CODE_CALL_TRANSFER_ACTIVE = 0x6A,
  197. };
  198. enum { /*CODECS*/
  199. INFO_CODEC_ULAW=2,
  200. INFO_CODEC_ALAW=3
  201. };
  202. enum layer_e {
  203. L3,
  204. L2,
  205. L1,
  206. UNKNOWN
  207. };
  208. /*! Maximum phone number (address) length plus null terminator */
  209. #define MISDN_MAX_NUMBER_LEN (31 + 1)
  210. /*! Maximum name length plus null terminator (From ECMA-164) */
  211. #define MISDN_MAX_NAME_LEN (50 + 1)
  212. /*! Maximum subaddress length plus null terminator */
  213. #define MISDN_MAX_SUBADDRESS_LEN (23 + 1)
  214. /*! Maximum keypad facility content length plus null terminator */
  215. #define MISDN_MAX_KEYPAD_LEN (31 + 1)
  216. /*! \brief Dialed/Called information struct */
  217. struct misdn_party_dialing {
  218. /*! \brief Type-of-number in ISDN terms for the dialed/called number */
  219. enum mISDN_NUMBER_TYPE number_type;
  220. /*! \brief Type-of-number numbering plan. */
  221. enum mISDN_NUMBER_PLAN number_plan;
  222. /*! \brief Dialed/Called Phone Number (Address) */
  223. char number[MISDN_MAX_NUMBER_LEN];
  224. /*! \brief Dialed/Called Subaddress number */
  225. char subaddress[MISDN_MAX_SUBADDRESS_LEN];
  226. };
  227. /*! \brief Connected-Line/Calling/Redirecting ID info struct */
  228. struct misdn_party_id {
  229. /*! \brief Number presentation restriction code
  230. * 0=Allowed, 1=Restricted, 2=Unavailable
  231. */
  232. int presentation;
  233. /*! \brief Number screening code
  234. * 0=Unscreened, 1=Passed Screen, 2=Failed Screen, 3=Network Number
  235. */
  236. int screening;
  237. /*! \brief Type-of-number in ISDN terms for the number */
  238. enum mISDN_NUMBER_TYPE number_type;
  239. /*! \brief Type-of-number numbering plan. */
  240. enum mISDN_NUMBER_PLAN number_plan;
  241. /*! \brief Subscriber Name
  242. * \note The name is currently obtained from Asterisk for
  243. * potential use in display ie's since basic ISDN does
  244. * not support names directly.
  245. */
  246. char name[MISDN_MAX_NAME_LEN];
  247. /*! \brief Phone number (Address) */
  248. char number[MISDN_MAX_NUMBER_LEN];
  249. /*! \brief Subaddress number */
  250. char subaddress[MISDN_MAX_SUBADDRESS_LEN];
  251. };
  252. /*! \brief Redirecting information struct */
  253. struct misdn_party_redirecting {
  254. /*! \brief Who is redirecting the call (Sent to the party the call is redirected toward) */
  255. struct misdn_party_id from;
  256. /*! \brief Where the call is being redirected toward (Sent to the calling party) */
  257. struct misdn_party_id to;
  258. /*! \brief Reason a call is being redirected (Q.931 field value) */
  259. enum mISDN_REDIRECTING_REASON reason;
  260. /*! \brief Number of times the call has been redirected */
  261. int count;
  262. /*! \brief TRUE if the redirecting.to information has changed */
  263. int to_changed;
  264. };
  265. /*! \brief B channel control structure */
  266. struct misdn_bchannel {
  267. /*! \brief B channel send locking structure */
  268. struct send_lock *send_lock;
  269. #if defined(AST_MISDN_ENHANCEMENTS)
  270. /*! \brief The BC, HLC (optional) and LLC (optional) contents from the SETUP message. */
  271. struct Q931_Bc_Hlc_Llc setup_bc_hlc_llc;
  272. #endif /* defined(AST_MISDN_ENHANCEMENTS) */
  273. /*!
  274. * \brief Dialed/Called information struct
  275. * \note The number_type element is set to "dialplan" in /etc/asterisk/misdn.conf for outgoing calls
  276. */
  277. struct misdn_party_dialing dialed;
  278. /*! \brief Originating/Caller ID information struct
  279. * \note The number_type element can be set to "localdialplan" in /etc/asterisk/misdn.conf for outgoing calls
  280. * \note The number element can be set to "callerid" in /etc/asterisk/misdn.conf for outgoing calls
  281. */
  282. struct misdn_party_id caller;
  283. /*! \brief Incoming Caller ID string tag for special purpose
  284. * \note The element can be set to "incoming_cid_tag" in /etc/asterisk/misdn.conf for incoming calls
  285. */
  286. char incoming_cid_tag[MISDN_MAX_NAME_LEN];
  287. /*! \brief Connected-Party/Connected-Line ID information struct
  288. * \note The number_type element can be set to "cpndialplan" in /etc/asterisk/misdn.conf for outgoing calls
  289. */
  290. struct misdn_party_id connected;
  291. /*! \brief Redirecting information struct (Where a call diversion or transfer was invoked)
  292. * \note The redirecting subaddress is not defined in Q.931 so it is not used.
  293. */
  294. struct misdn_party_redirecting redirecting;
  295. /*! \brief TRUE if this is a dummy BC record */
  296. int dummy;
  297. /*! \brief TRUE if NT side of protocol (TE otherwise) */
  298. int nt;
  299. /*! \brief TRUE if ISDN-PRI (ISDN-BRI otherwise) */
  300. int pri;
  301. /*! \brief Logical Layer 1 port associated with this B channel */
  302. int port;
  303. /** init stuff **/
  304. /*! \brief B Channel mISDN driver stack ID */
  305. int b_stid;
  306. /* int b_addr; */
  307. /*! \brief B Channel mISDN driver layer ID from mISDN_new_layer() */
  308. int layer_id;
  309. /*! \brief B channel layer; set to 3 or 4 */
  310. int layer;
  311. /* state stuff */
  312. /*! \brief TRUE if DISCONNECT needs to be sent to clear a call */
  313. int need_disconnect;
  314. /*! \brief TRUE if RELEASE needs to be sent to clear a call */
  315. int need_release;
  316. /*! \brief TRUE if RELEASE_COMPLETE needs to be sent to clear a call */
  317. int need_release_complete;
  318. /*! \brief TRUE if allocate higher B channels first */
  319. int dec;
  320. /* var stuff */
  321. /*! \brief Layer 3 process ID */
  322. int l3_id;
  323. /*! \brief B channel process ID (1-5000) */
  324. int pid;
  325. /*! \brief Not used. Saved mISDN stack CONNECT_t ces value */
  326. int ces;
  327. /*! \brief B channel to restart if received a RESTART message */
  328. int restart_channel;
  329. /*! \brief Assigned B channel number B1, B2... 0 if not assigned */
  330. int channel;
  331. /*! \brief TRUE if the B channel number is preselected */
  332. int channel_preselected;
  333. /*! \brief TRUE if the B channel is allocated from the REGISTER pool */
  334. int is_register_pool;
  335. /*! \brief TRUE if B channel record is in use */
  336. int in_use;
  337. /*! \brief Time when empty_bc() last called on this record */
  338. struct timeval last_used;
  339. /*! \brief TRUE if call waiting */
  340. int cw;
  341. /*! \brief B Channel mISDN driver layer ID from mISDN_get_layerid() */
  342. int addr;
  343. /*! \brief B channel speech sample data buffer */
  344. char *bframe;
  345. /*! \brief B channel speech sample data buffer size */
  346. int bframe_len;
  347. int time_usec; /* Not used */
  348. /*! \brief Not used. Contents are setup but not used. */
  349. void *astbuf;
  350. /*! \brief TRUE if the TE side should choose the B channel to use
  351. * \note This value is user configurable in /etc/asterisk/misdn.conf
  352. */
  353. int te_choose_channel;
  354. /*! \brief TRUE if the call progress indicators can indicate an inband audio message for the user to listen to
  355. * \note This value is user configurable in /etc/asterisk/misdn.conf
  356. */
  357. int early_bconnect;
  358. /*! \brief Last decoded DTMF digit from mISDN driver */
  359. int dtmf;
  360. /*! \brief TRUE if we should produce DTMF tones ourselves
  361. * \note This value is user configurable in /etc/asterisk/misdn.conf
  362. */
  363. int send_dtmf;
  364. /*! \brief TRUE if we send SETUP_ACKNOWLEDGE on incoming calls anyway (instead of PROCEEDING).
  365. *
  366. * This requests additional INFORMATION messages, so we can
  367. * wait for digits without issues.
  368. * \note This value is user configurable in /etc/asterisk/misdn.conf
  369. */
  370. int need_more_infos;
  371. /*! \brief TRUE if all digits necessary to complete the call are available.
  372. * No more INFORMATION messages are needed.
  373. */
  374. int sending_complete;
  375. /*! \brief TRUE if we will not use jollys dsp */
  376. int nodsp;
  377. /*! \brief TRUE if we will not use the jitter buffer system */
  378. int nojitter;
  379. /*! \brief Progress Indicator IE coding standard field.
  380. * \note Collected from the incoming messages but not used.
  381. */
  382. int progress_coding;
  383. /*! \brief Progress Indicator IE location field.
  384. * \note Collected from the incoming messages but not used.
  385. */
  386. int progress_location;
  387. /*! \brief Progress Indicator IE progress description field.
  388. * Used to determine if there is an inband audio message present.
  389. */
  390. int progress_indicator;
  391. #if defined(AST_MISDN_ENHANCEMENTS)
  392. /*!
  393. * \brief TRUE if waiting for DivertingLegInformation3 to queue redirecting update.
  394. */
  395. int div_leg_3_rx_wanted;
  396. /*!
  397. * \brief TRUE if a DivertingLegInformation3 needs to be sent with CONNECT.
  398. */
  399. int div_leg_3_tx_pending;
  400. #endif /* defined(AST_MISDN_ENHANCEMENTS) */
  401. /*! \brief Inbound FACILITY message function type and contents */
  402. struct FacParm fac_in;
  403. /*! \brief Outbound FACILITY message function type and contents.
  404. * \note Filled in by misdn facility commands before FACILITY message sent.
  405. */
  406. struct FacParm fac_out;
  407. /* storing the current AOCD info here */
  408. enum FacFunction AOCDtype;
  409. union {
  410. struct FacAOCDCurrency currency;
  411. struct FacAOCDChargingUnit chargingUnit;
  412. } AOCD;
  413. /*! \brief TRUE if AOCDtype and AOCD data are ready to export to Asterisk */
  414. int AOCD_need_export;
  415. /*** CRYPTING STUFF ***/
  416. int crypt; /* Initialized, Not used */
  417. int curprx; /* Initialized, Not used */
  418. int curptx; /* Initialized, Not used */
  419. /*! \brief Blowfish encryption key string (secret) */
  420. char crypt_key[255];
  421. int crypt_state; /* Not used */
  422. /*** CRYPTING STUFF END***/
  423. /*! \brief Seems to have been intended for something to do with the jitter buffer.
  424. * \note Used as a boolean. Only initialized to 0 and referenced in a couple places
  425. */
  426. int active;
  427. int upset; /* Not used */
  428. /*! \brief TRUE if tone generator allowed to start */
  429. int generate_tone;
  430. /*! \brief Number of tone samples to generate */
  431. int tone_cnt;
  432. /*! \brief Current B Channel state */
  433. enum bchannel_state bc_state;
  434. /*! \brief This is used as a pending bridge join request for when bc_state becomes BCHAN_ACTIVATED */
  435. enum bchannel_state next_bc_state;
  436. /*! \brief Bridging conference ID */
  437. int conf_id;
  438. /*! \brief TRUE if this channel is on hold */
  439. int holded;
  440. /*! \brief TRUE if this channel is on the misdn_stack->holding list
  441. * \note If TRUE this implies that the structure is also malloced.
  442. */
  443. int stack_holder;
  444. /*!
  445. * \brief Put a display ie in the CONNECT message
  446. * \details
  447. * Put a display ie in the CONNECT message containing the following
  448. * information if it is available (nt port only):
  449. * 0 - Do not put the connected line information in the display ie.
  450. * 1 - Put the available connected line name in the display ie.
  451. * 2 - Put the available connected line number in the display ie.
  452. * 3 - Put the available connected line name and number in the display ie.
  453. */
  454. int display_connected;
  455. /*!
  456. * \brief Put a display ie in the SETUP message
  457. * \details
  458. * Put a display ie in the SETUP message containing the following
  459. * information if it is available (nt port only):
  460. * 0 - Do not put the caller information in the display ie.
  461. * 1 - Put the available caller name in the display ie.
  462. * 2 - Put the available caller number in the display ie.
  463. * 3 - Put the available caller name and number in the display ie.
  464. */
  465. int display_setup;
  466. /*!
  467. * \brief Select what to do with outgoing COLP information.
  468. * \details
  469. * 0 - pass (Send out COLP information unaltered.)
  470. * 1 - restricted (Force COLP to restricted on all outgoing COLP information.)
  471. * 2 - block (Do not send COLP information.)
  472. */
  473. int outgoing_colp;
  474. /*! \brief User set presentation restriction code
  475. * 0=Allowed, 1=Restricted, 2=Unavailable
  476. * \note It is settable by the misdn_set_opt() application.
  477. */
  478. int presentation;
  479. /*! \brief TRUE if the user set the presentation restriction code */
  480. int set_presentation;
  481. /*! \brief Notification indicator ie description code */
  482. enum mISDN_NOTIFY_CODE notify_description_code;
  483. /*! \brief SETUP message bearer capability field code value */
  484. int capability;
  485. /*! \brief Companding ALaw/uLaw encoding (INFO_CODEC_ALAW / INFO_CODEC_ULAW) */
  486. int law;
  487. /* V110 Stuff */
  488. /*! \brief Q.931 Bearer Capability IE Information Transfer Rate field. Initialized to 0x10 (64kbit). Altered by incoming SETUP messages. */
  489. int rate;
  490. /*! \brief Q.931 Bearer Capability IE Transfer Mode field. Initialized to 0 (Circuit). Altered by incoming SETUP messages. */
  491. int mode;
  492. /*! \brief Q.931 Bearer Capability IE User Information Layer 1 Protocol field code.
  493. * \note Collected from the incoming SETUP message but not used.
  494. */
  495. int user1;
  496. /*! \brief Q.931 Bearer Capability IE Layer 1 User Rate field.
  497. * \note Collected from the incoming SETUP message and exported to Asterisk variable MISDN_URATE.
  498. */
  499. int urate;
  500. /*! \brief TRUE if call made in digital HDLC mode
  501. * \note This value is user configurable in /etc/asterisk/misdn.conf.
  502. * It is also settable by the misdn_set_opt() application.
  503. */
  504. int hdlc;
  505. /* V110 */
  506. /*! \brief Display message that can be displayed by the user phone.
  507. * \note Maximum displayable length is 34 or 82 octets.
  508. * It is also settable by the misdn_set_opt() application.
  509. */
  510. char display[84];
  511. /*! \brief Q.931 Keypad Facility IE contents
  512. * \note Contents exported and imported to Asterisk variable MISDN_KEYPAD
  513. */
  514. char keypad[MISDN_MAX_KEYPAD_LEN];
  515. /*! \brief Current overlap dialing digits to/from INFORMATION messages */
  516. char info_dad[MISDN_MAX_NUMBER_LEN];
  517. /*! \brief Collected digits to go into info_dad[] while waiting for a SETUP_ACKNOWLEDGE to come in. */
  518. char infos_pending[MISDN_MAX_NUMBER_LEN];
  519. /* unsigned char info_keypad[MISDN_MAX_KEYPAD_LEN]; */
  520. /* unsigned char clisub[24]; */
  521. /* unsigned char cldsub[24]; */
  522. /*! \brief User-User information string.
  523. * \note Contents exported and imported to Asterisk variable MISDN_USERUSER
  524. * \note We only support ASCII strings (IA5 characters).
  525. */
  526. char uu[256];
  527. /*! \brief User-User information string length in uu[] */
  528. int uulen;
  529. /*! \brief Q.931 Cause for disconnection code (received)
  530. * \note Need to use the AST_CAUSE_xxx code definitions in causes.h
  531. */
  532. int cause;
  533. /*! \brief Q.931 Cause for disconnection code (sent)
  534. * \note Need to use the AST_CAUSE_xxx code definitions in causes.h
  535. * \note -1 is used to suppress including the cause code in the RELEASE message.
  536. */
  537. int out_cause;
  538. /* struct misdn_bchannel hold_bc; */
  539. /** list stuf **/
  540. #ifdef MISDN_1_2
  541. /*! \brief The configuration string for the mISDN dsp pipeline in /etc/asterisk/misdn.conf. */
  542. char pipeline[128];
  543. #else
  544. /*! \brief TRUE if the echo cancellor is enabled */
  545. int ec_enable;
  546. /*! \brief Number of taps in the echo cancellor when enabled.
  547. * \note This value is user configurable in /etc/asterisk/misdn.conf (echocancel)
  548. */
  549. int ec_deftaps;
  550. #endif
  551. /*! \brief TRUE if the channel was allocated from the available B channels */
  552. int channel_found;
  553. /*! \brief Who originated the call (ORG_AST, ORG_MISDN)
  554. * \note Set but not used when the misdn_set_opt() application enables echo cancellation.
  555. */
  556. int orig;
  557. /*! \brief Tx gain setting (range -8 to 8)
  558. * \note This value is user configurable in /etc/asterisk/misdn.conf.
  559. * It is also settable by the misdn_set_opt() application.
  560. */
  561. int txgain;
  562. /*! \brief Rx gain setting (range -8 to 8)
  563. * \note This value is user configurable in /etc/asterisk/misdn.conf.
  564. * It is also settable by the misdn_set_opt() application.
  565. */
  566. int rxgain;
  567. /*! \brief Next node in the misdn_stack.holding list */
  568. struct misdn_bchannel *next;
  569. };
  570. extern enum event_response_e (*cb_event) (enum event_e event, struct misdn_bchannel *bc, void *user_data);
  571. extern void (*cb_log) (int level, int port, char *tmpl, ...)
  572. __attribute__ ((format (printf, 3, 4)));
  573. extern int (*cb_jb_empty)(struct misdn_bchannel *bc, char *buffer, int len);
  574. struct misdn_lib_iface {
  575. enum event_response_e (*cb_event)(enum event_e event, struct misdn_bchannel *bc, void *user_data);
  576. void (*cb_log)(int level, int port, char *tmpl, ...)
  577. __attribute__ ((format (printf, 3, 4)));
  578. int (*cb_jb_empty)(struct misdn_bchannel *bc, char *buffer, int len);
  579. };
  580. /***** USER IFACE **********/
  581. void misdn_lib_nt_keepcalls(int kc);
  582. void misdn_lib_nt_debug_init( int flags, char *file );
  583. int misdn_lib_init(char *portlist, struct misdn_lib_iface* iface, void *user_data);
  584. int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event );
  585. void misdn_lib_destroy(void);
  586. void misdn_lib_isdn_l1watcher(int port);
  587. void misdn_lib_log_ies(struct misdn_bchannel *bc);
  588. char *manager_isdn_get_info(enum event_e event);
  589. struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout, int dec);
  590. #if defined(AST_MISDN_ENHANCEMENTS)
  591. struct misdn_bchannel *misdn_lib_get_register_bc(int port);
  592. #endif /* defined(AST_MISDN_ENHANCEMENTS) */
  593. void manager_bchannel_activate(struct misdn_bchannel *bc);
  594. void manager_bchannel_deactivate(struct misdn_bchannel * bc);
  595. int misdn_lib_tx2misdn_frm(struct misdn_bchannel *bc, void *data, int len);
  596. void manager_ph_control(struct misdn_bchannel *bc, int c1, int c2);
  597. void isdn_lib_update_rxgain (struct misdn_bchannel *bc);
  598. void isdn_lib_update_txgain (struct misdn_bchannel *bc);
  599. void isdn_lib_update_ec (struct misdn_bchannel *bc);
  600. void isdn_lib_stop_dtmf (struct misdn_bchannel *bc);
  601. int misdn_lib_port_restart(int port);
  602. int misdn_lib_pid_restart(int pid);
  603. int misdn_lib_send_restart(int port, int channel);
  604. int misdn_lib_get_port_info(int port);
  605. int misdn_lib_is_port_blocked(int port);
  606. int misdn_lib_port_block(int port);
  607. int misdn_lib_port_unblock(int port);
  608. int misdn_lib_port_is_pri(int port);
  609. int misdn_lib_port_is_nt(int port);
  610. int misdn_lib_port_up(int port, int notcheck);
  611. int misdn_lib_get_port_down(int port);
  612. int misdn_lib_get_port_up (int port) ;
  613. int misdn_lib_maxports_get(void) ;
  614. struct misdn_bchannel *misdn_lib_find_held_bc(int port, int l3_id);
  615. void misdn_lib_release(struct misdn_bchannel *bc);
  616. int misdn_cap_is_speech(int cap);
  617. int misdn_inband_avail(struct misdn_bchannel *bc);
  618. void manager_ec_enable(struct misdn_bchannel *bc);
  619. void manager_ec_disable(struct misdn_bchannel *bc);
  620. void misdn_lib_send_tone(struct misdn_bchannel *bc, enum tone_e tone);
  621. void get_show_stack_details(int port, char *buf);
  622. void misdn_lib_tone_generator_start(struct misdn_bchannel *bc);
  623. void misdn_lib_tone_generator_stop(struct misdn_bchannel *bc);
  624. void misdn_lib_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel *bc2);
  625. void misdn_lib_split_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel *bc2);
  626. void misdn_lib_echo(struct misdn_bchannel *bc, int onoff);
  627. int misdn_lib_is_ptp(int port);
  628. int misdn_lib_get_maxchans(int port);
  629. void misdn_lib_reinit_nt_stack(int port);
  630. #define PRI_TRANS_CAP_SPEECH 0x0
  631. #define PRI_TRANS_CAP_DIGITAL 0x08
  632. #define PRI_TRANS_CAP_RESTRICTED_DIGITAL 0x09
  633. #define PRI_TRANS_CAP_3_1K_AUDIO 0x10
  634. #define PRI_TRANS_CAP_7K_AUDIO 0x11
  635. char *bc_state2str(enum bchannel_state state);
  636. void bc_state_change(struct misdn_bchannel *bc, enum bchannel_state state);
  637. void misdn_dump_chanlist(void);
  638. void misdn_make_dummy(struct misdn_bchannel *dummybc, int port, int l3id, int nt, int channel);
  639. #endif /* TE_LIB */