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
35
36
37
38
39 #ifndef __WANPIPE_TDM_API_IFACE_H_
40 #define __WANPIPE_TDM_API_IFACE_H_
41
42
43 #if defined(__WINDOWS__)
44 typedef HANDLE sng_fd_t;
45 #else
46 typedef int sng_fd_t;
47 #endif
48
49
50 #define WP_TDM_FEATURE_DTMF_EVENTS 1
51 #define WP_TDM_FEATURE_FE_ALARM 1
52 #define WP_TDM_FEATURE_EVENTS 1
53 #define WP_TDM_FEATURE_LINK_STATUS 1
54
55 enum wanpipe_tdm_api_cmds {
56
57 SIOC_WP_TDM_GET_USR_MTU_MRU,
58
59 SIOC_WP_TDM_SET_USR_PERIOD,
60 SIOC_WP_TDM_GET_USR_PERIOD,
61
62 SIOC_WP_TDM_SET_HW_MTU_MRU,
63 SIOC_WP_TDM_GET_HW_MTU_MRU,
64
65 SIOC_WP_TDM_SET_CODEC,
66 SIOC_WP_TDM_GET_CODEC,
67
68 SIOC_WP_TDM_SET_POWER_LEVEL,
69 SIOC_WP_TDM_GET_POWER_LEVEL,
70
71 SIOC_WP_TDM_TOGGLE_RX,
72 SIOC_WP_TDM_TOGGLE_TX,
73
74 SIOC_WP_TDM_GET_HW_CODING,
75 SIOC_WP_TDM_SET_HW_CODING,
76
77 SIOC_WP_TDM_GET_FULL_CFG,
78
79 SIOC_WP_TDM_SET_EC_TAP,
80 SIOC_WP_TDM_GET_EC_TAP,
81
82 SIOC_WP_TDM_ENABLE_RBS_EVENTS,
83 SIOC_WP_TDM_DISABLE_RBS_EVENTS,
84 SIOC_WP_TDM_WRITE_RBS_BITS,
85
86 SIOC_WP_TDM_GET_STATS,
87 SIOC_WP_TDM_FLUSH_BUFFERS,
88
89 SIOC_WP_TDM_READ_EVENT,
90
91 SIOC_WP_TDM_SET_EVENT,
92
93 SIOC_WP_TDM_SET_RX_GAINS,
94 SIOC_WP_TDM_SET_TX_GAINS,
95 SIOC_WP_TDM_CLEAR_RX_GAINS,
96 SIOC_WP_TDM_CLEAR_TX_GAINS,
97
98 SIOC_WP_TDM_GET_FE_ALARMS,
99
100 SIOC_WP_TDM_ENABLE_HWEC,
101 SIOC_WP_TDM_DISABLE_HWEC,
102
103 SIOC_WP_TDM_SET_FE_STATUS,
104 SIOC_WP_TDM_GET_FE_STATUS,
105
106 SIOC_WP_TDM_GET_HW_DTMF,
107
108 SIOC_WP_TDM_NOTSUPP
109
110 };
111
112 #define SIOC_WP_TDM_GET_LINK_STATUS SIOC_WP_TDM_GET_FE_STATUS
113
114 enum wanpipe_tdm_api_events {
115 WP_TDMAPI_EVENT_NONE,
116 WP_TDMAPI_EVENT_RBS,
117 WP_TDMAPI_EVENT_ALARM,
118 WP_TDMAPI_EVENT_DTMF,
119 WP_TDMAPI_EVENT_RM_DTMF,
120 WP_TDMAPI_EVENT_RXHOOK,
121 WP_TDMAPI_EVENT_RING,
122 WP_TDMAPI_EVENT_RING_DETECT,
123 WP_TDMAPI_EVENT_RING_TRIP_DETECT,
124 WP_TDMAPI_EVENT_TONE,
125 WP_TDMAPI_EVENT_TXSIG_KEWL,
126 WP_TDMAPI_EVENT_TXSIG_START,
127 WP_TDMAPI_EVENT_TXSIG_OFFHOOK,
128 WP_TDMAPI_EVENT_TXSIG_ONHOOK,
129 WP_TDMAPI_EVENT_ONHOOKTRANSFER,
130 WP_TDMAPI_EVENT_SETPOLARITY,
131 WP_TDMAPI_EVENT_BRI_CHAN_LOOPBACK,
132 WP_TDMAPI_EVENT_LINK_STATUS
133 };
134
135 #define WP_TDMAPI_EVENT_FE_ALARM WP_TDMAPI_EVENT_ALARM
136
137
138 #define WP_TDMAPI_EVENT_ENABLE 0x01
139 #define WP_TDMAPI_EVENT_DISABLE 0x02
140 #define WP_TDMAPI_EVENT_MODE_DECODE(mode) \
141 ((mode) == WP_TDMAPI_EVENT_ENABLE) ? "Enable" : \
142 ((mode) == WP_TDMAPI_EVENT_DISABLE) ? "Disable" : \
143 "(Unknown mode)"
144
145 #define WPTDM_A_BIT WAN_RBS_SIG_A
146 #define WPTDM_B_BIT WAN_RBS_SIG_B
147 #define WPTDM_C_BIT WAN_RBS_SIG_C
148 #define WPTDM_D_BIT WAN_RBS_SIG_D
149
150 #define WP_TDMAPI_EVENT_RXHOOK_OFF 0x01
151 #define WP_TDMAPI_EVENT_RXHOOK_ON 0x02
152 #define WP_TDMAPI_EVENT_RXHOOK_DECODE(state) \
153 ((state) == WP_TDMAPI_EVENT_RXHOOK_OFF) ? "Off-hook" : \
154 ((state) == WP_TDMAPI_EVENT_RXHOOK_ON) ? "On-hook" : \
155 "(Unknown state)"
156
157 #define WP_TDMAPI_EVENT_RING_PRESENT 0x01
158 #define WP_TDMAPI_EVENT_RING_STOP 0x02
159 #define WP_TDMAPI_EVENT_RING_DECODE(state) \
160 ((state) == WP_TDMAPI_EVENT_RING_PRESENT) ? "Ring Present" : \
161 ((state) == WP_TDMAPI_EVENT_RING_STOP) ? "Ring Stop" : \
162 "(Unknown state)"
163
164 #define WP_TDMAPI_EVENT_RING_TRIP_PRESENT 0x01
165 #define WP_TDMAPI_EVENT_RING_TRIP_STOP 0x02
166 #define WP_TDMAPI_EVENT_RING_TRIP_DECODE(state) \
167 ((state) == WP_TDMAPI_EVENT_RING_TRIP_PRESENT) ? "Ring Present" : \
168 ((state) == WP_TDMAPI_EVENT_RING_TRIP_STOP) ? "Ring Stop" : \
169 "(Unknown state)"
170
171 #define WP_TDMAPI_EVENT_LINK_STATUS_CONNECTED 0x01
172 #define WP_TDMAPI_EVENT_LINK_STATUS_DISCONNECTED 0x02
173 #define WP_TDMAPI_EVENT_LINK_STATUS_DECODE(status) \
174 ((status) == WP_TDMAPI_EVENT_LINK_STATUS_CONNECTED) ? "Connected" : \
175 ((status) == WP_TDMAPI_EVENT_LINK_STATUS_DISCONNECTED) ? "Disconnected" : \
176 "Unknown"
177 #define WP_TDMAPI_EVENT_TONE_DIAL 0x01
178 #define WP_TDMAPI_EVENT_TONE_BUSY 0x02
179 #define WP_TDMAPI_EVENT_TONE_RING 0x03
180 #define WP_TDMAPI_EVENT_TONE_CONGESTION 0x04
181
182
183 #define WAN_BRI_BCHAN1 0x01
184 #define WAN_BRI_BCHAN2 0x02
185 #define WAN_BRI_DCHAN 0x03
186
187
188 typedef struct {
189
190 u_int8_t type;
191 u_int8_t mode;
192 u_int32_t time_stamp;
193 u_int8_t channel;
194 u_int32_t chan_map;
195 u_int8_t span;
196 union {
197 struct {
198 u_int8_t alarm;
199 } te1_alarm;
200 struct {
201 u_int8_t rbs_bits;
202 } te1_rbs;
203 struct {
204 u_int8_t state;
205 u_int8_t sig;
206 } rm_hook;
207 struct {
208 u_int8_t state;
209 } rm_ring;
210 struct {
211 u_int8_t type;
212 } rm_tone;
213 struct {
214 u_int8_t digit;
215 u_int8_t port;
216 u_int8_t type;
217 } dtmf;
218 struct {
219 u_int16_t polarity;
220 u_int16_t ohttimer;
221 } rm_common;
222 struct{
223 u_int16_t status;
224 } linkstatus;
225 } wp_tdm_api_event_u;
226 #define wp_tdm_api_event_type type
227 #define wp_tdm_api_event_mode mode
228 #define wp_tdm_api_event_alarm wp_tdm_api_event_u.te1_alarm.alarm
229 #define wp_tdm_api_event_alarm wp_tdm_api_event_u.te1_alarm.alarm
230 #define wp_tdm_api_event_rbs_bits wp_tdm_api_event_u.te1_rbs.rbs_bits
231 #define wp_tdm_api_event_hook_state wp_tdm_api_event_u.rm_hook.state
232 #define wp_tdm_api_event_hook_sig wp_tdm_api_event_u.rm_hook.sig
233 #define wp_tdm_api_event_ring_state wp_tdm_api_event_u.rm_ring.state
234 #define wp_tdm_api_event_tone_type wp_tdm_api_event_u.rm_tone.type
235 #define wp_tdm_api_event_dtmf_digit wp_tdm_api_event_u.dtmf.digit
236 #define wp_tdm_api_event_dtmf_type wp_tdm_api_event_u.dtmf.type
237 #define wp_tdm_api_event_dtmf_port wp_tdm_api_event_u.dtmf.port
238 #define wp_tdm_api_event_ohttimer wp_tdm_api_event_u.rm_common.ohttimer
239 #define wp_tdm_api_event_polarity wp_tdm_api_event_u.rm_common.polarity
240 #define wp_tdm_api_event_link_status wp_tdm_api_event_u.linkstatus.status
241 } wp_tdm_api_event_t;
242
243 typedef struct {
244 union {
245 unsigned char reserved[16];
246 }wp_rx_hdr_u;
247 } wp_tdm_api_rx_hdr_t;
248
249 typedef struct {
250 wp_tdm_api_rx_hdr_t hdr;
251 unsigned char data[1];
252 } wp_tdm_api_rx_element_t;
253
254 typedef struct {
255 union {
256 struct {
257 unsigned char _rbs_rx_bits;
258 unsigned int _time_stamp;
259 }wp_tx;
260 unsigned char reserved[16];
261 }wp_tx_hdr_u;
262 #define wp_api_time_stamp wp_tx_hdr_u.wp_tx._time_stamp
263 } wp_tdm_api_tx_hdr_t;
264
265 typedef struct {
266 wp_tdm_api_tx_hdr_t hdr;
267 unsigned char data[1];
268 } wp_tdm_api_tx_element_t;
269
270
271
272 typedef struct wp_tdm_chan_stats
273 {
274 unsigned int rx_packets;
275 unsigned int tx_packets;
276 unsigned int rx_bytes;
277 unsigned int tx_bytes;
278 unsigned int rx_errors;
279 unsigned int tx_errors;
280 unsigned int rx_dropped;
281 unsigned int tx_dropped;
282 unsigned int multicast;
283 #if !defined(__WINDOWS__)
284 unsigned int collisions;
285 #endif
286
287 unsigned int rx_length_errors;
288 unsigned int rx_over_errors;
289 unsigned int rx_crc_errors;
290 unsigned int rx_frame_errors;
291 #if !defined(__WINDOWS__)
292 unsigned int rx_fifo_errors;
293 #endif
294 unsigned int rx_missed_errors;
295
296
297 #if !defined(__WINDOWS__)
298 unsigned int tx_aborted_errors;
299 unsigned int tx_carrier_errors;
300 #endif
301 unsigned int tx_fifo_errors;
302 unsigned int tx_heartbeat_errors;
303 unsigned int tx_window_errors;
304
305 }wp_tdm_chan_stats_t;
306
307
308
309 typedef struct wanpipe_tdm_api_cmd{
310 unsigned int cmd;
311 unsigned int hw_tdm_coding;
312 unsigned int hw_mtu_mru;
313 unsigned int usr_period;
314 unsigned int tdm_codec;
315 unsigned int power_level;
316 unsigned int rx_disable;
317 unsigned int tx_disable;
318 unsigned int usr_mtu_mru;
319 unsigned int ec_tap;
320 unsigned int rbs_poll;
321 unsigned int rbs_rx_bits;
322 unsigned int rbs_tx_bits;
323 unsigned int hdlc;
324 unsigned int idle_flag;
325 unsigned int fe_alarms;
326 wp_tdm_chan_stats_t stats;
327
328 wp_tdm_api_event_t event;
329 unsigned int data_len;
330 void *data;
331 unsigned char fe_status;
332 unsigned int hw_dtmf;
333 }wanpipe_tdm_api_cmd_t;
334
335 typedef struct wanpipe_tdm_api_event{
336 int (*wp_rbs_event)(sng_fd_t fd, unsigned char rbs_bits);
337 int (*wp_dtmf_event)(sng_fd_t fd, unsigned char dtmf, unsigned char type, unsigned char port);
338 int (*wp_rxhook_event)(sng_fd_t fd, unsigned char hook_state);
339 int (*wp_ring_detect_event)(sng_fd_t fd, unsigned char ring_state);
340 int (*wp_ring_trip_detect_event)(sng_fd_t fd, unsigned char ring_state);
341 int (*wp_fe_alarm_event)(sng_fd_t fd, unsigned char fe_alarm_event);
342 int (*wp_link_status_event)(sng_fd_t fd, unsigned char link_status_event);
343 }wanpipe_tdm_api_event_t;
344
345 typedef struct wanpipe_tdm_api{
346 wanpipe_tdm_api_cmd_t wp_tdm_cmd;
347 wanpipe_tdm_api_event_t wp_tdm_event;
348 }wanpipe_tdm_api_t;
349
350
351 #endif