libsangoma  1
wanpipe_api_legacy.h
Go to the documentation of this file.
1 /******************************************************************************/
35 #ifndef __WANPIPE_API_LEGACY__
36 #define __WANPIPE_API_LEGACY__
37 
38 #pragma pack(1)
39 
40 
41 /****************************************************************/
46 #define WAN_API_MAX_DATA 4096
47 typedef struct{
48  unsigned char pktType;
49  unsigned short length;
50  unsigned char result;
51  union {
52  struct {
53  unsigned char arg1;
54  unsigned short time_stamp;
55  } chdlc;
56  struct {
57  unsigned char attr;
58  unsigned short time_stamp;
59  } fr;
60  struct {
61  unsigned char qdm;
62  unsigned char cause;
63  unsigned char diagn;
64  unsigned short lcn;
65  } x25;
66  struct {
67  unsigned char station;
68  unsigned char PF_bit;
69  unsigned short poll_interval;
70  unsigned char general_mailbox_byte;
71  }sdlc;
72  struct {
73  unsigned char exception;
74  }xdlc;
75  } wan_protocol;
76 #define wan_apihdr_chdlc_error_flag wan_protocol.chdlc.arg1
77 #define wan_apihdr_chdlc_attr wan_protocol.chdlc.arg1
78 #define wan_apihdr_chdlc_time_stamp wan_protocol.chdlc.time_stamp
79 #define wan_apihdr_fr_attr wan_protocol.fr.attr
80 #define wan_apihdr_fr_time_stamp wan_protocol.fr.time_stamp
81 #define wan_apihdr_x25_qdm wan_protocol.x25.qdm
82 #define wan_apihdr_x25_cause wan_protocol.x25.cause
83 #define wan_apihdr_x25_diagn wan_protocol.x25.diagn
84 #define wan_apihdr_x25_lcn wan_protocol.x25.lcn
85 
86 #define wan_apihdr_sdlc_station wan_protocol.sdlc.station
87 #define wan_apihdr_sdlc_pf wan_protocol.sdlc.PF_bit
88 #define wan_apihdr_sdlc_poll_interval wan_protocol.sdlc.poll_interval
89 #define wan_apihdr_sdlc_general_mb_byte wan_protocol.sdlc.general_mailbox_byte
90 
91 #define wan_apihdr_xdlc_exception wan_protocol.xdlc.exception
93 
94 typedef struct{
95  wan_api_hdr_t api_hdr;
96  unsigned char data[WAN_API_MAX_DATA];
97 #define wan_api_pktType api_hdr.pktType
98 #define wan_api_length api_hdr.length
99 #define wan_api_result api_hdr.result
100 #define wan_api_chdlc_error_flag api_hdr.wan_apihdr_chdlc_error_flag
101 #define wan_api_chdlc_time_stamp api_hdr.wan_apihdr_chdlc_time_stamp
102 #define wan_api_chdlc_attr api_hdr.wan_apihdr_chdlc_attr
103 #define wan_api_chdlc_misc_Tx_bits api_hdr.wan_apihdr_chdlc_misc_Tx_bits
104 #define wan_api_fr_attr api_hdr.wan_apihdr_fr_attr
105 #define wan_api_fr_time_stamp api_hdr.wan_apihdr_fr_time_stamp
106 #define wan_api_x25_qdm api_hdr.wan_apihdr_x25_qdm
107 #define wan_api_x25_cause api_hdr.wan_apihdr_x25_cause
108 #define wan_api_x25_diagn api_hdr.wan_apihdr_x25_diagn
109 #define wan_api_x25_lcn api_hdr.wan_apihdr_x25_lcn
110 #define wan_api_sdlc_station api_hdr.wan_apihdr_sdlc_station
111 #define wan_api_sdlc_pf api_hdr.wan_apihdr_sdlc_pf
112 #define wan_api_sdlc_poll_interval api_hdr.wan_apihdr_sdlc_poll_interval
113 #define wan_api_sdlc_general_mb_byte api_hdr.wan_apihdr_sdlc_general_mb_byte
114 #define wan_api_xdlc_exception api_hdr.wan_apihdr_xdlc_exception
115 } wan_api_t;
116 
117 
118 #define WAN_MAX_DATA_SIZE 5000
119 #define MAX_LGTH_UDP_MGNT_PKT WAN_MAX_DATA_SIZE
120 
121 #define WAN_MAILBOX_SIZE 16
122 #define WAN_MAX_POS_DATA_SIZE 1030
123 #define WAN_MAX_MBOX_DATA_SIZE 2032
124 
125 #define WAN_MAX_CMD_DATA_SIZE 990
126 
133 typedef struct wan_cmd_api_
134 {
135  unsigned int cmd;
136  unsigned short len;
137  unsigned char bar;
138  unsigned int offset;
139  int ret; /* return value */
140  unsigned char data[WAN_MAX_CMD_DATA_SIZE];
141 } wan_cmd_api_t;
142 
143 
144 
145 
155 typedef struct wan_cmd {
156  union {
157  struct {
158  unsigned char opp_flag;
159  unsigned char command;
160  unsigned short data_len;
161  unsigned char return_code;
162  union {
163  struct {
164  unsigned char PF_bit; /* the HDLC P/F bit */
165  } hdlc;
166  struct {
167  unsigned short dlci; /* DLCI number */
168  unsigned char attr; /* FECN, BECN, DE and C/R bits */
169  unsigned short rxlost1; /* frames discarded at int. level */
170  unsigned int rxlost2; /* frames discarded at app. level */
171  } fr;
172  struct {
173  unsigned char pf; /* P/F bit */
174  unsigned short lcn; /* logical channel */
175  unsigned char qdm; /* Q/D/M bits */
176  unsigned char cause; /* cause field */
177  unsigned char diagn; /* diagnostics */
178  unsigned char pktType; /* packet type */
179  } x25;
180  struct {
181  unsigned char misc_Tx_Rx_bits; /* miscellaneous transmit and receive bits */
182  unsigned char Rx_error_bits; /* an indication of a block received with an error */
183  unsigned short Rx_time_stamp; /* a millisecond receive time stamp */
184  unsigned char port; /* comm port */
185  } bscstrm;
186  struct {
187  unsigned char misc_tx_rx_bits;
188  unsigned short heading_length;
189  unsigned short notify;
190  unsigned char station;
191  unsigned char poll_address;
192  unsigned char select_address;
193  unsigned char device_address;
194  unsigned char notify_extended;
195  } bsc;
196  struct {
197  unsigned char sdlc_address;
198  unsigned char PF_bit;
199  unsigned short poll_interval;
200  unsigned char general_mailbox_byte;
201  } sdlc;
202  struct {
203  unsigned char force;
204  } fe;
205  } wan_protocol;
206  } wan_p_cmd;
207  struct {
208  unsigned char opp_flag;
209  unsigned char pos_state;
210  unsigned char async_state;
211  } wan_pos_cmd;
212  unsigned char mbox[WAN_MAILBOX_SIZE];
213  } wan_cmd_u;
214 #define wan_cmd_opp_flag wan_cmd_u.wan_p_cmd.opp_flag
215 #define wan_cmd_command wan_cmd_u.wan_p_cmd.command
216 #define wan_cmd_data_len wan_cmd_u.wan_p_cmd.data_len
217 #define wan_cmd_return_code wan_cmd_u.wan_p_cmd.return_code
218 #define wan_cmd_hdlc_PF_bit wan_cmd_u.wan_p_cmd.wan_protocol.hdlc.PF_bit
219 #define wan_cmd_fe_force wan_cmd_u.wan_p_cmd.wan_protocol.fe.force
220 #define wan_cmd_fr_dlci wan_cmd_u.wan_p_cmd.wan_protocol.fr.dlci
221 #define wan_cmd_fr_attr wan_cmd_u.wan_p_cmd.wan_protocol.fr.attr
222 #define wan_cmd_fr_rxlost1 wan_cmd_u.wan_p_cmd.wan_protocol.fr.rxlost1
223 #define wan_cmd_fr_rxlost2 wan_cmd_u.wan_p_cmd.wan_protocol.fr.rxlost2
224 #define wan_cmd_x25_pf wan_cmd_u.wan_p_cmd.wan_protocol.x25.pf
225 #define wan_cmd_x25_lcn wan_cmd_u.wan_p_cmd.wan_protocol.x25.lcn
226 #define wan_cmd_x25_qdm wan_cmd_u.wan_p_cmd.wan_protocol.x25.qdm
227 #define wan_cmd_x25_cause wan_cmd_u.wan_p_cmd.wan_protocol.x25.cause
228 #define wan_cmd_x25_diagn wan_cmd_u.wan_p_cmd.wan_protocol.x25.diagn
229 #define wan_cmd_x25_pktType wan_cmd_u.wan_p_cmd.wan_protocol.x25.pktType
230 #define wan_cmd_bscstrm_misc_bits wan_cmd_u.wan_p_cmd.wan_protocol.bscstrm.misc_Tx_Rx_bits
231 #define wan_cmd_bscstrm_Rx_err_bits wan_cmd_u.wan_p_cmd.wan_protocol.bscstrm.Rx_error_bits
232 #define wan_cmd_bscstrm_Rx_time_stamp wan_cmd_u.wan_p_cmd.wan_protocol.bscstrm.Rx_time_stamp
233 #define wan_cmd_bscstrm_port wan_cmd_u.wan_p_cmd.wan_protocol.bscstrm.port
234 #define wan_cmd_bsc_misc_bits wan_cmd_u.wan_p_cmd.wan_protocol.bsc.misc_tx_rx_bits
235 #define wan_cmd_bsc_heading_len wan_cmd_u.wan_p_cmd.wan_protocol.bsc.heading_length
236 #define wan_cmd_bsc_notify wan_cmd_u.wan_p_cmd.wan_protocol.bsc.notify
237 #define wan_cmd_bsc_station wan_cmd_u.wan_p_cmd.wan_protocol.bsc.station
238 #define wan_cmd_bsc_poll_addr wan_cmd_u.wan_p_cmd.wan_protocol.bsc.poll_address
239 #define wan_cmd_bsc_select_addr wan_cmd_u.wan_p_cmd.wan_protocol.bsc.select_address
240 #define wan_cmd_bsc_device_addr wan_cmd_u.wan_p_cmd.wan_protocol.bsc.device_address
241 #define wan_cmd_bsc_notify_ext wan_cmd_u.wan_p_cmd.wan_protocol.bsc.notify_extended
242 #define wan_cmd_sdlc_address wan_cmd_u.wan_p_cmd.wan_protocol.sdlc.sdlc_address
243 #define wan_cmd_sdlc_pf wan_cmd_u.wan_p_cmd.wan_protocol.sdlc.PF_bit
244 #define wan_cmd_sdlc_poll_interval wan_cmd_u.wan_p_cmd.wan_protocol.sdlc.poll_interval
245 #define wan_cmd_sdlc_general_mb_byte wan_cmd_u.wan_p_cmd.wan_protocol.sdlc.general_mailbox_byte
246 
247 #define wan_cmd_pos_opp_flag wan_cmd_u.wan_pos_cmd.opp_flag
248 #define wan_cmd_pos_pos_state wan_cmd_u.wan_pos_cmd.pos_state
249 #define wan_cmd_pos_async_state wan_cmd_u.wan_pos_cmd.async_state
250 } wan_cmd_t;
251 
252 
253 typedef struct {
255  union {
256  struct {
257  unsigned char command;
258  unsigned short data_len;
259  unsigned char return_code;
260  unsigned char port_num;
261  unsigned char attr;
262  unsigned char reserved[10];
263  unsigned char data[WAN_MAX_POS_DATA_SIZE];
264  } pos_data;
265  unsigned char data[WAN_MAX_MBOX_DATA_SIZE];
266  } wan_u_data;
267 #define wan_opp_flag wan_cmd.wan_cmd_opp_flag
268 #define wan_command wan_cmd.wan_cmd_command
269 #define wan_data_len wan_cmd.wan_cmd_data_len
270 #define wan_return_code wan_cmd.wan_cmd_return_code
271 #define wan_hdlc_PF_bit wan_cmd.wan_cmd_hdlc_PF_bit
272 #define wan_fr_dlci wan_cmd.wan_cmd_fr_dlci
273 #define wan_fr_attr wan_cmd.wan_cmd_fr_attr
274 #define wan_fr_rxlost1 wan_cmd.wan_cmd_fr_rxlost1
275 #define wan_fr_rxlost2 wan_cmd.wan_cmd_fr_rxlost2
276 #define wan_x25_pf wan_cmd.wan_cmd_x25_pf
277 #define wan_x25_lcn wan_cmd.wan_cmd_x25_lcn
278 #define wan_x25_qdm wan_cmd.wan_cmd_x25_qdm
279 #define wan_x25_cause wan_cmd.wan_cmd_x25_cause
280 #define wan_x25_diagn wan_cmd.wan_cmd_x25_diagn
281 #define wan_x25_pktType wan_cmd.wan_cmd_x25_pktType
282 #define wan_bscstrm_misc_bits wan_cmd.wan_cmd_bscstrm_misc_bits
283 #define wan_bscstrm_Rx_err_bits wan_cmd.wan_cmd_bscstrm_Rx_error_bits
284 #define wan_bscstrm_Rx_time_stamp wan_cmd.wan_cmd_bscstrm_Rx_time_stamp
285 #define wan_bscstrm_port wan_cmd.wan_cmd_bscstrm_port
286 #define wan_bsc_misc_bits wan_cmd.wan_cmd_bsc_misc_bits
287 #define wan_bsc_heading_len wan_cmd.wan_cmd_bsc_heading_length
288 #define wan_bsc_notify wan_cmd.wan_cmd_bsc_notify
289 #define wan_bsc_station wan_cmd.wan_cmd_bsc_station
290 #define wan_bsc_poll_addr wan_cmd.wan_cmd_bsc_poll_address
291 #define wan_bsc_select_addr wan_cmd.wan_cmd_bsc_select_address
292 #define wan_bsc_device_addr wan_cmd.wan_cmd_bsc_device_address
293 #define wan_bsc_notify_ext wan_cmd.wan_cmd_bsc_notify_extended
294 #define wan_sdlc_address wan_cmd.wan_cmd_sdlc_address
295 #define wan_sdlc_pf wan_cmd.wan_cmd_sdlc_pf
296 #define wan_sdlc_poll_interval wan_cmd.wan_cmd_sdlc_poll_interval
297 #define wan_sdlc_general_mb_byte wan_cmd.wan_cmd_sdlc_general_mb_byte
298 #define wan_data wan_u_data.data
299 
300 #define wan_pos_opp_flag wan_cmd.wan_cmd_pos_opp_flag
301 #define wan_pos_pos_state wan_cmd.wan_cmd_pos_pos_state
302 #define wan_pos_async_state wan_cmd.wan_cmd_pos_async_state
303 #define wan_pos_command wan_u_data.pos_data.command
304 #define wan_pos_data_len wan_u_data.pos_data.data_len
305 #define wan_pos_return_code wan_u_data.pos_data.return_code
306 #define wan_pos_port_num wan_u_data.pos_data.port_num
307 #define wan_pos_attr wan_u_data.pos_data.attr
308 #define wan_pos_data wan_u_data.pos_data.data
309 } wan_mbox_t;
310 
311 #define WAN_MBOX_INIT(mbox) memset(mbox, 0, sizeof(wan_cmd_t));
312 
313 
314 #pragma pack()
315 
316 #endif /* __WANPIPE_API_LEGACY__ */
unsigned char opp_flag
unsigned short data_len
Wanpipe Legacy Command Structure.
unsigned char return_code
Wanpipe UDP CMD Structure.
unsigned char command
#define WAN_API_MAX_DATA