1 
2 /*
3  *
4  Copyright (c) Eicon Networks, 2002.
5  *
6  This source file is supplied for the use with
7  Eicon Networks range of DIVA Server Adapters.
8  *
9  Eicon File Revision :    2.1
10  *
11  This program is free software; you can redistribute it and/or modify
12  it under the terms of the GNU General Public License as published by
13  the Free Software Foundation; either version 2, or (at your option)
14  any later version.
15  *
16  This program is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY
18  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19  See the GNU General Public License for more details.
20  *
21  You should have received a copy of the GNU General Public License
22  along with this program; if not, write to the Free Software
23  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  *
25  */
26 
27 /*#define DEBUG */
28 
29 #include <linux/types.h>
30 
31 #define IMPLEMENT_DTMF 1
32 #define IMPLEMENT_LINE_INTERCONNECT2 1
33 #define IMPLEMENT_ECHO_CANCELLER 1
34 #define IMPLEMENT_RTP 1
35 #define IMPLEMENT_T38 1
36 #define IMPLEMENT_FAX_SUB_SEP_PWD 1
37 #define IMPLEMENT_V18 1
38 #define IMPLEMENT_DTMF_TONE 1
39 #define IMPLEMENT_PIAFS 1
40 #define IMPLEMENT_FAX_PAPER_FORMATS 1
41 #define IMPLEMENT_VOWN 1
42 #define IMPLEMENT_CAPIDTMF 1
43 #define IMPLEMENT_FAX_NONSTANDARD 1
44 #define VSWITCH_SUPPORT 1
45 
46 
47 #define IMPLEMENT_LINE_INTERCONNECT 0
48 #define IMPLEMENT_MARKED_OK_AFTER_FC 1
49 
50 #include "capidtmf.h"
51 
52 /*------------------------------------------------------------------*/
53 /* Common API internal definitions                                  */
54 /*------------------------------------------------------------------*/
55 
56 #define MAX_APPL 240
57 #define MAX_NCCI           127
58 
59 #define MSG_IN_QUEUE_SIZE  ((4096 + 3) & 0xfffc)  /* must be multiple of 4 */
60 
61 
62 #define MSG_IN_OVERHEAD    sizeof(APPL   *)
63 
64 #define MAX_NL_CHANNEL     255
65 #define MAX_DATA_B3        8
66 #define MAX_DATA_ACK       MAX_DATA_B3
67 #define MAX_MULTI_IE       6
68 #define MAX_MSG_SIZE       256
69 #define MAX_MSG_PARMS      10
70 #define MAX_CPN_MASK_SIZE  16
71 #define MAX_MSN_CONFIG     10
72 #define EXT_CONTROLLER     0x80
73 #define CODEC              0x01
74 #define CODEC_PERMANENT    0x02
75 #define ADV_VOICE          0x03
76 #define MAX_CIP_TYPES      5  /* kind of CIP types for group optimization */
77 
78 #define FAX_CONNECT_INFO_BUFFER_SIZE  256
79 #define NCPI_BUFFER_SIZE              256
80 
81 #define MAX_CHANNELS_PER_PLCI         8
82 #define MAX_INTERNAL_COMMAND_LEVELS   4
83 #define INTERNAL_REQ_BUFFER_SIZE      272
84 
85 #define INTERNAL_IND_BUFFER_SIZE      768
86 
87 #define DTMF_PARAMETER_BUFFER_SIZE    12
88 #define ADV_VOICE_COEF_BUFFER_SIZE    50
89 
90 #define LI_PLCI_B_QUEUE_ENTRIES       256
91 
92 
93 
94 typedef struct _APPL APPL;
95 typedef struct _PLCI PLCI;
96 typedef struct _NCCI NCCI;
97 typedef struct _DIVA_CAPI_ADAPTER DIVA_CAPI_ADAPTER;
98 typedef struct _DATA_B3_DESC DATA_B3_DESC;
99 typedef struct _DATA_ACK_DESC DATA_ACK_DESC;
100 typedef struct manufacturer_profile_s MANUFACTURER_PROFILE;
101 typedef struct fax_ncpi_s FAX_NCPI;
102 typedef struct api_parse_s API_PARSE;
103 typedef struct api_save_s API_SAVE;
104 typedef struct msn_config_s MSN_CONFIG;
105 typedef struct msn_config_max_s MSN_CONFIG_MAX;
106 typedef struct msn_ld_s MSN_LD;
107 
108 struct manufacturer_profile_s {
109 	dword private_options;
110 	dword rtp_primary_payloads;
111 	dword rtp_additional_payloads;
112 };
113 
114 struct fax_ncpi_s {
115 	word options;
116 	word format;
117 };
118 
119 struct msn_config_s {
120 	byte msn[MAX_CPN_MASK_SIZE];
121 };
122 
123 struct msn_config_max_s {
124 	MSN_CONFIG    msn_conf[MAX_MSN_CONFIG];
125 };
126 
127 struct msn_ld_s {
128 	dword low;
129 	dword high;
130 };
131 
132 struct api_parse_s {
133 	word          length;
134 	byte *info;
135 };
136 
137 struct api_save_s {
138 	API_PARSE     parms[MAX_MSG_PARMS + 1];
139 	byte          info[MAX_MSG_SIZE];
140 };
141 
142 struct _DATA_B3_DESC {
143 	word          Handle;
144 	word          Number;
145 	word          Flags;
146 	word          Length;
147 	void *P;
148 };
149 
150 struct _DATA_ACK_DESC {
151 	word          Handle;
152 	word          Number;
153 };
154 
155 typedef void (*t_std_internal_command)(dword Id, PLCI *plci, byte Rc);
156 
157 /************************************************************************/
158 /* Don't forget to adapt dos.asm after changing the _APPL structure!!!! */
159 struct _APPL {
160 	word          Id;
161 	word          NullCREnable;
162 	word          CDEnable;
163 	dword         S_Handle;
164 
165 
166 
167 
168 
169 
170 	LIST_ENTRY    s_function;
171 	dword         s_context;
172 	word          s_count;
173 	APPL *s_next;
174 	byte *xbuffer_used;
175 	void **xbuffer_internal;
176 	void **xbuffer_ptr;
177 
178 
179 
180 
181 
182 
183 	byte *queue;
184 	word          queue_size;
185 	word          queue_free;
186 	word          queue_read;
187 	word          queue_write;
188 	word          queue_signal;
189 	byte          msg_lost;
190 	byte          appl_flags;
191 	word          Number;
192 
193 	word          MaxBuffer;
194 	byte          MaxNCCI;
195 	byte          MaxNCCIData;
196 	word          MaxDataLength;
197 	word          NCCIDataFlowCtrlTimer;
198 	byte *ReceiveBuffer;
199 	word *DataNCCI;
200 	word *DataFlags;
201 };
202 
203 
204 struct _PLCI {
205 	ENTITY        Sig;
206 	ENTITY        NL;
207 	word          RNum;
208 	word          RFlags;
209 	BUFFERS       RData[2];
210 	BUFFERS       XData[1];
211 	BUFFERS       NData[2];
212 
213 	DIVA_CAPI_ADAPTER   *adapter;
214 	APPL      *appl;
215 	PLCI      *relatedPTYPLCI;
216 	byte          Id;
217 	byte          State;
218 	byte          sig_req;
219 	byte          nl_req;
220 	byte          SuppState;
221 	byte          channels;
222 	byte          tel;
223 	byte          B1_resource;
224 	byte          B2_prot;
225 	byte          B3_prot;
226 
227 	word          command;
228 	word          m_command;
229 	word          internal_command;
230 	word          number;
231 	word          req_in_start;
232 	word          req_in;
233 	word          req_out;
234 	word          msg_in_write_pos;
235 	word          msg_in_read_pos;
236 	word          msg_in_wrap_pos;
237 
238 	void *data_sent_ptr;
239 	byte          data_sent;
240 	byte          send_disc;
241 	byte          sig_global_req;
242 	byte          sig_remove_id;
243 	byte          nl_global_req;
244 	byte          nl_remove_id;
245 	byte          b_channel;
246 	byte          adv_nl;
247 	byte          manufacturer;
248 	byte          call_dir;
249 	byte          hook_state;
250 	byte          spoofed_msg;
251 	byte          ptyState;
252 	byte          cr_enquiry;
253 	word          hangup_flow_ctrl_timer;
254 
255 	word          ncci_ring_list;
256 	byte          inc_dis_ncci_table[MAX_CHANNELS_PER_PLCI];
257 	t_std_internal_command internal_command_queue[MAX_INTERNAL_COMMAND_LEVELS];
258 	DECLARE_BITMAP(c_ind_mask_table, MAX_APPL);
259 	DECLARE_BITMAP(group_optimization_mask_table, MAX_APPL);
260 	byte          RBuffer[200];
261 	dword         msg_in_queue[MSG_IN_QUEUE_SIZE/sizeof(dword)];
262 	API_SAVE      saved_msg;
263 	API_SAVE      B_protocol;
264 	byte          fax_connect_info_length;
265 	byte          fax_connect_info_buffer[FAX_CONNECT_INFO_BUFFER_SIZE];
266 	byte          fax_edata_ack_length;
267 	word          nsf_control_bits;
268 	byte          ncpi_state;
269 	byte          ncpi_buffer[NCPI_BUFFER_SIZE];
270 
271 	byte          internal_req_buffer[INTERNAL_REQ_BUFFER_SIZE];
272 	byte          internal_ind_buffer[INTERNAL_IND_BUFFER_SIZE + 3];
273 	dword         requested_options_conn;
274 	dword         requested_options;
275 	word          B1_facilities;
276 	API_SAVE   *adjust_b_parms_msg;
277 	word          adjust_b_facilities;
278 	word          adjust_b_command;
279 	word          adjust_b_ncci;
280 	word          adjust_b_mode;
281 	word          adjust_b_state;
282 	byte          adjust_b_restore;
283 
284 	byte          dtmf_rec_active;
285 	word          dtmf_rec_pulse_ms;
286 	word          dtmf_rec_pause_ms;
287 	byte          dtmf_send_requests;
288 	word          dtmf_send_pulse_ms;
289 	word          dtmf_send_pause_ms;
290 	word          dtmf_cmd;
291 	word          dtmf_msg_number_queue[8];
292 	byte          dtmf_parameter_length;
293 	byte          dtmf_parameter_buffer[DTMF_PARAMETER_BUFFER_SIZE];
294 
295 
296 	t_capidtmf_state capidtmf_state;
297 
298 
299 	byte          li_bchannel_id;    /* BRI: 1..2, PRI: 1..32 */
300 	byte          li_channel_bits;
301 	byte          li_notify_update;
302 	word          li_cmd;
303 	word          li_write_command;
304 	word          li_write_channel;
305 	word          li_plci_b_write_pos;
306 	word          li_plci_b_read_pos;
307 	word          li_plci_b_req_pos;
308 	dword         li_plci_b_queue[LI_PLCI_B_QUEUE_ENTRIES];
309 
310 
311 	word          ec_cmd;
312 	word          ec_idi_options;
313 	word          ec_tail_length;
314 
315 
316 	byte          tone_last_indication_code;
317 
318 	byte          vswitchstate;
319 	byte          vsprot;
320 	byte          vsprotdialect;
321 	byte          notifiedcall; /* Flag if it is a spoofed call */
322 
323 	int           rx_dma_descriptor;
324 	dword         rx_dma_magic;
325 };
326 
327 
328 struct _NCCI {
329 	byte          data_out;
330 	byte          data_pending;
331 	byte          data_ack_out;
332 	byte          data_ack_pending;
333 	DATA_B3_DESC  DBuffer[MAX_DATA_B3];
334 	DATA_ACK_DESC DataAck[MAX_DATA_ACK];
335 };
336 
337 
338 struct _DIVA_CAPI_ADAPTER {
339 	IDI_CALL      request;
340 	byte          Id;
341 	byte          max_plci;
342 	byte          max_listen;
343 	byte          listen_active;
344 	PLCI      *plci;
345 	byte          ch_ncci[MAX_NL_CHANNEL + 1];
346 	byte          ncci_ch[MAX_NCCI + 1];
347 	byte          ncci_plci[MAX_NCCI + 1];
348 	byte          ncci_state[MAX_NCCI + 1];
349 	byte          ncci_next[MAX_NCCI + 1];
350 	NCCI          ncci[MAX_NCCI + 1];
351 
352 	byte          ch_flow_control[MAX_NL_CHANNEL + 1];  /* Used by XON protocol */
353 	byte          ch_flow_control_pending;
354 	byte          ch_flow_plci[MAX_NL_CHANNEL + 1];
355 	int           last_flow_control_ch;
356 
357 	dword         Info_Mask[MAX_APPL];
358 	dword         CIP_Mask[MAX_APPL];
359 
360 	dword         Notification_Mask[MAX_APPL];
361 	PLCI      *codec_listen[MAX_APPL];
362 	dword         requested_options_table[MAX_APPL];
363 	API_PROFILE   profile;
364 	MANUFACTURER_PROFILE man_profile;
365 	dword         manufacturer_features;
366 
367 	byte          AdvCodecFLAG;
368 	PLCI      *AdvCodecPLCI;
369 	PLCI      *AdvSignalPLCI;
370 	APPL      *AdvSignalAppl;
371 	byte          TelOAD[23];
372 	byte          TelOSA[23];
373 	byte          scom_appl_disable;
374 	PLCI      *automatic_lawPLCI;
375 	byte          automatic_law;
376 	byte          u_law;
377 
378 	byte          adv_voice_coef_length;
379 	byte          adv_voice_coef_buffer[ADV_VOICE_COEF_BUFFER_SIZE];
380 
381 	byte          li_pri;
382 	byte          li_channels;
383 	word          li_base;
384 
385 	byte adapter_disabled;
386 	byte group_optimization_enabled; /* use application groups if enabled */
387 	dword sdram_bar;
388 	byte flag_dynamic_l1_down; /* for hunt groups:down layer 1 if no appl present*/
389 	byte FlowControlIdTable[256];
390 	byte FlowControlSkipTable[256];
391 	void *os_card; /* pointer to associated OS dependent adapter structure */
392 };
393 
394 
395 /*------------------------------------------------------------------*/
396 /* Application flags                                                */
397 /*------------------------------------------------------------------*/
398 
399 #define APPL_FLAG_OLD_LI_SPEC           0x01
400 #define APPL_FLAG_PRIV_EC_SPEC          0x02
401 
402 
403 /*------------------------------------------------------------------*/
404 /* API parameter definitions                                        */
405 /*------------------------------------------------------------------*/
406 
407 #define X75_TTX         1       /* x.75 for ttx                     */
408 #define TRF             2       /* transparent with hdlc framing    */
409 #define TRF_IN          3       /* transparent with hdlc fr. inc.   */
410 #define SDLC            4       /* sdlc, sna layer-2                */
411 #define X75_BTX         5       /* x.75 for btx                     */
412 #define LAPD            6       /* lapd (Q.921)                     */
413 #define X25_L2          7       /* x.25 layer-2                     */
414 #define V120_L2         8       /* V.120 layer-2 protocol           */
415 #define V42_IN          9       /* V.42 layer-2 protocol, incoming */
416 #define V42            10       /* V.42 layer-2 protocol            */
417 #define MDM_ATP        11       /* AT Parser built in the L2        */
418 #define X75_V42BIS     12       /* ISO7776 (X.75 SLP) modified to support V.42 bis compression */
419 #define RTPL2_IN       13       /* RTP layer-2 protocol, incoming  */
420 #define RTPL2          14       /* RTP layer-2 protocol             */
421 #define V120_V42BIS    15       /* V.120 layer-2 protocol supporting V.42 bis compression */
422 
423 #define T70NL           1
424 #define X25PLP          2
425 #define T70NLX          3
426 #define TRANSPARENT_NL  4
427 #define ISO8208         5
428 #define T30             6
429 
430 
431 /*------------------------------------------------------------------*/
432 /* FAX interface to IDI                                             */
433 /*------------------------------------------------------------------*/
434 
435 #define CAPI_MAX_HEAD_LINE_SPACE        89
436 #define CAPI_MAX_DATE_TIME_LENGTH       18
437 
438 #define T30_MAX_STATION_ID_LENGTH       20
439 #define T30_MAX_SUBADDRESS_LENGTH       20
440 #define T30_MAX_PASSWORD_LENGTH         20
441 
442 typedef struct t30_info_s T30_INFO;
443 struct t30_info_s {
444 	byte          code;
445 	byte          rate_div_2400;
446 	byte          resolution;
447 	byte          data_format;
448 	byte          pages_low;
449 	byte          pages_high;
450 	byte          operating_mode;
451 	byte          control_bits_low;
452 	byte          control_bits_high;
453 	byte          feature_bits_low;
454 	byte          feature_bits_high;
455 	byte          recording_properties;
456 	byte          universal_6;
457 	byte          universal_7;
458 	byte          station_id_len;
459 	byte          head_line_len;
460 	byte          station_id[T30_MAX_STATION_ID_LENGTH];
461 /* byte          head_line[];      */
462 /* byte          sub_sep_length;   */
463 /* byte          sub_sep_field[];  */
464 /* byte          pwd_length;       */
465 /* byte          pwd_field[];      */
466 /* byte          nsf_info_length;   */
467 /* byte          nsf_info_field[];  */
468 };
469 
470 
471 #define T30_RESOLUTION_R8_0385          0x00
472 #define T30_RESOLUTION_R8_0770_OR_200   0x01
473 #define T30_RESOLUTION_R8_1540          0x02
474 #define T30_RESOLUTION_R16_1540_OR_400  0x04
475 #define T30_RESOLUTION_R4_0385_OR_100   0x08
476 #define T30_RESOLUTION_300_300          0x10
477 #define T30_RESOLUTION_INCH_BASED       0x40
478 #define T30_RESOLUTION_METRIC_BASED     0x80
479 
480 #define T30_RECORDING_WIDTH_ISO_A4      0
481 #define T30_RECORDING_WIDTH_ISO_B4      1
482 #define T30_RECORDING_WIDTH_ISO_A3      2
483 #define T30_RECORDING_WIDTH_COUNT       3
484 
485 #define T30_RECORDING_LENGTH_ISO_A4     0
486 #define T30_RECORDING_LENGTH_ISO_B4     1
487 #define T30_RECORDING_LENGTH_UNLIMITED  2
488 #define T30_RECORDING_LENGTH_COUNT      3
489 
490 #define T30_MIN_SCANLINE_TIME_00_00_00  0
491 #define T30_MIN_SCANLINE_TIME_05_05_05  1
492 #define T30_MIN_SCANLINE_TIME_10_05_05  2
493 #define T30_MIN_SCANLINE_TIME_10_10_10  3
494 #define T30_MIN_SCANLINE_TIME_20_10_10  4
495 #define T30_MIN_SCANLINE_TIME_20_20_20  5
496 #define T30_MIN_SCANLINE_TIME_40_20_20  6
497 #define T30_MIN_SCANLINE_TIME_40_40_40  7
498 #define T30_MIN_SCANLINE_TIME_RES_8     8
499 #define T30_MIN_SCANLINE_TIME_RES_9     9
500 #define T30_MIN_SCANLINE_TIME_RES_10    10
501 #define T30_MIN_SCANLINE_TIME_10_10_05  11
502 #define T30_MIN_SCANLINE_TIME_20_10_05  12
503 #define T30_MIN_SCANLINE_TIME_20_20_10  13
504 #define T30_MIN_SCANLINE_TIME_40_20_10  14
505 #define T30_MIN_SCANLINE_TIME_40_40_20  15
506 #define T30_MIN_SCANLINE_TIME_COUNT     16
507 
508 #define T30_DATA_FORMAT_SFF             0
509 #define T30_DATA_FORMAT_ASCII           1
510 #define T30_DATA_FORMAT_NATIVE          2
511 #define T30_DATA_FORMAT_COUNT           3
512 
513 
514 #define T30_OPERATING_MODE_STANDARD     0
515 #define T30_OPERATING_MODE_CLASS2       1
516 #define T30_OPERATING_MODE_CLASS1       2
517 #define T30_OPERATING_MODE_CAPI         3
518 #define T30_OPERATING_MODE_CAPI_NEG     4
519 #define T30_OPERATING_MODE_COUNT        5
520 
521 /* EDATA transmit messages */
522 #define EDATA_T30_DIS         0x01
523 #define EDATA_T30_FTT         0x02
524 #define EDATA_T30_MCF         0x03
525 #define EDATA_T30_PARAMETERS  0x04
526 
527 /* EDATA receive messages */
528 #define EDATA_T30_DCS         0x81
529 #define EDATA_T30_TRAIN_OK    0x82
530 #define EDATA_T30_EOP         0x83
531 #define EDATA_T30_MPS         0x84
532 #define EDATA_T30_EOM         0x85
533 #define EDATA_T30_DTC         0x86
534 #define EDATA_T30_PAGE_END    0x87   /* Indicates end of page data. Reserved, but not implemented ! */
535 #define EDATA_T30_EOP_CAPI    0x88
536 
537 
538 #define T30_SUCCESS                        0
539 #define T30_ERR_NO_DIS_RECEIVED            1
540 #define T30_ERR_TIMEOUT_NO_RESPONSE        2
541 #define T30_ERR_RETRY_NO_RESPONSE          3
542 #define T30_ERR_TOO_MANY_REPEATS           4
543 #define T30_ERR_UNEXPECTED_MESSAGE         5
544 #define T30_ERR_UNEXPECTED_DCN             6
545 #define T30_ERR_DTC_UNSUPPORTED            7
546 #define T30_ERR_ALL_RATES_FAILED           8
547 #define T30_ERR_TOO_MANY_TRAINS            9
548 #define T30_ERR_RECEIVE_CORRUPTED          10
549 #define T30_ERR_UNEXPECTED_DISC            11
550 #define T30_ERR_APPLICATION_DISC           12
551 #define T30_ERR_INCOMPATIBLE_DIS           13
552 #define T30_ERR_INCOMPATIBLE_DCS           14
553 #define T30_ERR_TIMEOUT_NO_COMMAND         15
554 #define T30_ERR_RETRY_NO_COMMAND           16
555 #define T30_ERR_TIMEOUT_COMMAND_TOO_LONG   17
556 #define T30_ERR_TIMEOUT_RESPONSE_TOO_LONG  18
557 #define T30_ERR_NOT_IDENTIFIED             19
558 #define T30_ERR_SUPERVISORY_TIMEOUT        20
559 #define T30_ERR_TOO_LONG_SCAN_LINE         21
560 /* #define T30_ERR_RETRY_NO_PAGE_AFTER_MPS    22 */
561 #define T30_ERR_RETRY_NO_PAGE_RECEIVED     23
562 #define T30_ERR_RETRY_NO_DCS_AFTER_FTT     24
563 #define T30_ERR_RETRY_NO_DCS_AFTER_EOM     25
564 #define T30_ERR_RETRY_NO_DCS_AFTER_MPS     26
565 #define T30_ERR_RETRY_NO_DCN_AFTER_MCF     27
566 #define T30_ERR_RETRY_NO_DCN_AFTER_RTN     28
567 #define T30_ERR_RETRY_NO_CFR               29
568 #define T30_ERR_RETRY_NO_MCF_AFTER_EOP     30
569 #define T30_ERR_RETRY_NO_MCF_AFTER_EOM     31
570 #define T30_ERR_RETRY_NO_MCF_AFTER_MPS     32
571 #define T30_ERR_SUB_SEP_UNSUPPORTED        33
572 #define T30_ERR_PWD_UNSUPPORTED            34
573 #define T30_ERR_SUB_SEP_PWD_UNSUPPORTED    35
574 #define T30_ERR_INVALID_COMMAND_FRAME      36
575 #define T30_ERR_UNSUPPORTED_PAGE_CODING    37
576 #define T30_ERR_INVALID_PAGE_CODING        38
577 #define T30_ERR_INCOMPATIBLE_PAGE_CONFIG   39
578 #define T30_ERR_TIMEOUT_FROM_APPLICATION   40
579 #define T30_ERR_V34FAX_NO_REACTION_ON_MARK 41
580 #define T30_ERR_V34FAX_TRAINING_TIMEOUT    42
581 #define T30_ERR_V34FAX_UNEXPECTED_V21      43
582 #define T30_ERR_V34FAX_PRIMARY_CTS_ON      44
583 #define T30_ERR_V34FAX_TURNAROUND_POLLING  45
584 #define T30_ERR_V34FAX_V8_INCOMPATIBILITY  46
585 
586 
587 #define T30_CONTROL_BIT_DISABLE_FINE       0x0001
588 #define T30_CONTROL_BIT_ENABLE_ECM         0x0002
589 #define T30_CONTROL_BIT_ECM_64_BYTES       0x0004
590 #define T30_CONTROL_BIT_ENABLE_2D_CODING   0x0008
591 #define T30_CONTROL_BIT_ENABLE_T6_CODING   0x0010
592 #define T30_CONTROL_BIT_ENABLE_UNCOMPR     0x0020
593 #define T30_CONTROL_BIT_ACCEPT_POLLING     0x0040
594 #define T30_CONTROL_BIT_REQUEST_POLLING    0x0080
595 #define T30_CONTROL_BIT_MORE_DOCUMENTS     0x0100
596 #define T30_CONTROL_BIT_ACCEPT_SUBADDRESS  0x0200
597 #define T30_CONTROL_BIT_ACCEPT_SEL_POLLING 0x0400
598 #define T30_CONTROL_BIT_ACCEPT_PASSWORD    0x0800
599 #define T30_CONTROL_BIT_ENABLE_V34FAX      0x1000
600 #define T30_CONTROL_BIT_EARLY_CONNECT      0x2000
601 
602 #define T30_CONTROL_BIT_ALL_FEATURES  (T30_CONTROL_BIT_ENABLE_ECM | T30_CONTROL_BIT_ENABLE_2D_CODING |   T30_CONTROL_BIT_ENABLE_T6_CODING | T30_CONTROL_BIT_ENABLE_UNCOMPR |   T30_CONTROL_BIT_ENABLE_V34FAX)
603 
604 #define T30_FEATURE_BIT_FINE               0x0001
605 #define T30_FEATURE_BIT_ECM                0x0002
606 #define T30_FEATURE_BIT_ECM_64_BYTES       0x0004
607 #define T30_FEATURE_BIT_2D_CODING          0x0008
608 #define T30_FEATURE_BIT_T6_CODING          0x0010
609 #define T30_FEATURE_BIT_UNCOMPR_ENABLED    0x0020
610 #define T30_FEATURE_BIT_POLLING            0x0040
611 #define T30_FEATURE_BIT_MORE_DOCUMENTS     0x0100
612 #define T30_FEATURE_BIT_V34FAX             0x1000
613 
614 
615 #define T30_NSF_CONTROL_BIT_ENABLE_NSF     0x0001
616 #define T30_NSF_CONTROL_BIT_RAW_INFO       0x0002
617 #define T30_NSF_CONTROL_BIT_NEGOTIATE_IND  0x0004
618 #define T30_NSF_CONTROL_BIT_NEGOTIATE_RESP 0x0008
619 
620 #define T30_NSF_ELEMENT_NSF_FIF            0x00
621 #define T30_NSF_ELEMENT_NSC_FIF            0x01
622 #define T30_NSF_ELEMENT_NSS_FIF            0x02
623 #define T30_NSF_ELEMENT_COMPANY_NAME       0x03
624 
625 
626 /*------------------------------------------------------------------*/
627 /* Analog modem definitions                                         */
628 /*------------------------------------------------------------------*/
629 
630 typedef struct async_s ASYNC_FORMAT;
631 struct async_s {
632 	unsigned pe:1;
633 	unsigned parity:2;
634 	unsigned spare:2;
635 	unsigned stp:1;
636 	unsigned ch_len:2;   /* 3th octett in CAI */
637 };
638 
639 
640 /*------------------------------------------------------------------*/
641 /* PLCI/NCCI states                                                 */
642 /*------------------------------------------------------------------*/
643 
644 #define IDLE                    0
645 #define OUTG_CON_PENDING        1
646 #define INC_CON_PENDING         2
647 #define INC_CON_ALERT           3
648 #define INC_CON_ACCEPT          4
649 #define INC_ACT_PENDING         5
650 #define LISTENING               6
651 #define CONNECTED               7
652 #define OUTG_DIS_PENDING        8
653 #define INC_DIS_PENDING         9
654 #define LOCAL_CONNECT           10
655 #define INC_RES_PENDING         11
656 #define OUTG_RES_PENDING        12
657 #define SUSPENDING              13
658 #define ADVANCED_VOICE_SIG      14
659 #define ADVANCED_VOICE_NOSIG    15
660 #define RESUMING                16
661 #define INC_CON_CONNECTED_ALERT 17
662 #define OUTG_REJ_PENDING        18
663 
664 
665 /*------------------------------------------------------------------*/
666 /* auxiliary states for supplementary services                     */
667 /*------------------------------------------------------------------*/
668 
669 #define IDLE                0
670 #define HOLD_REQUEST        1
671 #define HOLD_INDICATE       2
672 #define CALL_HELD           3
673 #define RETRIEVE_REQUEST    4
674 #define RETRIEVE_INDICATION 5
675 
676 /*------------------------------------------------------------------*/
677 /* Capi IE + Msg types                                              */
678 /*------------------------------------------------------------------*/
679 #define ESC_CAUSE        0x800 | CAU        /* Escape cause element */
680 #define ESC_MSGTYPE      0x800 | MSGTYPEIE  /* Escape message type  */
681 #define ESC_CHI          0x800 | CHI        /* Escape channel id    */
682 #define ESC_LAW          0x800 | BC         /* Escape law info      */
683 #define ESC_CR           0x800 | CRIE       /* Escape CallReference */
684 #define ESC_PROFILE      0x800 | PROFILEIE  /* Escape profile       */
685 #define ESC_SSEXT        0x800 | SSEXTIE    /* Escape Supplem. Serv.*/
686 #define ESC_VSWITCH      0x800 | VSWITCHIE  /* Escape VSwitch       */
687 #define CST              0x14               /* Call State i.e.      */
688 #define PI               0x1E               /* Progress Indicator   */
689 #define NI               0x27               /* Notification Ind     */
690 #define CONN_NR          0x4C               /* Connected Number     */
691 #define CONG_RNR         0xBF               /* Congestion RNR       */
692 #define CONG_RR          0xB0               /* Congestion RR        */
693 #define RESERVED         0xFF               /* Res. for future use  */
694 #define ON_BOARD_CODEC   0x02               /* external controller  */
695 #define HANDSET          0x04               /* Codec+Handset(Pro11) */
696 #define HOOK_SUPPORT     0x01               /* activate Hook signal */
697 #define SCR              0x7a               /* unscreened number    */
698 
699 #define HOOK_OFF_REQ     0x9001             /* internal conn req    */
700 #define HOOK_ON_REQ      0x9002             /* internal disc req    */
701 #define SUSPEND_REQ      0x9003             /* internal susp req    */
702 #define RESUME_REQ       0x9004             /* internal resume req  */
703 #define USELAW_REQ       0x9005             /* internal law    req  */
704 #define LISTEN_SIG_ASSIGN_PEND  0x9006
705 #define PERM_LIST_REQ    0x900a             /* permanent conn DCE   */
706 #define C_HOLD_REQ       0x9011
707 #define C_RETRIEVE_REQ   0x9012
708 #define C_NCR_FAC_REQ    0x9013
709 #define PERM_COD_ASSIGN  0x9014
710 #define PERM_COD_CALL    0x9015
711 #define PERM_COD_HOOK    0x9016
712 #define PERM_COD_CONN_PEND 0x9017           /* wait for connect_con */
713 #define PTY_REQ_PEND     0x9018
714 #define CD_REQ_PEND      0x9019
715 #define CF_START_PEND    0x901a
716 #define CF_STOP_PEND     0x901b
717 #define ECT_REQ_PEND     0x901c
718 #define GETSERV_REQ_PEND 0x901d
719 #define BLOCK_PLCI       0x901e
720 #define INTERR_NUMBERS_REQ_PEND         0x901f
721 #define INTERR_DIVERSION_REQ_PEND       0x9020
722 #define MWI_ACTIVATE_REQ_PEND           0x9021
723 #define MWI_DEACTIVATE_REQ_PEND         0x9022
724 #define SSEXT_REQ_COMMAND               0x9023
725 #define SSEXT_NC_REQ_COMMAND            0x9024
726 #define START_L1_SIG_ASSIGN_PEND        0x9025
727 #define REM_L1_SIG_ASSIGN_PEND          0x9026
728 #define CONF_BEGIN_REQ_PEND             0x9027
729 #define CONF_ADD_REQ_PEND               0x9028
730 #define CONF_SPLIT_REQ_PEND             0x9029
731 #define CONF_DROP_REQ_PEND              0x902a
732 #define CONF_ISOLATE_REQ_PEND           0x902b
733 #define CONF_REATTACH_REQ_PEND          0x902c
734 #define VSWITCH_REQ_PEND                0x902d
735 #define GET_MWI_STATE                   0x902e
736 #define CCBS_REQUEST_REQ_PEND           0x902f
737 #define CCBS_DEACTIVATE_REQ_PEND        0x9030
738 #define CCBS_INTERROGATE_REQ_PEND       0x9031
739 
740 #define NO_INTERNAL_COMMAND             0
741 #define DTMF_COMMAND_1                  1
742 #define DTMF_COMMAND_2                  2
743 #define DTMF_COMMAND_3                  3
744 #define MIXER_COMMAND_1                 4
745 #define MIXER_COMMAND_2                 5
746 #define MIXER_COMMAND_3                 6
747 #define ADV_VOICE_COMMAND_CONNECT_1     7
748 #define ADV_VOICE_COMMAND_CONNECT_2     8
749 #define ADV_VOICE_COMMAND_CONNECT_3     9
750 #define ADV_VOICE_COMMAND_DISCONNECT_1  10
751 #define ADV_VOICE_COMMAND_DISCONNECT_2  11
752 #define ADV_VOICE_COMMAND_DISCONNECT_3  12
753 #define ADJUST_B_RESTORE_1              13
754 #define ADJUST_B_RESTORE_2              14
755 #define RESET_B3_COMMAND_1              15
756 #define SELECT_B_COMMAND_1              16
757 #define FAX_CONNECT_INFO_COMMAND_1      17
758 #define FAX_CONNECT_INFO_COMMAND_2      18
759 #define FAX_ADJUST_B23_COMMAND_1        19
760 #define FAX_ADJUST_B23_COMMAND_2        20
761 #define EC_COMMAND_1                    21
762 #define EC_COMMAND_2                    22
763 #define EC_COMMAND_3                    23
764 #define RTP_CONNECT_B3_REQ_COMMAND_1    24
765 #define RTP_CONNECT_B3_REQ_COMMAND_2    25
766 #define RTP_CONNECT_B3_REQ_COMMAND_3    26
767 #define RTP_CONNECT_B3_RES_COMMAND_1    27
768 #define RTP_CONNECT_B3_RES_COMMAND_2    28
769 #define RTP_CONNECT_B3_RES_COMMAND_3    29
770 #define HOLD_SAVE_COMMAND_1             30
771 #define RETRIEVE_RESTORE_COMMAND_1      31
772 #define FAX_DISCONNECT_COMMAND_1        32
773 #define FAX_DISCONNECT_COMMAND_2        33
774 #define FAX_DISCONNECT_COMMAND_3        34
775 #define FAX_EDATA_ACK_COMMAND_1         35
776 #define FAX_EDATA_ACK_COMMAND_2         36
777 #define FAX_CONNECT_ACK_COMMAND_1       37
778 #define FAX_CONNECT_ACK_COMMAND_2       38
779 #define STD_INTERNAL_COMMAND_COUNT      39
780 
781 #define UID              0x2d               /* User Id for Mgmt      */
782 
783 #define CALL_DIR_OUT             0x01       /* call direction of initial call */
784 #define CALL_DIR_IN              0x02
785 #define CALL_DIR_ORIGINATE       0x04       /* DTE/DCE direction according to */
786 #define CALL_DIR_ANSWER          0x08       /*   state of B-Channel Operation */
787 #define CALL_DIR_FORCE_OUTG_NL   0x10       /* for RESET_B3 reconnect, after DISC_B3... */
788 
789 #define AWAITING_MANUF_CON 0x80             /* command spoofing flags */
790 #define SPOOFING_REQUIRED  0xff
791 #define AWAITING_SELECT_B  0xef
792 
793 /*------------------------------------------------------------------*/
794 /* B_CTRL / DSP_CTRL                                                */
795 /*------------------------------------------------------------------*/
796 
797 #define DSP_CTRL_OLD_SET_MIXER_COEFFICIENTS     0x01
798 #define DSP_CTRL_SET_BCHANNEL_PASSIVATION_BRI   0x02
799 #define DSP_CTRL_SET_DTMF_PARAMETERS            0x03
800 
801 #define MANUFACTURER_FEATURE_SLAVE_CODEC          0x00000001L
802 #define MANUFACTURER_FEATURE_FAX_MORE_DOCUMENTS   0x00000002L
803 #define MANUFACTURER_FEATURE_HARDDTMF             0x00000004L
804 #define MANUFACTURER_FEATURE_SOFTDTMF_SEND        0x00000008L
805 #define MANUFACTURER_FEATURE_DTMF_PARAMETERS      0x00000010L
806 #define MANUFACTURER_FEATURE_SOFTDTMF_RECEIVE     0x00000020L
807 #define MANUFACTURER_FEATURE_FAX_SUB_SEP_PWD      0x00000040L
808 #define MANUFACTURER_FEATURE_V18                  0x00000080L
809 #define MANUFACTURER_FEATURE_MIXER_CH_CH          0x00000100L
810 #define MANUFACTURER_FEATURE_MIXER_CH_PC          0x00000200L
811 #define MANUFACTURER_FEATURE_MIXER_PC_CH          0x00000400L
812 #define MANUFACTURER_FEATURE_MIXER_PC_PC          0x00000800L
813 #define MANUFACTURER_FEATURE_ECHO_CANCELLER       0x00001000L
814 #define MANUFACTURER_FEATURE_RTP                  0x00002000L
815 #define MANUFACTURER_FEATURE_T38                  0x00004000L
816 #define MANUFACTURER_FEATURE_TRANSP_DELIVERY_CONF 0x00008000L
817 #define MANUFACTURER_FEATURE_XONOFF_FLOW_CONTROL  0x00010000L
818 #define MANUFACTURER_FEATURE_OOB_CHANNEL          0x00020000L
819 #define MANUFACTURER_FEATURE_IN_BAND_CHANNEL      0x00040000L
820 #define MANUFACTURER_FEATURE_IN_BAND_FEATURE      0x00080000L
821 #define MANUFACTURER_FEATURE_PIAFS                0x00100000L
822 #define MANUFACTURER_FEATURE_DTMF_TONE            0x00200000L
823 #define MANUFACTURER_FEATURE_FAX_PAPER_FORMATS    0x00400000L
824 #define MANUFACTURER_FEATURE_OK_FC_LABEL          0x00800000L
825 #define MANUFACTURER_FEATURE_VOWN                 0x01000000L
826 #define MANUFACTURER_FEATURE_XCONNECT             0x02000000L
827 #define MANUFACTURER_FEATURE_DMACONNECT           0x04000000L
828 #define MANUFACTURER_FEATURE_AUDIO_TAP            0x08000000L
829 #define MANUFACTURER_FEATURE_FAX_NONSTANDARD      0x10000000L
830 
831 /*------------------------------------------------------------------*/
832 /* DTMF interface to IDI                                            */
833 /*------------------------------------------------------------------*/
834 
835 
836 #define DTMF_DIGIT_TONE_LOW_GROUP_697_HZ        0x00
837 #define DTMF_DIGIT_TONE_LOW_GROUP_770_HZ        0x01
838 #define DTMF_DIGIT_TONE_LOW_GROUP_852_HZ        0x02
839 #define DTMF_DIGIT_TONE_LOW_GROUP_941_HZ        0x03
840 #define DTMF_DIGIT_TONE_LOW_GROUP_MASK          0x03
841 #define DTMF_DIGIT_TONE_HIGH_GROUP_1209_HZ      0x00
842 #define DTMF_DIGIT_TONE_HIGH_GROUP_1336_HZ      0x04
843 #define DTMF_DIGIT_TONE_HIGH_GROUP_1477_HZ      0x08
844 #define DTMF_DIGIT_TONE_HIGH_GROUP_1633_HZ      0x0c
845 #define DTMF_DIGIT_TONE_HIGH_GROUP_MASK         0x0c
846 #define DTMF_DIGIT_TONE_CODE_0                  0x07
847 #define DTMF_DIGIT_TONE_CODE_1                  0x00
848 #define DTMF_DIGIT_TONE_CODE_2                  0x04
849 #define DTMF_DIGIT_TONE_CODE_3                  0x08
850 #define DTMF_DIGIT_TONE_CODE_4                  0x01
851 #define DTMF_DIGIT_TONE_CODE_5                  0x05
852 #define DTMF_DIGIT_TONE_CODE_6                  0x09
853 #define DTMF_DIGIT_TONE_CODE_7                  0x02
854 #define DTMF_DIGIT_TONE_CODE_8                  0x06
855 #define DTMF_DIGIT_TONE_CODE_9                  0x0a
856 #define DTMF_DIGIT_TONE_CODE_STAR               0x03
857 #define DTMF_DIGIT_TONE_CODE_HASHMARK           0x0b
858 #define DTMF_DIGIT_TONE_CODE_A                  0x0c
859 #define DTMF_DIGIT_TONE_CODE_B                  0x0d
860 #define DTMF_DIGIT_TONE_CODE_C                  0x0e
861 #define DTMF_DIGIT_TONE_CODE_D                  0x0f
862 
863 #define DTMF_UDATA_REQUEST_SEND_DIGITS            16
864 #define DTMF_UDATA_REQUEST_ENABLE_RECEIVER        17
865 #define DTMF_UDATA_REQUEST_DISABLE_RECEIVER       18
866 #define DTMF_UDATA_INDICATION_DIGITS_SENT         16
867 #define DTMF_UDATA_INDICATION_DIGITS_RECEIVED     17
868 #define DTMF_UDATA_INDICATION_MODEM_CALLING_TONE  18
869 #define DTMF_UDATA_INDICATION_FAX_CALLING_TONE    19
870 #define DTMF_UDATA_INDICATION_ANSWER_TONE         20
871 
872 #define UDATA_REQUEST_MIXER_TAP_DATA        27
873 #define UDATA_INDICATION_MIXER_TAP_DATA     27
874 
875 #define DTMF_LISTEN_ACTIVE_FLAG        0x01
876 #define DTMF_SEND_DIGIT_FLAG           0x01
877 
878 
879 /*------------------------------------------------------------------*/
880 /* Mixer interface to IDI                                           */
881 /*------------------------------------------------------------------*/
882 
883 
884 #define LI2_FLAG_PCCONNECT_A_B 0x40000000
885 #define LI2_FLAG_PCCONNECT_B_A 0x80000000
886 
887 #define MIXER_BCHANNELS_BRI    2
888 #define MIXER_IC_CHANNELS_BRI  MIXER_BCHANNELS_BRI
889 #define MIXER_IC_CHANNEL_BASE  MIXER_BCHANNELS_BRI
890 #define MIXER_CHANNELS_BRI     (MIXER_BCHANNELS_BRI + MIXER_IC_CHANNELS_BRI)
891 #define MIXER_CHANNELS_PRI     32
892 
893 typedef struct li_config_s LI_CONFIG;
894 
895 struct xconnect_card_address_s {
896 	dword low;
897 	dword high;
898 };
899 
900 struct xconnect_transfer_address_s {
901 	struct xconnect_card_address_s card_address;
902 	dword offset;
903 };
904 
905 struct li_config_s {
906 	DIVA_CAPI_ADAPTER   *adapter;
907 	PLCI   *plci;
908 	struct xconnect_transfer_address_s send_b;
909 	struct xconnect_transfer_address_s send_pc;
910 	byte   *flag_table;  /* dword aligned and sized */
911 	byte   *coef_table;  /* dword aligned and sized */
912 	byte channel;
913 	byte curchnl;
914 	byte chflags;
915 };
916 
917 extern LI_CONFIG   *li_config_table;
918 extern word li_total_channels;
919 
920 #define LI_CHANNEL_INVOLVED        0x01
921 #define LI_CHANNEL_ACTIVE          0x02
922 #define LI_CHANNEL_TX_DATA         0x04
923 #define LI_CHANNEL_RX_DATA         0x08
924 #define LI_CHANNEL_CONFERENCE      0x10
925 #define LI_CHANNEL_ADDRESSES_SET   0x80
926 
927 #define LI_CHFLAG_MONITOR          0x01
928 #define LI_CHFLAG_MIX              0x02
929 #define LI_CHFLAG_LOOP             0x04
930 
931 #define LI_FLAG_INTERCONNECT       0x01
932 #define LI_FLAG_MONITOR            0x02
933 #define LI_FLAG_MIX                0x04
934 #define LI_FLAG_PCCONNECT          0x08
935 #define LI_FLAG_CONFERENCE         0x10
936 #define LI_FLAG_ANNOUNCEMENT       0x20
937 
938 #define LI_COEF_CH_CH              0x01
939 #define LI_COEF_CH_PC              0x02
940 #define LI_COEF_PC_CH              0x04
941 #define LI_COEF_PC_PC              0x08
942 #define LI_COEF_CH_CH_SET          0x10
943 #define LI_COEF_CH_PC_SET          0x20
944 #define LI_COEF_PC_CH_SET          0x40
945 #define LI_COEF_PC_PC_SET          0x80
946 
947 #define LI_REQ_SILENT_UPDATE       0xffff
948 
949 #define LI_PLCI_B_LAST_FLAG        ((dword) 0x80000000L)
950 #define LI_PLCI_B_DISC_FLAG        ((dword) 0x40000000L)
951 #define LI_PLCI_B_SKIP_FLAG        ((dword) 0x20000000L)
952 #define LI_PLCI_B_FLAG_MASK        ((dword) 0xe0000000L)
953 
954 #define UDATA_REQUEST_SET_MIXER_COEFS_BRI       24
955 #define UDATA_REQUEST_SET_MIXER_COEFS_PRI_SYNC  25
956 #define UDATA_REQUEST_SET_MIXER_COEFS_PRI_ASYN  26
957 #define UDATA_INDICATION_MIXER_COEFS_SET        24
958 
959 #define MIXER_FEATURE_ENABLE_TX_DATA        0x0001
960 #define MIXER_FEATURE_ENABLE_RX_DATA        0x0002
961 
962 #define MIXER_COEF_LINE_CHANNEL_MASK        0x1f
963 #define MIXER_COEF_LINE_FROM_PC_FLAG        0x20
964 #define MIXER_COEF_LINE_TO_PC_FLAG          0x40
965 #define MIXER_COEF_LINE_ROW_FLAG            0x80
966 
967 #define UDATA_REQUEST_XCONNECT_FROM         28
968 #define UDATA_INDICATION_XCONNECT_FROM      28
969 #define UDATA_REQUEST_XCONNECT_TO           29
970 #define UDATA_INDICATION_XCONNECT_TO        29
971 
972 #define XCONNECT_CHANNEL_PORT_B             0x0000
973 #define XCONNECT_CHANNEL_PORT_PC            0x8000
974 #define XCONNECT_CHANNEL_PORT_MASK          0x8000
975 #define XCONNECT_CHANNEL_NUMBER_MASK        0x7fff
976 #define XCONNECT_CHANNEL_PORT_COUNT         2
977 
978 #define XCONNECT_SUCCESS           0x0000
979 #define XCONNECT_ERROR             0x0001
980 
981 
982 /*------------------------------------------------------------------*/
983 /* Echo canceller interface to IDI                                  */
984 /*------------------------------------------------------------------*/
985 
986 
987 #define PRIVATE_ECHO_CANCELLER         0
988 
989 #define PRIV_SELECTOR_ECHO_CANCELLER   255
990 
991 #define EC_ENABLE_OPERATION            1
992 #define EC_DISABLE_OPERATION           2
993 #define EC_FREEZE_COEFFICIENTS         3
994 #define EC_RESUME_COEFFICIENT_UPDATE   4
995 #define EC_RESET_COEFFICIENTS          5
996 
997 #define EC_DISABLE_NON_LINEAR_PROCESSING     0x0001
998 #define EC_DO_NOT_REQUIRE_REVERSALS          0x0002
999 #define EC_DETECT_DISABLE_TONE               0x0004
1000 
1001 #define EC_SUCCESS                           0
1002 #define EC_UNSUPPORTED_OPERATION             1
1003 
1004 #define EC_BYPASS_DUE_TO_CONTINUOUS_2100HZ   1
1005 #define EC_BYPASS_DUE_TO_REVERSED_2100HZ     2
1006 #define EC_BYPASS_RELEASED                   3
1007 
1008 #define DSP_CTRL_SET_LEC_PARAMETERS          0x05
1009 
1010 #define LEC_ENABLE_ECHO_CANCELLER            0x0001
1011 #define LEC_ENABLE_2100HZ_DETECTOR           0x0002
1012 #define LEC_REQUIRE_2100HZ_REVERSALS         0x0004
1013 #define LEC_MANUAL_DISABLE                   0x0008
1014 #define LEC_ENABLE_NONLINEAR_PROCESSING      0x0010
1015 #define LEC_FREEZE_COEFFICIENTS              0x0020
1016 #define LEC_RESET_COEFFICIENTS               0x8000
1017 
1018 #define LEC_MAX_SUPPORTED_TAIL_LENGTH        32
1019 
1020 #define LEC_UDATA_INDICATION_DISABLE_DETECT  9
1021 
1022 #define LEC_DISABLE_TYPE_CONTIGNUOUS_2100HZ  0x00
1023 #define LEC_DISABLE_TYPE_REVERSED_2100HZ     0x01
1024 #define LEC_DISABLE_RELEASED                 0x02
1025 
1026 
1027 /*------------------------------------------------------------------*/
1028 /* RTP interface to IDI                                             */
1029 /*------------------------------------------------------------------*/
1030 
1031 
1032 #define B1_RTP                  31
1033 #define B2_RTP                  31
1034 #define B3_RTP                  31
1035 
1036 #define PRIVATE_RTP                    1
1037 
1038 #define RTP_PRIM_PAYLOAD_PCMU_8000     0
1039 #define RTP_PRIM_PAYLOAD_1016_8000     1
1040 #define RTP_PRIM_PAYLOAD_G726_32_8000  2
1041 #define RTP_PRIM_PAYLOAD_GSM_8000      3
1042 #define RTP_PRIM_PAYLOAD_G723_8000     4
1043 #define RTP_PRIM_PAYLOAD_DVI4_8000     5
1044 #define RTP_PRIM_PAYLOAD_DVI4_16000    6
1045 #define RTP_PRIM_PAYLOAD_LPC_8000      7
1046 #define RTP_PRIM_PAYLOAD_PCMA_8000     8
1047 #define RTP_PRIM_PAYLOAD_G722_16000    9
1048 #define RTP_PRIM_PAYLOAD_QCELP_8000    12
1049 #define RTP_PRIM_PAYLOAD_G728_8000     14
1050 #define RTP_PRIM_PAYLOAD_G729_8000     18
1051 #define RTP_PRIM_PAYLOAD_GSM_HR_8000   30
1052 #define RTP_PRIM_PAYLOAD_GSM_EFR_8000  31
1053 
1054 #define RTP_ADD_PAYLOAD_BASE           32
1055 #define RTP_ADD_PAYLOAD_RED            32
1056 #define RTP_ADD_PAYLOAD_CN_8000        33
1057 #define RTP_ADD_PAYLOAD_DTMF           34
1058 
1059 #define RTP_SUCCESS                         0
1060 #define RTP_ERR_SSRC_OR_PAYLOAD_CHANGE      1
1061 
1062 #define UDATA_REQUEST_RTP_RECONFIGURE       64
1063 #define UDATA_INDICATION_RTP_CHANGE         65
1064 #define BUDATA_REQUEST_QUERY_RTCP_REPORT    1
1065 #define BUDATA_INDICATION_RTCP_REPORT       1
1066 
1067 #define RTP_CONNECT_OPTION_DISC_ON_SSRC_CHANGE    0x00000001L
1068 #define RTP_CONNECT_OPTION_DISC_ON_PT_CHANGE      0x00000002L
1069 #define RTP_CONNECT_OPTION_DISC_ON_UNKNOWN_PT     0x00000004L
1070 #define RTP_CONNECT_OPTION_NO_SILENCE_TRANSMIT    0x00010000L
1071 
1072 #define RTP_PAYLOAD_OPTION_VOICE_ACTIVITY_DETECT  0x0001
1073 #define RTP_PAYLOAD_OPTION_DISABLE_POST_FILTER    0x0002
1074 #define RTP_PAYLOAD_OPTION_G723_LOW_CODING_RATE   0x0100
1075 
1076 #define RTP_PACKET_FILTER_IGNORE_UNKNOWN_SSRC     0x00000001L
1077 
1078 #define RTP_CHANGE_FLAG_SSRC_CHANGE               0x00000001L
1079 #define RTP_CHANGE_FLAG_PAYLOAD_TYPE_CHANGE       0x00000002L
1080 #define RTP_CHANGE_FLAG_UNKNOWN_PAYLOAD_TYPE      0x00000004L
1081 
1082 
1083 /*------------------------------------------------------------------*/
1084 /* T.38 interface to IDI                                            */
1085 /*------------------------------------------------------------------*/
1086 
1087 
1088 #define B1_T38                  30
1089 #define B2_T38                  30
1090 #define B3_T38                  30
1091 
1092 #define PRIVATE_T38                    2
1093 
1094 
1095 /*------------------------------------------------------------------*/
1096 /* PIAFS interface to IDI                                            */
1097 /*------------------------------------------------------------------*/
1098 
1099 
1100 #define B1_PIAFS                29
1101 #define B2_PIAFS                29
1102 
1103 #define PRIVATE_PIAFS           29
1104 
1105 /*
1106   B2 configuration for PIAFS:
1107   +---------------------+------+-----------------------------------------+
1108   | PIAFS Protocol      | byte | Bit 1 - Protocol Speed                  |
1109   | Speed configuration |      |         0 - 32K                         |
1110   |                     |      |         1 - 64K (default)               |
1111   |                     |      | Bit 2 - Variable Protocol Speed         |
1112   |                     |      |         0 - Speed is fix                |
1113   |                     |      |         1 - Speed is variable (default) |
1114   +---------------------+------+-----------------------------------------+
1115   | Direction           | word | Enable compression/decompression for    |
1116   |                     |      | 0: All direction                        |
1117   |                     |      | 1: disable outgoing data                |
1118   |                     |      | 2: disable incoming data               |
1119   |                     |      | 3: disable both direction (default)     |
1120   +---------------------+------+-----------------------------------------+
1121   | Number of code      | word | Parameter P1 of V.42bis in accordance   |
1122   | words               |      | with V.42bis                            |
1123   +---------------------+------+-----------------------------------------+
1124   | Maximum String      | word | Parameter P2 of V.42bis in accordance   |
1125   | Length              |      | with V.42bis                            |
1126   +---------------------+------+-----------------------------------------+
1127   | control (UDATA)     | byte | enable PIAFS control communication      |
1128   | abilities           |      |                                         |
1129   +---------------------+------+-----------------------------------------+
1130 */
1131 #define PIAFS_UDATA_ABILITIES  0x80
1132 
1133 /*------------------------------------------------------------------*/
1134 /* FAX SUB/SEP/PWD extension                                        */
1135 /*------------------------------------------------------------------*/
1136 
1137 
1138 #define PRIVATE_FAX_SUB_SEP_PWD        3
1139 
1140 
1141 
1142 /*------------------------------------------------------------------*/
1143 /* V.18 extension                                                   */
1144 /*------------------------------------------------------------------*/
1145 
1146 
1147 #define PRIVATE_V18                    4
1148 
1149 
1150 
1151 /*------------------------------------------------------------------*/
1152 /* DTMF TONE extension                                              */
1153 /*------------------------------------------------------------------*/
1154 
1155 
1156 #define DTMF_GET_SUPPORTED_DETECT_CODES  0xf8
1157 #define DTMF_GET_SUPPORTED_SEND_CODES    0xf9
1158 #define DTMF_LISTEN_TONE_START           0xfa
1159 #define DTMF_LISTEN_TONE_STOP            0xfb
1160 #define DTMF_SEND_TONE                   0xfc
1161 #define DTMF_LISTEN_MF_START             0xfd
1162 #define DTMF_LISTEN_MF_STOP              0xfe
1163 #define DTMF_SEND_MF                     0xff
1164 
1165 #define DTMF_MF_DIGIT_TONE_CODE_1               0x10
1166 #define DTMF_MF_DIGIT_TONE_CODE_2               0x11
1167 #define DTMF_MF_DIGIT_TONE_CODE_3               0x12
1168 #define DTMF_MF_DIGIT_TONE_CODE_4               0x13
1169 #define DTMF_MF_DIGIT_TONE_CODE_5               0x14
1170 #define DTMF_MF_DIGIT_TONE_CODE_6               0x15
1171 #define DTMF_MF_DIGIT_TONE_CODE_7               0x16
1172 #define DTMF_MF_DIGIT_TONE_CODE_8               0x17
1173 #define DTMF_MF_DIGIT_TONE_CODE_9               0x18
1174 #define DTMF_MF_DIGIT_TONE_CODE_0               0x19
1175 #define DTMF_MF_DIGIT_TONE_CODE_K1              0x1a
1176 #define DTMF_MF_DIGIT_TONE_CODE_K2              0x1b
1177 #define DTMF_MF_DIGIT_TONE_CODE_KP              0x1c
1178 #define DTMF_MF_DIGIT_TONE_CODE_S1              0x1d
1179 #define DTMF_MF_DIGIT_TONE_CODE_ST              0x1e
1180 
1181 #define DTMF_DIGIT_CODE_COUNT                   16
1182 #define DTMF_MF_DIGIT_CODE_BASE                 DSP_DTMF_DIGIT_CODE_COUNT
1183 #define DTMF_MF_DIGIT_CODE_COUNT                15
1184 #define DTMF_TOTAL_DIGIT_CODE_COUNT             (DSP_MF_DIGIT_CODE_BASE + DSP_MF_DIGIT_CODE_COUNT)
1185 
1186 #define DTMF_TONE_DIGIT_BASE                    0x80
1187 
1188 #define DTMF_SIGNAL_NO_TONE                     (DTMF_TONE_DIGIT_BASE + 0)
1189 #define DTMF_SIGNAL_UNIDENTIFIED_TONE           (DTMF_TONE_DIGIT_BASE + 1)
1190 
1191 #define DTMF_SIGNAL_DIAL_TONE                   (DTMF_TONE_DIGIT_BASE + 2)
1192 #define DTMF_SIGNAL_PABX_INTERNAL_DIAL_TONE     (DTMF_TONE_DIGIT_BASE + 3)
1193 #define DTMF_SIGNAL_SPECIAL_DIAL_TONE           (DTMF_TONE_DIGIT_BASE + 4)   /* stutter dial tone */
1194 #define DTMF_SIGNAL_SECOND_DIAL_TONE            (DTMF_TONE_DIGIT_BASE + 5)
1195 #define DTMF_SIGNAL_RINGING_TONE                (DTMF_TONE_DIGIT_BASE + 6)
1196 #define DTMF_SIGNAL_SPECIAL_RINGING_TONE        (DTMF_TONE_DIGIT_BASE + 7)
1197 #define DTMF_SIGNAL_BUSY_TONE                   (DTMF_TONE_DIGIT_BASE + 8)
1198 #define DTMF_SIGNAL_CONGESTION_TONE             (DTMF_TONE_DIGIT_BASE + 9)   /* reorder tone */
1199 #define DTMF_SIGNAL_SPECIAL_INFORMATION_TONE    (DTMF_TONE_DIGIT_BASE + 10)
1200 #define DTMF_SIGNAL_COMFORT_TONE                (DTMF_TONE_DIGIT_BASE + 11)
1201 #define DTMF_SIGNAL_HOLD_TONE                   (DTMF_TONE_DIGIT_BASE + 12)
1202 #define DTMF_SIGNAL_RECORD_TONE                 (DTMF_TONE_DIGIT_BASE + 13)
1203 #define DTMF_SIGNAL_CALLER_WAITING_TONE         (DTMF_TONE_DIGIT_BASE + 14)
1204 #define DTMF_SIGNAL_CALL_WAITING_TONE           (DTMF_TONE_DIGIT_BASE + 15)
1205 #define DTMF_SIGNAL_PAY_TONE                    (DTMF_TONE_DIGIT_BASE + 16)
1206 #define DTMF_SIGNAL_POSITIVE_INDICATION_TONE    (DTMF_TONE_DIGIT_BASE + 17)
1207 #define DTMF_SIGNAL_NEGATIVE_INDICATION_TONE    (DTMF_TONE_DIGIT_BASE + 18)
1208 #define DTMF_SIGNAL_WARNING_TONE                (DTMF_TONE_DIGIT_BASE + 19)
1209 #define DTMF_SIGNAL_INTRUSION_TONE              (DTMF_TONE_DIGIT_BASE + 20)
1210 #define DTMF_SIGNAL_CALLING_CARD_SERVICE_TONE   (DTMF_TONE_DIGIT_BASE + 21)
1211 #define DTMF_SIGNAL_PAYPHONE_RECOGNITION_TONE   (DTMF_TONE_DIGIT_BASE + 22)
1212 #define DTMF_SIGNAL_CPE_ALERTING_SIGNAL         (DTMF_TONE_DIGIT_BASE + 23)
1213 #define DTMF_SIGNAL_OFF_HOOK_WARNING_TONE       (DTMF_TONE_DIGIT_BASE + 24)
1214 
1215 #define DTMF_SIGNAL_INTERCEPT_TONE              (DTMF_TONE_DIGIT_BASE + 63)
1216 
1217 #define DTMF_SIGNAL_MODEM_CALLING_TONE          (DTMF_TONE_DIGIT_BASE + 64)
1218 #define DTMF_SIGNAL_FAX_CALLING_TONE            (DTMF_TONE_DIGIT_BASE + 65)
1219 #define DTMF_SIGNAL_ANSWER_TONE                 (DTMF_TONE_DIGIT_BASE + 66)
1220 #define DTMF_SIGNAL_REVERSED_ANSWER_TONE        (DTMF_TONE_DIGIT_BASE + 67)
1221 #define DTMF_SIGNAL_ANSAM_TONE                  (DTMF_TONE_DIGIT_BASE + 68)
1222 #define DTMF_SIGNAL_REVERSED_ANSAM_TONE         (DTMF_TONE_DIGIT_BASE + 69)
1223 #define DTMF_SIGNAL_BELL103_ANSWER_TONE         (DTMF_TONE_DIGIT_BASE + 70)
1224 #define DTMF_SIGNAL_FAX_FLAGS                   (DTMF_TONE_DIGIT_BASE + 71)
1225 #define DTMF_SIGNAL_G2_FAX_GROUP_ID             (DTMF_TONE_DIGIT_BASE + 72)
1226 #define DTMF_SIGNAL_HUMAN_SPEECH                (DTMF_TONE_DIGIT_BASE + 73)
1227 #define DTMF_SIGNAL_ANSWERING_MACHINE_390       (DTMF_TONE_DIGIT_BASE + 74)
1228 
1229 #define DTMF_MF_LISTEN_ACTIVE_FLAG     0x02
1230 #define DTMF_SEND_MF_FLAG              0x02
1231 #define DTMF_TONE_LISTEN_ACTIVE_FLAG   0x04
1232 #define DTMF_SEND_TONE_FLAG            0x04
1233 
1234 #define PRIVATE_DTMF_TONE              5
1235 
1236 
1237 /*------------------------------------------------------------------*/
1238 /* FAX paper format extension                                       */
1239 /*------------------------------------------------------------------*/
1240 
1241 
1242 #define PRIVATE_FAX_PAPER_FORMATS      6
1243 
1244 
1245 
1246 /*------------------------------------------------------------------*/
1247 /* V.OWN extension                                                  */
1248 /*------------------------------------------------------------------*/
1249 
1250 
1251 #define PRIVATE_VOWN                   7
1252 
1253 
1254 
1255 /*------------------------------------------------------------------*/
1256 /* FAX non-standard facilities extension                            */
1257 /*------------------------------------------------------------------*/
1258 
1259 
1260 #define PRIVATE_FAX_NONSTANDARD        8
1261 
1262 
1263 
1264 /*------------------------------------------------------------------*/
1265 /* Advanced voice                                                   */
1266 /*------------------------------------------------------------------*/
1267 
1268 #define ADV_VOICE_WRITE_ACTIVATION    0
1269 #define ADV_VOICE_WRITE_DEACTIVATION  1
1270 #define ADV_VOICE_WRITE_UPDATE        2
1271 
1272 #define ADV_VOICE_OLD_COEF_COUNT    6
1273 #define ADV_VOICE_NEW_COEF_BASE     (ADV_VOICE_OLD_COEF_COUNT * sizeof(word))
1274 
1275 /*------------------------------------------------------------------*/
1276 /* B1 resource switching                                            */
1277 /*------------------------------------------------------------------*/
1278 
1279 #define B1_FACILITY_LOCAL  0x01
1280 #define B1_FACILITY_MIXER  0x02
1281 #define B1_FACILITY_DTMFX  0x04
1282 #define B1_FACILITY_DTMFR  0x08
1283 #define B1_FACILITY_VOICE  0x10
1284 #define B1_FACILITY_EC     0x20
1285 
1286 #define ADJUST_B_MODE_SAVE          0x0001
1287 #define ADJUST_B_MODE_REMOVE_L23    0x0002
1288 #define ADJUST_B_MODE_SWITCH_L1     0x0004
1289 #define ADJUST_B_MODE_NO_RESOURCE   0x0008
1290 #define ADJUST_B_MODE_ASSIGN_L23    0x0010
1291 #define ADJUST_B_MODE_USER_CONNECT  0x0020
1292 #define ADJUST_B_MODE_CONNECT       0x0040
1293 #define ADJUST_B_MODE_RESTORE       0x0080
1294 
1295 #define ADJUST_B_START                     0
1296 #define ADJUST_B_SAVE_MIXER_1              1
1297 #define ADJUST_B_SAVE_DTMF_1               2
1298 #define ADJUST_B_REMOVE_L23_1              3
1299 #define ADJUST_B_REMOVE_L23_2              4
1300 #define ADJUST_B_SAVE_EC_1                 5
1301 #define ADJUST_B_SAVE_DTMF_PARAMETER_1     6
1302 #define ADJUST_B_SAVE_VOICE_1              7
1303 #define ADJUST_B_SWITCH_L1_1               8
1304 #define ADJUST_B_SWITCH_L1_2               9
1305 #define ADJUST_B_RESTORE_VOICE_1           10
1306 #define ADJUST_B_RESTORE_VOICE_2           11
1307 #define ADJUST_B_RESTORE_DTMF_PARAMETER_1  12
1308 #define ADJUST_B_RESTORE_DTMF_PARAMETER_2  13
1309 #define ADJUST_B_RESTORE_EC_1              14
1310 #define ADJUST_B_RESTORE_EC_2              15
1311 #define ADJUST_B_ASSIGN_L23_1              16
1312 #define ADJUST_B_ASSIGN_L23_2              17
1313 #define ADJUST_B_CONNECT_1                 18
1314 #define ADJUST_B_CONNECT_2                 19
1315 #define ADJUST_B_CONNECT_3                 20
1316 #define ADJUST_B_CONNECT_4                 21
1317 #define ADJUST_B_RESTORE_DTMF_1            22
1318 #define ADJUST_B_RESTORE_DTMF_2            23
1319 #define ADJUST_B_RESTORE_MIXER_1           24
1320 #define ADJUST_B_RESTORE_MIXER_2           25
1321 #define ADJUST_B_RESTORE_MIXER_3           26
1322 #define ADJUST_B_RESTORE_MIXER_4           27
1323 #define ADJUST_B_RESTORE_MIXER_5           28
1324 #define ADJUST_B_RESTORE_MIXER_6           29
1325 #define ADJUST_B_RESTORE_MIXER_7           30
1326 #define ADJUST_B_END                       31
1327 
1328 /*------------------------------------------------------------------*/
1329 /* XON Protocol def's                                               */
1330 /*------------------------------------------------------------------*/
1331 #define N_CH_XOFF               0x01
1332 #define N_XON_SENT              0x02
1333 #define N_XON_REQ               0x04
1334 #define N_XON_CONNECT_IND       0x08
1335 #define N_RX_FLOW_CONTROL_MASK  0x3f
1336 #define N_OK_FC_PENDING         0x80
1337 #define N_TX_FLOW_CONTROL_MASK  0xc0
1338 
1339 /*------------------------------------------------------------------*/
1340 /* NCPI state                                                       */
1341 /*------------------------------------------------------------------*/
1342 #define NCPI_VALID_CONNECT_B3_IND  0x01
1343 #define NCPI_VALID_CONNECT_B3_ACT  0x02
1344 #define NCPI_VALID_DISC_B3_IND     0x04
1345 #define NCPI_CONNECT_B3_ACT_SENT   0x08
1346 #define NCPI_NEGOTIATE_B3_SENT     0x10
1347 #define NCPI_MDM_CTS_ON_RECEIVED   0x40
1348 #define NCPI_MDM_DCD_ON_RECEIVED   0x80
1349 
1350 /*------------------------------------------------------------------*/
1351