1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 #ifndef FTDM_ZT_H
35 #define FTDM_ZT_H
36 #include "freetdm.h"
37 #include <sys/ioctl.h>
38 #include <poll.h>
39
40 #ifdef __sun
41 #include <unistd.h>
42 #include <sys/ioccom.h>
43 #include <stropts.h>
44 #endif
45
46
47
48
49
50
51
52
53 struct zt_params {
54 int chan_no;
55 int span_no;
56 int chan_position;
57 int sig_type;
58 int sig_cap;
59 int receive_offhook;
60 int receive_bits;
61 int transmit_bits;
62 int transmit_hook_sig;
63 int receive_hook_sig;
64 int g711_type;
65 int idlebits;
66 char chan_name[40];
67 int prewink_time;
68 int preflash_time;
69 int wink_time;
70 int flash_time;
71 int start_time;
72 int receive_wink_time;
73 int receive_flash_time;
74 int debounce_time;
75 int pulse_break_time;
76 int pulse_make_time;
77 int pulse_after_time;
78
79 uint32_t chan_alarms;
80 };
81
82 typedef struct zt_params zt_params_t;
83
84
85 struct zt_confinfo {
86 int chan_no;
87 int conference_number;
88 int conference_mode;
89 };
90
91
92 struct zt_gains {
93 int chan_no;
94 unsigned char receive_gain[256];
95 unsigned char transmit_gain[256];
96 };
97
98
99 struct zt_spaninfo {
100 int span_no;
101 char name[20];
102 char description[40];
103 int alarms;
104 int transmit_level;
105 int receive_level;
106 int bpv_count;
107 int crc4_count;
108 int ebit_count;
109 int fas_count;
110 int irq_misses;
111 int sync_src;
112 int configured_chan_count;
113 int channel_count;
114 int span_count;
115
116
117 int lbo;
118 int lineconfig;
119
120 char lboname[40];
121 char location[40];
122 char manufacturer[40];
123 char devicetype[40];
124 int irq;
125 int linecompat;
126 char spantype[6];
127 };
128
129 struct zt_maintinfo {
130 int span_no;
131 int command;
132 };
133
134 struct zt_lineconfig {
135
136 int span;
137 char name[20];
138 int lbo;
139 int lineconfig;
140 int sync;
141 };
142
143 struct zt_chanconfig {
144
145 int chan;
146 char name[40];
147 int sigtype;
148 int deflaw;
149 int master;
150 int idlebits;
151 char netdev_name[16];
152 };
153
154 struct zt_bufferinfo {
155
156 int txbufpolicy;
157 int rxbufpolicy;
158 int numbufs;
159 int bufsize;
160 int readbufs;
161 int writebufs;
162 };
163
164
165
166
167 typedef enum {
168 ZT_G711_DEFAULT = 0,
169 ZT_G711_MULAW = 1,
170 ZT_G711_ALAW = 2
171 } zt_g711_t;
172
173 typedef enum {
174 ZT_EVENT_NONE = 0,
175 ZT_EVENT_ONHOOK = 1,
176 ZT_EVENT_RINGOFFHOOK = 2,
177 ZT_EVENT_WINKFLASH = 3,
178 ZT_EVENT_ALARM = 4,
179 ZT_EVENT_NOALARM = 5,
180 ZT_EVENT_ABORT = 6,
181 ZT_EVENT_OVERRUN = 7,
182 ZT_EVENT_BADFCS = 8,
183 ZT_EVENT_DIALCOMPLETE = 9,
184 ZT_EVENT_RINGERON = 10,
185 ZT_EVENT_RINGEROFF = 11,
186 ZT_EVENT_HOOKCOMPLETE = 12,
187 ZT_EVENT_BITSCHANGED = 13,
188 ZT_EVENT_PULSE_START = 14,
189 ZT_EVENT_TIMER_EXPIRED = 15,
190 ZT_EVENT_TIMER_PING = 16,
191 ZT_EVENT_POLARITY = 17,
192 ZT_EVENT_RINGBEGIN = 18
193 } zt_event_t;
194
195 typedef enum {
196 ZT_FLUSH_READ = 1,
197 ZT_FLUSH_WRITE = 2,
198 ZT_FLUSH_BOTH = (ZT_FLUSH_READ | ZT_FLUSH_WRITE),
199 ZT_FLUSH_EVENT = 4,
200 ZT_FLUSH_ALL = (ZT_FLUSH_READ | ZT_FLUSH_WRITE | ZT_FLUSH_EVENT)
201 } zt_flush_t;
202
203 typedef enum {
204 ZT_IOMUX_READ = 1,
205 ZT_IOMUX_WRITE = 2,
206 ZT_IOMUX_WRITEEMPTY = 4,
207 ZT_IOMUX_SIGEVENT = 8,
208 ZT_IOMUX_NOWAIT = 256
209 } zt_iomux_t;
210
211 typedef enum {
212 ZT_ONHOOK = 0,
213 ZT_OFFHOOK = 1,
214 ZT_WINK = 2,
215 ZT_FLASH = 3,
216 ZT_START = 4,
217 ZT_RING = 5,
218 ZT_RINGOFF = 6
219 } zt_hookstate_t;
220
221 typedef enum {
222 ZT_MAINT_NONE = 0,
223 ZT_MAINT_LOCALLOOP = 1,
224 ZT_MAINT_REMOTELOOP = 2,
225 ZT_MAINT_LOOPUP = 3,
226 ZT_MAINT_LOOPDOWN = 4,
227 ZT_MAINT_LOOPSTOP = 5
228 } zt_maintenance_mode_t;
229
230 typedef enum {
231
232 ZT_SIG_NONE = 0,
233
234 ZT_SIG_FXSLS = ((1 << 0) | (1 << 13)),
235 ZT_SIG_FXSGS = ((1 << 1) | (1 << 13)),
236 ZT_SIG_FXSKS = ((1 << 2) | (1 << 13)),
237 ZT_SIG_FXOLS = ((1 << 3) | (1 << 12)),
238 ZT_SIG_FXOGS = ((1 << 4) | (1 << 12)),
239 ZT_SIG_FXOKS = ((1 << 5) | (1 << 12)),
240 ZT_SIG_EM = (1 << 6),
241 ZT_SIG_CLEAR = (1 << 7),
242 ZT_SIG_HDLCRAW = ((1 << 8) | ZT_SIG_CLEAR),
243 ZT_SIG_HDLCFCS = ((1 << 9) | ZT_SIG_HDLCRAW),
244 ZT_SIG_CAS = (1 << 15),
245 ZT_SIG_HARDHDLC = ((1 << 19) | ZT_SIG_CLEAR),
246 } zt_sigtype_t;
247
248 typedef enum {
249 ZT_DBIT = 1,
250 ZT_CBIT = 2,
251 ZT_BBIT = 4,
252 ZT_ABIT = 8
253 } zt_cas_bit_t;
254
255
256
257 #define ZT_MAX_BLOCKSIZE 8192
258 #define ZT_DEFAULT_MTU_MRU 2048
259
260
261
262 #define ZT_CODE 'J'
263 #define DAHDI_CODE 0xDA
264
265
266 #define ZT_GET_BLOCKSIZE _IOR (ZT_CODE, 1, int)
267 #define ZT_SET_BLOCKSIZE _IOW (ZT_CODE, 2, int)
268 #define ZT_FLUSH _IOW (ZT_CODE, 3, int)
269 #define ZT_SYNC _IOW (ZT_CODE, 4, int)
270 #define ZT_GET_PARAMS _IOR (ZT_CODE, 5, struct zt_params)
271 #define ZT_SET_PARAMS _IOW (ZT_CODE, 6, struct zt_params)
272 #define ZT_HOOK _IOW (ZT_CODE, 7, int)
273 #define ZT_GETEVENT _IOR (ZT_CODE, 8, int)
274 #define ZT_IOMUX _IOWR (ZT_CODE, 9, int)
275 #define ZT_SPANSTAT _IOWR (ZT_CODE, 10, struct zt_spaninfo)
276 #define ZT_MAINT _IOW (ZT_CODE, 11, struct zt_maintinfo)
277 #define ZT_GETCONF _IOWR (ZT_CODE, 12, struct zt_confinfo)
278 #define ZT_SETCONF _IOWR (ZT_CODE, 13, struct zt_confinfo)
279 #define ZT_CONFLINK _IOW (ZT_CODE, 14, struct zt_confinfo)
280 #define ZT_CONFDIAG _IOR (ZT_CODE, 15, int)
281
282 #define ZT_GETGAINS _IOWR (ZT_CODE, 16, struct zt_gains)
283 #define ZT_SETGAINS _IOWR (ZT_CODE, 17, struct zt_gains)
284 #define ZT_SPANCONFIG _IOW (ZT_CODE, 18, struct zt_lineconfig)
285 #define ZT_CHANCONFIG _IOW (ZT_CODE, 19, struct zt_chanconfig)
286 #define ZT_SET_BUFINFO _IOW (ZT_CODE, 27, struct zt_bufferinfo)
287 #define ZT_GET_BUFINFO _IOR (ZT_CODE, 28, struct zt_bufferinfo)
288 #define ZT_AUDIOMODE _IOW (ZT_CODE, 32, int)
289 #define ZT_ECHOCANCEL _IOW (ZT_CODE, 33, int)
290 #define ZT_HDLCRAWMODE _IOW (ZT_CODE, 36, int)
291 #define ZT_HDLCFCSMODE _IOW (ZT_CODE, 37, int)
292
293
294 #define ZT_SPECIFY _IOW (ZT_CODE, 38, int)
295
296
297 #define ZT_SETLAW _IOW (ZT_CODE, 39, int)
298
299
300 #define ZT_SETLINEAR _IOW (ZT_CODE, 40, int)
301
302 #define ZT_GETCONFMUTE _IOR (ZT_CODE, 49, int)
303 #define ZT_ECHOTRAIN _IOW (ZT_CODE, 50, int)
304
305
306 #define ZT_SETTXBITS _IOW (ZT_CODE, 43, int)
307 #define ZT_GETRXBITS _IOR (ZT_CODE, 45, int)
308
309 #define DAHDI_GET_BLOCKSIZE _IOR (DAHDI_CODE, 1, int)
310 #define DAHDI_SET_BLOCKSIZE _IOW (DAHDI_CODE, 1, int)
311 #define DAHDI_FLUSH _IOW (DAHDI_CODE, 3, int)
312 #define DAHDI_SYNC _IO (DAHDI_CODE, 4)
313 #define DAHDI_GET_PARAMS _IOR (DAHDI_CODE, 5, struct zt_params)
314 #define DAHDI_SET_PARAMS _IOW (DAHDI_CODE, 5, struct zt_params)
315 #define DAHDI_HOOK _IOW (DAHDI_CODE, 7, int)
316 #define DAHDI_GETEVENT _IOR (DAHDI_CODE, 8, int)
317 #define DAHDI_IOMUX _IOWR (DAHDI_CODE, 9, int)
318 #define DAHDI_SPANSTAT _IOWR (DAHDI_CODE, 10, struct zt_spaninfo)
319 #define DAHDI_MAINT _IOW (DAHDI_CODE, 11, struct zt_maintinfo)
320 #define DAHDI_GETCONF _IOR (DAHDI_CODE, 12, struct zt_confinfo)
321 #define DAHDI_SETCONF _IOW (DAHDI_CODE, 12, struct zt_confinfo)
322 #define DAHDI_CONFLINK _IOW (DAHDI_CODE, 14, struct zt_confinfo)
323 #define DAHDI_CONFDIAG _IOR (DAHDI_CODE, 15, int)
324
325 #define DAHDI_GETGAINS _IOR (DAHDI_CODE, 16, struct zt_gains)
326 #define DAHDI_SETGAINS _IOW (DAHDI_CODE, 16, struct zt_gains)
327 #define DAHDI_SPANCONFIG _IOW (DAHDI_CODE, 18, struct zt_lineconfig)
328 #define DAHDI_CHANCONFIG _IOW (DAHDI_CODE, 19, struct zt_chanconfig)
329 #define DAHDI_SET_BUFINFO _IOW (DAHDI_CODE, 27, struct zt_bufferinfo)
330 #define DAHDI_GET_BUFINFO _IOR (DAHDI_CODE, 27, struct zt_bufferinfo)
331 #define DAHDI_AUDIOMODE _IOW (DAHDI_CODE, 32, int)
332 #define DAHDI_ECHOCANCEL _IOW (DAHDI_CODE, 33, int)
333 #define DAHDI_HDLCRAWMODE _IOW (DAHDI_CODE, 36, int)
334 #define DAHDI_HDLCFCSMODE _IOW (DAHDI_CODE, 37, int)
335
336
337 #define DAHDI_SPECIFY _IOW (DAHDI_CODE, 38, int)
338
339
340 #define DAHDI_SETLAW _IOW (DAHDI_CODE, 39, int)
341
342
343 #define DAHDI_SETLINEAR _IOW (DAHDI_CODE, 40, int)
344
345 #define DAHDI_GETCONFMUTE _IOR (DAHDI_CODE, 49, int)
346 #define DAHDI_ECHOTRAIN _IOW (DAHDI_CODE, 50, int)
347
348
349 #define DAHDI_SETTXBITS _IOW (DAHDI_CODE, 43, int)
350 #define DAHDI_GETRXBITS _IOR (DAHDI_CODE, 43, int)
351
352
353 #endif
354
355
356
357
358
359
360
361
362
363
364